[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] blockdev: insert blockdev into QemuOptsList when ho
From: |
Jun Li |
Subject: |
[Qemu-devel] [PATCH] blockdev: insert blockdev into QemuOptsList when hotplug via blockdev-add |
Date: |
Sun, 20 Apr 2014 18:29:54 +0800 |
Currently, when using blockdev-add to add a drive, qemu can not insert
this new drive to QemuOptsList. So this will cause the bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1088176
This patch check the ID is duplicate or not firstly, then if not, insert
the new drive with this ID to QemuOptsList.
Signed-off-by: Jun Li <address@hidden>
---
blockdev.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index 5dd01ea..b4d63e0 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2270,10 +2270,13 @@ void qmp_block_job_complete(const char *device, Error
**errp)
void qmp_blockdev_add(BlockdevOptions *options, Error **errp)
{
QmpOutputVisitor *ov = qmp_output_visitor_new();
+ QemuOptsList *list = qemu_find_opts("drive");
+ const char *id = options->id;
DriveInfo *dinfo;
QObject *obj;
QDict *qdict;
Error *local_err = NULL;
+ QemuOpts *opts = NULL;
/* Require an ID in the top level */
if (!options->has_id) {
@@ -2281,6 +2284,19 @@ void qmp_blockdev_add(BlockdevOptions *options, Error
**errp)
goto fail;
}
+ /*
+ * Check the ID is duplicate ID or not.
+ * If not, insert this blockdev into QemuOptsList.
+ */
+ opts = qemu_opts_create(list, id, 1, &local_err);
+ if (opts == NULL) {
+ if (local_err) {
+ qerror_report_err(local_err);
+ error_free(local_err);
+ }
+ goto fail;
+ }
+
/* TODO Sort it out in raw-posix and drive_init: Reject aio=native with
* cache.direct=false instead of silently switching to aio=threads, except
* if called from drive_init.
--
1.8.3.1
- [Qemu-devel] [PATCH] blockdev: insert blockdev into QemuOptsList when hotplug via blockdev-add,
Jun Li <=