From: Liu Ping Fan <pingf...@linux.vnet.ibm.com> When add it at qdev_device_add(), so need to release it at qmp_device_del().
Signed-off-by: Liu Ping Fan <pingf...@linux.vnet.ibm.com> --- hw/qdev-monitor.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/hw/qdev-monitor.c b/hw/qdev-monitor.c index fdd9539..29ace17 100644 --- a/hw/qdev-monitor.c +++ b/hw/qdev-monitor.c @@ -599,6 +599,7 @@ int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data) void qmp_device_del(const char *id, Error **errp) { DeviceState *dev; + int ret; dev = qdev_find_recursive(sysbus_get_default(), id); if (NULL == dev) { @@ -606,7 +607,12 @@ void qmp_device_del(const char *id, Error **errp) return; } - qdev_unplug_req(dev, errp); + ret = qdev_unplug_req(dev, errp); + if (ret == 0) { + /* to here, dev->id is not zero, so need to release */ + object_property_del_child(qdev_get_peripheral(), + OBJECT(dev), NULL); + } } void qdev_machine_init(void) -- 1.7.4.4