[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 6/9] qdev: make devices created with device_add null
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 6/9] qdev: make devices created with device_add nullable so they can be deleted |
Date: |
Sun, 26 Aug 2012 10:51:35 -0500 |
A management tool can destroy these devices by writing an empty string into
the child link property.
Signed-off-by: Anthony Liguori <address@hidden>
---
hw/qdev-monitor.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c
index 018b386..3f08575 100644
--- a/hw/qdev-monitor.c
+++ b/hw/qdev-monitor.c
@@ -469,15 +469,20 @@ DeviceState *qdev_device_add(QemuOpts *opts)
return NULL;
}
if (qdev->id) {
- object_property_add_child(qdev_get_peripheral(), qdev->id,
- OBJECT(qdev), NULL);
+ object_property_add_nullable_child(qdev_get_peripheral(), qdev->id,
+ OBJECT(qdev), NULL);
} else {
static int anon_count;
gchar *name = g_strdup_printf("device[%d]", anon_count++);
- object_property_add_child(qdev_get_peripheral_anon(), name,
- OBJECT(qdev), NULL);
+ object_property_add_nullable_child(qdev_get_peripheral_anon(), name,
+ OBJECT(qdev), NULL);
g_free(name);
- }
+ }
+
+ /* Drop the allocation reference -- the container link will ensure the
+ object stays alive. */
+ object_unref(OBJECT(qdev));
+
if (qdev_init(qdev) < 0) {
qerror_report(QERR_DEVICE_INIT_FAILED, driver);
return NULL;
--
1.7.5.4
- [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 1/9] savevm: don't rely on paths if we can store a DeviceState object, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 6/9] qdev: make devices created with device_add nullable so they can be deleted,
Anthony Liguori <=
- [Qemu-devel] [PATCH 4/9] object: remove object_finalize, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 7/9] qdev: add notifier for when the device loses its parent bus (eject), Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 2/9] object: automatically free objects based on a release function, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 8/9] qdev: make qdev_set_parent_bus() just set a link property, Anthony Liguori, 2012/08/26
- [Qemu-devel] [PATCH 9/9] hotplug: refactor hotplug to leverage new QOM functions, Anthony Liguori, 2012/08/26