[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V26 13/32] vvfat.c: handle cross_driver's create_opt
From: |
Chunyan Liu |
Subject: |
[Qemu-devel] [PATCH V26 13/32] vvfat.c: handle cross_driver's create_options and create_opts |
Date: |
Tue, 29 Apr 2014 17:08:22 +0800 |
vvfat shares create options of qcow driver. To avoid vvfat broken when
qcow driver changes from QEMUOptionParameter to QemuOpts, let it able
to handle both cases.
Signed-off-by: Chunyan Liu <address@hidden>
---
block/vvfat.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index 155fc9b..b49ec96 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2907,7 +2907,8 @@ static BlockDriver vvfat_write_target = {
static int enable_write_target(BDRVVVFATState *s)
{
BlockDriver *bdrv_qcow;
- QEMUOptionParameter *options;
+ QemuOptsList *create_opts = NULL;
+ QemuOpts *opts = NULL;
Error *local_err = NULL;
int ret;
int size = sector2cluster(s, s->sector_count);
@@ -2922,11 +2923,17 @@ static int enable_write_target(BDRVVVFATState *s)
}
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, &local_err);
+ ret = bdrv_create(bdrv_qcow, s->qcow_filename, NULL, opts, &local_err);
if (ret < 0) {
qerror_report_err(local_err);
error_free(local_err);
@@ -2955,6 +2962,8 @@ static int enable_write_target(BDRVVVFATState *s)
return 0;
err:
+ qemu_opts_del(opts);
+ qemu_opts_free(create_opts);
g_free(s->qcow_filename);
s->qcow_filename = NULL;
return ret;
--
1.8.4.5
- [Qemu-devel] [PATCH V26 20/32] qed.c: replace QEMUOptionParameter with QemuOpts, (continued)
- [Qemu-devel] [PATCH V26 20/32] qed.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 07/32] QemuOpts: add qemu_opt_get_*_del functions for replace work, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 26/32] ssh.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 06/32] QemuOpts: move qemu_opt_del ahead for later calling, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 08/32] QemuOpts: add qemu_opts_print_help to replace print_option_help, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 32/32] QemuOpts: cleanup tmp 'allocated' member from QemuOptsList, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 15/32] gluster.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 14/32] cow.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 25/32] sheepdog.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 09/32] QemuOpts: add conversion between QEMUOptionParameter to QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 13/32] vvfat.c: handle cross_driver's create_options and create_opts,
Chunyan Liu <=
- [Qemu-devel] [PATCH V26 12/32] change block layer to support both QemuOpts and QEMUOptionParamter, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 30/32] vpc.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 01/32] QemuOpts: move find_desc_by_name ahead for later calling, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 04/32] qapi: output def_value_str when query command line options, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 02/32] QemuOpts: add def_value_str to QemuOptDesc, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 21/32] raw-posix.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 23/32] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 10/32] QemuOpts: add qemu_opts_append to replace append_option_parameters, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 18/32] qcow.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29
- [Qemu-devel] [PATCH V26 19/32] qcow2.c: replace QEMUOptionParameter with QemuOpts, Chunyan Liu, 2014/04/29