From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjQJs-0004Dz-4P for qemu-devel@nongnu.org; Wed, 29 Oct 2014 06:17:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjQJi-0001rf-MT for qemu-devel@nongnu.org; Wed, 29 Oct 2014 06:17:36 -0400 Received: from mail-wg0-x22e.google.com ([2a00:1450:400c:c00::22e]:38291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjQJi-0001rI-Gl for qemu-devel@nongnu.org; Wed, 29 Oct 2014 06:17:26 -0400 Received: by mail-wg0-f46.google.com with SMTP id x13so1494918wgg.19 for ; Wed, 29 Oct 2014 03:17:25 -0700 (PDT) Received: from playground.station (net-37-117-142-149.cust.vodafonedsl.it. [37.117.142.149]) by mx.google.com with ESMTPSA id u8sm18211597wiz.14.2014.10.29.03.17.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2014 03:17:24 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 29 Oct 2014 11:17:19 +0100 Message-Id: <1414577839-18695-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH v2] virtio: link the rng backend through an alias property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org The virtio-rng backend is currently linked twice, once in the proxy device (e.g. virtio-rng-pci) and once in virtio-rng-device. This causes a double unref of the backend when the parent device is unplugged. To fix this, make the proxy device use an alias, similar to what is already being done for the iothread link. Signed-off-by: Paolo Bonzini --- v1->v2: also change s390-virtio-bus.c (Gonglei) --- hw/s390x/s390-virtio-bus.c | 6 ++---- hw/s390x/virtio-ccw.c | 6 ++---- hw/virtio/virtio-pci.c | 7 ++----- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c index 2059874..39dc201 100644 --- a/hw/s390x/s390-virtio-bus.c +++ b/hw/s390x/s390-virtio-bus.c @@ -311,10 +311,8 @@ static void s390_virtio_rng_instance_init(Object *obj) virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG); - object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, - (Object **)&dev->vdev.conf.rng, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL); + object_property_add_alias(obj, "rng", OBJECT(&dev->vdev), + "rng", &error_abort); } static uint64_t s390_virtio_device_vq_token(VirtIOS390Device *dev, int vq) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 1c0d913..ea236c9 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1544,10 +1544,8 @@ static void virtio_ccw_rng_instance_init(Object *obj) virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG); - object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, - (Object **)&dev->vdev.conf.rng, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL); + object_property_add_alias(obj, "rng", OBJECT(&dev->vdev), + "rng", &error_abort); } static Property virtio_ccw_rng_properties[] = { diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 542fb9e..e490ade 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1525,11 +1525,8 @@ static void virtio_rng_initfn(Object *obj) virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG); - object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, - (Object **)&dev->vdev.conf.rng, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL); - + object_property_add_alias(obj, "rng", OBJECT(&dev->vdev), "rng", + &error_abort); } static const TypeInfo virtio_rng_pci_info = { -- 1.8.3.1