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(a)redhat.com>
---
src/libvirt-domain.c | 12 +++++++++++-
src/qemu/qemu_driver.c | 14 --------------
2 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index af69d12..a4ae327 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -7252,8 +7252,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);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index a5ee99d..aa58aa2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4902,13 +4902,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) {
@@ -4924,13 +4917,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;
--
2.0.5