qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: <arei.gonglei@huawei.com>
To: qemu-devel@nongnu.org
Cc: weidong.huang@huawei.com, mst@redhat.com, armbru@redhat.com,
	luonengjun@huawei.com, peter.huangpeng@huawei.com, agraf@suse.de,
	borntraeger@de.ibm.com, Gonglei <arei.gonglei@huawei.com>,
	stefanha@redhat.com, cornelia.huck@de.ibm.com,
	pbonzini@redhat.com, rth@twiddle.net
Subject: [Qemu-devel] [PATCH v3 02/12] virtio-net: fix virtio-net child refcount in transports
Date: Tue, 30 Sep 2014 17:49:34 +0800	[thread overview]
Message-ID: <1412070584-5200-3-git-send-email-arei.gonglei@huawei.com> (raw)
In-Reply-To: <1412070584-5200-1-git-send-email-arei.gonglei@huawei.com>

From: Gonglei <arei.gonglei@huawei.com>

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 >= 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 <arei.gonglei@huawei.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 hw/s390x/s390-virtio-bus.c | 1 +
 hw/s390x/virtio-ccw.c      | 1 +
 hw/virtio/virtio-pci.c     | 1 +
 3 files changed, 3 insertions(+)

diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index 5b5d595..297eac2 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -161,6 +161,7 @@ static void s390_virtio_net_instance_init(Object *obj)
     VirtIONetS390 *dev = VIRTIO_NET_S390(obj);
     object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
     object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+    object_unref(OBJECT(&dev->vdev));
     qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
 }
 
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 7d67577..bb699f2 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -794,6 +794,7 @@ static void virtio_ccw_net_instance_init(Object *obj)
     VirtIONetCcw *dev = VIRTIO_NET_CCW(obj);
     object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
     object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+    object_unref(OBJECT(&dev->vdev));
     qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
 }
 
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 155fac9..b82b738 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1465,6 +1465,7 @@ static void virtio_net_pci_instance_init(Object *obj)
     VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
     object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
     object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
+    object_unref(OBJECT(&dev->vdev));
     qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
 }
 
-- 
1.7.12.4

  parent reply	other threads:[~2014-09-30  9:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30  9:49 [Qemu-devel] [PATCH v3 00/12] virtio: fix virtio child recount in transports arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 01/12] virtio-net: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-30  9:49 ` arei.gonglei [this message]
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 03/12] virtio/vhost-scsi: " arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 04/12] virtio/vhost-scsi: fix virtio-scsi/vhost-scsi child refcount in transports arei.gonglei
2014-09-30 10:54   ` Cornelia Huck
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 05/12] virtio-serial: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 06/12] virtio-serial: fix virtio-serial child refcount in transports arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 07/12] virtio-rng: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 08/12] virtio-rng: fix virtio-rng child refcount in transports arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 09/12] virtio-balloon: fix virtio-balloon " arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 10/12] virtio-9p: use aliases instead of duplicate qdev properties arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 11/12] virtio-9p: fix virtio-9p child refcount in transports arei.gonglei
2014-09-30  9:49 ` [Qemu-devel] [PATCH v3 12/12] virtio: add a wrapper for virtio-backend initialization arei.gonglei
2014-09-30 10:57   ` Cornelia Huck
2014-09-30 10:45 ` [Qemu-devel] [PATCH v3 00/12] virtio: fix virtio child recount in transports Michael S. Tsirkin

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=1412070584-5200-3-git-send-email-arei.gonglei@huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=luonengjun@huawei.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@redhat.com \
    --cc=weidong.huang@huawei.com \
    /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).