virt-install: add support for virtio-rng devices

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2013-09-18 15:29:29 +02:00 committed by Cole Robinson
parent 8abcae5073
commit a55438f880
4 changed files with 96 additions and 0 deletions

View File

@ -1215,6 +1215,55 @@ Make the host's TPM accessible to a single guest.
See C<http://libvirt.org/formatdomain.html#elementsTpm> for complete
details.
=item --rng=TYPE[,OPTS]
Configure a virtual RNG device.
Type can be B<random> or B<egd>.
If the specified type is B<random> then these values must
be specified:
=over 4
=item B<backend_device>
The device to use as a source of entropy.
=back
Whereas, when the type is B<egd>, these values must be provided:
=over 4
=item B<backend_host>
Specify the host of the Entropy Gathering Daemon to connect to.
=item B<backend_service>
Specify the port of the Entropy Gathering Daemon to connect to.
=item B<backend_type>
Specify the type of the connection: B<tcp> or B<udp>.
=back
An example invocation:
=over 4
=item B<--rng egd,backend_host=localhost,backend_service=8000,backend_type=tcp>
Connect to localhost to the TCP port 8000 to get entropy data.
See C<http://libvirt.org/formatdomain.html#elementsRng> for complete
details.
=back
=back
=head2 Miscellaneous Options

View File

@ -436,6 +436,12 @@ 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.add_valid("--rng random,device=/dev/random") # random device backend
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 = vinst.add_category("xen", "--connect %(XENURI)s --noautoconsole")
c.add_compare("--disk %(EXISTIMG1)s --import", "xen-default") # Xen default

View File

@ -527,6 +527,7 @@ def build_guest_instance(conn, options):
cli.get_hostdevs(options.hostdevs, guest)
cli.get_smartcard(guest, options.smartcard)
cli.get_tpm(guest, options.tpm)
cli.get_rng(guest, options.rng)
if not guest.get_devices("input"):
guest.add_default_input_device()

View File

@ -852,6 +852,17 @@ def get_tpm(guest, tpm_opts):
guest.add_device(dev)
def get_rng(guest, rng_opts):
for rng in listify(rng_opts):
try:
dev = parse_rng(guest, rng)
except Exception, e:
fail(_("Error in RNG device parameters: %s") % str(e))
if dev:
guest.add_device(dev)
def get_controller(guest, sc_opts):
for sc in listify(sc_opts):
try:
@ -992,6 +1003,9 @@ def add_device_options(devg):
devg.add_option("", "--tpm", dest="tpm", action="append",
help=_("Configure a guest TPM device. Ex:\n"
"--tpm type=passthrough"))
devg.add_option("", "--rng", dest="rng", action="append",
help=_("Configure a guest RNG device. Ex:\n"
"--rng type=egd,host=localhost,service=708"))
def add_gfx_option(devg):
@ -1731,6 +1745,32 @@ def parse_tpm(guest, optstring, dev=None):
return dev
def parse_rng(guest, optstring, dev=None):
if optstring is None:
return None
opts = parse_optstr(optstring, remove_first="type")
if opts.get("type") == "none":
return None
if not dev:
dev = virtinst.VirtualRNGDevice(guest.conn)
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")
return dev
######################
# --watchdog parsing #
######################