Signed-off-by: juergen.gross@xxxxxxxxxxxxxx diff -r 3985fea87987 tools/libxl/xl_cmdimpl.c --- a/tools/libxl/xl_cmdimpl.c Fri Sep 10 19:06:33 2010 +0100 +++ b/tools/libxl/xl_cmdimpl.c Wed Sep 15 09:21:36 2010 +0200 @@ -3398,7 +3398,7 @@ int main_vcpulist(int argc, char **argv) } } - vcpulist(argc - 2, argv + 2); + vcpulist(argc - optind, argv + optind); return 0; } @@ -3487,22 +3487,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; } @@ -3531,22 +3532,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; }