Received: from eggs.gnu.org ([2001:4830:134:3::10]:37694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6c-0001WR-Fn for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQn6W-0007eo-F8 for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:38 -0400 Received: from mail-yh0-f54.google.com ([209.85.213.54]:42141) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6W-0007ej-9m for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:32 -0400 Received: by mail-yh0-f54.google.com with SMTP id f73so1710175yha.41 for ; Thu, 20 Mar 2014 17:14:32 -0700 (PDT) From: Leandro Dorileo Date: Thu, 20 Mar 2014 21:13:20 -0300 Message-Id: <1395360813-2833-14-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 13/26] qed: migrate qed 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 qed block driver. Signed-off-by: Leandro Dorileo --- block/qed.c | 79 +++++++++++++++++++++++++++---------------------------------- 1 file changed, 35 insertions(+), 44 deletions(-) diff --git a/block/qed.c b/block/qed.c index 3bd9db9..c082ba3 100644 --- a/block/qed.c +++ b/block/qed.c @@ -621,7 +621,7 @@ out: return ret; } -static int bdrv_qed_create(const char *filename, QEMUOptionParameter *options, +static int bdrv_qed_create(const char *filename, QemuOpts *options, Error **errp) { uint64_t image_size = 0; @@ -630,24 +630,11 @@ static int bdrv_qed_create(const char *filename, QEMUOptionParameter *options, const char *backing_file = NULL; const char *backing_fmt = NULL; - while (options && options->name) { - if (!strcmp(options->name, BLOCK_OPT_SIZE)) { - image_size = options->value.n; - } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { - backing_file = options->value.s; - } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FMT)) { - backing_fmt = options->value.s; - } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) { - if (options->value.n) { - cluster_size = options->value.n; - } - } else if (!strcmp(options->name, BLOCK_OPT_TABLE_SIZE)) { - if (options->value.n) { - table_size = options->value.n; - } - } - options++; - } + image_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0); + backing_file = qemu_opt_get(options, BLOCK_OPT_BACKING_FILE); + backing_fmt = qemu_opt_get(options, BLOCK_OPT_BACKING_FMT); + cluster_size = qemu_opt_get_size(options, BLOCK_OPT_CLUSTER_SIZE, 0); + table_size = qemu_opt_get_size(options, BLOCK_OPT_TABLE_SIZE, 0); if (!qed_is_cluster_size_valid(cluster_size)) { fprintf(stderr, "QED cluster size must be within range [%u, %u] and power of 2\n", @@ -1593,36 +1580,40 @@ static int bdrv_qed_check(BlockDriverState *bs, BdrvCheckResult *result, return qed_check(s, result, !!fix); } -static QEMUOptionParameter qed_create_options[] = { - { - .name = BLOCK_OPT_SIZE, - .type = OPT_SIZE, - .help = "Virtual disk size (in bytes)" - }, { - .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_CLUSTER_SIZE, - .type = OPT_SIZE, - .help = "Cluster size (in bytes)", - .value = { .n = QED_DEFAULT_CLUSTER_SIZE }, - }, { - .name = BLOCK_OPT_TABLE_SIZE, - .type = OPT_SIZE, - .help = "L1/L2 table size (in clusters)" - }, - { /* end of list */ } +static QemuOptsList qed_create_options = { + .name = "qed_create_options", + .head = QTAILQ_HEAD_INITIALIZER(qed_create_options.head), + .desc = { + { + .name = BLOCK_OPT_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Virtual disk size (in bytes)" + }, { + .name = BLOCK_OPT_BACKING_FILE, + .type = QEMU_OPT_STRING, + .help = "File name of a base image" + }, { + .name = BLOCK_OPT_BACKING_FMT, + .type = QEMU_OPT_STRING, + .help = "Image format of the base image" + }, { + .name = BLOCK_OPT_CLUSTER_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Cluster size (in bytes)", + .def_val = QEMU_OPT_VAL_SIZE(QED_DEFAULT_CLUSTER_SIZE), + }, { + .name = BLOCK_OPT_TABLE_SIZE, + .type = QEMU_OPT_SIZE, + .help = "L1/L2 table size (in clusters)" + }, + { /* end of list */ } + } }; static BlockDriver bdrv_qed = { .format_name = "qed", .instance_size = sizeof(BDRVQEDState), - .create_options = qed_create_options, + .create_options = &qed_create_options, .bdrv_probe = bdrv_qed_probe, .bdrv_rebind = bdrv_qed_rebind, -- 1.9.0