Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- Notes: Version 2: - adapted to changes in previous patches - fix build after rebase src/qemu/qemu_capabilities.c | 25 +++++++++++++++---------- src/qemu/qemu_capabilities.h | 6 ++++-- src/qemu/qemu_capspriv.h | 3 ++- src/qemu/qemu_domain.c | 18 +++++++++++------- src/qemu/qemu_driver.c | 9 ++++++--- src/qemu/qemu_process.c | 14 +++++++++++--- tests/qemucapsprobe.c | 2 +- 7 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 86e40ba..3aa348c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -843,7 +843,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); } @@ -883,7 +883,7 @@ virQEMUCapsInitGuest(virCapsPtr caps, if (!kvmbin) continue; - if (!(kvmbinCaps = virQEMUCapsCacheLookup(cache, kvmbin))) { + if (!(kvmbinCaps = virQEMUCapsCacheLookup(caps, cache, kvmbin))) { virResetLastError(); VIR_FREE(kvmbin); continue; @@ -2047,7 +2047,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; @@ -3871,7 +3871,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, @@ -3949,13 +3950,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); } @@ -4050,7 +4052,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; @@ -4070,7 +4074,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) { @@ -4090,11 +4094,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 dcd358a..c05adfd 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -452,9 +452,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 3f16dbe..0e30381 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2359,7 +2359,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; @@ -2390,7 +2391,7 @@ qemuDomainDefPostParse(virDomainDefPtr def, static int qemuDomainDefValidate(const virDomainDef *def, - virCapsPtr caps ATTRIBUTE_UNUSED, + virCapsPtr caps, void *opaque) { virQEMUDriverPtr driver = opaque; @@ -2398,7 +2399,8 @@ qemuDomainDefValidate(const virDomainDef *def, size_t topologycpus; int ret = -1; - if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, + if (!(qemuCaps = virQEMUCapsCacheLookup(caps, + driver->qemuCapsCache, def->emulator))) goto cleanup; @@ -2552,7 +2554,7 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr, static int qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, const virDomainDef *def, - virCapsPtr caps ATTRIBUTE_UNUSED, + virCapsPtr caps, unsigned int parseFlags, void *opaque) { @@ -2561,7 +2563,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 && @@ -2758,7 +2761,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, static int qemuDomainDefAssignAddresses(virDomainDef *def, - virCapsPtr caps ATTRIBUTE_UNUSED, + virCapsPtr caps, unsigned int parseFlags ATTRIBUTE_UNUSED, void *opaque) { @@ -2767,7 +2770,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 2acff16..ca47b4e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8373,7 +8373,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) { @@ -15742,7 +15743,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) @@ -18667,7 +18669,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 b2d1127..83e64b2 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3248,6 +3248,7 @@ qemuProcessReconnect(void *opaque) int ret; unsigned int stopFlags = 0; bool jobStarted = false; + virCapsPtr caps = NULL; VIR_FREE(data); @@ -3258,6 +3259,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; @@ -3327,7 +3331,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; @@ -3427,6 +3432,7 @@ qemuProcessReconnect(void *opaque) virDomainObjEndAPI(&obj); virObjectUnref(conn); virObjectUnref(cfg); + virObjectUnref(caps); virNWFilterUnlockFilterUpdates(); return; @@ -4656,7 +4662,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; @@ -6272,7 +6279,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.10.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list