From f196d727de175080b185e83139f2afb422aa8b00 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Sun, 17 Aug 2014 19:45:19 -0500 Subject: [CHANGE 1/2] hw/qdev: emit DEVICE_DELETED event only if the device is initialized To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Marcel Apfelbaum Message-id: <1408304719-8105-1-git-send-email-marcel.a@redhat.com> Patchwork-id: 60603 O-Subject: [RHEL-6.6 qemu-kvm PATCH] hw/qdev: emit DEVICE_DELETED event only if the device is initialized Bugzilla: 1124314 RH-Acked-by: Paolo Bonzini RH-Acked-by: Alex Williamson RH-Acked-by: Markus Armbruster Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1124314 Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=7851079 Upstream-status: N/A Upstream commit 0402a5 based the decision to emit the event on device's "realized" mechanism, which we're not backporting into RHEL 6. As an alternative we can use device's state property to know if the device is initialized. Signed-off-by: Marcel Apfelbaum --- This little bug is related to [RHEL-6.6 qemu-kvm PATCH v5 0/7] qmp: query-pci and DEVICE_DELETED backport While not compulsory, I think that there is no real thraet to add it to RHEL 6.6. hw/qdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) Signed-off-by: Jeff E. Nelson --- hw/qdev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/qdev.c b/hw/qdev.c index b4102ca..640a63b 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -383,7 +383,10 @@ void qdev_free(DeviceState *dev) } } - monitor_protocol_event(QEVENT_DEVICE_DELETED, event_data); + if (dev->state == DEV_STATE_INITIALIZED) { + monitor_protocol_event(QEVENT_DEVICE_DELETED, event_data); + } + qobject_decref(event_data); qemu_free(dev); } -- 1.9.3