qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>
Subject: Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer
Date: Tue, 20 Sep 2011 08:55:47 -0500	[thread overview]
Message-ID: <4E789B63.10703@us.ibm.com> (raw)
In-Reply-To: <4E78934C.4080308@redhat.com>

On 09/20/2011 08:21 AM, Gerd Hoffmann wrote:
> On 09/20/11 15:04, Anthony Liguori wrote:
>> On 09/20/2011 01:36 AM, Gerd Hoffmann wrote:
>>> On 09/19/11 18:27, Anthony Liguori wrote:
>>>> On 09/19/2011 02:34 AM, Gerd Hoffmann wrote:
>>>>> FYI: Keeping the pointer to the QemuOpts has one more reason: It will
>>>>> free the
>>>>> QemuOpts on hot-unplug, which is needed to free the id from QemuOpts
>>>>> point of
>>>>> view, which in turn allows to re-use the id when hot-plugging the same
>>>>> (or
>>>>> another) device later on.
>>>>
>>>> You mean, tie QemuOpts life cycle to devices life cycle
>>>
>>> Yes.
>>>
>>>> such that you
>>>> cannot accidentally create a non-device QemuOpts that conflicts with the
>>>> id of a device?
>>>
>>> Device QemuOpts have their own id namespace, so this is just about
>>> conflicts
>>> within devices. This ...
>>>
>>> device_add e1000,id=nic1
>>> device_del nic1
>>> device_add e1000,id=nic1
>>>
>>> ... will work only if you free the QemuOpts when deleting a device,
>>> otherwise
>>> QemuOpts will complain that nic1 is used already.
>>
>> But we can just verify that the id specified for qdev is unique at
>> creation time and fail creation if it isn't, no?
>>
>> Since not all devices are assigned names via qemuopts, that seems like a
>> safer approach anyway.
>
> I think that happens anyway (didn't check the source though).
>
> Problem is that QemuOpts wants IDs being unique too, so keep the QemuOpts
> hanging around instead of releasing them makes QemuOpts complain about nic1 not
> being unique although there isn't such a device in qdev space.

I don't think we have a firm requirement that the QemuOpts namespace == device 
namespace.  At any rate, it's not enforced today because devices can be created 
(with an id) outside of device_add.

> Oh, and not
> releasing the QemuOpts would also leak memory on each hot-unplug.

If you look at my patch, opts is freed at the end of device_add so there is no leak.

Regards,

Anthony Liguori

>
> cheers,
> Gerd
>
>
>

  reply	other threads:[~2011-09-20 13:56 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-16 16:00 [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 01/14] apic: rename apic.id -> apic.index Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 02/14] qdev: enforce that no devices overload the id property Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 03/14] qdev: push id into qdev_create calls Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer Anthony Liguori
2011-09-19  7:34   ` Gerd Hoffmann
2011-09-19 16:27     ` Anthony Liguori
2011-09-20  6:36       ` Gerd Hoffmann
2011-09-20 13:04         ` Anthony Liguori
2011-09-20 13:21           ` Gerd Hoffmann
2011-09-20 13:55             ` Anthony Liguori [this message]
2011-09-20 14:11               ` Gerd Hoffmann
2011-09-16 16:00 ` [Qemu-devel] [PATCH 05/14] qdev: remove opts pointer tracking Anthony Liguori
2011-09-19  7:35   ` Gerd Hoffmann
2011-09-16 16:00 ` [Qemu-devel] [PATCH 06/14] qdev: add ability to do QOM-style derived naming Anthony Liguori
2011-09-17 18:39   ` Blue Swirl
2011-09-16 16:00 ` [Qemu-devel] [PATCH 07/14] sysbus: add an id argument to sysbus_create_simple() Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 08/14] sysbus: make create_varargs take an id Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 09/14] fw_cfg: add name to global fw_cfg device Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 10/14] isa: add name parameter to device creation Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 11/14] pci: obtain devfn before initializing the device Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 12/14] pci: give pci devices a default name Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 13/14] ide: give IDE drives a default name in qdev Anthony Liguori
2011-09-16 16:00 ` [Qemu-devel] [PATCH 14/14] pc: assign names to machine created devices Anthony Liguori
2011-09-16 16:22 ` [Qemu-devel] [PATCH 00/14] qdev: assign unique names to all devices (part 1) Anthony Liguori
2011-09-16 16:48 ` Jan Kiszka
2011-09-16 16:54   ` Anthony Liguori
2011-09-16 17:03     ` Jan Kiszka
2011-09-16 18:06       ` Anthony Liguori
2011-09-16 17:11     ` Kevin Wolf
2011-09-16 18:03       ` Anthony Liguori
2011-09-19  7:26         ` Jan Kiszka
2011-09-19 14:05           ` Anthony Liguori
2011-09-19 14:24             ` Kevin Wolf
2011-09-20  8:32               ` Jan Kiszka
2011-09-19  7:41         ` Kevin Wolf
2011-09-16 18:21   ` Anthony Liguori
2011-09-19  7:34     ` Jan Kiszka
2011-09-17 18:41 ` Blue Swirl

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=4E789B63.10703@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=armbru@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kraxel@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).