virt-install: accept a single argument form for RNG devices

Detect the "--rng /dev/random" case and assume it is the "random" type.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2013-09-25 22:15:24 +02:00
parent 15eac4de59
commit 601eb5f15e
3 changed files with 25 additions and 10 deletions

View File

@ -1258,6 +1258,11 @@ An example invocation:
Connect to localhost to the TCP port 8000 to get entropy data.
=item B<--rng /dev/random>
Use the /dev/random device to get entropy data, this form implicitly uses the
"random" model.
See C<http://libvirt.org/formatdomain.html#elementsRng> for complete
details.

View File

@ -438,6 +438,8 @@ c.add_invalid("--tpm passthrough,model=foo") # Invalid model
c = vinst.add_category("tpm", "--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

View File

@ -1005,6 +1005,7 @@ def add_device_options(devg):
"--tpm type=passthrough"))
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"))
@ -1750,7 +1751,8 @@ def parse_rng(guest, optstring, dev=None):
return None
opts = parse_optstr(optstring, remove_first="type")
if opts.get("type") == "none":
dev_type = opts.get("type")
if dev_type == "none":
return None
if not dev:
@ -1758,15 +1760,21 @@ def parse_rng(guest, optstring, dev=None):
set_param = _build_set_param(dev, opts)
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")
set_param("device", "device")
set_param("model", "model")
set_param("rate_bytes", "rate_bytes")
set_param("rate_period", "rate_period")
if dev_type.startswith("/"):
# if the provided type begins with '/' then assume it is the name of
# the RNG device and that its type is "random".
dev.device = dev_type
dev.type = "random"
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")
set_param("device", "device")
set_param("model", "model")
set_param("rate_bytes", "rate_bytes")
set_param("rate_period", "rate_period")
return dev