From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37914) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn7D-0002C6-PA for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:15:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQn77-00083x-Op for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:15:15 -0400 Received: from mail-yh0-f44.google.com ([209.85.213.44]:52667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn77-00083f-Jd for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:15:09 -0400 Received: by mail-yh0-f44.google.com with SMTP id f10so1718389yha.31 for ; Thu, 20 Mar 2014 17:15:09 -0700 (PDT) From: Leandro Dorileo Date: Thu, 20 Mar 2014 21:13:29 -0300 Message-Id: <1395360813-2833-23-git-send-email-l@dorileo.org> In-Reply-To: <1395360813-2833-1-git-send-email-l@dorileo.org> References: <1395360813-2833-1-git-send-email-l@dorileo.org> Subject: [Qemu-devel] [PATCH 22/26] vmdk: migrate vmdk driver QemuOptionParameter usage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , Liu Yuan , Jeff Cody , Markus Armbruster , Peter Lieven , "Richard W.M. Jones" , Luiz Capitulino , Leandro Dorileo , Ronnie Sahlberg , Josh Durgin , Anthony Liguori , Paolo Bonzini , Stefan Weil , Max Reitz , MORITA Kazutaka , Benoit Canet Do the directly migration from QemuOptionParameter to QemuOpts on vmdk block driver. Signed-off-by: Leandro Dorileo --- block/vmdk.c | 105 ++++++++++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index b69988d..1974c30 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -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) -- 1.9.0