]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: stop creating capabilities at driver startup
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 2 Dec 2019 13:04:26 +0000 (13:04 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Mon, 9 Dec 2019 10:17:27 +0000 (10:17 +0000)
Now that nearly all internal APIs use the QEMU capabilities or other
QEMU driver data directly, there's no compelling benefit to create
virCapsPtr at driver startup.

Skipping this means we don't probe capabilities for all 30 system
emulator targets at startup, only those emulators which are referenced
by an XML doc. This massively improves libvirtd startup time when the
capabilities cache is not populated. It even improves startup time
when the cache is up to date, as we don't bother to load files from
the cache until we need them.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_conf.c
src/qemu/qemu_driver.c

index 9df4ae12302717f5f098a7cb21d6339d69272c7d..c24c99d1299a05d7c5a3a37d367a2490427c80df 100644 (file)
@@ -1318,13 +1318,14 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver,
         driver->caps = caps;
     } else {
         qemuDriverLock(driver);
-    }
 
-    if (driver->caps->nguests == 0 && !refresh) {
-        VIR_DEBUG("Capabilities didn't detect any guests. Forcing a "
-            "refresh.");
-        qemuDriverUnlock(driver);
-        return virQEMUDriverGetCapabilities(driver, true);
+        if (driver->caps == NULL ||
+            driver->caps->nguests == 0) {
+            VIR_DEBUG("Capabilities didn't detect any guests. Forcing a "
+                      "refresh.");
+            qemuDriverUnlock(driver);
+            return virQEMUDriverGetCapabilities(driver, true);
+        }
     }
 
     ret = virObjectRef(driver->caps);
index a30a27dbab3cd686d2661b2a0bc59184f623265e..e17e9ca86d9a4983e33bed180a506165507a608d 100644 (file)
@@ -907,9 +907,6 @@ qemuStateInitialize(bool privileged,
     if (!qemu_driver->qemuCapsCache)
         goto error;
 
-    if ((qemu_driver->caps = virQEMUDriverCreateCapabilities(qemu_driver)) == NULL)
-        goto error;
-
     if (!(sec_managers = qemuSecurityGetNested(qemu_driver->securityManager)))
         goto error;