|
|
9ae3a8 |
From c9489944db197e5c1b4086dc92a41f6c364976b0 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Mon, 9 Sep 2013 14:28:17 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 26/38] block: Allow "driver" option on the top level
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1378736903-18489-27-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 54213
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 26/32] block: Allow "driver" option on the top level
|
|
|
9ae3a8 |
Bugzilla: 1005818
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Bugzilla: 1005818
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This is traditionally -drive format=..., which is now translated into
|
|
|
9ae3a8 |
the new driver option. This gives us a more consistent way to select the
|
|
|
9ae3a8 |
driver of BlockDriverStates that can be used in QMP context, too.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 74fe54f2a1b5c4f4498a8fe521e1dfc936656cd4)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 7 +++++++
|
|
|
9ae3a8 |
blockdev.c | 20 ++++++++++----------
|
|
|
9ae3a8 |
2 files changed, 17 insertions(+), 10 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block.c | 7 +++++++
|
|
|
9ae3a8 |
blockdev.c | 20 ++++++++++----------
|
|
|
9ae3a8 |
2 files changed, 17 insertions(+), 10 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block.c b/block.c
|
|
|
9ae3a8 |
index 20820fa..f4a89b9 100644
|
|
|
9ae3a8 |
--- a/block.c
|
|
|
9ae3a8 |
+++ b/block.c
|
|
|
9ae3a8 |
@@ -972,6 +972,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
|
|
|
9ae3a8 |
char tmp_filename[PATH_MAX + 1];
|
|
|
9ae3a8 |
BlockDriverState *file = NULL;
|
|
|
9ae3a8 |
QDict *file_options = NULL;
|
|
|
9ae3a8 |
+ const char *drvname;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* NULL means an empty set of options */
|
|
|
9ae3a8 |
if (options == NULL) {
|
|
|
9ae3a8 |
@@ -1061,6 +1062,12 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Find the right image format driver */
|
|
|
9ae3a8 |
+ drvname = qdict_get_try_str(options, "driver");
|
|
|
9ae3a8 |
+ if (drvname) {
|
|
|
9ae3a8 |
+ drv = bdrv_find_whitelisted_format(drvname, !(flags & BDRV_O_RDWR));
|
|
|
9ae3a8 |
+ qdict_del(options, "driver");
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
if (!drv) {
|
|
|
9ae3a8 |
ret = find_image_format(file, filename, &drv;;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index bd33c17..1c9ca4d 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -322,7 +322,6 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
enum { MEDIA_DISK, MEDIA_CDROM } media;
|
|
|
9ae3a8 |
int bus_id, unit_id;
|
|
|
9ae3a8 |
int cyls, heads, secs, translation;
|
|
|
9ae3a8 |
- BlockDriver *drv = NULL;
|
|
|
9ae3a8 |
int max_devs;
|
|
|
9ae3a8 |
int index;
|
|
|
9ae3a8 |
int ro = 0;
|
|
|
9ae3a8 |
@@ -338,6 +337,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
QemuOpts *opts;
|
|
|
9ae3a8 |
QDict *bs_opts;
|
|
|
9ae3a8 |
const char *id;
|
|
|
9ae3a8 |
+ bool has_driver_specific_opts;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
translation = BIOS_ATA_TRANSLATION_AUTO;
|
|
|
9ae3a8 |
media = MEDIA_DISK;
|
|
|
9ae3a8 |
@@ -365,6 +365,8 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
qdict_del(bs_opts, "id");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ has_driver_specific_opts = !!qdict_size(bs_opts);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* extract parameters */
|
|
|
9ae3a8 |
bus_id = qemu_opt_get_number(opts, "bus", 0);
|
|
|
9ae3a8 |
unit_id = qemu_opt_get_number(opts, "unit", -1);
|
|
|
9ae3a8 |
@@ -477,11 +479,8 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
error_printf("\n");
|
|
|
9ae3a8 |
return NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
- drv = bdrv_find_whitelisted_format(buf, ro);
|
|
|
9ae3a8 |
- if (!drv) {
|
|
|
9ae3a8 |
- error_report("'%s' invalid format", buf);
|
|
|
9ae3a8 |
- return NULL;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ qdict_put(bs_opts, "driver", qstring_from_str(buf));
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* disk I/O throttling */
|
|
|
9ae3a8 |
@@ -658,7 +657,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
abort();
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
if (!file || !*file) {
|
|
|
9ae3a8 |
- if (qdict_size(bs_opts)) {
|
|
|
9ae3a8 |
+ if (has_driver_specific_opts) {
|
|
|
9ae3a8 |
file = NULL;
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
return dinfo;
|
|
|
9ae3a8 |
@@ -695,13 +694,13 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
error_report("warning: disabling copy_on_read on readonly drive");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, drv);
|
|
|
9ae3a8 |
- bs_opts = NULL;
|
|
|
9ae3a8 |
+ QINCREF(bs_opts);
|
|
|
9ae3a8 |
+ ret = bdrv_open(dinfo->bdrv, file, bs_opts, bdrv_flags, NULL);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
if (ret == -EMEDIUMTYPE) {
|
|
|
9ae3a8 |
error_report("could not open disk image %s: not in %s format",
|
|
|
9ae3a8 |
- file ?: dinfo->id, drv->format_name);
|
|
|
9ae3a8 |
+ file ?: dinfo->id, qdict_get_str(bs_opts, "driver"));
|
|
|
9ae3a8 |
} else {
|
|
|
9ae3a8 |
error_report("could not open disk image %s: %s",
|
|
|
9ae3a8 |
file ?: dinfo->id, strerror(-ret));
|
|
|
9ae3a8 |
@@ -712,6 +711,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
if (bdrv_key_required(dinfo->bdrv))
|
|
|
9ae3a8 |
autostart = 0;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ QDECREF(bs_opts);
|
|
|
9ae3a8 |
qemu_opts_del(opts);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
return dinfo;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|