qemuDomainObjPrivatePtr priv;
virDomainObjPtr vm;
virDomainDefPtr def;
+ virDomainDefPtr persistentDef;
int ret = -1;
- virCapsPtr caps = NULL;
qemuAgentCPUInfoPtr cpuinfo = NULL;
int ncpuinfo = -1;
size_t i;
if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup;
- if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
- goto cleanup;
-
- if (virDomainLiveConfigHelperMethod(caps, driver->xmlopt,
- vm, &flags, &def) < 0)
+ if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0)
goto cleanup;
- if (flags & VIR_DOMAIN_AFFECT_LIVE)
- def = vm->def;
-
if (flags & VIR_DOMAIN_VCPU_GUEST) {
- if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
+ if (persistentDef) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("vCPU count provided by the guest agent can only be "
" requested for live domains"));
ret++;
}
} else {
+ if (!def)
+ def = persistentDef;
+
if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
ret = def->maxvcpus;
else
cleanup:
virDomainObjEndAPI(&vm);
- virObjectUnref(caps);
VIR_FREE(cpuinfo);
return ret;
}