mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-10 01:18:03 +03:00
guest: Add default virtio-rng /dev/urandom (bz 1212082)
For guests that support it, per libosinfo, and new enough libvirt to handle /dev/urandom. See the bug for discussion https://bugzilla.redhat.com/show_bug.cgi?id=1212082
This commit is contained in:
parent
dff27a298e
commit
d62e975568
@ -63,5 +63,8 @@
|
|||||||
</video>
|
</video>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
|
<rng model="virtio">
|
||||||
|
<backend model="random">/dev/urandom</backend>
|
||||||
|
</rng>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -55,6 +55,9 @@
|
|||||||
<video>
|
<video>
|
||||||
<model type="qxl"/>
|
<model type="qxl"/>
|
||||||
</video>
|
</video>
|
||||||
|
<rng model="virtio">
|
||||||
|
<backend model="random">/dev/urandom</backend>
|
||||||
|
</rng>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
<domain type="kvm">
|
<domain type="kvm">
|
||||||
@ -111,5 +114,8 @@
|
|||||||
<video>
|
<video>
|
||||||
<model type="qxl"/>
|
<model type="qxl"/>
|
||||||
</video>
|
</video>
|
||||||
|
<rng model="virtio">
|
||||||
|
<backend model="random">/dev/urandom</backend>
|
||||||
|
</rng>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -72,6 +72,9 @@
|
|||||||
</video>
|
</video>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
|
<rng model="virtio">
|
||||||
|
<backend model="random">/dev/urandom</backend>
|
||||||
|
</rng>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
<domain type="kvm">
|
<domain type="kvm">
|
||||||
@ -144,5 +147,8 @@
|
|||||||
</video>
|
</video>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
|
<rng model="virtio">
|
||||||
|
<backend model="random">/dev/urandom</backend>
|
||||||
|
</rng>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -45,5 +45,8 @@
|
|||||||
<source mode="bind"/>
|
<source mode="bind"/>
|
||||||
<target type="virtio" name="org.qemu.guest_agent.0"/>
|
<target type="virtio" name="org.qemu.guest_agent.0"/>
|
||||||
</channel>
|
</channel>
|
||||||
|
<rng model="virtio">
|
||||||
|
<backend model="random">/dev/urandom</backend>
|
||||||
|
</rng>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -63,5 +63,8 @@
|
|||||||
</video>
|
</video>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
<redirdev bus="usb" type="spicevmc"/>
|
<redirdev bus="usb" type="spicevmc"/>
|
||||||
|
<rng model="virtio">
|
||||||
|
<backend model="random">/dev/urandom</backend>
|
||||||
|
</rng>
|
||||||
</devices>
|
</devices>
|
||||||
</domain>
|
</domain>
|
||||||
|
@ -2359,6 +2359,7 @@ class ParserRNG(VirtCLIParser):
|
|||||||
cli_arg_name = "rng"
|
cli_arg_name = "rng"
|
||||||
objclass = VirtualRNGDevice
|
objclass = VirtualRNGDevice
|
||||||
remove_first = "type"
|
remove_first = "type"
|
||||||
|
stub_none = False
|
||||||
|
|
||||||
def set_hosts_cb(self, inst, val, virtarg):
|
def set_hosts_cb(self, inst, val, virtarg):
|
||||||
namemap = {}
|
namemap = {}
|
||||||
@ -2386,6 +2387,10 @@ class ParserRNG(VirtCLIParser):
|
|||||||
inst.cli_backend_type = val
|
inst.cli_backend_type = val
|
||||||
|
|
||||||
def _parse(self, inst):
|
def _parse(self, inst):
|
||||||
|
if self.optstr == "none":
|
||||||
|
self.guest.skip_default_rng = True
|
||||||
|
return
|
||||||
|
|
||||||
inst.cli_backend_mode = "connect"
|
inst.cli_backend_mode = "connect"
|
||||||
inst.cli_backend_type = "udp"
|
inst.cli_backend_type = "udp"
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ from .devicedisk import VirtualDisk
|
|||||||
from .devicegraphics import VirtualGraphics
|
from .devicegraphics import VirtualGraphics
|
||||||
from .deviceinput import VirtualInputDevice
|
from .deviceinput import VirtualInputDevice
|
||||||
from .deviceredirdev import VirtualRedirDevice
|
from .deviceredirdev import VirtualRedirDevice
|
||||||
|
from .devicerng import VirtualRNGDevice
|
||||||
from .devicevideo import VirtualVideoDevice
|
from .devicevideo import VirtualVideoDevice
|
||||||
from .distroinstaller import DistroInstaller
|
from .distroinstaller import DistroInstaller
|
||||||
from .domainblkiotune import DomainBlkiotune
|
from .domainblkiotune import DomainBlkiotune
|
||||||
@ -124,6 +125,7 @@ class Guest(XMLBuilder):
|
|||||||
self.skip_default_sound = False
|
self.skip_default_sound = False
|
||||||
self.skip_default_usbredir = False
|
self.skip_default_usbredir = False
|
||||||
self.skip_default_graphics = False
|
self.skip_default_graphics = False
|
||||||
|
self.skip_default_rng = False
|
||||||
self.x86_cpu_default = self.cpu.SPECIAL_MODE_HOST_MODEL_ONLY
|
self.x86_cpu_default = self.cpu.SPECIAL_MODE_HOST_MODEL_ONLY
|
||||||
|
|
||||||
self.__os_object = None
|
self.__os_object = None
|
||||||
@ -641,6 +643,25 @@ class Guest(XMLBuilder):
|
|||||||
return
|
return
|
||||||
self.add_device(VirtualGraphics(self.conn))
|
self.add_device(VirtualGraphics(self.conn))
|
||||||
|
|
||||||
|
def add_default_rng(self):
|
||||||
|
if self.skip_default_rng:
|
||||||
|
return
|
||||||
|
if self.get_devices("rng"):
|
||||||
|
return
|
||||||
|
if not self.os.is_x86():
|
||||||
|
# Not strictly x86 specific, but some other archs like
|
||||||
|
# arm have limited virtio options in some situations, so
|
||||||
|
# it needs more work there.
|
||||||
|
return
|
||||||
|
|
||||||
|
if (self.conn.is_qemu() and
|
||||||
|
self._os_object.supports_virtiorng() and
|
||||||
|
self.conn.check_support(self.conn.SUPPORT_CONN_RNG_URANDOM)):
|
||||||
|
dev = VirtualRNGDevice(self.conn)
|
||||||
|
dev.type = "random"
|
||||||
|
dev.device = "/dev/urandom"
|
||||||
|
self.add_device(dev)
|
||||||
|
|
||||||
def add_default_devices(self):
|
def add_default_devices(self):
|
||||||
self.add_default_graphics()
|
self.add_default_graphics()
|
||||||
self.add_default_video_device()
|
self.add_default_video_device()
|
||||||
@ -648,6 +669,7 @@ class Guest(XMLBuilder):
|
|||||||
self.add_default_console_device()
|
self.add_default_console_device()
|
||||||
self.add_default_usb_controller()
|
self.add_default_usb_controller()
|
||||||
self.add_default_channels()
|
self.add_default_channels()
|
||||||
|
self.add_default_rng()
|
||||||
|
|
||||||
def _add_install_cdrom(self):
|
def _add_install_cdrom(self):
|
||||||
if self._install_cdrom_device:
|
if self._install_cdrom_device:
|
||||||
|
@ -494,6 +494,18 @@ class _OsVariant(object):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def supports_virtiorng(self):
|
||||||
|
if self._os:
|
||||||
|
fltr = libosinfo.Filter()
|
||||||
|
fltr.add_constraint("class", "rng")
|
||||||
|
devs = self._os.get_all_devices(fltr)
|
||||||
|
for dev in range(devs.get_length()):
|
||||||
|
d = devs.get_nth(dev)
|
||||||
|
if d.get_name() == "virtio-rng":
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def supports_qemu_ga(self):
|
def supports_qemu_ga(self):
|
||||||
return self._is_related_to(["debian8", "fedora18", "rhel6.0", "sles11sp4"])
|
return self._is_related_to(["debian8", "fedora18", "rhel6.0", "sles11sp4"])
|
||||||
|
|
||||||
|
@ -320,6 +320,7 @@ SUPPORT_CONN_SPICE_RENDERNODE = _make(version="3.1.0",
|
|||||||
SUPPORT_CONN_VIDEO_VIRTIO_ACCEL3D = _make(version="1.3.0",
|
SUPPORT_CONN_VIDEO_VIRTIO_ACCEL3D = _make(version="1.3.0",
|
||||||
hv_version={"qemu": "2.5.0", "test": 0})
|
hv_version={"qemu": "2.5.0", "test": 0})
|
||||||
SUPPORT_CONN_GRAPHICS_LISTEN_NONE = _make(version="2.0.0")
|
SUPPORT_CONN_GRAPHICS_LISTEN_NONE = _make(version="2.0.0")
|
||||||
|
SUPPORT_CONN_RNG_URANDOM = _make(version="1.3.4")
|
||||||
|
|
||||||
|
|
||||||
# This is for disk <driver name=qemu>. xen supports this, but it's
|
# This is for disk <driver name=qemu>. xen supports this, but it's
|
||||||
|
Loading…
Reference in New Issue
Block a user