From 3dd91af01f30c5bda6328454ef49f3afece755d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 2 Dec 2019 13:04:26 +0000 Subject: [PATCH] qemu: stop creating capabilities at driver startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Daniel P. Berrangé --- src/qemu/qemu_conf.c | 13 +++++++------ src/qemu/qemu_driver.c | 3 --- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 9df4ae1230..c24c99d129 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -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); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index a30a27dbab..e17e9ca86d 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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;