From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50282) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPwNM-0002UL-3w for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:28:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XPwNH-0002q0-2V for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:28:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XPwNG-0002pV-S2 for qemu-devel@nongnu.org; Fri, 05 Sep 2014 12:28:35 -0400 Date: Fri, 5 Sep 2014 17:28:24 +0100 From: Stefan Hajnoczi Message-ID: <20140905162824.GA12242@stefanha-thinkpad.redhat.com> References: <1409830892-5056-1-git-send-email-arei.gonglei@huawei.com> <20140905121012.GD27649@stefanha-thinkpad.redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="CE+1k2dSO48ffgeK" Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] virtio-pci: fix virtio-net child refcount in transports List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei Cc: 'Stefan Hajnoczi' , arei.gonglei@huawei.com, weidong.huang@huawei.com, qemu-devel@nongnu.org, mst@redhat.com --CE+1k2dSO48ffgeK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 05, 2014 at 11:46:32PM +0800, Gonglei wrote: > Hi, >=20 > > Subject: Re: [Qemu-devel] [PATCH] virtio-pci: fix virtio-net child refc= ount in > > transports > >=20 > > On Thu, Sep 04, 2014 at 07:41:32PM +0800, arei.gonglei@huawei.com wrote: > > > From: Gonglei > > > > > > object_initialize() leaves the object with a refcount of 1. > > > object_property_add_child() adds its own reference which is dropped > > > again when the property is deleted. > > > > > > The upshot of this is that we always have a refcount >=3D 1. Upon hot > > > unplug the virtio-net child is not finalized! > > > > > > Drop our reference after the child property has been added to the > > > parent. > > > > > > Signed-off-by: Gonglei > > > --- > > > Stefan had post virtio-blk in commit c5d49db4, but virtio-net has > > > the same problem. Maybe the other virtio devices have too. > > > --- > > > hw/virtio/virtio-pci.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c > > > index ddb5da1..78dcd68 100644 > > > --- a/hw/virtio/virtio-pci.c > > > +++ b/hw/virtio/virtio-pci.c > > > @@ -1456,6 +1456,7 @@ static void virtio_net_pci_instance_init(Object > > *obj) > > > VirtIONetPCI *dev =3D VIRTIO_NET_PCI(obj); > > > object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET= ); > > > object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vd= ev), > > NULL); > > > + object_unref(OBJECT(&dev->vdev)); > > > } > > > > > > static const TypeInfo virtio_net_pci_info =3D { > >=20 > > You just copied my commit but didn't consider all the work I did before > > to make virtio-blk safe. Similar work is necessary for virtio-net. > >=20 > > Before it is okay to finalize the virtio-net (dev->vdev) object,=20 >=20 > Sorry? In my case the virtio-net object will not be finalized at present > because its obj->ref is non-1 when we hot-unplug a virtio-net-pci device. "Before" refers to making virtio-pci/virtio-net fixes first and then object_unref() second. It does not mean "previously" here. --CE+1k2dSO48ffgeK Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUCeSoAAoJEJykq7OBq3PIz/YIAK+VNSHwlS5a81n79yLQQg6w LC5wPaqn4ftTbvIsxiTt3b0APav+L/M9yYYtPO6z3MSFXsJUVmqQPTsJNuW8EL31 XLvQk0W2+xAQIsumfE87wCpbIQNMo6dMow9bD+FghsJSMyNP2e35g9fVsYsSN6/X ATBy/Tu0c2rynJVcaWy7kj1x3EKMLVCpHXBsEMDdisUWvYIcBxkEG2JWf4IJu8kr hJIg7L5zF/3kSoRrasfJUz31cbIwKwuq4wb9EHKy8/TCCcVeGJtrk3ZPXrH8ZAKW OkzIPnGT515hJZSVGUKFO2ukIaIb0Y4N0pOptoXaF274bQZHW3hEFYQulh9fXQQ= =8M+G -----END PGP SIGNATURE----- --CE+1k2dSO48ffgeK--