}
static QEMUOptionParameter cow_create_options[] = {
- { BLOCK_OPT_SIZE, OPT_SIZE },
- { BLOCK_OPT_BACKING_FILE, OPT_STRING },
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_BACKING_FILE,
+ .type = OPT_STRING,
+ .help = "File name of a base image"
+ },
{ NULL }
};
static QEMUOptionParameter qcow_create_options[] = {
- { BLOCK_OPT_SIZE, OPT_SIZE },
- { BLOCK_OPT_BACKING_FILE, OPT_STRING },
- { BLOCK_OPT_ENCRYPT, OPT_FLAG },
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_BACKING_FILE,
+ .type = OPT_STRING,
+ .help = "File name of a base image"
+ },
+ {
+ .name = BLOCK_OPT_ENCRYPT,
+ .type = OPT_FLAG,
+ .help = "Encrypt the image"
+ },
{ NULL }
};
}
static QEMUOptionParameter qcow_create_options[] = {
- { BLOCK_OPT_SIZE, OPT_SIZE },
- { BLOCK_OPT_BACKING_FILE, OPT_STRING },
- { BLOCK_OPT_BACKING_FMT, OPT_STRING },
- { BLOCK_OPT_ENCRYPT, OPT_FLAG },
- { BLOCK_OPT_CLUSTER_SIZE, OPT_SIZE },
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_BACKING_FILE,
+ .type = OPT_STRING,
+ .help = "File name of a base image"
+ },
+ {
+ .name = BLOCK_OPT_BACKING_FMT,
+ .type = OPT_STRING,
+ .help = "Image format of the base image"
+ },
+ {
+ .name = BLOCK_OPT_ENCRYPT,
+ .type = OPT_FLAG,
+ .help = "Encrypt the image"
+ },
+ {
+ .name = BLOCK_OPT_CLUSTER_SIZE,
+ .type = OPT_SIZE,
+ .help = "qcow2 cluster size"
+ },
{ NULL }
};
static QEMUOptionParameter raw_create_options[] = {
- { BLOCK_OPT_SIZE, OPT_SIZE },
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = OPT_SIZE,
+ .help = "Virtual disk size"
+ },
{ NULL }
};
}
static QEMUOptionParameter raw_create_options[] = {
- { BLOCK_OPT_SIZE, OPT_SIZE },
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = OPT_SIZE,
+ .help = "Virtual disk size"
+ },
{ NULL }
};
static QEMUOptionParameter vmdk_create_options[] = {
- { BLOCK_OPT_SIZE, OPT_SIZE },
- { BLOCK_OPT_BACKING_FILE, OPT_STRING },
- { BLOCK_OPT_COMPAT6, OPT_FLAG },
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_BACKING_FILE,
+ .type = OPT_STRING,
+ .help = "File name of a base image"
+ },
+ {
+ .name = BLOCK_OPT_COMPAT6,
+ .type = OPT_FLAG,
+ .help = "VMDK version 6 image"
+ },
{ NULL }
};
}
static QEMUOptionParameter vpc_create_options[] = {
- { "size", OPT_SIZE },
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = OPT_SIZE,
+ .help = "Virtual disk size"
+ },
{ NULL }
};
break;
}
}
- if (optind >= argc)
- help();
- filename = argv[optind++];
/* Find driver and parse its options */
drv = bdrv_find_format(fmt);
if (!drv)
error("Unknown file format '%s'", fmt);
+ if (options && !strcmp(options, "?")) {
+ print_option_help(drv->create_options);
+ return 0;
+ }
+
if (options) {
param = parse_option_parameters(options, drv->create_options, param);
if (param == NULL) {
param = parse_option_parameters("", drv->create_options, param);
}
+ /* Get the filename */
+ if (optind >= argc)
+ help();
+ filename = argv[optind++];
+
/* Add size to parameters */
if (optind < argc) {
set_option_parameter(param, BLOCK_OPT_SIZE, argv[optind++]);
if (!drv)
error("Unknown file format '%s'", out_fmt);
+ if (options && !strcmp(options, "?")) {
+ print_option_help(drv->create_options);
+ return 0;
+ }
+
if (options) {
param = parse_option_parameters(options, drv->create_options, param);
if (param == NULL) {
list++;
}
}
+
+/*
+ * Prints an overview of all available options
+ */
+void print_option_help(QEMUOptionParameter *list)
+{
+ printf("Supported options:\n");
+ while (list && list->name) {
+ printf("%-16s %s\n", list->name,
+ list->help ? list->help : "No description available");
+ list++;
+ }
+}
uint64_t n;
char* s;
} value;
+ const char *help;
} QEMUOptionParameter;
QEMUOptionParameter *list, QEMUOptionParameter *dest);
void free_option_parameters(QEMUOptionParameter *list);
void print_option_parameters(QEMUOptionParameter *list);
+void print_option_help(QEMUOptionParameter *list);
#endif