From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6t-0001xK-DL for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:15:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQn6n-0007iR-E2 for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:55 -0400 Received: from mail-yh0-f51.google.com ([209.85.213.51]:50553) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6n-0007iN-9d for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:49 -0400 Received: by mail-yh0-f51.google.com with SMTP id f10so1696972yha.38 for ; Thu, 20 Mar 2014 17:14:49 -0700 (PDT) From: Leandro Dorileo Date: Thu, 20 Mar 2014 21:13:24 -0300 Message-Id: <1395360813-2833-18-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 17/26] rbd: migrate rbd 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 rbd block driver. Signed-off-by: Leandro Dorileo --- block/rbd.c | 60 +++++++++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index dbc79f4..ae8c471 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -282,7 +282,7 @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf) return ret; } -static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options, +static int qemu_rbd_create(const char *filename, QemuOpts *options, Error **errp) { int64_t bytes = 0; @@ -305,25 +305,19 @@ static int qemu_rbd_create(const char *filename, QEMUOptionParameter *options, return -EINVAL; } - /* Read out options */ - while (options && options->name) { - if (!strcmp(options->name, BLOCK_OPT_SIZE)) { - bytes = options->value.n; - } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) { - if (options->value.n) { - objsize = options->value.n; - if ((objsize - 1) & objsize) { /* not a power of 2? */ - error_report("obj size needs to be power of 2"); - return -EINVAL; - } - if (objsize < 4096) { - error_report("obj size too small"); - return -EINVAL; - } - obj_order = ffs(objsize) - 1; - } + bytes = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0); + objsize = qemu_opt_get_size(options, BLOCK_OPT_CLUSTER_SIZE, 0); + + if (objsize != 0) { + if ((objsize - 1) & objsize) { /* not a power of 2? */ + error_report("obj size needs to be power of 2"); + return -EINVAL; + } + if (objsize < 4096) { + error_report("obj size too small"); + return -EINVAL; } - options++; + obj_order = ffs(objsize) - 1; } clientname = qemu_rbd_parse_clientname(conf, clientname_buf); @@ -900,18 +894,22 @@ static BlockDriverAIOCB* qemu_rbd_aio_discard(BlockDriverState *bs, } #endif -static QEMUOptionParameter qemu_rbd_create_options[] = { - { - .name = BLOCK_OPT_SIZE, - .type = OPT_SIZE, - .help = "Virtual disk size" - }, - { - .name = BLOCK_OPT_CLUSTER_SIZE, - .type = OPT_SIZE, - .help = "RBD object size" +static QemuOptsList qemu_rbd_create_options = { + .name = "qemu_rbd_create_options", + .head = QTAILQ_HEAD_INITIALIZER(qemu_rbd_create_options.head), + .desc = { + { + .name = BLOCK_OPT_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Virtual disk size" + }, + { + .name = BLOCK_OPT_CLUSTER_SIZE, + .type = QEMU_OPT_SIZE, + .help = "RBD object size" + }, + {NULL} }, - {NULL} }; static BlockDriver bdrv_rbd = { @@ -923,7 +921,7 @@ static BlockDriver bdrv_rbd = { .bdrv_create = qemu_rbd_create, .bdrv_has_zero_init = bdrv_has_zero_init_1, .bdrv_get_info = qemu_rbd_getinfo, - .create_options = qemu_rbd_create_options, + .create_options = &qemu_rbd_create_options, .bdrv_getlength = qemu_rbd_getlength, .bdrv_truncate = qemu_rbd_truncate, .protocol_name = "rbd", -- 1.9.0