From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:51326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R60nz-0001Xd-V4 for qemu-devel@nongnu.org; Tue, 20 Sep 2011 09:56:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R60nv-00031x-4q for qemu-devel@nongnu.org; Tue, 20 Sep 2011 09:56:11 -0400 Received: from e35.co.us.ibm.com ([32.97.110.153]:44332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R60nu-00031t-UT for qemu-devel@nongnu.org; Tue, 20 Sep 2011 09:56:07 -0400 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e35.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p8KDZJtu009079 for ; Tue, 20 Sep 2011 07:35:19 -0600 Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8KDtq0I135926 for ; Tue, 20 Sep 2011 07:55:52 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8KDtnqg014747 for ; Tue, 20 Sep 2011 07:55:51 -0600 Message-ID: <4E789B63.10703@us.ibm.com> Date: Tue, 20 Sep 2011 08:55:47 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1316188834-13675-1-git-send-email-aliguori@us.ibm.com> <1316188834-13675-5-git-send-email-aliguori@us.ibm.com> <4E76F074.4030801@redhat.com> <4E776D6D.2040702@codemonkey.ws> <4E78345E.5080300@redhat.com> <4E788F57.40305@us.ibm.com> <4E78934C.4080308@redhat.com> In-Reply-To: <4E78934C.4080308@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 04/14] qdev: take ownership of id pointer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann Cc: qemu-devel@nongnu.org, Peter Maydell , Paolo Bonzini , Markus Armbruster , Jan Kiszka 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 > > >