From nobody Sat Apr 20 01:45:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1557847351; cv=none; d=zoho.com; s=zohoarc; b=DDcat0KaK+XLs4f2tgWRfA+tW8t8hhrW4P7vcuYf/fQ0eH9GIktiD/0gjz4B3udxFuHnM//Ywhlha6my5jaoP4FGCau23Colmbp69MRTC9279bUEJHMn+uptg5bK1TosM3KmhvcUK6o0Ky0hI9G0XiPmpyTFVM084DBDj2N+HI0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1557847351; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=WTgfxZJMEFHzMKgIezAqs6fWQq5BVO4HvFMEDaKTLMk=; b=U/paoX2eOg46HRjnUqiEH0U7JnazOSZmOdNSF9r0MxB98H99qfLv6JnBn8nWC10ICOty3caIlPxVpWGlpoVHg9U3h7LzxQFUoase30IM65Ca1y4n3e+CtD+EJvJPgQQ2mFEIAllWTxvjS+kjXqRKdXDuj0KFGk8gzBkgz3Krpg0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1557847351694948.4872282954103; Tue, 14 May 2019 08:22:31 -0700 (PDT) Received: from localhost ([127.0.0.1]:49795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQZFj-0001OE-U9 for importer@patchew.org; Tue, 14 May 2019 11:22:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:52615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQZDb-0000ON-RO for qemu-devel@nongnu.org; Tue, 14 May 2019 11:19:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQZDa-0001DT-Rx for qemu-devel@nongnu.org; Tue, 14 May 2019 11:19:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47446) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hQZDa-0001Cs-KZ for qemu-devel@nongnu.org; Tue, 14 May 2019 11:19:50 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D953301EA8F; Tue, 14 May 2019 15:19:49 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-28.ams2.redhat.com [10.36.116.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4A75100203C; Tue, 14 May 2019 15:19:45 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 83B3211385E4; Tue, 14 May 2019 17:19:42 +0200 (CEST) From: Markus Armbruster To: Laurent Vivier References: <20190514075602.7674-1-lvivier@redhat.com> Date: Tue, 14 May 2019 17:19:42 +0200 In-Reply-To: <20190514075602.7674-1-lvivier@redhat.com> (Laurent Vivier's message of "Tue, 14 May 2019 09:55:59 +0200") Message-ID: <8736lhdpwx.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 14 May 2019 15:19:49 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3.5/4] virtio-rng: Keep the default backend out of VirtIORNGConf 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: "Daniel P . =?utf-8?Q?Berrang=C3=A9?=" , "Michael S. Tsirkin" , Amit Shah , Richard Henderson , qemu-devel@nongnu.org, "Richard W . M . Jones" , Kashyap Chamarthy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The default backend is only used within virtio_rng_device_realize(). Replace VirtIORNGConf member default_backend by a local variable. Adjust its type to reduce conversions. While there, pass &error_abort instead of NULL when failure would be a programming error. Signed-off-by: Markus Armbruster --- hw/virtio/virtio-rng.c | 20 +++++++++----------- include/hw/virtio/virtio-rng.h | 2 -- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c index 30493a2586..73ffb476e0 100644 --- a/hw/virtio/virtio-rng.c +++ b/hw/virtio/virtio-rng.c @@ -16,6 +16,7 @@ #include "hw/virtio/virtio.h" #include "hw/virtio/virtio-rng.h" #include "sysemu/rng.h" +#include "sysemu/rng-random.h" #include "qom/object_interfaces.h" #include "trace.h" =20 @@ -189,27 +190,24 @@ static void virtio_rng_device_realize(DeviceState *de= v, Error **errp) } =20 if (vrng->conf.rng =3D=3D NULL) { - vrng->conf.default_backend =3D RNG_RANDOM(object_new(TYPE_RNG_RAND= OM)); + Object *default_backend =3D object_new(TYPE_RNG_RANDOM); =20 - user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend), + user_creatable_complete(USER_CREATABLE(default_backend), &local_err); if (local_err) { error_propagate(errp, local_err); - object_unref(OBJECT(vrng->conf.default_backend)); + object_unref(default_backend); return; } =20 - object_property_add_child(OBJECT(dev), - "default-backend", - OBJECT(vrng->conf.default_backend), - NULL); + object_property_add_child(OBJECT(dev), "default-backend", + default_backend, &error_abort); =20 /* The child property took a reference, we can safely drop ours no= w */ - object_unref(OBJECT(vrng->conf.default_backend)); + object_unref(default_backend); =20 - object_property_set_link(OBJECT(dev), - OBJECT(vrng->conf.default_backend), - "rng", NULL); + object_property_set_link(OBJECT(dev), default_backend, + "rng", &error_abort); } =20 vrng->rng =3D vrng->conf.rng; diff --git a/include/hw/virtio/virtio-rng.h b/include/hw/virtio/virtio-rng.h index 922dce7cac..28ff752c40 100644 --- a/include/hw/virtio/virtio-rng.h +++ b/include/hw/virtio/virtio-rng.h @@ -13,7 +13,6 @@ #define QEMU_VIRTIO_RNG_H =20 #include "sysemu/rng.h" -#include "sysemu/rng-random.h" #include "standard-headers/linux/virtio_rng.h" =20 #define TYPE_VIRTIO_RNG "virtio-rng-device" @@ -26,7 +25,6 @@ struct VirtIORNGConf { RngBackend *rng; uint64_t max_bytes; uint32_t period_ms; - RngRandom *default_backend; }; =20 typedef struct VirtIORNG { --=20 2.17.2