Hello, I didn't find a mailing list for rng-tools, so CC'ing the kernel lists and the last few committers. The first patch in this series adds a udev rule to start rngd for guests that have a virtio-rng device available. The second patch attempts to add autoconf magic to install the udev rule in the system dirs. However, installing as non-root will obviously fail. Prefixes are also not honoured. I don't know of a better way, and we probably should leave this to distributions. However, if someone has a better idea on how to expand this, please suggest. Amit Shah (2): rngd: add udev rule to source from hwrng if virtio-rng present Install udev rules in system-default directory 90-virtio-rng.rules | 1 + Makefile.am | 1 + configure.ac | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 90-virtio-rng.rules -- 1.9.3
Amit Shah
2014-Aug-07 13:08 UTC
[PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
On KVM guests where the virtio-rng device is available, and set as the current rng, this udev rule will start rngd which will feed in the host-provided entropy to /dev/random. Signed-off-by: Amit Shah <amit.shah at redhat.com> --- 90-virtio-rng.rules | 1 + 1 file changed, 1 insertion(+) create mode 100644 90-virtio-rng.rules diff --git a/90-virtio-rng.rules b/90-virtio-rng.rules new file mode 100644 index 0000000..07f2f9c --- /dev/null +++ b/90-virtio-rng.rules @@ -0,0 +1 @@ +KERNEL=="hw_random", ATTR{rng_current}=="virtio*", RUN+="/sbin/rngd -r /dev/hwrng" -- 1.9.3
Amit Shah
2014-Aug-07 13:09 UTC
[PATCH 2/2] Install udev rules in system-default directory
not-quite-Signed-off-by: Amit Shah <amit.shah at redhat.com> --- Makefile.am | 1 + configure.ac | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/Makefile.am b/Makefile.am index f8490a3..a2b8173 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,6 +8,7 @@ sbin_PROGRAMS = rngd bin_PROGRAMS = rngtest man_MANS = rngd.8 rngtest.1 noinst_LIBRARIES = librngd.a +udevrules_DATA = 90-virtio-rng.rules rngd_SOURCES = rngd.h rngd.c rngd_entsource.h rngd_entsource.c \ rngd_linux.h rngd_linux.c util.c \ diff --git a/configure.ac b/configure.ac index 27a2dba..4187aca 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,14 @@ AC_ARG_WITH([libgcrypt], [with_libgcrypt=check] ) +PKG_PROG_PKG_CONFIG + +AC_ARG_WITH([udevrulesdir], + AS_HELP_STRING([--with-udevrulesdir=DIR], [Directory for udev rules]), + [], + [with_udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)"/rules.d"]) +AC_SUBST([udevrulesdir], [$with_udevrulesdir]) + dnl Make sure anyone changing configure.ac/Makefile.am has a clue AM_MAINTAINER_MODE -- 1.9.3
H. Peter Anvin
2014-Aug-07 19:31 UTC
[PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
On 08/07/2014 06:08 AM, Amit Shah wrote:> On KVM guests where the virtio-rng device is available, and set as the > current rng, this udev rule will start rngd which will feed in the > host-provided entropy to /dev/random. > > Signed-off-by: Amit Shah <amit.shah at redhat.com> > --- > 90-virtio-rng.rules | 1 + > 1 file changed, 1 insertion(+) > create mode 100644 90-virtio-rng.rules > > diff --git a/90-virtio-rng.rules b/90-virtio-rng.rules > new file mode 100644 > index 0000000..07f2f9c > --- /dev/null > +++ b/90-virtio-rng.rules > @@ -0,0 +1 @@ > +KERNEL=="hw_random", ATTR{rng_current}=="virtio*", RUN+="/sbin/rngd -r /dev/hwrng" >I'm not sure this is really right. rngd can receive input from a number of sources, and I suspect it would be better to rngd to be started much earlier and perhaps get sent a SIGHUP to reconfigure when a hw_random device appears ... not just the virtio one. Currently rngd exits if there is no daemon. There are a few ways to deal with that: one is to run rngd on changes and leave a pid file around; the rngd can try to signal the old rngd or launch itself; another option would be to have a different rngd for each source. To some degree the above is obsolete when we get khwrngd widely deployed, but that is a new-kernel-only kind of thing. -hpa
Possibly Parallel Threads
- [PATCH 0/2] rng-tools: add udev rule for virtio-rng
- [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
- [PATCH 1/2] rngd: add udev rule to source from hwrng if virtio-rng present
- [PATCH 2/2] Install udev rules in system-default directory
- [PATCH 2/2] Install udev rules in system-default directory