]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Introduce qemuDomainUpdateQEMUCaps()
authorMarc Hartmayer <mhartmay@linux.ibm.com>
Thu, 20 Sep 2018 17:44:48 +0000 (19:44 +0200)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 1 Oct 2018 22:35:47 +0000 (18:35 -0400)
This function updates the used QEMU capabilities of @vm by querying
the QEMU capabilities cache.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_process.c

index 2453734b22401e920bccdeb880530042614e5a54..f00f1b3fdb8a4bf7be2521e8ea219d78560cf6c1 100644 (file)
@@ -13122,6 +13122,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)
 {
index 2f8a1bf03c6d743a83bc0ee1675573cd27f6ef40..80bd4bde9105f65029f0b58018a83c1ce6766d42 100644 (file)
@@ -1037,6 +1037,10 @@ int
 qemuDomainFixupCPUs(virDomainObjPtr vm,
                     virCPUDefPtr *origCPU);
 
+int
+qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
+                         virFileCachePtr qemuCapsCache);
+
 char *
 qemuDomainGetMachineName(virDomainObjPtr vm);
 
index 29b0ba1590a88a6e11e090d21e5d14076a632187..e9c76188a4967fd9ebb554deed06a3a7ac64fce5 100644 (file)
@@ -5298,10 +5298,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)
@@ -7403,10 +7400,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");
@@ -7869,9 +7863,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,