This function updates the used QEMU capabilities of @vm by querying
the QEMU capabilities cache.
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
---
src/qemu/qemu_domain.c | 25 +++++++++++++++++++++++++
src/qemu/qemu_domain.h | 4 ++++
src/qemu/qemu_process.c | 14 +++-----------
3 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 06aa1fac5d0b..eb80711597cb 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -13071,6 +13071,31 @@ qemuDomainFixupCPUs(virDomainObjPtr vm,
}
+/**
+ * qemuDomainUpdateQEMUCaps:
+ * @vm: domain object
+ * @qemuCapsCache: cache of QEMU capabilities
+ *
+ * This function updates the used QEMU capabilities of @vm by querying
+ * the QEMU capabilities cache.
+ *
+ * Returns 0 on success, -1 on error.
+ */
+int
+qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
+ virFileCachePtr qemuCapsCache)
+{
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+
+ virObjectUnref(priv->qemuCaps);
+ if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(qemuCapsCache,
+ vm->def->emulator,
+ vm->def->os.machine)))
+ return -1;
+ return 0;
+}
+
+
char *
qemuDomainGetMachineName(virDomainObjPtr vm)
{
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 914c9a6a8d14..080cac76e2b1 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -1030,6 +1030,10 @@ int
qemuDomainFixupCPUs(virDomainObjPtr vm,
virCPUDefPtr *origCPU);
+int
+qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
+ virFileCachePtr qemuCapsCache);
+
char *
qemuDomainGetMachineName(virDomainObjPtr vm);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index f9a01daee78a..44c63c42d618 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5287,10 +5287,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
}
VIR_DEBUG("Determining emulator version");
- virObjectUnref(priv->qemuCaps);
- if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
- vm->def->emulator,
- vm->def->os.machine)))
+ if (qemuDomainUpdateQEMUCaps(vm, driver->qemuCapsCache) < 0)
goto cleanup;
if (flags & VIR_QEMU_PROCESS_START_STANDALONE)
@@ -7391,10 +7388,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
goto error;
VIR_DEBUG("Determining emulator version");
- virObjectUnref(priv->qemuCaps);
- if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
- vm->def->emulator,
- vm->def->os.machine)))
+ if (qemuDomainUpdateQEMUCaps(vm, driver->qemuCapsCache) < 0)
goto error;
VIR_DEBUG("Preparing monitor state");
@@ -7857,9 +7851,7 @@ qemuProcessReconnect(void *opaque)
* caps in the domain status, so re-query them
*/
if (!priv->qemuCaps &&
- !(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
- obj->def->emulator,
- obj->def->os.machine)))
+ (qemuDomainUpdateQEMUCaps(obj, driver->qemuCapsCache) < 0))
goto error;
/* In case the domain shutdown while we were not running,
--
2.17.0