[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [v19 19/25] vmdk.c: replace QEMUOptionParameter with QemuOp
From: |
Chunyan Liu |
Subject: |
[Qemu-devel] [v19 19/25] vmdk.c: replace QEMUOptionParameter with QemuOpts |
Date: |
Mon, 20 Jan 2014 22:20:02 +0800 |
vmdk.c: replace QEMUOptionParameter with QemuOpts
Signed-off-by: Dong Xu Wang <address@hidden>
Signed-off-by: Chunyan Liu <address@hidden>
---
block/vmdk.c | 109 +++++++++++++++++++++++++++++----------------------------
1 files changed, 55 insertions(+), 54 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 974eaff..c3d4328 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1617,7 +1617,7 @@ static int filename_decompose(const char *filename, char
*path, char *prefix,
return VMDK_OK;
}
-static int vmdk_create(const char *filename, QEMUOptionParameter *options,
+static int vmdk_create(const char *filename, QemuOpts *opts,
Error **errp)
{
int idx = 0;
@@ -1667,22 +1667,17 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options,
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_del(opts, BLOCK_OPT_SIZE, 0);
+ adapter_type = qemu_opt_get_del(opts, BLOCK_OPT_ADAPTER_TYPE);
+ backing_file = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
+ if (qemu_opt_get_bool_del(opts, BLOCK_OPT_COMPAT6, false)) {
+ flags |= BLOCK_FLAG_COMPAT6;
+ }
+ fmt = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT);
+ if (qemu_opt_get_bool_del(opts, BLOCK_OPT_ZEROED_GRAIN, false)) {
+ zeroed_grain = true;
}
+
if (!adapter_type) {
adapter_type = "ide";
} else if (strcmp(adapter_type, "ide") &&
@@ -1801,7 +1796,7 @@ static int vmdk_create(const char *filename,
QEMUOptionParameter *options,
if (!split && !flat) {
desc_offset = 0x200;
} else {
- ret = bdrv_create_file(filename, options, NULL, &local_err);
+ ret = bdrv_create_file(filename, NULL, opts, &local_err);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not create image file");
goto exit;
@@ -1949,41 +1944,47 @@ 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 =
- "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 }
+static QemuOptsList vmdk_create_opts = {
+ .name = "vmdk-create-opts",
+ .head = QTAILQ_HEAD_INITIALIZER(vmdk_create_opts.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",
+ .def_value_str = "off"
+ },
+ {
+ .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 = QEMU_OPT_BOOL,
+ .help = "Enable efficient zero writes "
+ "using the zeroed-grain GTE feature"
+ },
+ { /* end of list */ }
+ }
};
static BlockDriver bdrv_vmdk = {
@@ -1996,14 +1997,14 @@ static BlockDriver bdrv_vmdk = {
.bdrv_write = vmdk_co_write,
.bdrv_co_write_zeroes = vmdk_co_write_zeroes,
.bdrv_close = vmdk_close,
- .bdrv_create = vmdk_create,
+ .bdrv_create2 = vmdk_create,
.bdrv_co_flush_to_disk = vmdk_co_flush,
.bdrv_co_get_block_status = vmdk_co_get_block_status,
.bdrv_get_allocated_file_size = vmdk_get_allocated_file_size,
.bdrv_has_zero_init = vmdk_has_zero_init,
.bdrv_get_specific_info = vmdk_get_specific_info,
- .create_options = vmdk_create_options,
+ .create_opts = &vmdk_create_opts,
};
static void bdrv_vmdk_init(void)
--
1.6.0.2
- [Qemu-devel] [v19 11/25] qcow2.c: replace QEMUOptionParameter with QemuOpts in amend options, (continued)
- [Qemu-devel] [v19 11/25] qcow2.c: replace QEMUOptionParameter with QemuOpts in amend options, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 15/25] rbd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 12/25] qed.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 13/25] raw-posix.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 16/25] sheepdog.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 14/25] raw-win32.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 18/25] vdi.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 17/25] ssh.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 21/25] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 19/25] vmdk.c: replace QEMUOptionParameter with QemuOpts,
Chunyan Liu <=
- [Qemu-devel] [v19 20/25] vpc.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 22/25] vhdx.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 23/25] vvfat.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 25/25] change back to original name from bdrv_create2 to bdrv_create, Chunyan Liu, 2014/01/20
- [Qemu-devel] [v19 24/25] cleanup QEMUOptionParameter, Chunyan Liu, 2014/01/20
- Re: [Qemu-devel] [v19 00/25] replace QEMUOptionParameter with QemuOpts, Kevin Wolf, 2014/01/22