xl: fixup command line handling for several commands.
authorIan Campbell <ian.campbell@citrix.com>
Thu, 29 Sep 2011 14:40:34 +0000 (15:40 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 29 Sep 2011 14:40:34 +0000 (15:40 +0100)
def_getopt already checks for a minimum number of arguments for us.

"xl save" simply need to use the correct argument for that value,
contrary to the change I made in 23876:b113d626cfaf

"xl block-list" does not need to check for at least 2 arguments, since
it's already been done by def_getopt.

"xl network-list" would previous accept zero arguments and just print
the table header. Insist on a domain argument.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/xl_cmdimpl.c

index 8b5b55b2dc795dc9260adfd9417d3c36feaf5522..8d20647979e46ee0371f585f6caf475117edad06 100644 (file)
@@ -2866,7 +2866,7 @@ int main_save(int argc, char **argv)
     int checkpoint = 0;
     int opt;
 
-    while ((opt = def_getopt(argc, argv, "c", "save", 1)) != -1) {
+    while ((opt = def_getopt(argc, argv, "c", "save", 2)) != -1) {
         switch (opt) {
         case 0: case 2:
             return opt;
@@ -2876,7 +2876,7 @@ int main_save(int argc, char **argv)
         }
     }
 
-    if (argc-optind < 2 || argc-optind > 3) {
+    if (argc-optind > 3) {
         help("save");
         return 2;
     }
@@ -4025,7 +4025,7 @@ int main_networklist(int argc, char **argv)
     libxl_nicinfo *nics;
     unsigned int nb, i;
 
-    if ((opt = def_getopt(argc, argv, "", "network-list", 0)) != -1)
+    if ((opt = def_getopt(argc, argv, "", "network-list", 1)) != -1)
         return opt;
 
     /*      Idx  BE   MAC   Hdl  Sta  evch txr/rxr  BE-path */
@@ -4096,10 +4096,6 @@ int main_blockattach(int argc, char **argv)
 
     if ((opt = def_getopt(argc, argv, "", "block-attach", 2)) != -1)
         return opt;
-    if ((argc-optind < 2)) {
-        help("block-attach");
-        return 2;
-    }
 
     if (domain_qualifier_to_domid(argv[optind], &fe_domid, 0) < 0) {
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);