Skip to content

Commit

Permalink
block: Bugfix 'format' and 'snapshot' used in drive option
Browse files Browse the repository at this point in the history
When use -drive file='xxx',format=qcow2,snapshot=on the error
message "Can't use snapshot=on with driver-specific options"
can be show, and fail to start the qemu.

This should not be happened, and there is no file.driver option
in qemu command line.

It is because the commit 74fe54f,
it puts 'driver' option if the command line use 'format' option.

This patch is to solve this bug.

Signed-off-by: Mike Qiu <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
QiuMike authored and kevmw committed Aug 9, 2013
1 parent 2e985fe commit 6db5f5d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
QDict *bs_opts;
const char *id;
bool has_driver_specific_opts;
BlockDriver *drv = NULL;

translation = BIOS_ATA_TRANSLATION_AUTO;
media = MEDIA_DISK;
Expand Down Expand Up @@ -485,7 +486,11 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
return NULL;
}

qdict_put(bs_opts, "driver", qstring_from_str(buf));
drv = bdrv_find_whitelisted_format(buf, ro);
if (!drv) {
error_report("'%s' invalid format", buf);
return NULL;
}
}

/* disk I/O throttling */
Expand Down Expand Up @@ -700,12 +705,13 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
}

QINCREF(bs_opts);
ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, NULL);
ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv);

if (ret < 0) {
if (ret == -EMEDIUMTYPE) {
error_report("could not open disk image %s: not in %s format",
file ?: dinfo->id, qdict_get_str(bs_opts, "driver"));
file ?: dinfo->id, drv ? drv->format_name :
qdict_get_str(bs_opts, "driver"));
} else {
error_report("could not open disk image %s: %s",
file ?: dinfo->id, strerror(-ret));
Expand Down

0 comments on commit 6db5f5d

Please sign in to comment.