[virt-tools-list] [PATCH 2/4] virt-install: EGD RNG devs need a host to connect to if backend_mode=bind

Giuseppe Scrivano gscrivan at redhat.com
Fri Oct 25 15:13:27 UTC 2013


Signed-off-by: Giuseppe Scrivano <gscrivan at redhat.com>
---
 man/virt-install.pod | 15 +++++++++++++++
 tests/clitest.py     |  7 ++++++-
 virtinst/cli.py      | 19 +++++++++++++++----
 3 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/man/virt-install.pod b/man/virt-install.pod
index c2c8378..4800b60 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -1288,6 +1288,21 @@ Specify the port of the Entropy Gathering Daemon to connect to.
 
 Specify the type of the connection: B<tcp> or B<udp>.
 
+=item B<backend_mode>
+
+Specify the mode of the connection.  It is either 'bind' (wait for
+connections on HOST:PORT) or 'connect' (send output to HOST:PORT).
+
+=item B<backend_connect_host>
+
+Specify the remote host to connect to when the specified backend_type is B<udp>
+and backend_mode is B<bind>.
+
+=item B<backend_connect_service>
+
+Specify the remote service to connect to when the specified backend_type is
+B<udp> and backend_mode is B<bind>.
+
 =back
 
 An example invocation:
diff --git a/tests/clitest.py b/tests/clitest.py
index 8032dcd..c858932 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -445,13 +445,18 @@ c.add_valid("--tpm passthrough,model=tpm-tis")  # --tpm backend type with model
 c.add_valid("--tpm passthrough,model=tpm-tis,path=/dev/tpm0")  # --tpm backend type with model and device path
 c.add_invalid("--tpm passthrough,model=foo")  # Invalid model
 
-c = vinst.add_category("tpm", "--noautoconsole --nodisks --pxe")
+
+c = vinst.add_category("rng", "--noautoconsole --nodisks --pxe")
 c.add_valid("--rng random,device=/dev/random")  # random device backend
 c.add_valid("--rng /dev/random")  # random device backend, short form
 c.add_invalid("--rng /FOO/BAR")  # random device backend, short form, invalid device
 c.add_valid("--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=tcp")  # egd backend
 c.add_valid("--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=tcp,backend_mode=bind")  # egd backend, bind mode
 c.add_invalid("--rng foo,backend_host=127.0.0.1,backend_service=8000,backend_mode=connect")  # invalid type
+c.add_invalid("--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind")  # invalid only bind for udp
+c.add_valid("--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=tcp,backend_mode=bind")  # egd backend, bind mode
+c.add_valid("--rng egd,backend_host=127.0.0.1,backend_service=8000,backend_type=udp,backend_mode=bind,backend_connect_host=foo,backend_connect_service=708")  # egd backend, udp mode bind, bind backend mode
+
 
 c = vinst.add_category("xen", "--connect %(XENURI)s --noautoconsole")
 c.add_compare("--disk %(EXISTIMG1)s --import", "xen-default")  # Xen default
diff --git a/virtinst/cli.py b/virtinst/cli.py
index f8cedda..95fe99b 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -926,7 +926,7 @@ def add_device_options(devg):
     devg.add_option("--rng", dest="rng", action="append",
                     help=_("Configure a guest RNG device. Ex:\n"
                            "--rng /dev/random\n"
-                           "--rng type=egd,host=localhost,service=708"))
+     "--rng egd,backend_host=localhost,backend_service=708,backend_type=tcp"))
 
 
 def add_gfx_option(devg):
@@ -1694,10 +1694,21 @@ def parse_rng(guest, optstr, dev):
     else:
         set_param("type", "type")
 
-    set_param("backend_source_host", "backend_host")
-    set_param("backend_source_service", "backend_service")
-    set_param("backend_source_mode", "backend_mode")
     set_param("backend_type", "backend_type")
+
+    backend_mode = opts.get("backend_mode", "connect")
+    if backend_mode == "connect":
+        set_param("connect_host", "backend_host")
+        set_param("connect_service", "backend_service")
+
+    if backend_mode == "bind":
+        set_param("bind_host", "backend_host")
+        set_param("bind_service", "backend_service")
+
+        if opts.get("backend_type", "udp"):
+            set_param("connect_host", "backend_connect_host")
+            set_param("connect_service", "backend_connect_service")
+
     set_param("device", "device")
     set_param("model", "model")
     set_param("rate_bytes", "rate_bytes")
-- 
1.8.3.1




More information about the virt-tools-list mailing list