return kbytes;
}
-static int def_getopt(int argc, char * const argv[], const char *optstring,
+#define COMMON_LONG_OPTS {"help", 0, 0, 'h'}
+
+static int def_getopt(int argc, char * const argv[],
+ const char *optstring,
+ const struct option *longopts,
const char* helpstr, int reqargs)
{
int opt;
+ const struct option def_options[] = {
+ COMMON_LONG_OPTS,
+ {0, 0, 0, 0}
+ };
+
+ if (!longopts)
+ longopts = def_options;
opterr = 0;
- while ((opt = getopt(argc, argv, optstring)) == '?') {
+ while ((opt = getopt_long(argc, argv, optstring, longopts, NULL)) == '?') {
if (optopt == 'h') {
help(helpstr);
return 0;
}
fprintf(stderr, "option `%c' not supported.\n", optopt);
}
+ if (opt == 'h') {
+ help(helpstr);
+ return 0;
+ }
if (opt != -1)
return opt;
char *mem;
int rc;
- if ((opt = def_getopt(argc, argv, "", "mem-max", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "mem-max", 2)) != -1)
return opt;
domid = find_domain(argv[optind]);
int opt = 0;
const char *mem;
- if ((opt = def_getopt(argc, argv, "", "mem-set", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "mem-set", 2)) != -1)
return opt;
domid = find_domain(argv[optind]);
int opt = 0;
const char *virtdev;
- if ((opt = def_getopt(argc, argv, "", "cd-eject", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cd-eject", 2)) != -1)
return opt;
domid = find_domain(argv[optind]);
const char *virtdev;
char *file = NULL; /* modified by cd_insert tokenising it */
- if ((opt = def_getopt(argc, argv, "", "cd-insert", 3)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cd-insert", 3)) != -1)
return opt;
domid = find_domain(argv[optind]);
int opt = 0, num = 0;
libxl_console_type type = 0;
- while ((opt = def_getopt(argc, argv, "n:t:", "console", 1)) != -1) {
+ while ((opt = def_getopt(argc, argv, "n:t:", NULL, "console", 1)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int main_vncviewer(int argc, char **argv)
{
- static const struct option long_options[] = {
+ static const struct option opts[] = {
{"autopass", 0, 0, 'a'},
{"vncviewer-autopass", 0, 0, 'a'},
- {"help", 0, 0, 'h'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
uint32_t domid;
int opt, autopass = 0;
- while (1) {
- opt = getopt_long(argc, argv, "ah", long_options, NULL);
- if (opt == -1)
- break;
-
+ while ((opt = def_getopt(argc, argv, "ah", opts, "vncviewer", 1)) != -1) {
switch (opt) {
+ case 0: case 2:
+ return opt;
case 'a':
autopass = 1;
break;
- case 'h':
- help("vncviewer");
- return 0;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
}
}
- if (argc - optind != 1) {
- help("vncviewer");
- return 2;
- }
-
domid = find_domain(argv[optind]);
if (vncviewer(domid, autopass))
uint32_t domid;
int opt;
- if ((opt = def_getopt(argc, argv, "", "pci-list", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "pci-list", 1)) != -1)
return opt;
domid = find_domain(argv[optind]);
int force = 0;
const char *bdf = NULL;
- while ((opt = def_getopt(argc, argv, "f", "pci-detach", 2)) != -1) {
+ while ((opt = def_getopt(argc, argv, "f", NULL, "pci-detach", 2)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int opt;
const char *bdf = NULL, *vs = NULL;
- if ((opt = def_getopt(argc, argv, "", "pci-attach", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "pci-attach", 2)) != -1)
return opt;
domid = find_domain(argv[optind]);
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "pci-assignable-list", 0)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "pci-assignable-list", 0)) != -1)
return opt;
pciassignable_list();
int opt;
const char *bdf = NULL;
- while ((opt = def_getopt(argc, argv, "", "pci-assignable-add", 1)) != -1) {
+ while ((opt = def_getopt(argc, argv, "", NULL, "pci-assignable-add", 1)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
const char *bdf = NULL;
int rebind = 0;
- while ((opt = def_getopt(argc, argv, "r", "pci-assignable-remove", 1)) != -1) {
+ while ((opt = def_getopt(argc, argv, "r", NULL, "pci-assignable-remove", 1)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int paused = 0, debug = 0, daemonize = 1, monitor = 1,
console_autoconnect = 0, vnc = 0, vncautopass = 0;
int opt, rc;
- int option_index = 0;
- static struct option long_options[] = {
+ static struct option opts[] = {
{"vncviewer", 0, 0, 'V'},
{"vncviewer-autopass", 0, 0, 'A'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
- while (1) {
- opt = getopt_long(argc, argv, "FhcpdeVA", long_options, &option_index);
- if (opt == -1)
- break;
-
+ while ((opt = def_getopt(argc, argv, "FhcpdeVA",
+ opts, "restore", 1)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
- case 'h':
- help("restore");
- return 2;
case 'c':
console_autoconnect = 1;
break;
int debug = 0, daemonize = 1, monitor = 1, remus = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "Fedr", "migrate-receive", 0)) != -1) {
+ while ((opt = def_getopt(argc, argv, "Fedr", NULL, "migrate-receive", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int checkpoint = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "c", "save", 2)) != -1) {
+ while ((opt = def_getopt(argc, argv, "c", NULL, "save", 2)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
char *host;
int opt, daemonize = 1, monitor = 1, debug = 0;
- while ((opt = def_getopt(argc, argv, "FC:s:ed", "migrate", 2)) != -1) {
+ while ((opt = def_getopt(argc, argv, "FC:s:ed", NULL, "migrate", 2)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "dump-core", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "dump-core", 2)) != -1)
return opt;
core_dump_domain(find_domain(argv[optind]), argv[optind + 1]);
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "pause", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "pause", 1)) != -1)
return opt;
pause_domain(find_domain(argv[optind]));
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "unpause", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "unpause", 1)) != -1)
return opt;
unpause_domain(find_domain(argv[optind]));
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "destroy", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "destroy", 1)) != -1)
return opt;
destroy_domain(find_domain(argv[optind]));
static int main_shutdown_or_reboot(int do_reboot, int argc, char **argv)
{
+ const char *what = do_reboot ? "reboot" : "shutdown";
void (*fn)(uint32_t domid,
libxl_evgen_domain_death **, libxl_ev_user, int) =
do_reboot ? &reboot_domain : &shutdown_domain;
int opt, i, nb_domain;
int wait_for_it = 0, all =0;
int fallback_trigger = 0;
- static struct option long_options[] = {
+ static struct option opts[] = {
{"all", 0, 0, 'a'},
{"wait", 0, 0, 'w'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
- while ((opt = getopt_long(argc, argv, "awF", long_options, NULL)) != -1) {
+ while ((opt = def_getopt(argc, argv, "awF", opts, what, 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int opt, verbose = 0;
int context = 0;
int details = 0;
- int option_index = 0;
- static struct option long_options[] = {
+ static struct option opts[] = {
{"long", 0, 0, 'l'},
- {"help", 0, 0, 'h'},
{"verbose", 0, 0, 'v'},
{"context", 0, 0, 'Z'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
libxl_dominfo *info, *info_free=0;
int nb_domain, rc;
- while (1) {
- opt = getopt_long(argc, argv, "lvhZ", long_options, &option_index);
- if (opt == -1)
- break;
-
+ while ((opt = def_getopt(argc, argv, "lvhZ", opts, "list", 0)) != -1) {
switch (opt) {
+ case 0: case 2:
+ return opt;
case 'l':
details = 1;
break;
case 'Z':
context = 1;
break;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
}
}
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "vm-list", 0)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "vm-list", 0)) != -1)
return opt;
list_vm();
int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0,
quiet = 0, monitor = 1, vnc = 0, vncautopass = 0;
int opt, rc;
- int option_index = 0;
- static struct option long_options[] = {
+ static struct option opts[] = {
{"dryrun", 0, 0, 'n'},
{"quiet", 0, 0, 'q'},
- {"help", 0, 0, 'h'},
{"defconfig", 1, 0, 'f'},
{"vncviewer", 0, 0, 'V'},
{"vncviewer-autopass", 0, 0, 'A'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
argc--; argv++;
}
- while (1) {
- opt = getopt_long(argc, argv, "Fhnqf:pcdeVA", long_options, &option_index);
- if (opt == -1)
- break;
-
+ while ((opt = def_getopt(argc, argv, "Fhnqf:pcdeVA", opts, "create", 0)) != -1) {
switch (opt) {
+ case 0: case 2:
+ return opt;
case 'f':
filename = optarg;
break;
case 'A':
vnc = vncautopass = 1;
break;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
}
}
int config_len = 0;
libxl_domain_config d_config;
int opt, rc;
- int option_index = 0;
int debug = 0;
- static struct option long_options[] = {
- {"help", 0, 0, 'h'},
+ static struct option opts[] = {
{"defconfig", 1, 0, 'f'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
argc--; argv++;
}
- while (1) {
- opt = getopt_long(argc, argv, "dhqf:", long_options, &option_index);
- if (opt == -1)
- break;
-
+ while ((opt = def_getopt(argc, argv, "dhqf:", opts, "config_update", 0)) != -1) {
switch (opt) {
+ case 0: case 2:
+ return opt;
case 'd':
debug = 1;
break;
case 'f':
filename = optarg;
break;
- case 'h':
- help("create");
- return 0;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
}
}
fprintf(stderr, "WARNING: \"button-press\" is deprecated. "
"Please use \"trigger\"\n");
- if ((opt = def_getopt(argc, argv, "", "button-press", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "button-press", 2)) != -1)
return opt;
button_press(find_domain(argv[optind]), argv[optind + 1]);
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "cpu-list", 0)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cpu-list", 0)) != -1)
return opt;
vcpulist(argc - optind, argv + optind);
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "vcpu-pin", 3)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "vcpu-pin", 3)) != -1)
return opt;
vcpupin(find_domain(argv[optind]), argv[optind+1] , argv[optind+2]);
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "vcpu-set", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "vcpu-set", 2)) != -1)
return opt;
vcpuset(find_domain(argv[optind]), argv[optind+1]);
int main_info(int argc, char **argv)
{
int opt;
- int option_index = 0;
- static struct option long_options[] = {
- {"help", 0, 0, 'h'},
+ static struct option opts[] = {
{"numa", 0, 0, 'n'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
int numa = 0;
- while ((opt = getopt_long(argc, argv, "hn", long_options, &option_index)) != -1) {
+ while ((opt = def_getopt(argc, argv, "hn", opts, "info", 0)) != -1) {
switch (opt) {
- case 'h':
- help("info");
- return 0;
+ case 0: case 2:
+ return opt;
case 'n':
numa = 1;
break;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
}
}
libxl_dominfo *info, *info_free = NULL;
int nb_domain, rc;
- if ((opt = def_getopt(argc, argv, "", "sharing", 0)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "sharing", 0)) != -1)
return opt;
if (optind >= argc) {
int opt_s = 0;
int tslice = 0, opt_t = 0, ratelimit = 0, opt_r = 0;
int opt, rc;
- int option_index = 0;
- static struct option long_options[] = {
+ static struct option opts[] = {
{"domain", 1, 0, 'd'},
{"weight", 1, 0, 'w'},
{"cap", 1, 0, 'c'},
{"tslice_ms", 1, 0, 't'},
{"ratelimit_us", 1, 0, 'r'},
{"cpupool", 1, 0, 'p'},
- {"help", 0, 0, 'h'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
- while (1) {
- opt = getopt_long(argc, argv, "d:w:c:p:t:r:hs", long_options,
- &option_index);
- if (opt == -1)
- break;
+ while ((opt = def_getopt(argc, argv, "d:w:c:p:t:r:hs", opts, "sched-credit", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
case 'p':
cpupool = optarg;
break;
- case 'h':
- help("sched-credit");
- return 0;
}
}
const char *cpupool = NULL;
int weight = 256, opt_w = 0;
int opt, rc;
- int option_index = 0;
- static struct option long_options[] = {
+ static struct option opts[] = {
{"domain", 1, 0, 'd'},
{"weight", 1, 0, 'w'},
{"cpupool", 1, 0, 'p'},
- {"help", 0, 0, 'h'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
- while (1) {
- opt = getopt_long(argc, argv, "d:w:p:h", long_options, &option_index);
- if (opt == -1)
- break;
+ while ((opt = def_getopt(argc, argv, "d:w:p:h", opts, "sched-credit2", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
case 'p':
cpupool = optarg;
break;
- case 'h':
- help("sched-credit");
- return 0;
}
}
int extra = 0, opt_e = 0;
int weight = 0, opt_w = 0;
int opt, rc;
- int option_index = 0;
- static struct option long_options[] = {
+ static struct option opts[] = {
{"period", 1, 0, 'p'},
{"slice", 1, 0, 's'},
{"latency", 1, 0, 'l'},
{"extra", 1, 0, 'e'},
{"weight", 1, 0, 'w'},
{"cpupool", 1, 0, 'c'},
- {"help", 0, 0, 'h'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
- while (1) {
- opt = getopt_long(argc, argv, "d:p:s:l:e:w:c:h", long_options,
- &option_index);
- if (opt == -1)
- break;
+ while ((opt = def_getopt(argc, argv, "d:p:s:l:e:w:c:h", opts, "sched-sedf", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
case 'c':
cpupool = optarg;
break;
- case 'h':
- help("sched-sedf");
- return 0;
}
}
int opt;
const char *domname = NULL;
- if ((opt = def_getopt(argc, argv, "", "domid", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "domid", 1)) != -1)
return opt;
domname = argv[optind];
char *domname = NULL;
char *endptr = NULL;
- if ((opt = def_getopt(argc, argv, "", "domname", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "domname", 1)) != -1)
return opt;
domid = strtol(argv[optind], &endptr, 10);
int opt;
const char *dom, *new_name;
- if ((opt = def_getopt(argc, argv, "", "rename", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "rename", 2)) != -1)
return opt;
dom = argv[optind++];
const char *trigger_name = NULL;
libxl_trigger trigger;
- if ((opt = def_getopt(argc, argv, "", "trigger", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "trigger", 2)) != -1)
return opt;
domid = find_domain(argv[optind++]);
int opt;
const char *sysrq = NULL;
- if ((opt = def_getopt(argc, argv, "", "sysrq", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "sysrq", 2)) != -1)
return opt;
domid = find_domain(argv[optind++]);
int opt;
char *keys;
- if ((opt = def_getopt(argc, argv, "", "debug-keys", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "debug-keys", 1)) != -1)
return opt;
keys = argv[optind];
char *line;
int opt, ret = 1;
- while ((opt = def_getopt(argc, argv, "c", "dmesg", 0)) != -1) {
+ while ((opt = def_getopt(argc, argv, "c", NULL, "dmesg", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
{
int opt;
- if ((opt = def_getopt(argc, argv, "", "top", 0)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "top", 0)) != -1)
return opt;
return system("xentop");
int i;
unsigned int val;
- if ((opt = def_getopt(argc, argv, "", "network-attach", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "network-attach", 1)) != -1)
return opt;
if (argc-optind > 11) {
libxl_nicinfo nicinfo;
int nb, i;
- if ((opt = def_getopt(argc, argv, "", "network-list", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "network-list", 1)) != -1)
return opt;
/* Idx BE MAC Hdl Sta evch txr/rxr BE-path */
int opt;
libxl_device_nic nic;
- if ((opt = def_getopt(argc, argv, "", "network-detach", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "network-detach", 2)) != -1)
return opt;
domid = find_domain(argv[optind]);
libxl_device_disk disk = { 0 };
XLU_Config *config = 0;
- if ((opt = def_getopt(argc, argv, "", "block-attach", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "block-attach", 2)) != -1)
return opt;
if (domain_qualifier_to_domid(argv[optind], &fe_domid, 0) < 0) {
libxl_device_disk *disks;
libxl_diskinfo diskinfo;
- if ((opt = def_getopt(argc, argv, "", "block-list", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "block-list", 1)) != -1)
return opt;
printf("%-5s %-3s %-6s %-5s %-6s %-8s %-30s\n",
int opt, rc = 0;
libxl_device_disk disk;
- if ((opt = def_getopt(argc, argv, "", "block-detach", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "block-detach", 2)) != -1)
return opt;
domid = find_domain(argv[optind]);
unsigned int val;
uint32_t domid;
- if ((opt = def_getopt(argc, argv, "", "vtpm-attach", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "vtpm-attach", 1)) != -1)
return opt;
if (domain_qualifier_to_domid(argv[optind], &domid, 0) < 0) {
libxl_vtpminfo vtpminfo;
int nb, i;
- if ((opt = def_getopt(argc, argv, "", "vtpm-list", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "vtpm-list", 1)) != -1)
return opt;
/* Idx BE UUID Hdl Sta evch rref BE-path */
libxl_device_vtpm vtpm;
libxl_uuid uuid;
- if ((opt = def_getopt(argc, argv, "", "vtpm-detach", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "vtpm-detach", 2)) != -1)
return opt;
domid = find_domain(argv[optind]);
int nb_doms = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "s", "uptime", 1)) != -1) {
+ while ((opt = def_getopt(argc, argv, "s", NULL, "uptime", 1)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int all = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "al", "tmem-list", 0)) != -1) {
+ while ((opt = def_getopt(argc, argv, "al", NULL, "tmem-list", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int all = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "a", "tmem-freeze", 0)) != -1) {
+ while ((opt = def_getopt(argc, argv, "a", NULL, "tmem-freeze", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int all = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "a", "tmem-thaw", 0)) != -1) {
+ while ((opt = def_getopt(argc, argv, "a", NULL, "tmem-thaw", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int all = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "aw:c:p:", "tmem-set", 0)) != -1) {
+ while ((opt = def_getopt(argc, argv, "aw:c:p:", NULL, "tmem-set", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int all = 0;
int opt;
- while ((opt = def_getopt(argc, argv, "au:A:", "tmem-shared-auth", 0)) != -1) {
+ while ((opt = def_getopt(argc, argv, "au:A:", NULL, "tmem-shared-auth", 0)) != -1) {
switch (opt) {
case 0: case 2:
return opt;
int opt;
int mb;
- if ((opt = def_getopt(argc, argv, "", "tmem-freeable", 0)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "tmem-freeable", 0)) != -1)
return opt;
mb = libxl_tmem_freeable(ctx);
const char *p;
char extra_config[1024];
int opt;
- int option_index = 0;
- static struct option long_options[] = {
- {"help", 0, 0, 'h'},
+ static struct option opts[] = {
{"defconfig", 1, 0, 'f'},
{"dryrun", 0, 0, 'n'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
int ret;
libxl_bitmap cpumap;
libxl_uuid uuid;
libxl_cputopology *topology;
- int rc = -ERROR_FAIL;
-
- while (1) {
- opt = getopt_long(argc, argv, "hnf:", long_options, &option_index);
- if (opt == -1)
- break;
+ int rc = -ERROR_FAIL;
+ while ((opt = def_getopt(argc, argv, "hnf:", opts, "cpupool-create", 0)) != -1) {
switch (opt) {
+ case 0: case 2:
+ return opt;
case 'f':
filename = optarg;
break;
- case 'h':
- help("cpupool-create");
- return 0;
case 'n':
dryrun_only = 1;
break;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
}
}
int main_cpupoollist(int argc, char **argv)
{
int opt;
- int option_index = 0;
- static struct option long_options[] = {
- {"help", 0, 0, 'h'},
+ static struct option opts[] = {
{"cpus", 0, 0, 'c'},
+ COMMON_LONG_OPTS,
{0, 0, 0, 0}
};
int opt_cpus = 0;
char *name;
int ret = 0;
- while (1) {
- opt = getopt_long(argc, argv, "hc", long_options, &option_index);
- if (opt == -1)
- break;
-
+ while ((opt = def_getopt(argc, argv, "hc", opts, "cpupool-list", 1)) != -1) {
switch (opt) {
- case 'h':
- help("cpupool-list");
- return 0;
+ case 0: case 2:
+ break;
case 'c':
opt_cpus = 1;
break;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
}
}
- if ((optind + 1) < argc) {
- help("cpupool-list");
- return -ERROR_FAIL;
- }
if (optind < argc) {
pool = argv[optind];
if (libxl_name_to_cpupoolid(ctx, pool, &poolid)) {
const char *pool;
uint32_t poolid;
- if ((opt = def_getopt(argc, argv, "", "cpupool-destroy", 1)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cpupool-destroy", 1)) != -1)
return opt;
pool = argv[optind];
const char *new_name;
uint32_t poolid;
- if ((opt = def_getopt(argc, argv, "", "cpupool-rename", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cpupool-rename", 2)) != -1)
return opt;
pool = argv[optind++];
int node;
int n;
- if ((opt = def_getopt(argc, argv, "", "cpupool-cpu-add", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cpupool-cpu-add", 2)) != -1)
return opt;
pool = argv[optind++];
int node;
int n;
- if ((opt = def_getopt(argc, argv, "", "cpupool-cpu-remove", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cpupool-cpu-remove", 2)) != -1)
return opt;
pool = argv[optind++];
const char *dom;
uint32_t domid;
- if ((opt = def_getopt(argc, argv, "", "cpupool-migrate", 2)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cpupool-migrate", 2)) != -1)
return opt;
dom = argv[optind++];
libxl_cputopology *topology;
libxl_dominfo info;
- if ((opt = def_getopt(argc, argv, "", "cpupool-numa-split", 0)) != -1)
+ if ((opt = def_getopt(argc, argv, "", NULL, "cpupool-numa-split", 0)) != -1)
return opt;
ret = 0;
r_info.blackhole = 0;
r_info.compression = 1;
- while ((opt = def_getopt(argc, argv, "bui:s:e", "remus", 2)) != -1) {
+ while ((opt = def_getopt(argc, argv, "bui:s:e", NULL, "remus", 2)) != -1) {
switch (opt) {
case 0: case 2:
return opt;