Skip to content

Commit

Permalink
vvfat.c: handle cross_driver's create_options and create_opts
Browse files Browse the repository at this point in the history
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 <cyliu@suse.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
  • Loading branch information
Chunyan Liu authored and stefanhaRH committed Jun 16, 2014
1 parent 83d0521 commit facdbb0
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions block/vvfat.c
Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down

0 comments on commit facdbb0

Please sign in to comment.