qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug
@ 2012-08-26 15:51 Anthony Liguori
  2012-08-26 15:51 ` [Qemu-devel] [PATCH 1/9] savevm: don't rely on paths if we can store a DeviceState object Anthony Liguori
                   ` (10 more replies)
  0 siblings, 11 replies; 24+ messages in thread
From: Anthony Liguori @ 2012-08-26 15:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Liu Ping Fan, Andreas Faerber

Right now, you need to pair up object_new with object_delete.  This is
impractical when using reference counting because we would like to ensure that
object_unref() also frees memory when needed.

The first few patches fix this problem by introducing a release callback so
that objects that need special release behavior (i.e. g_free) can do that.

Since link and child properties all hold references, in order to actually free
an object, we need to break those links.  User created devices end up as
children of a container.  But child properties cannot be removed which means
there's no obvious way to remove the reference and ultimately free the object.

We introduce the concept of "nullable child" properties to solve this.  This is
a child property that can be broken by writing NULL to the child link.  Today
we set all /peripheral* children to be nullable so that they can be deleted by
management tools.

In terms of modeling hotplug, we represent unplug by removing the object from
the parent bus.  We need to register a notifier for when this happens so that
we can also remove the parent's child property to ultimately release the object.

Putting it all together, we have:

1) qmp_device_del will issue a callback to a device.  The default callback will
   do a forced eject (which means writing NULL to the parent_bus link).

2) PCI hotplug is a bit more sophisticated in that it waits for the guest to
   do the ejection.

3) qmp_device_del will register an eject notifier such that the device gets
   completely removed.

There's a slightly change in behavior here.  A device is not automatically
destroyed based on a guest initiated eject.  A management tool must explicitly
break the parent's link to the child in order for the device to disappear
completely.  device_del behaves exactly as it does today though.

This is an RFC.  I've tested the series quite a lot (it was hard to get the
reference counting right) but not enough to apply.  I also don't think the
series is quite split right and may not bisect cleanly.

I also want to write up a document describing object life cycle since admittedly
the above is probably not that easy to follow.

I wanted to share this now though because it works and I think the concepts are
right.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-10-09 17:15 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-26 15:51 [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 1/9] savevm: don't rely on paths if we can store a DeviceState object Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 2/9] object: automatically free objects based on a release function Anthony Liguori
2012-08-27 13:31   ` Andreas Färber
2012-08-26 15:51 ` [Qemu-devel] [PATCH 3/9] qbus: remove glib_allocated/qom_allocated and use release hook to free memory Anthony Liguori
2012-08-27 14:02   ` Andreas Färber
2012-08-27 14:22     ` Anthony Liguori
2012-08-27 14:43       ` Andreas Färber
2012-08-26 15:51 ` [Qemu-devel] [PATCH 4/9] object: remove object_finalize Anthony Liguori
2012-08-27 15:01   ` Andreas Färber
2012-08-27 15:49     ` Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 5/9] object: add support for nullable child properties Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 6/9] qdev: make devices created with device_add nullable so they can be deleted Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 7/9] qdev: add notifier for when the device loses its parent bus (eject) Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 8/9] qdev: make qdev_set_parent_bus() just set a link property Anthony Liguori
2012-08-27  7:22   ` liu ping fan
2012-08-27 13:12     ` Anthony Liguori
2012-08-26 15:51 ` [Qemu-devel] [PATCH 9/9] hotplug: refactor hotplug to leverage new QOM functions Anthony Liguori
2012-08-27  7:22   ` liu ping fan
2012-08-27  7:22 ` [Qemu-devel] [RFC PATCH 0/9] qom: improve reference counting and hotplug liu ping fan
2012-08-27 11:46   ` Andreas Färber
2012-08-27 12:09     ` Paolo Bonzini
2012-08-27 13:15       ` Anthony Liguori
2012-10-09 17:15 ` Vasilis Liaskovitis

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).