Received: from eggs.gnu.org ([2001:4830:134:3::10]:54364) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuJx2-0006rK-Ao for qemu-devel@nongnu.org; Thu, 05 Nov 2015 07:47:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZuJwy-0003KN-6v for qemu-devel@nongnu.org; Thu, 05 Nov 2015 07:47:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZuJwy-0003KE-22 for qemu-devel@nongnu.org; Thu, 05 Nov 2015 07:47:32 -0500 From: Markus Armbruster References: <1445253099-16894-1-git-send-email-pbonzini@redhat.com> <87ziytehr2.fsf@blackfin.pond.sub.org> <563B4629.10903@suse.de> <563B49C1.9080305@redhat.com> Date: Thu, 05 Nov 2015 13:47:28 +0100 In-Reply-To: <563B49C1.9080305@redhat.com> (Paolo Bonzini's message of "Thu, 5 Nov 2015 13:21:21 +0100") Message-ID: <87a8qswr33.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qdev: free qemu-opts when the QOM path goes away List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: "Michael S. Tsirkin" , Andreas =?utf-8?Q?F=C3=A4rber?= , qemu-devel@nongnu.org Paolo Bonzini writes: > On 05/11/2015 13:06, Andreas F=C3=A4rber wrote: >> > 1. Wouldn't it be cleaner to delete dev-opts *before* sending >> > DEVICE_DELETED? Like this: >> >=20 >> > +++ b/hw/core/qdev.c >> > @@ -1244,6 +1244,9 @@ static void device_unparent(Object *obj) >> > dev->parent_bus =3D NULL; >> > } >> >=20 >> > + qemu_opts_del(dev->opts); >> > + dev->opts =3D NULL; >> > + >> > /* Only send event if the device had been completely realized= */ >> > if (dev->pending_deleted_event) { >> > gchar *path =3D object_get_canonical_path(OBJECT(dev)); >>=20 >> To me this proposal sounds sane, but I did not get to tracing the code >> flow here. Paolo, which approach do you prefer and why? > > It doesn't really matter, because the BQL is being held here. > > On the other hand, if the opts are deleted in finalize, there is an > arbitrary delay because finalize is typically called after a > synchronize_rcu period. > >>> > 2. If the device is a block device, then unplugging it also deletes i= ts >>> > backend (ugly wart we keep for backward compatibility; *not* for >>> > blockdev-add, though). This backend also has a QemuOpts. It gets >>> > deleted in drive_info_del(). Just like device_finalize(), it runs >>> > within object_unref(), i.e. after DEVICE_DELETED is sent. Same ra= ce, >>> > different ID, or am I missing something? >>> >=20 >>> > See also https://bugzilla.redhat.com/show_bug.cgi?id=3D1256044 >> >> If we can leave this patch decoupled from block layer and decide soonish >> on the desired approach, I'd be happy to include it in my upcoming >> qom-devices pull. > > I agree with you, the block layer bug is separate. Related, but clearly separate. Mentioning it in the commit message would be nice, though.