From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDTOJ-0002zg-SP for qemu-devel@nongnu.org; Wed, 12 Feb 2014 01:33:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WDTOD-00013R-Li for qemu-devel@nongnu.org; Wed, 12 Feb 2014 01:33:51 -0500 Received: from victor.provo.novell.com ([137.65.250.26]:58433) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WDTOD-00012w-Dv for qemu-devel@nongnu.org; Wed, 12 Feb 2014 01:33:45 -0500 From: Chunyan Liu Date: Wed, 12 Feb 2014 14:33:22 +0800 Message-Id: <1392186806-10418-23-git-send-email-cyliu@suse.com> In-Reply-To: <1392186806-10418-1-git-send-email-cyliu@suse.com> References: <1392186806-10418-1-git-send-email-cyliu@suse.com> Subject: [Qemu-devel] [PATCH v20 22/26] vpc.c: replace QEMUOptionParameter with QemuOpts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Dong Xu Wang , Chunyan Liu , stefanha@redhat.com vpc.c: replace QEMUOptionParameter with QemuOpts Signed-off-by: Dong Xu Wang Signed-off-by: Chunyan Liu --- block/vpc.c | 52 +++++++++++++++++++++++++++------------------------- 1 files changed, 27 insertions(+), 25 deletions(-) diff --git a/block/vpc.c b/block/vpc.c index 1d326cb..f77f4a5 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -713,12 +713,12 @@ static int create_fixed_disk(int fd, uint8_t *buf, int64_t total_size) return ret; } -static int vpc_create(const char *filename, QEMUOptionParameter *options, +static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) { uint8_t buf[1024]; VHDFooter *footer = (VHDFooter *) buf; - QEMUOptionParameter *disk_type_param; + const char *disk_type_param; int fd, i; uint16_t cyls = 0; uint8_t heads = 0; @@ -729,13 +729,12 @@ static int vpc_create(const char *filename, QEMUOptionParameter *options, int ret = -EIO; /* Read out options */ - total_size = get_option_parameter(options, BLOCK_OPT_SIZE)->value.n; - - disk_type_param = get_option_parameter(options, BLOCK_OPT_SUBFMT); - if (disk_type_param && disk_type_param->value.s) { - if (!strcmp(disk_type_param->value.s, "dynamic")) { + total_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0); + disk_type_param = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT); + if (disk_type_param) { + if (!strcmp(disk_type_param, "dynamic")) { disk_type = VHD_DYNAMIC; - } else if (!strcmp(disk_type_param->value.s, "fixed")) { + } else if (!strcmp(disk_type_param, "fixed")) { disk_type = VHD_FIXED; } else { return -EINVAL; @@ -841,20 +840,24 @@ static void vpc_close(BlockDriverState *bs) error_free(s->migration_blocker); } -static QEMUOptionParameter vpc_create_options[] = { - { - .name = BLOCK_OPT_SIZE, - .type = OPT_SIZE, - .help = "Virtual disk size" - }, - { - .name = BLOCK_OPT_SUBFMT, - .type = OPT_STRING, - .help = - "Type of virtual hard disk format. Supported formats are " - "{dynamic (default) | fixed} " - }, - { NULL } +static QemuOptsList vpc_create_opts = { + .name = "vpc-create-opts", + .head = QTAILQ_HEAD_INITIALIZER(vpc_create_opts.head), + .desc = { + { + .name = BLOCK_OPT_SIZE, + .type = QEMU_OPT_SIZE, + .help = "Virtual disk size" + }, + { + .name = BLOCK_OPT_SUBFMT, + .type = QEMU_OPT_STRING, + .help = + "Type of virtual hard disk format. Supported formats are " + "{dynamic (default) | fixed} " + }, + { /* end of list */ } + } }; static BlockDriver bdrv_vpc = { @@ -865,14 +868,13 @@ static BlockDriver bdrv_vpc = { .bdrv_open = vpc_open, .bdrv_close = vpc_close, .bdrv_reopen_prepare = vpc_reopen_prepare, - .bdrv_create = vpc_create, - + .bdrv_create2 = vpc_create, .bdrv_read = vpc_co_read, .bdrv_write = vpc_co_write, .bdrv_get_info = vpc_get_info, - .create_options = vpc_create_options, + .create_opts = &vpc_create_opts, .bdrv_has_zero_init = vpc_has_zero_init, }; -- 1.6.0.2