From nobody Tue Feb 10 15:46:44 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1498654842522919.8467907043503; Wed, 28 Jun 2017 06:00:42 -0700 (PDT) Received: from localhost ([::1]:33247 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQCaH-00055r-5N for importer@patchew.org; Wed, 28 Jun 2017 09:00:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dQCPX-0003L1-Op for qemu-devel@nongnu.org; Wed, 28 Jun 2017 08:49:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dQCPU-0001K9-MK for qemu-devel@nongnu.org; Wed, 28 Jun 2017 08:49:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57528) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dQCPU-0001Jq-DJ for qemu-devel@nongnu.org; Wed, 28 Jun 2017 08:49:32 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4AB9E8553E; Wed, 28 Jun 2017 12:49:31 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-85.pek2.redhat.com [10.72.12.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE17589A9B; Wed, 28 Jun 2017 12:49:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4AB9E8553E Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4AB9E8553E From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 28 Jun 2017 20:48:50 +0800 Message-Id: <20170628124850.12821-8-famz@redhat.com> In-Reply-To: <20170628124850.12821-1-famz@redhat.com> References: <20170628124850.12821-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 28 Jun 2017 12:49:31 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 7/7] virtio-rng: Use DEFINE_PROP_LINK X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Markus Armbruster , "Dr . David Alan Gilbert" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fam Zheng --- hw/virtio/virtio-pci.c | 2 -- hw/virtio/virtio-rng.c | 16 ++++------------ include/hw/virtio/virtio-rng.h | 2 +- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index eb03ba5..0938db4 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -2459,8 +2459,6 @@ static void virtio_rng_initfn(Object *obj) =20 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG); - object_property_add_alias(obj, "rng", OBJECT(&dev->vdev), "rng", - &error_abort); } =20 static const TypeInfo virtio_rng_pci_info =3D { diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index a6ee501..218778b 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -199,7 +199,7 @@ static void virtio_rng_device_realize(DeviceState *dev,= Error **errp) "rng", NULL); } =20 - vrng->rng =3D vrng->conf.rng; + vrng->rng =3D RNG_BACKEND(vrng->conf.rng); if (vrng->rng =3D=3D NULL) { error_setg(errp, "'rng' parameter expects a valid object"); return; @@ -246,6 +246,9 @@ static Property virtio_rng_properties[] =3D { */ DEFINE_PROP_UINT64("max-bytes", VirtIORNG, conf.max_bytes, INT64_MAX), DEFINE_PROP_UINT32("period", VirtIORNG, conf.period_ms, 1 << 16), + DEFINE_PROP_LINK("rng", VirtIORNG, conf.rng, TYPE_RNG_BACKEND, + qdev_prop_allow_set_link_before_realize, + OBJ_PROP_LINK_UNREF_ON_RELEASE), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -262,21 +265,10 @@ static void virtio_rng_class_init(ObjectClass *klass,= void *data) vdc->get_features =3D get_features; } =20 -static void virtio_rng_initfn(Object *obj) -{ - VirtIORNG *vrng =3D VIRTIO_RNG(obj); - - object_property_add_link(obj, "rng", TYPE_RNG_BACKEND, - (Object **)&vrng->conf.rng, - qdev_prop_allow_set_link_before_realize, - OBJ_PROP_LINK_UNREF_ON_RELEASE, NULL); -} - static const TypeInfo virtio_rng_info =3D { .name =3D TYPE_VIRTIO_RNG, .parent =3D TYPE_VIRTIO_DEVICE, .instance_size =3D sizeof(VirtIORNG), - .instance_init =3D virtio_rng_initfn, .class_init =3D virtio_rng_class_init, }; =20 diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h index 922dce7..8d45597 100644 --- a/include/hw/virtio/virtio-rng.h +++ b/include/hw/virtio/virtio-rng.h @@ -23,7 +23,7 @@ OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_RNG) =20 struct VirtIORNGConf { - RngBackend *rng; + Object *rng; uint64_t max_bytes; uint32_t period_ms; RngRandom *default_backend; --=20 2.9.4