提交 875a731d 编写于 作者: P Peter Krempa

qemu: Simplify qemuDomainGetVcpusFlags by using virDomainObjGetOneDef

virDomainObjGetOneDef is simpler to use than virDomainObjGetDefs
上级 f3a70065
...@@ -5479,7 +5479,6 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) ...@@ -5479,7 +5479,6 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
qemuDomainObjPrivatePtr priv; qemuDomainObjPrivatePtr priv;
virDomainObjPtr vm; virDomainObjPtr vm;
virDomainDefPtr def; virDomainDefPtr def;
virDomainDefPtr persistentDef;
int ret = -1; int ret = -1;
qemuAgentCPUInfoPtr cpuinfo = NULL; qemuAgentCPUInfoPtr cpuinfo = NULL;
int ncpuinfo = -1; int ncpuinfo = -1;
...@@ -5498,11 +5497,11 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) ...@@ -5498,11 +5497,11 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0) if (virDomainGetVcpusFlagsEnsureACL(dom->conn, vm->def, flags) < 0)
goto cleanup; goto cleanup;
if (virDomainObjGetDefs(vm, flags, &def, &persistentDef) < 0) if (!(def = virDomainObjGetOneDef(vm, flags)))
goto cleanup; goto cleanup;
if (flags & VIR_DOMAIN_VCPU_GUEST) { if (flags & VIR_DOMAIN_VCPU_GUEST) {
if (persistentDef) { if (!virDomainObjIsActive(vm)) {
virReportError(VIR_ERR_INVALID_ARG, "%s", virReportError(VIR_ERR_INVALID_ARG, "%s",
_("vCPU count provided by the guest agent can only be " _("vCPU count provided by the guest agent can only be "
" requested for live domains")); " requested for live domains"));
...@@ -5543,9 +5542,6 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) ...@@ -5543,9 +5542,6 @@ qemuDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags)
ret++; ret++;
} }
} else { } else {
if (!def)
def = persistentDef;
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) if (flags & VIR_DOMAIN_VCPU_MAXIMUM)
ret = def->maxvcpus; ret = def->maxvcpus;
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册