[PATCH 1/5] virsh-domain: Fix declarations of flag variables in cmdChangeMedia

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

 



"flags" were declared as signed and the parameter options can be
declared directly.

Also use macros for mutual exclusion on some of the incompatible
parameter variables.
---
 tools/virsh-domain.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 11db36b..68df01e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9903,26 +9903,21 @@ cmdChangeMedia(vshControl *ctl, const vshCmd *cmd)
     const char *doc = NULL;
     xmlNodePtr disk_node = NULL;
     const char *disk_xml = NULL;
-    unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
-    bool config, live, current, force = false;
-    bool eject, insert, update = false;
     bool ret = false;
     int prepare_type = 0;
     const char *action = NULL;
+    bool config = vshCommandOptBool(cmd, "config");
+    bool live = vshCommandOptBool(cmd, "live");
+    bool current = vshCommandOptBool(cmd, "current");
+    bool force = vshCommandOptBool(cmd, "force");
+    bool eject = vshCommandOptBool(cmd, "eject");
+    bool insert = vshCommandOptBool(cmd, "insert");
+    bool update = vshCommandOptBool(cmd, "update");
+    unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;

-    config = vshCommandOptBool(cmd, "config");
-    live = vshCommandOptBool(cmd, "live");
-    current = vshCommandOptBool(cmd, "current");
-    force = vshCommandOptBool(cmd, "force");
-    eject = vshCommandOptBool(cmd, "eject");
-    insert = vshCommandOptBool(cmd, "insert");
-    update = vshCommandOptBool(cmd, "update");
-
-    if (eject + insert + update > 1) {
-        vshError(ctl, "%s", _("--eject, --insert, and --update must be specified "
-                            "exclusively."));
-        return false;
-    }
+    VSH_EXCLUSIVE_OPTIONS_VAR(eject, insert);
+    VSH_EXCLUSIVE_OPTIONS_VAR(eject, update);
+    VSH_EXCLUSIVE_OPTIONS_VAR(insert, update);

     if (eject) {
         prepare_type = VSH_PREPARE_DISK_XML_EJECT;
-- 
1.8.1.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]