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 <jeremy.fitzhardinge@citrix.com>
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);
}
}
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]);
{ "block-attach",
&main_blockattach,
"Create a new virtual block device",
- "<Domain> <BackDev> <FrontDev> <Mode> [BackDomain]",
+ "<Domain> <BackDev> <FrontDev> [<Mode>] [BackDomain]",
},
{ "block-list",
&main_blocklist,