qemu: Refactor qemuDomainGetEmulatorPinInfo by reusing virDomainObjGetDefs

This commit is contained in:
Peter Krempa 2015-05-29 14:29:06 +02:00
parent 6a34d41894
commit 09fc61264a

View File

@ -5402,14 +5402,13 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
int maplen,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm = NULL;
virDomainDefPtr targetDef = NULL;
virDomainDefPtr def;
virDomainDefPtr targetDef;
int ret = -1;
int hostcpus;
virBitmapPtr cpumask = NULL;
virBitmapPtr bitmap = NULL;
virCapsPtr caps = NULL;
virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
VIR_DOMAIN_AFFECT_CONFIG, -1);
@ -5420,18 +5419,11 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
if (virDomainGetEmulatorPinInfoEnsureACL(dom->conn, vm->def) < 0)
goto cleanup;
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
if (virDomainObjGetDefs(vm, flags, &def, &targetDef) < 0)
goto cleanup;
if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
vm, &flags, &targetDef) < 0)
goto cleanup;
if (flags & VIR_DOMAIN_AFFECT_LIVE)
targetDef = vm->def;
/* Coverity didn't realize that targetDef must be set if we got here. */
sa_assert(targetDef);
if (def)
targetDef = def;
if ((hostcpus = nodeGetCPUCount()) < 0)
goto cleanup;
@ -5453,7 +5445,6 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom,
cleanup:
virDomainObjEndAPI(&vm);
virObjectUnref(caps);
virBitmapFree(bitmap);
return ret;
}