|
|
9ae3a8 |
From 615669f863855880e3adfcc8046e34cdc6d7e8d6 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 5 Nov 2013 14:09:03 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 50/87] blockdev: Pass QDict to blockdev_init()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1383660558-32096-10-git-send-email-kwolf@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 55388
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 09/24] blockdev: Pass QDict to blockdev_init()
|
|
|
9ae3a8 |
Bugzilla: 978402
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Working on a QDict instead of a QemuOpts that accepts anything is more
|
|
|
9ae3a8 |
in line with bdrv_open(). A QDict is what qmp_blockdev_add() already has
|
|
|
9ae3a8 |
anyway, so this saves additional conversions. And last, but not least,
|
|
|
9ae3a8 |
it allows later patches to easily extract legacy options into a
|
|
|
9ae3a8 |
separate, typed QemuOpts for drive_init() (the untyped QemuOpts that
|
|
|
9ae3a8 |
drive_init already has doesn't allow access to numbers, only strings,
|
|
|
9ae3a8 |
and is therefore useless without conversion).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Benoit Canet <benoit@irqsave.net>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit f298d071662af6cf5dc221ee3e3bd0154035e570)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
blockdev.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 34 +++++++++++++++++-----------------
|
|
|
9ae3a8 |
1 file changed, 17 insertions(+), 17 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockdev.c | 34 +++++++++++++++++-----------------
|
|
|
9ae3a8 |
1 files changed, 17 insertions(+), 17 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
9ae3a8 |
index 03ee554..8dd9fd7 100644
|
|
|
9ae3a8 |
--- a/blockdev.c
|
|
|
9ae3a8 |
+++ b/blockdev.c
|
|
|
9ae3a8 |
@@ -217,7 +217,10 @@ static void bdrv_format_print(void *opaque, const char *name)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void drive_uninit(DriveInfo *dinfo)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- qemu_opts_del(dinfo->opts);
|
|
|
9ae3a8 |
+ if (dinfo->opts) {
|
|
|
9ae3a8 |
+ qemu_opts_del(dinfo->opts);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
bdrv_delete(dinfo->bdrv);
|
|
|
9ae3a8 |
g_free(dinfo->id);
|
|
|
9ae3a8 |
QTAILQ_REMOVE(&drives, dinfo, next);
|
|
|
9ae3a8 |
@@ -321,7 +324,8 @@ static bool do_check_io_limits(BlockIOLimit *io_limits, Error **errp)
|
|
|
9ae3a8 |
return true;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static DriveInfo *blockdev_init(QemuOpts *all_opts,
|
|
|
9ae3a8 |
+/* Takes the ownership of bs_opts */
|
|
|
9ae3a8 |
+static DriveInfo *blockdev_init(QDict *bs_opts,
|
|
|
9ae3a8 |
BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
const char *buf;
|
|
|
9ae3a8 |
@@ -345,7 +349,6 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
|
|
|
9ae3a8 |
int ret;
|
|
|
9ae3a8 |
Error *error = NULL;
|
|
|
9ae3a8 |
QemuOpts *opts;
|
|
|
9ae3a8 |
- QDict *bs_opts;
|
|
|
9ae3a8 |
const char *id;
|
|
|
9ae3a8 |
bool has_driver_specific_opts;
|
|
|
9ae3a8 |
BlockDriver *drv = NULL;
|
|
|
9ae3a8 |
@@ -353,9 +356,9 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
|
|
|
9ae3a8 |
translation = BIOS_ATA_TRANSLATION_AUTO;
|
|
|
9ae3a8 |
media = MEDIA_DISK;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- /* Check common options by copying from all_opts to opts, all other options
|
|
|
9ae3a8 |
- * are stored in bs_opts. */
|
|
|
9ae3a8 |
- id = qemu_opts_id(all_opts);
|
|
|
9ae3a8 |
+ /* Check common options by copying from bs_opts to opts, all other options
|
|
|
9ae3a8 |
+ * stay in bs_opts for processing by bdrv_open(). */
|
|
|
9ae3a8 |
+ id = qdict_get_try_str(bs_opts, "id");
|
|
|
9ae3a8 |
opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
|
|
|
9ae3a8 |
if (error_is_set(&error)) {
|
|
|
9ae3a8 |
qerror_report_err(error);
|
|
|
9ae3a8 |
@@ -363,8 +366,6 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
|
|
|
9ae3a8 |
return NULL;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- bs_opts = qdict_new();
|
|
|
9ae3a8 |
- qemu_opts_to_qdict(all_opts, bs_opts);
|
|
|
9ae3a8 |
qemu_opts_absorb_qdict(opts, bs_opts, &error);
|
|
|
9ae3a8 |
if (error_is_set(&error)) {
|
|
|
9ae3a8 |
qerror_report_err(error);
|
|
|
9ae3a8 |
@@ -634,7 +635,6 @@ static DriveInfo *blockdev_init(QemuOpts *all_opts,
|
|
|
9ae3a8 |
dinfo->heads = heads;
|
|
|
9ae3a8 |
dinfo->secs = secs;
|
|
|
9ae3a8 |
dinfo->trans = translation;
|
|
|
9ae3a8 |
- dinfo->opts = all_opts;
|
|
|
9ae3a8 |
dinfo->refcount = 1;
|
|
|
9ae3a8 |
if (serial != NULL) {
|
|
|
9ae3a8 |
dinfo->serial = g_strdup(serial);
|
|
|
9ae3a8 |
@@ -756,6 +756,7 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
const char *value;
|
|
|
9ae3a8 |
DriveInfo *dinfo;
|
|
|
9ae3a8 |
+ QDict *bs_opts;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Change legacy command line options into QMP ones */
|
|
|
9ae3a8 |
qemu_opt_rename(all_opts, "iops", "throttling.iops-total");
|
|
|
9ae3a8 |
@@ -793,14 +794,19 @@ DriveInfo *drive_init(QemuOpts *all_opts, BlockInterfaceType block_default_type)
|
|
|
9ae3a8 |
qemu_opt_unset(all_opts, "cache");
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ /* Get a QDict for processing the options */
|
|
|
9ae3a8 |
+ bs_opts = qdict_new();
|
|
|
9ae3a8 |
+ qemu_opts_to_qdict(all_opts, bs_opts);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* Actual block device init: Functionality shared with blockdev-add */
|
|
|
9ae3a8 |
- dinfo = blockdev_init(all_opts, block_default_type);
|
|
|
9ae3a8 |
+ dinfo = blockdev_init(bs_opts, block_default_type);
|
|
|
9ae3a8 |
if (dinfo == NULL) {
|
|
|
9ae3a8 |
goto fail;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Set legacy DriveInfo fields */
|
|
|
9ae3a8 |
dinfo->enable_auto_del = true;
|
|
|
9ae3a8 |
+ dinfo->opts = all_opts;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
fail:
|
|
|
9ae3a8 |
return dinfo;
|
|
|
9ae3a8 |
@@ -1699,13 +1705,7 @@ void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
qdict_flatten(qdict);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- QemuOpts *opts = qemu_opts_from_qdict(&qemu_drive_opts, qdict, &local_err);
|
|
|
9ae3a8 |
- if (error_is_set(&local_err)) {
|
|
|
9ae3a8 |
- error_propagate(errp, local_err);
|
|
|
9ae3a8 |
- goto fail;
|
|
|
9ae3a8 |
- }
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- dinfo = blockdev_init(opts, IF_NONE);
|
|
|
9ae3a8 |
+ dinfo = blockdev_init(qdict, IF_NONE);
|
|
|
9ae3a8 |
if (!dinfo) {
|
|
|
9ae3a8 |
error_setg(errp, "Could not open image");
|
|
|
9ae3a8 |
goto fail;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|