qemu: use new macros for setvcpus to check flags and cleanup the code

Now that we have macros for exclusive flags and flag requirements we can
use them to cleanup the code for setvcpus and error out for all wrong
flag combination.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2015-03-25 22:33:10 +01:00
parent 6e3f9cbc9c
commit 28ca8520bb
2 changed files with 11 additions and 15 deletions

View File

@ -7245,8 +7245,18 @@ virDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus,
virCheckDomainReturn(domain, -1);
virCheckReadOnlyGoto(domain->conn->flags, error);
VIR_REQUIRE_FLAG_GOTO(VIR_DOMAIN_VCPU_MAXIMUM,
VIR_DOMAIN_AFFECT_CONFIG,
error);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_CURRENT,
VIR_DOMAIN_AFFECT_LIVE,
error);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_AFFECT_CURRENT,
VIR_DOMAIN_AFFECT_CONFIG,
error);
VIR_EXCLUSIVE_FLAGS_GOTO(VIR_DOMAIN_VCPU_GUEST,
VIR_DOMAIN_VCPU_MAXIMUM,
VIR_DOMAIN_AFFECT_CONFIG,
error);
virCheckNonZeroArgGoto(nvcpus, error);

View File

@ -4942,13 +4942,6 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
goto endjob;
}
/* MAXIMUM cannot be mixed with LIVE. */
if ((flags & VIR_DOMAIN_VCPU_MAXIMUM) && (flags & VIR_DOMAIN_AFFECT_LIVE)) {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("cannot adjust maximum vcpus on running domain"));
goto endjob;
}
if (flags & VIR_DOMAIN_AFFECT_LIVE)
maxvcpus = vm->def->maxvcpus;
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
@ -4964,13 +4957,6 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
}
if (flags & VIR_DOMAIN_VCPU_GUEST) {
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("setting vcpus via guest agent isn't supported "
"on offline domain"));
goto endjob;
}
if (!qemuDomainAgentAvailable(vm, true))
goto endjob;