From 4a615aa668506a44cc604bcdd8efe5faab828ae0 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <gscrivan@redhat.com>
Date: Mon, 30 Sep 2013 17:15:41 +0200
Subject: [RHEL-7.0 virt-manager PATCH] virtManager: add GUI elements for
showing RNG devices
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit 92db24aa12c0728348b3672f0ed2591c56b2a2e8)
Conflicts:
ui/vmm-details.ui
virtManager/details.py
virtManager/domain.py
---
ui/vmm-details.ui | 231 +++++++++++++++++++++++++++++++++++++++++++++++++
virtManager/details.py | 47 +++++++++-
virtManager/domain.py | 3 +
3 files changed, 280 insertions(+), 1 deletion(-)
diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui
index 58fe289..5ef2f73 100644
--- a/ui/vmm-details.ui
+++ b/ui/vmm-details.ui
@@ -6956,6 +6956,237 @@ I/O:</property>
<property name="tab_fill">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkFrame" id="frame21">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkVBox" id="rng-box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkTable" id="table16">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">3</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="rng-type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-type</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label91">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Type:</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-device">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-device</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Device:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-host">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-host</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Host:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-service">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-service</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Service:</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Backend type:</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-backend-type">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-backend-type</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-rate-period">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-rate-period</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Rate (period):</property>
+ </object>
+ <packing>
+ <property name="top_attach">6</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-label7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Mode:</property>
+ </object>
+ <packing>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-mode">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-mode</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Rate (bytes):</property>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="rng-rate-bytes">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label">rng-rate-bytes</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">7</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="label89">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Random Number Generator</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">18</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label88">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">rng</property>
+ </object>
+ <packing>
+ <property name="position">18</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
</object>
</child>
</object>
diff --git a/virtManager/details.py b/virtManager/details.py
index a62d58c..48f9faa 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -121,13 +121,14 @@ HW_LIST_TYPE_CONTROLLER = 14
HW_LIST_TYPE_FILESYSTEM = 15
HW_LIST_TYPE_SMARTCARD = 16
HW_LIST_TYPE_REDIRDEV = 17
+HW_LIST_TYPE_RNG = 18
remove_pages = [HW_LIST_TYPE_NIC, HW_LIST_TYPE_INPUT,
HW_LIST_TYPE_GRAPHICS, HW_LIST_TYPE_SOUND, HW_LIST_TYPE_CHAR,
HW_LIST_TYPE_HOSTDEV, HW_LIST_TYPE_DISK, HW_LIST_TYPE_VIDEO,
HW_LIST_TYPE_WATCHDOG, HW_LIST_TYPE_CONTROLLER,
HW_LIST_TYPE_FILESYSTEM, HW_LIST_TYPE_SMARTCARD,
- HW_LIST_TYPE_REDIRDEV]
+ HW_LIST_TYPE_REDIRDEV, HW_LIST_TYPE_RNG]
# Boot device columns
BOOT_DEV_TYPE = 0
@@ -1337,6 +1338,8 @@ class vmmDetails(vmmGObjectUI):
self.refresh_smartcard_page()
elif pagetype == HW_LIST_TYPE_REDIRDEV:
self.refresh_redir_page()
+ elif pagetype == HW_LIST_TYPE_RNG:
+ self.refresh_rng_page()
else:
pagetype = -1
except Exception, e:
@@ -3205,6 +3208,43 @@ class vmmDetails(vmmGObjectUI):
self.widget("redir-type-label").set_text(rd.type)
self.widget("redir-type-combo").hide()
+ def refresh_rng_page(self):
+ dev = self.get_hw_selection(HW_LIST_COL_DEVICE)
+ values = {
+ "rng-type" : "type",
+ "rng-device" : "device",
+ "rng-host" : "backend_source_host",
+ "rng-service" : "backend_source_service",
+ "rng-mode" : "backend_source_mode",
+ "rng-backend-type" : "backend_type",
+ "rng-rate-bytes" : "rate_bytes",
+ "rng-rate-period" : "rate_period"
+ }
+ rewriter = {
+ "rng-type" : lambda x:
+ virtinst.VirtualRNGDevice.get_pretty_type(x),
+ "rng-backend-type" : lambda x:
+ virtinst.VirtualRNGDevice.get_pretty_backend_type(x),
+ "rng-mode" : lambda x:
+ virtinst.VirtualRNGDevice.get_pretty_mode(x)
+ }
+
+ is_egd = dev.type == virtinst.VirtualRNGDevice.TYPE_EGD
+ self.widget("rng-device").set_sensitive(not is_egd)
+ self.widget("rng-host").set_sensitive(is_egd)
+ self.widget("rng-service").set_sensitive(is_egd)
+ self.widget("rng-mode").set_sensitive(is_egd)
+ self.widget("rng-backend-type").set_sensitive(is_egd)
+
+ for k, prop in values.items():
+ val = "-"
+ if dev.supports_property(prop):
+ val = getattr(dev, prop) or "-"
+ r = rewriter.get(k)
+ if r:
+ val = r(val)
+ self.widget(k).set_text(val)
+
def refresh_char_page(self):
chardev = self.get_hw_selection(HW_LIST_COL_DEVICE)
if not chardev:
@@ -3641,6 +3681,11 @@ class vmmDetails(vmmGObjectUI):
update_hwlist(HW_LIST_TYPE_SMARTCARD, sc,
_("Smartcard"), "device_serial")
+ # Populate list of RNG devices
+ for rng in self.vm.get_rng_devices():
+ update_hwlist(HW_LIST_TYPE_RNG, rng,
+ _("RNG"), "system-run")
+
devs = range(len(hw_list_model))
devs.reverse()
for i in devs:
diff --git a/virtManager/domain.py b/virtManager/domain.py
index e6e642b..a51e421 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -55,6 +55,7 @@ def compare_device(origdev, newdev, idx):
"filesystem" : ["target" , "vmmindex"],
"smartcard" : ["mode" , "vmmindex"],
"redirdev" : ["bus" , "type", "vmmindex"],
+ "rng" : ["type" , "vmmindex"],
}
if id(origdev) == id(newdev):
@@ -1086,6 +1087,8 @@ class vmmDomain(vmmLibvirtObject):
return self._build_device_list("smartcard")
def get_redirdev_devices(self):
return self._build_device_list("redirdev")
+ def get_rng_devices(self):
+ return self._build_device_list("rng")
def get_disk_devices(self, refresh_if_necc=True, inactive=False):
devs = self._build_device_list("disk", refresh_if_necc, inactive)
--
1.8.3.2