|
|
0a122b |
From b4d1a1c8b3448337e9b5e33706913b82356d22a7 Mon Sep 17 00:00:00 2001
|
|
|
0a122b |
From: Amos Kong <akong@redhat.com>
|
|
|
0a122b |
Date: Tue, 11 Mar 2014 23:59:22 +0100
|
|
|
0a122b |
Subject: [PATCH 1/6] qdev-monitor: Set properties after parent is assigned in device_add
|
|
|
0a122b |
MIME-Version: 1.0
|
|
|
0a122b |
Content-Type: text/plain; charset=UTF-8
|
|
|
0a122b |
Content-Transfer-Encoding: 8bit
|
|
|
0a122b |
|
|
|
0a122b |
RH-Author: Amos Kong <akong@redhat.com>
|
|
|
0a122b |
Message-id: <1394582362-8252-1-git-send-email-akong@redhat.com>
|
|
|
0a122b |
Patchwork-id: 58081
|
|
|
0a122b |
O-Subject: [RHEL-7.0 qemu-kvm PATCH] qdev-monitor: Set properties after parent is assigned in device_add
|
|
|
0a122b |
Bugzilla: 1046248
|
|
|
0a122b |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
|
|
|
0a122b |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
0a122b |
|
|
|
0a122b |
Bugzilla: 1046248
|
|
|
0a122b |
Brew: https://brewweb.devel.redhat.com/taskinfo?taskID=7190260
|
|
|
0a122b |
Upstream: backported from qemu-cpu subtree (qom-next branch)
|
|
|
0a122b |
commit bd140cf43d0373cca4c17efaf2ce730cdcbc0c4e
|
|
|
0a122b |
|
|
|
0a122b |
Test steps:
|
|
|
0a122b |
(qemu) device_add e1000,addr=adsf
|
|
|
0a122b |
Property 'e1000.addr' doesn't take value 'adsf'
|
|
|
0a122b |
(qemu) info qtree
|
|
|
0a122b |
Then qemu crashed.
|
|
|
0a122b |
|
|
|
0a122b |
Currently we set a link to the new device from its parent bus, but the
|
|
|
0a122b |
device hasn't been added to QOM tree yet. When it fails to set properties,
|
|
|
0a122b |
object_unparent() can't clean up the device.
|
|
|
0a122b |
|
|
|
0a122b |
Delay setting of device properties until the device has been added to
|
|
|
0a122b |
the QOM composition tree. This way, when setting a property fails,
|
|
|
0a122b |
object_unparent() can clean up the device properly.
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Amos Kong <akong@redhat.com>
|
|
|
0a122b |
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
0a122b |
Signed-off-by: Andreas Färber <afaerber@suse.de>
|
|
|
0a122b |
---
|
|
|
0a122b |
qdev-monitor.c | 15 +++++++++------
|
|
|
0a122b |
1 file changed, 9 insertions(+), 6 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
0a122b |
---
|
|
|
0a122b |
qdev-monitor.c | 15 +++++++++------
|
|
|
0a122b |
1 files changed, 9 insertions(+), 6 deletions(-)
|
|
|
0a122b |
|
|
|
0a122b |
diff --git a/qdev-monitor.c b/qdev-monitor.c
|
|
|
0a122b |
index d7b9f04..ee891ea 100644
|
|
|
0a122b |
--- a/qdev-monitor.c
|
|
|
0a122b |
+++ b/qdev-monitor.c
|
|
|
0a122b |
@@ -522,7 +522,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
|
|
|
0a122b |
return NULL;
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
- /* create device, set properties */
|
|
|
0a122b |
+ /* create device */
|
|
|
0a122b |
dev = DEVICE(object_new(driver));
|
|
|
0a122b |
|
|
|
0a122b |
if (bus) {
|
|
|
0a122b |
@@ -533,11 +533,7 @@ DeviceState *qdev_device_add(QemuOpts *opts)
|
|
|
0a122b |
if (id) {
|
|
|
0a122b |
dev->id = id;
|
|
|
0a122b |
}
|
|
|
0a122b |
- if (qemu_opt_foreach(opts, set_property, dev, 1) != 0) {
|
|
|
0a122b |
- object_unparent(OBJECT(dev));
|
|
|
0a122b |
- object_unref(OBJECT(dev));
|
|
|
0a122b |
- return NULL;
|
|
|
0a122b |
- }
|
|
|
0a122b |
+
|
|
|
0a122b |
if (dev->id) {
|
|
|
0a122b |
object_property_add_child(qdev_get_peripheral(), dev->id,
|
|
|
0a122b |
OBJECT(dev), NULL);
|
|
|
0a122b |
@@ -549,6 +545,13 @@ DeviceState *qdev_device_add(QemuOpts *opts)
|
|
|
0a122b |
g_free(name);
|
|
|
0a122b |
}
|
|
|
0a122b |
|
|
|
0a122b |
+ /* set properties */
|
|
|
0a122b |
+ if (qemu_opt_foreach(opts, set_property, dev, 1) != 0) {
|
|
|
0a122b |
+ object_unparent(OBJECT(dev));
|
|
|
0a122b |
+ object_unref(OBJECT(dev));
|
|
|
0a122b |
+ return NULL;
|
|
|
0a122b |
+ }
|
|
|
0a122b |
+
|
|
|
0a122b |
dev->opts = opts;
|
|
|
0a122b |
object_property_set_bool(OBJECT(dev), true, "realized", &err;;
|
|
|
0a122b |
if (err != NULL) {
|
|
|
0a122b |
--
|
|
|
0a122b |
1.7.1
|
|
|
0a122b |
|