Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 25 +++++++++++++++---------- src/qemu/qemu_capabilities.h | 6 ++++-- src/qemu/qemu_capspriv.h | 3 ++- src/qemu/qemu_domain.c | 13 ++++++++----- src/qemu/qemu_driver.c | 9 ++++++--- src/qemu/qemu_process.c | 14 +++++++++++--- tests/qemucapsprobe.c | 2 +- 7 files changed, 47 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 232ae1f..8f55fcc 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -837,7 +837,7 @@ virQEMUCapsInitGuest(virCapsPtr caps, /* Ignore binary if extracting version info fails */ if (binary) { - if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) { + if (!(qemubinCaps = virQEMUCapsCacheLookup(caps, cache, binary))) { virResetLastError(); VIR_FREE(binary); } @@ -877,7 +877,7 @@ virQEMUCapsInitGuest(virCapsPtr caps, if (!kvmbin) continue; - if (!(kvmbinCaps = virQEMUCapsCacheLookup(cache, kvmbin))) { + if (!(kvmbinCaps = virQEMUCapsCacheLookup(caps, cache, kvmbin))) { virResetLastError(); VIR_FREE(kvmbin); continue; @@ -1986,7 +1986,7 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps, return -1; } - qemucaps = virQEMUCapsCacheLookup(capsCache, capsdata->emulator); + qemucaps = virQEMUCapsCacheLookup(caps, capsCache, capsdata->emulator); VIR_FREE(capsdata); if (!qemucaps) return -1; @@ -3783,7 +3783,8 @@ virQEMUCapsLogProbeFailure(const char *binary) virQEMUCapsPtr -virQEMUCapsNewForBinaryInternal(const char *binary, +virQEMUCapsNewForBinaryInternal(virCapsPtr caps ATTRIBUTE_UNUSED, + const char *binary, const char *libDir, const char *cacheDir, uid_t runUid, @@ -3861,13 +3862,14 @@ virQEMUCapsNewForBinaryInternal(const char *binary, } static virQEMUCapsPtr -virQEMUCapsNewForBinary(const char *binary, +virQEMUCapsNewForBinary(virCapsPtr caps, + const char *binary, const char *libDir, const char *cacheDir, uid_t runUid, gid_t runGid) { - return virQEMUCapsNewForBinaryInternal(binary, libDir, cacheDir, + return virQEMUCapsNewForBinaryInternal(caps, binary, libDir, cacheDir, runUid, runGid, false); } @@ -3960,7 +3962,9 @@ virQEMUCapsCacheNew(const char *libDir, const char *qemuTestCapsName; virQEMUCapsPtr -virQEMUCapsCacheLookup(virQEMUCapsCachePtr cache, const char *binary) +virQEMUCapsCacheLookup(virCapsPtr caps, + virQEMUCapsCachePtr cache, + const char *binary) { virQEMUCapsPtr ret = NULL; @@ -3980,7 +3984,7 @@ virQEMUCapsCacheLookup(virQEMUCapsCachePtr cache, const char *binary) if (!ret) { VIR_DEBUG("Creating capabilities for %s", binary); - ret = virQEMUCapsNewForBinary(binary, cache->libDir, + ret = virQEMUCapsNewForBinary(caps, binary, cache->libDir, cache->cacheDir, cache->runUid, cache->runGid); if (ret) { @@ -4000,11 +4004,12 @@ virQEMUCapsCacheLookup(virQEMUCapsCachePtr cache, const char *binary) virQEMUCapsPtr -virQEMUCapsCacheLookupCopy(virQEMUCapsCachePtr cache, +virQEMUCapsCacheLookupCopy(virCapsPtr caps, + virQEMUCapsCachePtr cache, const char *binary, const char *machineType) { - virQEMUCapsPtr qemuCaps = virQEMUCapsCacheLookup(cache, binary); + virQEMUCapsPtr qemuCaps = virQEMUCapsCacheLookup(caps, cache, binary); virQEMUCapsPtr ret; if (!qemuCaps) diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 9fd38d9..df49809 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -445,9 +445,11 @@ void virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps, virQEMUCapsCachePtr virQEMUCapsCacheNew(const char *libDir, const char *cacheDir, uid_t uid, gid_t gid); -virQEMUCapsPtr virQEMUCapsCacheLookup(virQEMUCapsCachePtr cache, +virQEMUCapsPtr virQEMUCapsCacheLookup(virCapsPtr caps, + virQEMUCapsCachePtr cache, const char *binary); -virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virQEMUCapsCachePtr cache, +virQEMUCapsPtr virQEMUCapsCacheLookupCopy(virCapsPtr caps, + virQEMUCapsCachePtr cache, const char *binary, const char *machineType); virQEMUCapsPtr virQEMUCapsCacheLookupByArch(virQEMUCapsCachePtr cache, diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h index c409acb..ac3693b 100644 --- a/src/qemu/qemu_capspriv.h +++ b/src/qemu/qemu_capspriv.h @@ -40,7 +40,8 @@ struct _virQEMUCapsCache { virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemuCaps); virQEMUCapsPtr -virQEMUCapsNewForBinaryInternal(const char *binary, +virQEMUCapsNewForBinaryInternal(virCapsPtr caps, + const char *binary, const char *libDir, const char *cacheDir, uid_t runUid, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index efc46f9..9ba7cbd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2285,7 +2285,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, !(def->emulator = virDomainDefGetDefaultEmulator(def, caps))) goto cleanup; - if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, + if (!(qemuCaps = virQEMUCapsCacheLookup(caps, + driver->qemuCapsCache, def->emulator))) goto cleanup; @@ -2442,7 +2443,7 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps ATTRIBUTE_UNUSED, + virCapsPtr caps, unsigned int parseFlags, void *opaque) { @@ -2451,7 +2452,8 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); int ret = -1; - qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator); + qemuCaps = virQEMUCapsCacheLookup(caps, driver->qemuCapsCache, + def->emulator); if (dev->type == VIR_DOMAIN_DEVICE_NET && dev->data.net->type != VIR_DOMAIN_NET_TYPE_HOSTDEV && @@ -2628,7 +2630,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, static int qemuDomainDefAssignAddresses(virDomainDef *def, - virCapsPtr caps ATTRIBUTE_UNUSED, + virCapsPtr caps, unsigned int parseFlags ATTRIBUTE_UNUSED, void *opaque) { @@ -2637,7 +2639,8 @@ qemuDomainDefAssignAddresses(virDomainDef *def, int ret = -1; bool newDomain = parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE; - if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, + if (!(qemuCaps = virQEMUCapsCacheLookup(caps, + driver->qemuCapsCache, def->emulator))) goto cleanup; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7e4f4e7..695da14 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8270,7 +8270,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom, if (priv->qemuCaps) qemuCaps = virObjectRef(priv->qemuCaps); - else if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, vm->def->emulator))) + else if (!(qemuCaps = virQEMUCapsCacheLookup(caps, driver->qemuCapsCache, + vm->def->emulator))) goto endjob; if (flags & VIR_DOMAIN_AFFECT_CONFIG) { @@ -15634,7 +15635,8 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn, virAsprintf(&def->name, "attach-pid-%u", pid_value) < 0) goto cleanup; - if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) + if (!(qemuCaps = virQEMUCapsCacheLookup(caps, driver->qemuCapsCache, + def->emulator))) goto cleanup; if (qemuAssignDeviceAliases(def, qemuCaps) < 0) @@ -18533,7 +18535,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (emulatorbin) { virArch arch_from_caps; - if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, + if (!(qemuCaps = virQEMUCapsCacheLookup(caps, + driver->qemuCapsCache, emulatorbin))) goto cleanup; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 4d709fc..ae94c21 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3246,6 +3246,7 @@ qemuProcessReconnect(void *opaque) int ret; unsigned int stopFlags = 0; bool jobStarted = false; + virCapsPtr caps = NULL; VIR_FREE(data); @@ -3256,6 +3257,9 @@ qemuProcessReconnect(void *opaque) cfg = virQEMUDriverGetConfig(driver); priv = obj->privateData; + if (!(caps = virQEMUDriverGetCapabilities(driver, false))) + goto error; + if (qemuDomainObjBeginJob(driver, obj, QEMU_JOB_MODIFY) < 0) goto error; jobStarted = true; @@ -3325,7 +3329,8 @@ qemuProcessReconnect(void *opaque) * caps in the domain status, so re-query them */ if (!priv->qemuCaps && - !(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache, + !(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps, + driver->qemuCapsCache, obj->def->emulator, obj->def->os.machine))) goto error; @@ -3422,6 +3427,7 @@ qemuProcessReconnect(void *opaque) virDomainObjEndAPI(&obj); virObjectUnref(conn); virObjectUnref(cfg); + virObjectUnref(caps); virNWFilterUnlockFilterUpdates(); return; @@ -4609,7 +4615,8 @@ qemuProcessInit(virQEMUDriverPtr driver, VIR_DEBUG("Determining emulator version"); virObjectUnref(priv->qemuCaps); - if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache, + if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps, + driver->qemuCapsCache, vm->def->emulator, vm->def->os.machine))) goto cleanup; @@ -6043,7 +6050,8 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, VIR_DEBUG("Determining emulator version"); virObjectUnref(priv->qemuCaps); - if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache, + if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(caps, + driver->qemuCapsCache, vm->def->emulator, vm->def->os.machine))) goto error; diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c index ced0512..fb9f3e9 100644 --- a/tests/qemucapsprobe.c +++ b/tests/qemucapsprobe.c @@ -70,7 +70,7 @@ main(int argc, char **argv) if (virThreadCreate(&thread, false, eventLoop, NULL) < 0) return EXIT_FAILURE; - if (!(caps = virQEMUCapsNewForBinaryInternal(argv[1], "/tmp", NULL, + if (!(caps = virQEMUCapsNewForBinaryInternal(NULL, argv[1], "/tmp", NULL, -1, -1, true))) return EXIT_FAILURE; -- 2.9.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list