Blame SOURCES/0036-launch-Add-a-virtio-rng-device-to-the-guest.patch

e76f14
From a8c286e9a7972833e1c8cf7da8d91406fa8d0f79 Mon Sep 17 00:00:00 2001
e76f14
From: "Richard W.M. Jones" <rjones@redhat.com>
e76f14
Date: Tue, 22 Mar 2016 14:51:19 +0000
e76f14
Subject: [PATCH] launch: Add a virtio-rng device to the guest.
e76f14
e76f14
(cherry picked from commit 9423c16607259b30985c46d04db9958ec079aa42)
e76f14
---
e76f14
 src/launch-direct.c  | 11 +++++++++++
e76f14
 src/launch-libvirt.c | 14 ++++++++++++++
e76f14
 2 files changed, 25 insertions(+)
e76f14
e76f14
diff --git a/src/launch-direct.c b/src/launch-direct.c
e76f14
index 8d99979..25c97a7 100644
e76f14
--- a/src/launch-direct.c
e76f14
+++ b/src/launch-direct.c
e76f14
@@ -454,6 +454,17 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
e76f14
   ADD_CMDLINE ("-initrd");
e76f14
   ADD_CMDLINE (initrd);
e76f14
 
e76f14
+  /* Add a random number generator (backend for virtio-rng).  This
e76f14
+   * isn't strictly necessary but means we won't need to hang around
e76f14
+   * when needing entropy.
e76f14
+   */
e76f14
+  if (qemu_supports_device (g, data, "virtio-rng-pci")) {
e76f14
+    ADD_CMDLINE ("-object");
e76f14
+    ADD_CMDLINE ("rng-random,filename=/dev/urandom,id=rng0");
e76f14
+    ADD_CMDLINE ("-device");
e76f14
+    ADD_CMDLINE ("virtio-rng-pci,rng=rng0");
e76f14
+  }
e76f14
+
e76f14
   /* Add drives */
e76f14
   virtio_scsi = qemu_supports_virtio_scsi (g, data);
e76f14
 
e76f14
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
e76f14
index ceaa696..3df1833 100644
e76f14
--- a/src/launch-libvirt.c
e76f14
+++ b/src/launch-libvirt.c
e76f14
@@ -1304,6 +1304,20 @@ construct_libvirt_xml_devices (guestfs_h *g,
e76f14
     }
e76f14
 #endif
e76f14
 
e76f14
+    /* Add a random number generator (backend for virtio-rng). */
e76f14
+    start_element ("rng") {
e76f14
+      attribute ("model", "virtio");
e76f14
+      start_element ("backend") {
e76f14
+        attribute ("model", "random");
e76f14
+        /* It'd be nice to do this, but libvirt says:
e76f14
+         *   file '/dev/urandom' is not a supported random source
e76f14
+         * Let libvirt pick /dev/random automatically instead.
e76f14
+         * See also: https://bugzilla.redhat.com/show_bug.cgi?id=1074464
e76f14
+         */
e76f14
+        //string ("/dev/urandom");
e76f14
+      } end_element ();
e76f14
+    } end_element ();
e76f14
+
e76f14
     /* virtio-scsi controller. */
e76f14
     start_element ("controller") {
e76f14
       attribute ("type", "scsi");
e76f14
-- 
e76f14
1.8.3.1
e76f14