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

[Xen-changelog] [xen-unstable] xl: correct vcpu-pin and vcpu-list parameter checking



# HG changeset patch
# User Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
# Date 1284658166 -3600
# Node ID d978675f3d53d48273eae0739d01b806ea9f1068
# Parent  4e47a7db9711818048ea2dd0d111286e8bcf1249
xl: correct vcpu-pin and vcpu-list parameter checking

attached patch corrects parameter checking of vcpu-pin and vcpu-list
sub-commands.

Signed-off-by: Juergen Gross <juergen.gross@xxxxxxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   61 +++++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 30 deletions(-)

diff -r 4e47a7db9711 -r d978675f3d53 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Thu Sep 16 18:02:40 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Thu Sep 16 18:29:26 2010 +0100
@@ -3402,7 +3402,7 @@ int main_vcpulist(int argc, char **argv)
         }
     }
 
-    vcpulist(argc - 2, argv + 2);
+    vcpulist(argc - optind, argv + optind);
     return 0;
 }
 
@@ -3491,22 +3491,23 @@ int main_vcpupin(int argc, char **argv)
 {
     int opt;
 
-    if (argc != 5) {
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
+            help("vcpu-pin");
+            return 0;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (optind != argc - 3) {
         help("vcpu-pin");
-        return 0;
-    }
-    while ((opt = getopt(argc, argv, "h")) != -1) {
-        switch (opt) {
-        case 'h':
-            help("vcpu-pin");
-            return 0;
-        default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
-            break;
-        }
-    }
-
-    vcpupin(argv[2], argv[3] , argv[4]);
+        return 2;
+    }
+
+    vcpupin(argv[optind], argv[optind+1] , argv[optind+2]);
     return 0;
 }
 
@@ -3535,22 +3536,22 @@ int main_vcpuset(int argc, char **argv)
 {
     int opt;
 
-    if (argc != 4) {
+    while ((opt = getopt(argc, argv, "h")) != -1) {
+        switch (opt) {
+        case 'h':
         help("vcpu-set");
-        return 0;
-    }
-    while ((opt = getopt(argc, argv, "h")) != -1) {
-        switch (opt) {
-        case 'h':
+            return 0;
+        default:
+            fprintf(stderr, "option `%c' not supported.\n", opt);
+            break;
+        }
+    }
+
+    if (optind >= argc - 1) {
         help("vcpu-set");
-            return 0;
-        default:
-            fprintf(stderr, "option `%c' not supported.\n", opt);
-            break;
-        }
-    }
-
-    vcpuset(argv[2], argv[3]);
+        return 2;
+    }
+    vcpuset(argv[optind], argv[optind+1]);
     return 0;
 }
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.