[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container |
Date: |
Fri, 10 Feb 2017 14:12:23 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 |
On 10/02/2017 13:59, Marc-André Lureau wrote:
> > But if you unparent with the last ref, you remove the burden of knowing
> > if the object has been parented from the user. I don't see why that
> > would conflict with object_unparent(), you could still unparent(), and
> > keep the object referenced somewhere else.
>
> Isn't that exactly why you want them to be different? unparent can do
> much more than unref, for example in the case of a device it will also
> unrealize it and destroy all buses underneath it. Because the device
>
> Shouldn't the last unref also unrealize/destroy everything?
How could someone say they have the "last unref"? They didn't get that
reference from anywhere, the reference is owned by the parent object's
child property.
> and bus have a circular reference, you cannot trigger the magic unparent
> behavior just by unref'ing the device.
>
> Whoo, we have circular references on purposes? Is this lifecycle
> documented somewhere? I wonder the rationale behind it.
The same as Libreoffice: we had a model with no reference counting (just
"qdev_free") and we tried to adapt it to QOM's reference counting model,
in our case by exploiting the object tree.
> There are just two cases:
>
> - destruction immediately after creation, e.g. on error: new/unref
>
> - successful creation: new/add_child/unref, unparent when deleting
>
> and it's simpler to remember these two than to add magic behavior.
>
> That doesn't change the problem, the user may not know if the object is
> parented.
If the user got a reference for himself via object_ref or object_new, it
must use object_unref.
If the user wants to remove public knowledge of an object, then they
must use object_unparent. If the object is not parented, there's a
violation of QOM rules somewhere.
Paolo
- Re: [Qemu-devel] [PATCH 05/22] main: free root container, (continued)
[Qemu-devel] [PATCH 06/22] char: add a /chardevs container, Marc-André Lureau, 2017/02/02
- Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container, Paolo Bonzini, 2017/02/06
- Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container, Marc-André Lureau, 2017/02/07
- Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container, Paolo Bonzini, 2017/02/09
- Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container, Marc-André Lureau, 2017/02/10
- Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container, Paolo Bonzini, 2017/02/10
- Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container, Marc-André Lureau, 2017/02/10
- Re: [Qemu-devel] [PATCH 06/22] char: add a /chardevs container,
Paolo Bonzini <=
[Qemu-devel] [PATCH 07/22] char: use /chardevs container instead of chardevs list, Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 08/22] char: remove qemu_chardev_add, Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 09/22] char: remove chardevs list, Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 10/22] char: useless NULL check, Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 11/22] qcow2: remove useless NULL check, Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 12/22] char-socket: introduce update_disconnected_filename(), Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 13/22] char-socket: update local address after listen, Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 14/22] char-socket: add 'addr' property, Marc-André Lureau, 2017/02/02
[Qemu-devel] [PATCH 15/22] char-socket: add 'connected' property, Marc-André Lureau, 2017/02/02