[PATCH 5/6] qemu: Implement support for EGD backend for virtio-rng

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds a new capability bit QEMU_CAPS_OBJECT_RNG_EGD and code
to support the egd backend for the VirtIO RNG device.

The device is added by 3 qemu command line options:
-chardev socket,id=charrng0,host=1.2.3.4,port=1234 (communication
                                                    backend)
-object rng-egd,chardev=charrng0,id=rng0 (RNG protocol client)
-device virtio-rng-pci,rng=rng0,bus=pci.0,addr=0x4 (the RNG device)
---
 src/qemu/qemu_capabilities.c |  3 +++
 src/qemu/qemu_capabilities.h |  1 +
 src/qemu/qemu_command.c      | 22 +++++++++++++++++++---
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a316a56..8cb3c8e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -207,6 +207,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
               "add-fd",
               "virtio-rng",
               "rng-random",
+
+              "rng-egd", /* 130 */
     );

 struct _virQEMUCaps {
@@ -1357,6 +1359,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
     { "usb-net", QEMU_CAPS_DEVICE_USB_NET},
     { "virtio-rng-pci", QEMU_CAPS_DEVICE_VIRTIO_RNG },
     { "rng-random", QEMU_CAPS_OBJECT_RNG_RANDOM },
+    { "rng-egd", QEMU_CAPS_OBJECT_RNG_EGD },
 };


diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index ee0d0ca..53dbcac 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -169,6 +169,7 @@ enum virQEMUCapsFlags {
     QEMU_CAPS_DEVICE_VIRTIO_RNG  = 128, /* virtio-rng device */
     QEMU_CAPS_OBJECT_RNG_RANDOM  = 129, /* the rng-random backend for
                                            virtio rng */
+    QEMU_CAPS_OBJECT_RNG_EGD     = 130, /* EGD protocol daemon for rng */

     QEMU_CAPS_LAST,                   /* this must always be the last item */
 };
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7ffa6ab..d3a9b70 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4225,6 +4225,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,
                         virQEMUCapsPtr qemuCaps)
 {
     virBuffer buf = VIR_BUFFER_INITIALIZER;
+    char *backend = NULL;
     int ret = -1;

     switch ((enum virDomainRNGBackend) dev->backend) {
@@ -4245,9 +4246,23 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,
         break;

     case VIR_DOMAIN_RNG_BACKEND_EGD:
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("egd RNG backend not yet implemented"));
-        goto cleanup;
+
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_EGD)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("this qemu doesn't support the rng-egd "
+                             "backend"));
+            goto cleanup;
+        }
+
+        if (!(backend = qemuBuildChrChardevStr(dev->source.chardev,
+                                               dev->info.alias, qemuCaps)))
+            goto cleanup;
+
+        virCommandAddArgList(cmd, "-chardev", backend, NULL);
+
+        virCommandAddArg(cmd, "-object");
+        virCommandAddArgFormat(cmd, "rng-egd,chardev=char%s,id=%s",
+                               dev->info.alias, dev->info.alias);
         break;

     case VIR_DOMAIN_RNG_BACKEND_LAST:
@@ -4258,6 +4273,7 @@ qemuBuildRNGBackendArgs(virCommandPtr cmd,

 cleanup:
     virBufferFreeAndReset(&buf);
+    VIR_FREE(backend);
     return ret;
 }

-- 
1.8.1.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]