qemu: Introduce qemuDomainUpdateQEMUCaps()

This function updates the used QEMU capabilities of @vm by querying
the QEMU capabilities cache.

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Marc Hartmayer 2018-09-20 19:44:48 +02:00 committed by John Ferlan
parent a4c12a5096
commit 9f81dc1081
3 changed files with 32 additions and 11 deletions

View File

@ -13122,6 +13122,31 @@ qemuDomainFixupCPUs(virDomainObjPtr vm,
} }
/**
* qemuDomainUpdateQEMUCaps:
* @vm: domain object
* @qemuCapsCache: cache of QEMU capabilities
*
* This function updates the used QEMU capabilities of @vm by querying
* the QEMU capabilities cache.
*
* Returns 0 on success, -1 on error.
*/
int
qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
virFileCachePtr qemuCapsCache)
{
qemuDomainObjPrivatePtr priv = vm->privateData;
virObjectUnref(priv->qemuCaps);
if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(qemuCapsCache,
vm->def->emulator,
vm->def->os.machine)))
return -1;
return 0;
}
char * char *
qemuDomainGetMachineName(virDomainObjPtr vm) qemuDomainGetMachineName(virDomainObjPtr vm)
{ {

View File

@ -1037,6 +1037,10 @@ int
qemuDomainFixupCPUs(virDomainObjPtr vm, qemuDomainFixupCPUs(virDomainObjPtr vm,
virCPUDefPtr *origCPU); virCPUDefPtr *origCPU);
int
qemuDomainUpdateQEMUCaps(virDomainObjPtr vm,
virFileCachePtr qemuCapsCache);
char * char *
qemuDomainGetMachineName(virDomainObjPtr vm); qemuDomainGetMachineName(virDomainObjPtr vm);

View File

@ -5298,10 +5298,7 @@ qemuProcessInit(virQEMUDriverPtr driver,
} }
VIR_DEBUG("Determining emulator version"); VIR_DEBUG("Determining emulator version");
virObjectUnref(priv->qemuCaps); if (qemuDomainUpdateQEMUCaps(vm, driver->qemuCapsCache) < 0)
if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
vm->def->emulator,
vm->def->os.machine)))
goto cleanup; goto cleanup;
if (flags & VIR_QEMU_PROCESS_START_STANDALONE) if (flags & VIR_QEMU_PROCESS_START_STANDALONE)
@ -7403,10 +7400,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED,
goto error; goto error;
VIR_DEBUG("Determining emulator version"); VIR_DEBUG("Determining emulator version");
virObjectUnref(priv->qemuCaps); if (qemuDomainUpdateQEMUCaps(vm, driver->qemuCapsCache) < 0)
if (!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
vm->def->emulator,
vm->def->os.machine)))
goto error; goto error;
VIR_DEBUG("Preparing monitor state"); VIR_DEBUG("Preparing monitor state");
@ -7869,9 +7863,7 @@ qemuProcessReconnect(void *opaque)
* caps in the domain status, so re-query them * caps in the domain status, so re-query them
*/ */
if (!priv->qemuCaps && if (!priv->qemuCaps &&
!(priv->qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache, (qemuDomainUpdateQEMUCaps(obj, driver->qemuCapsCache) < 0))
obj->def->emulator,
obj->def->os.machine)))
goto error; goto error;
/* In case the domain shutdown while we were not running, /* In case the domain shutdown while we were not running,