From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwV3c-0004gG-PH for qemu-devel@nongnu.org; Mon, 16 Jun 2014 07:26:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WwV3X-0001yK-O1 for qemu-devel@nongnu.org; Mon, 16 Jun 2014 07:26:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48199) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WwV3X-0001yE-F6 for qemu-devel@nongnu.org; Mon, 16 Jun 2014 07:26:31 -0400 From: Stefan Hajnoczi Date: Mon, 16 Jun 2014 19:23:43 +0800 Message-Id: <1402917843-6459-20-git-send-email-stefanha@redhat.com> In-Reply-To: <1402917843-6459-1-git-send-email-stefanha@redhat.com> References: <1402917843-6459-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 19/39] vvfat.c: handle cross_driver's create_options and create_opts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Chunyan Liu , Stefan Hajnoczi From: Chunyan Liu vvfat shares create options of qcow driver. To avoid vvfat breaking when qcow driver changes from QEMUOptionParameter to QemuOpts, let it able to handle both cases. Signed-off-by: Chunyan Liu Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- block/vvfat.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index d895582..b1ab195 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2910,8 +2910,9 @@ static BlockDriver vvfat_write_target = { static int enable_write_target(BDRVVVFATState *s, Error **errp) { - BlockDriver *bdrv_qcow; - QEMUOptionParameter *options; + BlockDriver *bdrv_qcow = NULL; + QemuOptsList *create_opts = NULL; + QemuOpts *opts = NULL; int ret; int size = sector2cluster(s, s->sector_count); s->used_clusters = calloc(size, 1); @@ -2926,12 +2927,21 @@ static int enable_write_target(BDRVVVFATState *s, Error **errp) } bdrv_qcow = bdrv_find_format("qcow"); - options = parse_option_parameters("", bdrv_qcow->create_options, NULL); - set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count * 512); - set_option_parameter(options, BLOCK_OPT_BACKING_FILE, "fat:"); + assert(!(bdrv_qcow->create_opts && bdrv_qcow->create_options)); + if (bdrv_qcow->create_options) { + create_opts = params_to_opts(bdrv_qcow->create_options); + } else { + create_opts = bdrv_qcow->create_opts; + } + opts = qemu_opts_create(create_opts, NULL, 0, &error_abort); + qemu_opt_set_number(opts, BLOCK_OPT_SIZE, s->sector_count * 512); + qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, "fat:"); - ret = bdrv_create(bdrv_qcow, s->qcow_filename, options, NULL, errp); - free_option_parameters(options); + ret = bdrv_create(bdrv_qcow, s->qcow_filename, NULL, opts, errp); + qemu_opts_del(opts); + if (bdrv_qcow->create_options) { + qemu_opts_free(create_opts); + } if (ret < 0) { goto err; } -- 1.9.3