Blame SOURCES/virt-manager-virtManager-add-GUI-elements-for-showing-RNG-devices.patch

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