nova/nova/virt/libvirt
Kashyap Chamarthy de512f2c02 libvirt: Add a default VirtIO-RNG device to guests
tl;dr: We're adding the default VirtIO-RNG device to ensure guests are
       not starved of entropy (and thus not hang) during boot time.

Background
----------

From Nova Git history, commit b94550f419 ("libvirt: configuration
element for a random number generator device") _did_ add a default RNG
device (but with its entropy source to the undesirable '/dev/random').
However, the default RNG device was immediately removed in another
commit (605677c -- "libvirt: remove explicit /dev/random rng default"),
with this rationale:

    libvirt (or rather qemu) will default to /dev/random if no rng device
    path is specified [...]

    It's preferable for us to not duplicate this default to allow for a
    future where libvirt or the hypervisor needs to make more intelligent
    decisions about the default device to use.

The above reasoning doesn't hold up, because:

(a) libvirt does not make "policy" decisions, such as choosing an
    entropy source (or any other such).  Therefore Nova, as a management
    application, should make the decision here.

(b) More importantly, when QEMU exposes a VirtIO-RNG device to the
    guest, that device needs a source of entropy; and QEMU by default
    uses the legacy and problematic `/dev/random` as the source —
    instead of the preferred `/dev/urandom`.  So QEMU's default for
    VirtIO-RNG devices is not sufficient, and Nova should not rely on
    it.  (Discussion[+] on 'qemu-devel' list to consider changing QEMU's
    default.)

                    * * *

In this patch:

  - Make Nova configure a VirtIO-RNG device by default for guests.
    (Which will be using `/dev/urandom` as the default entropy source.)
    This will also work for Windows guests, when using VirtIO-Win
    drivers[*] on the Linux host.

  - The 'hw_rng_model' image metadata property is now rendered
    (temporarily) useless -- as it's not used anywhere outside the
    _add_rng_device() method.  But we don't want to deprecate it yet, as
    we may extend it (see code comment for details); docucment that.

[*] https://docs.pagure.org/docs-fedora/create-windows-vms-using-virtio.html
[+] https://lists.nongnu.org/archive/html/qemu-devel/2018-09/msg02724.html
    -- "[RFC] Virtio RNG: Consider changing the default entropy source to
    /dev/urandom?"

Closes-Bug: #1789868

Change-Id: I28e66c9640c38d23b8c0dbd0b05f5260bfcf6d30
Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2020-01-23 13:24:52 +01:00
..
storage Merge "Leave brackets on Ceph IP addresses for libguestfs" 2019-10-14 20:56:14 +00:00
volume Add missing parameter 2019-09-24 16:42:56 +01:00
__init__.py
blockinfo.py Add reminder to update corresponding glance docs 2019-09-13 10:59:42 +01:00
config.py Create a controller for qga when SEV is used 2019-12-10 11:01:08 +00:00
designer.py Switch to uses_virtio to enable iommu driver for AMD SEV 2019-12-10 11:01:08 +00:00
driver.py libvirt: Add a default VirtIO-RNG device to guests 2020-01-23 13:24:52 +01:00
guest.py libvirt: Remove 'enable_hairpin' 2019-11-29 17:20:02 +00:00
host.py libvirt: check job status for VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED event 2019-11-05 16:05:02 +00:00
imagebackend.py Consolidate [image_cache] conf options 2019-11-13 11:09:03 -06:00
imagecache.py Consolidate [image_cache] conf options 2019-11-13 11:09:03 -06:00
instancejobtracker.py Remove translation of log messages 2017-06-13 11:20:28 +07:00
migration.py libvirt: check job status for VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED event 2019-11-05 16:05:02 +00:00
utils.py Merge "Add reminder to update corresponding glance docs" 2019-09-23 19:58:54 +00:00
vif.py nova-net: Copy shared utils from nova-net module 2020-01-08 13:54:12 +00:00