From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6F-0000sW-Ln for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQn69-0007ac-8m for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:15 -0400 Received: from mail-yk0-f169.google.com ([209.85.160.169]:62810) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn68-0007aW-Uv for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:09 -0400 Received: by mail-yk0-f169.google.com with SMTP id 142so4367617ykq.0 for ; Thu, 20 Mar 2014 17:14:08 -0700 (PDT) From: Leandro Dorileo Date: Thu, 20 Mar 2014 21:13:14 -0300 Message-Id: <1395360813-2833-8-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 07/26] cow: migrate cow 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 cow block driver. Signed-off-by: Leandro Dorileo --- block/cow.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/block/cow.c b/block/cow.c index 30deb88..811f7f7 100644 --- a/block/cow.c +++ b/block/cow.c @@ -324,8 +324,7 @@ static void cow_close(BlockDriverState *bs) { } -static int cow_create(const char *filename, QEMUOptionParameter *options, - Error **errp) +static int cow_create(const char *filename, QemuOpts *options, Error **errp) { struct cow_header_v2 cow_header; struct stat st; @@ -335,16 +334,13 @@ static int cow_create(const char *filename, QEMUOptionParameter *options, int ret; BlockDriverState *cow_bs; - /* Read out options */ - while (options && options->name) { - if (!strcmp(options->name, BLOCK_OPT_SIZE)) { - image_sectors = options->value.n / 512; - } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) { - image_filename = options->value.s; - } - options++; + image_sectors = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0); + if (image_sectors) { + image_sectors = image_sectors / 512; } + image_filename = qemu_opt_get(options, BLOCK_OPT_BACKING_FILE); + ret = bdrv_create_file(filename, options, &local_err); if (ret < 0) { error_propagate(errp, local_err); @@ -393,18 +389,22 @@ exit: return ret; } -static QEMUOptionParameter cow_create_options[] = { - { - .name = BLOCK_OPT_SIZE, - .type = OPT_SIZE, - .help = "Virtual disk size" - }, - { - .name = BLOCK_OPT_BACKING_FILE, - .type = OPT_STRING, - .help = "File name of a base image" +static QemuOptsList cow_create_options = { + .name = "cow_create_options", + .head = QTAILQ_HEAD_INITIALIZER(cow_create_options.head), + .desc = { + { + .name = BLOCK_OPT_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Virtual disk size" + }, + { + .name = BLOCK_OPT_BACKING_FILE, + .type = QEMU_OPT_STRING, + .help = "File name of a base image" + }, + { NULL } }, - { NULL } }; static BlockDriver bdrv_cow = { @@ -421,7 +421,7 @@ static BlockDriver bdrv_cow = { .bdrv_write = cow_co_write, .bdrv_co_get_block_status = cow_co_get_block_status, - .create_options = cow_create_options, + .create_options = &cow_create_options, }; static void bdrv_cow_init(void) -- 1.9.0