From patchwork Fri Mar 21 00:13:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leandro Dorileo X-Patchwork-Id: 332456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EBA912C00AE for ; Fri, 21 Mar 2014 11:26:33 +1100 (EST) Received: from localhost ([::1]:50213 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQnI7-00084I-M4 for incoming@patchwork.ozlabs.org; Thu, 20 Mar 2014 20:26:31 -0400 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) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KsXcU/nVMaLJfbZppYw8lhN0MNc/XR67wLQPEsRcEOI=; b=ciZvZk6PvmID/pnXzNeWnK6QAT1brLyzjcwhUXX6VRdeScCAiO0b2q7ekTtj/Br+jw xyQ68ZzXK9u9Yfs4B4xGN4U6MFwEAwQtuX4UBe22m0xHJ62AMx5vUqIrYnjNrGpQTJ00 2kZUKh9CBhQ244PTqNDK3R94T0qGL9J8+3bIGxJum15vFpOcyNLaPmdjZFmdRQ5KTmC+ ErHfHKkJ8QL/eExd2ZH2thlszOgEkr/wC0/3rvjzZq6jYYdcfEyz7yL+wpmR6aE0/0Gn 2blGbwb82gjIlb70hzOAmVQqpWUvXJ6V3eONeGp1oZoLuVbRPC3UwzwIxAcc6YJGZnlP favg== X-Gm-Message-State: ALoCoQnImbWssLRpm0jcLFcfkX0WwMBpyoz0NfgtGlB0ExBQbnnqClWZeXDgZQvss/gYa2K6zJ4o X-Received: by 10.236.156.65 with SMTP id l41mr38795010yhk.9.1395360909287; Thu, 20 Mar 2014 17:15:09 -0700 (PDT) Received: from dorilex-lnv.MultilaserAP ([177.194.92.107]) by mx.google.com with ESMTPSA id k63sm5501231yhg.37.2014.03.20.17.15.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Mar 2014 17:15:08 -0700 (PDT) From: Leandro Dorileo To: qemu-devel@nongnu.org Date: Thu, 20 Mar 2014 21:13:29 -0300 Message-Id: <1395360813-2833-23-git-send-email-l@dorileo.org> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395360813-2833-1-git-send-email-l@dorileo.org> References: <1395360813-2833-1-git-send-email-l@dorileo.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.213.44 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 Subject: [Qemu-devel] [PATCH 22/26] vmdk: migrate vmdk driver QemuOptionParameter usage X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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)