From: Keir Fraser Date: Fri, 21 May 2010 14:25:10 +0000 (+0100) Subject: xl: fix block-attach command parsing X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~12100 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8aca668075d380c94dac7dba9f292f8cde239b9c;p=xen.git xl: fix block-attach command parsing Fix two command-line parsing problems: - the argc check is wrong: it must be provided with the frontend device - the ro/rw mode is optional, so default to rw if it is absent Also, update the usage message accordingly. Signed-off-by: Jeremy Fitzhardinge --- diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 4f03e8eb64..5c84d33e1d 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3444,7 +3444,7 @@ int main_blockattach(int argc, char **argv) uint32_t fe_domid, be_domid = 0; libxl_device_disk disk = { 0 }; - if ((argc < 3) || (argc > 6)) { + if ((argc < 4) || (argc > 6)) { help("block-attach"); exit(0); } @@ -3489,7 +3489,7 @@ int main_blockattach(int argc, char **argv) } disk.virtpath = argv[3]; disk.unpluggable = 1; - disk.readwrite = (argv[4][0] == 'w') ? 1 : 0; + disk.readwrite = (argc <= 4 || argv[4][0] == 'w') ? 1 : 0; if (domain_qualifier_to_domid(argv[1], &fe_domid, 0) < 0) { fprintf(stderr, "%s is an invalid domain identifier\n", argv[1]); diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index d34e569888..e1caca9db0 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -216,7 +216,7 @@ struct cmd_spec cmd_table[] = { { "block-attach", &main_blockattach, "Create a new virtual block device", - " [BackDomain]", + " [] [BackDomain]", }, { "block-list", &main_blocklist,