For testing purposes it's sometimes desired to be able to control the
presence of capabilities of qemu. This adds the possibility to do this
via the qemu namespace.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_domain.c | 8 ++++++++
src/qemu/qemu_process.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 5caa31d3bc..2e0a0ca88b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8285,6 +8285,7 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
size_t i;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivatePtr priv = obj->privateData;
+ bool custom_hypervisor_feat = false;
if (virQEMUDriverIsPrivileged(driver) &&
(!cfg->clearEmulatorCapabilities ||
@@ -8299,6 +8300,13 @@ void qemuDomainObjCheckTaint(virQEMUDriverPtr driver,
qemuDomainXmlNsDefPtr qemuxmlns = obj->def->namespaceData;
if (qemuxmlns->num_args || qemuxmlns->num_env)
qemuDomainObjTaint(driver, obj, VIR_DOMAIN_TAINT_CUSTOM_ARGV, logCtxt);
+ if (qemuxmlns->ncapsadd > 0 || qemuxmlns->ncapsdel > 0)
+ custom_hypervisor_feat = true;
+ }
+
+ if (custom_hypervisor_feat) {
+ qemuDomainObjTaint(driver, obj,
+ VIR_DOMAIN_TAINT_CUSTOM_HYPERVISOR_FEATURE, logCtxt);
}
if (obj->def->cpu && obj->def->cpu->mode ==
VIR_CPU_MODE_HOST_PASSTHROUGH)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 1626796c19..8fafd067ce 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5406,6 +5406,42 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
}
+static int
+qemuProcessStartUpdateCustomCaps(virDomainObjPtr vm)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ qemuDomainXmlNsDefPtr nsdef = vm->def->namespaceData;
+ int tmp;
+ size_t i;
+
+ if (nsdef) {
+ for (i = 0; i < nsdef->ncapsadd; i++) {
+ if ((tmp = virQEMUCapsTypeFromString(nsdef->capsadd[i])) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("invalid qemu namespace capability
'%s'"),
+ nsdef->capsadd[i]);
+ return -1;
+ }
+
+ virQEMUCapsSet(priv->qemuCaps, tmp);
+ }
+
+ for (i = 0; i < nsdef->ncapsdel; i++) {
+ if ((tmp = virQEMUCapsTypeFromString(nsdef->capsdel[i])) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("invalid qemu namespace capability
'%s'"),
+ nsdef->capsdel[i]);
+ return -1;
+ }
+
+ virQEMUCapsClear(priv->qemuCaps, tmp);
+ }
+ }
+
+ return 0;
+}
+
+
/**
* qemuProcessInit:
*
@@ -5476,6 +5512,10 @@ qemuProcessInit(virQEMUDriverPtr driver,
if (virDomainObjSetDefTransient(caps, driver->xmlopt, vm) < 0)
goto cleanup;
+ /* Update qemu capabilities according to lists passed in via namespace */
+ if (qemuProcessStartUpdateCustomCaps(vm) < 0)
+ goto cleanup;
+
if (flags & VIR_QEMU_PROCESS_START_PRETEND) {
if (qemuDomainSetPrivatePaths(driver, vm) < 0) {
virDomainObjRemoveTransientDef(vm);
--
2.21.0