提交 b27adaed 编写于 作者: J Jiri Denemark

qemu: Propagate virCapsPtr to virQEMUCapsNewForBinaryInternal

Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 85105b0a
......@@ -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)
......
......@@ -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,
......
......@@ -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,
......
......@@ -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;
......
......@@ -8376,7 +8376,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) {
......@@ -15745,7 +15746,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)
......@@ -18673,7 +18675,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
if (emulatorbin) {
virArch arch_from_caps;
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
if (!(qemuCaps = virQEMUCapsCacheLookup(caps,
driver->qemuCapsCache,
emulatorbin)))
goto cleanup;
......
......@@ -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;
......@@ -4664,7 +4670,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;
......@@ -6282,7 +6289,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;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册