From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36779) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjI3n-0007X6-1h for qemu-devel@nongnu.org; Tue, 28 Oct 2014 21:28:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XjI3c-00050C-Us for qemu-devel@nongnu.org; Tue, 28 Oct 2014 21:28:27 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:51041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XjI3c-0004yn-Am for qemu-devel@nongnu.org; Tue, 28 Oct 2014 21:28:16 -0400 Message-ID: <5450429E.6070802@huawei.com> Date: Wed, 29 Oct 2014 09:27:58 +0800 From: Gonglei MIME-Version: 1.0 References: <1414538251-11428-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1414538251-11428-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio: link the rng backend through an alias property List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, stefanha@redhat.com On 2014/10/29 7:17, Paolo Bonzini wrote: > The virtio-rng backend is currently linked twice, once in > virtio-rng-pci/virtio-rng-ccw and once in virtio-rng-device. This > causes a double unref of the backend when the parent device is unplugged. > > To fix this, make virtio-rng-pci/virtio-rng-ccw use an alias, similar > to what is already being done for the iothread link. > I think s390_virtio_rng should also use an alias for rng backend. Best regards, -Gonglei > Signed-off-by: Paolo Bonzini > --- > hw/s390x/virtio-ccw.c | 6 ++---- > hw/virtio/virtio-pci.c | 7 ++----- > 2 files changed, 4 insertions(+), 9 deletions(-) > > 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 = {