@@ -1681,8 +1681,7 @@ static int filename_decompose(const char *filename, char *path, char *prefix,
return VMDK_OK;
}
-static int vmdk_create(const char *filename, QEMUOptionParameter *options,
- Error **errp)
+static int vmdk_create(const char *filename, QemuOpts *options, Error **errp)
{
int idx = 0;
BlockDriverState *new_bs = NULL;
@@ -1704,6 +1703,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
uint32_t number_heads = 16;
bool zeroed_grain = false;
uint32_t desc_offset = 0, desc_len;
+ bool compat6;
const char desc_template[] =
"# Disk DescriptorFile\n"
"version=1\n"
@@ -1730,23 +1730,19 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
ret = -EINVAL;
goto exit;
}
- /* Read out options */
- while (options && options->name) {
- if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
- total_size = options->value.n;
- } else if (!strcmp(options->name, BLOCK_OPT_ADAPTER_TYPE)) {
- adapter_type = options->value.s;
- } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {
- backing_file = options->value.s;
- } else if (!strcmp(options->name, BLOCK_OPT_COMPAT6)) {
- flags |= options->value.n ? BLOCK_FLAG_COMPAT6 : 0;
- } else if (!strcmp(options->name, BLOCK_OPT_SUBFMT)) {
- fmt = options->value.s;
- } else if (!strcmp(options->name, BLOCK_OPT_ZEROED_GRAIN)) {
- zeroed_grain |= options->value.n;
- }
- options++;
+
+ total_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0);
+ adapter_type = qemu_opt_get(options, BLOCK_OPT_ADAPTER_TYPE);
+ backing_file = qemu_opt_get(options, BLOCK_OPT_BACKING_FILE);
+
+ compat6 = qemu_opt_get_bool(options, BLOCK_OPT_COMPAT6, false);
+ if (compat6) {
+ flags |= BLOCK_FLAG_COMPAT6;
}
+
+ fmt = qemu_opt_get(options, BLOCK_OPT_SUBFMT);
+ zeroed_grain = qemu_opt_get_bool(options, BLOCK_OPT_ZEROED_GRAIN, false);
+
if (!adapter_type) {
adapter_type = "ide";
} else if (strcmp(adapter_type, "ide") &&
@@ -2062,41 +2058,46 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs)
return spec_info;
}
-static QEMUOptionParameter vmdk_create_options[] = {
- {
- .name = BLOCK_OPT_SIZE,
- .type = OPT_SIZE,
- .help = "Virtual disk size"
- },
- {
- .name = BLOCK_OPT_ADAPTER_TYPE,
- .type = OPT_STRING,
- .help = "Virtual adapter type, can be one of "
- "ide (default), lsilogic, buslogic or legacyESX"
- },
- {
- .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"
- },
- {
- .name = BLOCK_OPT_SUBFMT,
- .type = OPT_STRING,
- .help =
+static QemuOptsList vmdk_create_options = {
+ .name = "vmdk_create_options",
+ .head = QTAILQ_HEAD_INITIALIZER(vmdk_create_options.head),
+ .desc = {
+ {
+ .name = BLOCK_OPT_SIZE,
+ .type = QEMU_OPT_SIZE,
+ .help = "Virtual disk size"
+ },
+ {
+ .name = BLOCK_OPT_ADAPTER_TYPE,
+ .type = QEMU_OPT_STRING,
+ .help = "Virtual adapter type, can be one of "
+ "ide (default), lsilogic, buslogic or legacyESX"
+ },
+ {
+ .name = BLOCK_OPT_BACKING_FILE,
+ .type = QEMU_OPT_STRING,
+ .help = "File name of a base image"
+ },
+ {
+ .name = BLOCK_OPT_COMPAT6,
+ .type = QEMU_OPT_BOOL,
+ .help = "VMDK version 6 image"
+ },
+ {
+ .name = BLOCK_OPT_SUBFMT,
+ .type = QEMU_OPT_STRING,
+ .help =
"VMDK flat extent format, can be one of "
"{monolithicSparse (default) | monolithicFlat | twoGbMaxExtentSparse | twoGbMaxExtentFlat | streamOptimized} "
- },
- {
- .name = BLOCK_OPT_ZEROED_GRAIN,
- .type = OPT_FLAG,
- .help = "Enable efficient zero writes using the zeroed-grain GTE feature"
- },
- { NULL }
+ },
+ {
+ .name = BLOCK_OPT_ZEROED_GRAIN,
+ .type = QEMU_OPT_BOOL,
+ .help = "Enable efficient zero writes using the zeroed-grain "
+ "GTE feature"
+ },
+ { NULL }
+ }
};
static BlockDriver bdrv_vmdk = {
@@ -2118,7 +2119,7 @@ static BlockDriver bdrv_vmdk = {
.bdrv_get_specific_info = vmdk_get_specific_info,
.bdrv_refresh_limits = vmdk_refresh_limits,
- .create_options = vmdk_create_options,
+ .create_options = &vmdk_create_options,
};
static void bdrv_vmdk_init(void)
Do the directly migration from QemuOptionParameter to QemuOpts on vmdk block driver. Signed-off-by: Leandro Dorileo <l@dorileo.org> --- block/vmdk.c | 105 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 52 deletions(-)