[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 19/39] vvfat.c: handle cross_driver's create_options
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 19/39] vvfat.c: handle cross_driver's create_options and create_opts |
Date: |
Mon, 16 Jun 2014 19:23:43 +0800 |
From: Chunyan Liu <address@hidden>
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 <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
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
- [Qemu-devel] [PULL 09/39] QemuOpts: add def_value_str to QemuOptDesc, (continued)
- [Qemu-devel] [PULL 09/39] QemuOpts: add def_value_str to QemuOptDesc, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 10/39] qapi: output def_value_str when query command line options, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 11/39] QemuOpts: change opt->name|str from (const char *) to (char *), Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 12/39] QemuOpts: move qemu_opt_del ahead for later calling, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 13/39] QemuOpts: add qemu_opt_get_*_del functions for replace work, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 14/39] QemuOpts: add qemu_opts_print_help to replace print_option_help, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 15/39] QemuOpts: add conversion between QEMUOptionParameter to QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 16/39] QemuOpts: add qemu_opts_append to replace append_option_parameters, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 17/39] QemuOpts: check NULL input for qemu_opts_del, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 18/39] change block layer to support both QemuOpts and QEMUOptionParamter, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 19/39] vvfat.c: handle cross_driver's create_options and create_opts,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 20/39] cow.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 21/39] gluster.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 22/39] iscsi.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 23/39] nfs.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 24/39] qcow.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 25/39] QemuOpts: export qemu_opt_find, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 26/39] qcow2.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 27/39] qed.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 28/39] raw-posix.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16