[PATCH v2 5/7] qemu: use new macros for setvcpus to check flags and cleanup the code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]