qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liu Ping Fan <qemulist@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH] qom: trigger unrealized when device_finalize
Date: Fri,  5 Jul 2013 11:26:07 +0800	[thread overview]
Message-ID: <1372994767-29506-1-git-send-email-pingfank@linux.vnet.ibm.com> (raw)

Currently, unrealized is triggered in device_unparent(). But
unrealized normally involves the reclaim of resource occupied by
DeviceState. To obey the idiom that reclaiming resource when
refcnt reach zero, move it on the path of object_finalize().

As for device_unparent(), it would be the place to detach the
device from the other system.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 hw/core/qdev.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 9190a7e..4258d8a 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -768,6 +768,10 @@ static void device_initfn(Object *obj)
 static void device_finalize(Object *obj)
 {
     DeviceState *dev = DEVICE(obj);
+
+    if (dev->realized) {
+        object_property_set_bool(obj, false, "realized", NULL);
+    }
     if (dev->opts) {
         qemu_opts_del(dev->opts);
     }
@@ -794,9 +798,6 @@ static void device_unparent(Object *obj)
         bus = QLIST_FIRST(&dev->child_bus);
         qbus_free(bus);
     }
-    if (dev->realized) {
-        object_property_set_bool(obj, false, "realized", NULL);
-    }
     if (dev->parent_bus) {
         bus_remove_child(dev->parent_bus, dev);
         object_unref(OBJECT(dev->parent_bus));
-- 
1.8.1.4

             reply	other threads:[~2013-07-05  3:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-05  3:26 Liu Ping Fan [this message]
2013-07-05  7:04 ` [Qemu-devel] [PATCH] qom: trigger unrealized when device_finalize Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1372994767-29506-1-git-send-email-pingfank@linux.vnet.ibm.com \
    --to=qemulist@gmail.com \
    --cc=afaerber@suse.de \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).