These XML attributes have been mandatory since the introduction of SEV
support to libvirt. This design decision was based on QEMU's
requirement for these to be mandatory for migration purposes, as
differences in these values across platforms must result in the
pre-migration checks failing (not that migration with SEV works at the
time of this patch).
This patch enables autofill of these attributes right before launching
QEMU and thus updating the live XML.
Signed-off-by: Erik Skultety <eskultet(a)redhat.com>
---
src/conf/domain_conf.h | 2 ++
src/qemu/qemu_process.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 902dd58112..cd344716a3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2491,7 +2491,9 @@ struct _virDomainSEVDef {
char *dh_cert;
char *session;
unsigned int policy;
+ bool haveCbitpos;
unsigned int cbitpos;
+ bool haveReducedPhysBits;
unsigned int reduced_phys_bits;
};
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 16d6f54f66..6422881a33 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6233,6 +6233,33 @@ qemuProcessPrepareAllowReboot(virDomainObjPtr vm)
}
+static int
+qemuProcessUpdateSEVInfo(virDomainObjPtr vm)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ virQEMUCapsPtr qemuCaps = priv->qemuCaps;
+ virDomainSEVDefPtr sev = vm->def->sev;
+ virSEVCapabilityPtr sevCaps = NULL;
+
+ /* if platform specific info like 'cbitpos' and 'reducedPhysBits'
have
+ * not been supplied, we need to autofill them from caps now as both are
+ * mandatory on QEMU cmdline
+ */
+ sevCaps = virQEMUCapsGetSEVCapabilities(qemuCaps);
+ if (!sev->haveCbitpos) {
+ sev->cbitpos = sevCaps->cbitpos;
+ sev->haveCbitpos = true;
+ }
+
+ if (!sev->haveReducedPhysBits) {
+ sev->reduced_phys_bits = sevCaps->reduced_phys_bits;
+ sev->haveReducedPhysBits = true;
+ }
+
+ return 0;
+}
+
+
/**
* qemuProcessPrepareDomain:
* @driver: qemu driver
@@ -6361,6 +6388,12 @@ qemuProcessPrepareDomain(virQEMUDriverPtr driver,
for (i = 0; i < vm->def->nshmems; i++)
qemuDomainPrepareShmemChardev(vm->def->shmems[i]);
+ if (vm->def->sev) {
+ VIR_DEBUG("Updating SEV platform info");
+ if (qemuProcessUpdateSEVInfo(vm) < 0)
+ return -1;
+ }
+
return 0;
}
--
2.26.2