From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6J-0000yK-Hp for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQn6D-0007b7-3W for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:19 -0400 Received: from mail-yh0-f52.google.com ([209.85.213.52]:46987) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQn6C-0007b1-Sx for qemu-devel@nongnu.org; Thu, 20 Mar 2014 20:14:13 -0400 Received: by mail-yh0-f52.google.com with SMTP id c41so1696735yho.11 for ; Thu, 20 Mar 2014 17:14:12 -0700 (PDT) From: Leandro Dorileo Date: Thu, 20 Mar 2014 21:13:15 -0300 Message-Id: <1395360813-2833-9-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 08/26] gluster: migrate gluster 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 gluster block driver. Signed-off-by: Leandro Dorileo --- block/gluster.c | 68 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 31 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index a44d612..e8d966e 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -470,14 +470,15 @@ static inline int qemu_gluster_zerofill(struct glfs_fd *fd, int64_t offset, } #endif -static int qemu_gluster_create(const char *filename, - QEMUOptionParameter *options, Error **errp) +static int qemu_gluster_create(const char *filename, QemuOpts *options, + Error **errp) { struct glfs *glfs; struct glfs_fd *fd; int ret = 0; int prealloc = 0; int64_t total_size = 0; + const char *prealloc_opt; GlusterConf *gconf = g_malloc0(sizeof(GlusterConf)); glfs = qemu_gluster_init(gconf, filename, errp); @@ -486,24 +487,25 @@ static int qemu_gluster_create(const char *filename, goto out; } - while (options && options->name) { - if (!strcmp(options->name, BLOCK_OPT_SIZE)) { - total_size = options->value.n / BDRV_SECTOR_SIZE; - } else if (!strcmp(options->name, BLOCK_OPT_PREALLOC)) { - if (!options->value.s || !strcmp(options->value.s, "off")) { - prealloc = 0; - } else if (!strcmp(options->value.s, "full") && - gluster_supports_zerofill()) { - prealloc = 1; - } else { - error_setg(errp, "Invalid preallocation mode: '%s'" - " or GlusterFS doesn't support zerofill API", - options->value.s); - ret = -EINVAL; - goto out; - } + total_size = qemu_opt_get_size(options, BLOCK_OPT_SIZE, 0); + if (total_size) { + total_size = total_size / BDRV_SECTOR_SIZE; + } + + prealloc_opt = qemu_opt_get(options, BLOCK_OPT_PREALLOC); + if (prealloc_opt) { + if (!strcmp(prealloc_opt, "off")) { + prealloc = 0; + } else if (!strcmp(prealloc_opt, "full") && + gluster_supports_zerofill()) { + prealloc = 1; + } else { + error_setg(errp, "Invalid preallocation mode: '%s'" + " or GlusterFS doesn't support zerofill API", + prealloc_opt); + ret = -EINVAL; + goto out; } - options++; } fd = glfs_creat(glfs, gconf->image, @@ -688,18 +690,22 @@ static int qemu_gluster_has_zero_init(BlockDriverState *bs) return 0; } -static QEMUOptionParameter qemu_gluster_create_options[] = { - { - .name = BLOCK_OPT_SIZE, - .type = OPT_SIZE, - .help = "Virtual disk size" - }, - { - .name = BLOCK_OPT_PREALLOC, - .type = OPT_STRING, - .help = "Preallocation mode (allowed values: off, full)" +static QemuOptsList qemu_gluster_create_options = { + .name = "qemu_gluster_create_options", + .head = QTAILQ_HEAD_INITIALIZER(qemu_gluster_create_options.head), + .desc = { + { + .name = BLOCK_OPT_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Virtual disk size" + }, + { + .name = BLOCK_OPT_PREALLOC, + .type = QEMU_OPT_STRING, + .help = "Preallocation mode (allowed values: off, full)" + }, + { NULL } }, - { NULL } }; static BlockDriver bdrv_gluster = { @@ -726,7 +732,7 @@ static BlockDriver bdrv_gluster = { #ifdef CONFIG_GLUSTERFS_ZEROFILL .bdrv_co_write_zeroes = qemu_gluster_co_write_zeroes, #endif - .create_options = qemu_gluster_create_options, + .create_options = &qemu_gluster_create_options, }; static BlockDriver bdrv_gluster_tcp = { -- 1.9.0