[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Refresh QEMU driver caps in getCapabilities

Hi all,

The attached patch fixes QEMU getCapabilities to refresh caps before
returning them to the user. Currently the capabilities are only
refreshed once (at daemon startup), which means libvirtd needs to be
restarted to pick up changes if QEMU or KVM are installed while the
daemon is running. See:

There are several things 'wrong' with this change:

- We reset/rescan fields that won't change (host arch, mac address
prefix). This should be fixed at some point, but isn't a big deal since
total performance impact is negligible (see below).

- We only refresh the capabilities when the user calls getCapabilities,
which means we are still carrying around stale caps prior to that, which
is what libvirt validates against. In practice, virt-manager and
virt-install both call getCapabilities often so this isn't an issue,
though the caps internal API should probably address this at some point.

To test the performance impact, I used a simple python script:

import libvirt
conn = libvirt.open("qemu:///system")
for i in range(0, 30):

The time difference was on average .02 seconds slower, which I think is

If at somepoint in the future, capabilities generation becomes smarter
(searching PATH emulators, scraping device list output, etc.) it might
be worth re-checking the time impact. But for now it doesn't seem to be
an issue.

diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 79ee072..6b5c17f 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -1872,10 +1872,12 @@ static int qemudGetNodeInfo(virConnectPtr conn,
 static char *qemudGetCapabilities(virConnectPtr conn) {
     struct qemud_driver *driver = conn->privateData;
-    char *xml;
+    char *xml = NULL;
-    if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
+    virCapabilitiesFree(qemu_driver->caps);
+    if ((qemu_driver->caps = qemudCapsInit()) == NULL ||
+        (xml = virCapabilitiesFormatXML(driver->caps)) == NULL)

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]