qemu: process: Move SEV capability check to qemuValidateDomainDef

Checks such as this one should be done at domain def validation time,
not before starting the QEMU process.
As for this change, existing domains will see some QEMU error when
starting as opposed to a libvirt error that this QEMU binary doesn't
support SEV, but that's okay, we never guaranteed error messages to
remain the same.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Erik Skultety 2020-10-15 11:18:58 +02:00
parent 649f720a9a
commit 1fdc907325
2 changed files with 8 additions and 9 deletions

View File

@ -6393,8 +6393,6 @@ qemuProcessSEVCreateFile(virDomainObjPtr vm,
static int
qemuProcessPrepareSEVGuestInput(virDomainObjPtr vm)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virQEMUCapsPtr qemuCaps = priv->qemuCaps;
virDomainSEVDefPtr sev = vm->def->sev;
if (!sev)
@ -6402,13 +6400,6 @@ qemuProcessPrepareSEVGuestInput(virDomainObjPtr vm)
VIR_DEBUG("Preparing SEV guest");
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Domain %s asked for 'sev' launch but this "
"QEMU does not support SEV feature"), vm->def->name);
return -1;
}
if (sev->dh_cert) {
if (qemuProcessSEVCreateFile(vm, "dh_cert", sev->dh_cert) < 0)
return -1;

View File

@ -1210,6 +1210,14 @@ qemuValidateDomainDef(const virDomainDef *def,
if (qemuValidateDomainDefPanic(def, qemuCaps) < 0)
return -1;
if (def->sev &&
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("SEV launch security is not supported with "
"this QEMU binary"));
return -1;
}
return 0;
}