From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgnJ5-0000kN-BD for qemu-devel@nongnu.org; Tue, 29 Sep 2015 01:18:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZgnJ4-0006Hp-7N for qemu-devel@nongnu.org; Tue, 29 Sep 2015 01:18:27 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:52238) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZgnJ3-0006HK-Sp for qemu-devel@nongnu.org; Tue, 29 Sep 2015 01:18:26 -0400 Date: Tue, 29 Sep 2015 15:01:09 +1000 From: David Gibson Message-ID: <20150929050109.GL19428@voom.redhat.com> References: <20150928101346.23919.3988.stgit@bahia.huguette.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="yQDbd2FCF2Yhw41T" Content-Disposition: inline In-Reply-To: <20150928101346.23919.3988.stgit@bahia.huguette.org> Subject: Re: [Qemu-devel] [PATCH] spapr: add a default rng device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: Thomas Huth , qemu-devel@nongnu.org --yQDbd2FCF2Yhw41T Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 28, 2015 at 12:13:47PM +0200, Greg Kurz wrote: > A recent patch by Thomas Huth brought a new spapr-rng pseudo-device to > provide high-quality random numbers to guests. The device may either be > backed by a "RngBackend" or the in-kernel implementation of the H_RANDOM > hypercall. >=20 > Since modern POWER8 based servers always provide a hardware rng, it makes > sense to create a spapr-rng device with use-kvm=3Dtrue by default when it > is available. >=20 > Of course we want the user to have full control on how the rng is handled. > The default device WILL NOT be created in the following cases: > - the -nodefaults option was passed > - a spapr-rng device was already passed on the command line >=20 > The default device is created at reset time to ensure devices specified on > the command line have been created. >=20 > Signed-off-by: Greg Kurz So, I think the concept is ok, but.. > --- > hw/ppc/spapr.c | 17 +++++++++++++++++ > hw/ppc/spapr_rng.c | 2 +- > target-ppc/kvm.c | 9 +++++---- > target-ppc/kvm_ppc.h | 6 ++++++ > 4 files changed, 29 insertions(+), 5 deletions(-) >=20 > diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c > index 7f4f196e53e5..ee048ecffd0c 100644 > --- a/hw/ppc/spapr.c > +++ b/hw/ppc/spapr.c > @@ -1059,6 +1059,14 @@ static int spapr_check_htab_fd(sPAPRMachineState *= spapr) > return rc; > } > =20 > +static void spapr_rng_create(void) > +{ > + Object *rng =3D object_new(TYPE_SPAPR_RNG); > + > + object_property_set_bool(rng, true, "use-kvm", &error_abort); > + object_property_set_bool(rng, true, "realized", &error_abort); > +} > + > static void ppc_spapr_reset(void) > { > sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); > @@ -1082,6 +1090,15 @@ static void ppc_spapr_reset(void) > spapr->rtas_addr =3D rtas_limit - RTAS_MAX_SIZE; > spapr->fdt_addr =3D spapr->rtas_addr - FDT_MAX_SIZE; > =20 > + /* Create a rng device if the user did not provide it already and > + * KVM has hwrng support. > + */ > + if (defaults_enabled() && > + kvmppc_hwrng_present() && > + !object_resolve_path_type("", TYPE_SPAPR_RNG, NULL)) { > + spapr_rng_create(); > + } > + Constructing the RNG at reset time is just wrong. Using defaults_enabled() is ugly at the best of times, using it at reset, after construction of the qom tree is generally complete, is just hideous. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --yQDbd2FCF2Yhw41T Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJWChsUAAoJEGw4ysog2bOShVAP/jXeYtaX2HEhoEPe2UA6DpsV yunhZ+258jz38c/E2wnkCIdNvChpRT64vzsz05uuxXKCs61KWfJ9AYi0FBHr+qkJ Ju5TC0OQ9Y7rxiKL3gqXHwAEbqmhemV+wuB8q26NmGRA/jyTw4QBalQLtn4pBaix PqudwHxJa/delAP7YfHG9ugqRFsj4Wr/vl/ed0ijBUlCWXdCJGQoBMVz10DX2KpO K4komP0Ogyqp8+PQHM1Sy2ny3EezU1SUfxyIpO4lvPMuaTzc7lmct3nVTNLUSq/2 XAjzASb1Pw6POrq4OdKqwzhMa7UQMeP/ovpknkrKgqzcBO7hH09iwp99LdJ7lUFh iadqm0mCdq0gQDAFR0hXQ63QohVUYxgrrHEiBsWZPVrQOn4e25gZ6N0ELkBkJBOv RTh1aU4uzKbsOyXJC7OhR3WVYQxWGhEp70d8za4ywz5i3Odu3NkX25GEyTzI7l7K 4K0BwbHapac4ZeXKbRhkimw/zZ4ajCk9WBgPP1lfv3pUv+lcxIbEde90TnOm4lAq q4kX2JMkxiLrEmR9zwJMkkKKg6nE2RzX8XJ1efmWlg/WTNoMjOm9jhr/Y1gk9sd6 XslU+kAcCOMULghaN5+DurUE6UT8BBU3pcYIsPbPSg8mNsdG0+2mvwTm9GVnMHZy JxpgJXGwp7+CkYzdRkrP =70Z7 -----END PGP SIGNATURE----- --yQDbd2FCF2Yhw41T--