Blob Blame History Raw
From e810fadbc755b722c33862556dffae8a3450544b Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <gscrivan@redhat.com>
Date: Wed, 30 Oct 2013 14:55:59 +0100
Subject: [RHEL-7.0 virt-manager PATCH] virt-manager: show correctly EGD RNG
 devices information

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
(cherry picked from commit 408771004fa54825eb30cd7cc43b9b7b2accd151)

Conflicts:
	ui/vmm-details.ui
	virtManager/details.py
---
 ui/vmm-details.ui      | 116 ++++++++++++++++++++++++++++++++++++++-----------
 virtManager/details.py |  30 ++++++++-----
 2 files changed, 111 insertions(+), 35 deletions(-)

diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui
index 5ef2f73..4296827 100644
--- a/ui/vmm-details.ui
+++ b/ui/vmm-details.ui
@@ -6970,7 +6970,9 @@ I/O:</property>
                                       <object class="GtkTable" id="table16">
                                         <property name="visible">True</property>
                                         <property name="can_focus">False</property>
+                                        <property name="halign">start</property>
                                         <property name="border_width">3</property>
+                                        <property name="n_rows">10</property>
                                         <property name="column_spacing">6</property>
                                         <property name="row_spacing">6</property>
                                         <child>
@@ -7017,11 +7019,11 @@ I/O:</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-host">
+                                          <object class="GtkLabel" id="rng-connect-host">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="xalign">0</property>
-                                            <property name="label">rng-host</property>
+                                            <property name="label">rng-connect-host</property>
                                           </object>
                                           <packing>
                                             <property name="left_attach">1</property>
@@ -7040,11 +7042,11 @@ I/O:</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-service">
+                                          <object class="GtkLabel" id="rng-connect-service">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="xalign">0</property>
-                                            <property name="label">rng-service</property>
+                                            <property name="label">rng-connect-service</property>
                                           </object>
                                           <packing>
                                             <property name="left_attach">1</property>
@@ -7063,26 +7065,41 @@ I/O:</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-label4">
+                                          <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">Backend type:</property>
+                                            <property name="label" translatable="yes">Rate (bytes):</property>
                                           </object>
                                           <packing>
-                                            <property name="top_attach">4</property>
+                                            <property name="top_attach">9</property>
+                                            <property name="bottom_attach">10</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-backend-type">
+                                          <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-backend-type</property>
+                                            <property name="label">rng-rate-bytes</property>
                                           </object>
                                           <packing>
                                             <property name="left_attach">1</property>
-                                            <property name="top_attach">4</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">9</property>
+                                            <property name="bottom_attach">10</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">8</property>
+                                            <property name="bottom_attach">9</property>
                                           </packing>
                                         </child>
                                         <child>
@@ -7094,64 +7111,113 @@ I/O:</property>
                                           </object>
                                           <packing>
                                             <property name="left_attach">1</property>
-                                            <property name="top_attach">6</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">8</property>
+                                            <property name="bottom_attach">9</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-label6">
+                                          <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">Rate (period):</property>
+                                            <property name="label" translatable="yes">Mode:</property>
+                                          </object>
+                                          <packing>
+                                            <property name="top_attach">7</property>
+                                            <property name="bottom_attach">8</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="right_attach">2</property>
+                                            <property name="top_attach">7</property>
+                                            <property name="bottom_attach">8</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">6</property>
+                                            <property name="bottom_attach">7</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-label7">
+                                          <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="right_attach">2</property>
+                                            <property name="top_attach">6</property>
+                                            <property name="bottom_attach">7</property>
+                                          </packing>
+                                        </child>
+                                        <child>
+                                          <object class="GtkLabel" id="rng-label8">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="xalign">1</property>
-                                            <property name="label" translatable="yes">Mode:</property>
+                                            <property name="label" translatable="yes">Bind Host:</property>
                                           </object>
                                           <packing>
-                                            <property name="top_attach">5</property>
+                                            <property name="top_attach">4</property>
+                                            <property name="bottom_attach">5</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-mode">
+                                          <object class="GtkLabel" id="rng-bind-host">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="xalign">0</property>
-                                            <property name="label">rng-mode</property>
+                                            <property name="label">rng-bind-host</property>
                                           </object>
                                           <packing>
                                             <property name="left_attach">1</property>
-                                            <property name="top_attach">5</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">4</property>
+                                            <property name="bottom_attach">5</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-label5">
+                                          <object class="GtkLabel" id="rng-label9">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="xalign">1</property>
-                                            <property name="label" translatable="yes">Rate (bytes):</property>
+                                            <property name="label" translatable="yes">Bind Service:</property>
                                           </object>
                                           <packing>
-                                            <property name="top_attach">7</property>
+                                            <property name="top_attach">5</property>
+                                            <property name="bottom_attach">6</property>
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkLabel" id="rng-rate-bytes">
+                                          <object class="GtkLabel" id="rng-bind-service">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
                                             <property name="xalign">0</property>
-                                            <property name="label">rng-rate-bytes</property>
+                                            <property name="label">rng-bind-service</property>
                                           </object>
                                           <packing>
                                             <property name="left_attach">1</property>
-                                            <property name="top_attach">7</property>
+                                            <property name="right_attach">2</property>
+                                            <property name="top_attach">5</property>
+                                            <property name="bottom_attach">6</property>
                                           </packing>
                                         </child>
                                       </object>
diff --git a/virtManager/details.py b/virtManager/details.py
index 48f9faa..be3b6ec 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -38,6 +38,7 @@ from virtManager.console import vmmConsolePages
 from virtManager.serialcon import vmmSerialConsole
 from virtManager.graphwidgets import Sparkline
 from virtManager import util as util
+from virtinst import VirtualRNGDevice

 import virtinst

@@ -3211,30 +3212,34 @@ class vmmDetails(vmmGObjectUI):
     def refresh_rng_page(self):
         dev = self.get_hw_selection(HW_LIST_COL_DEVICE)
         values = {
+            "rng-bind-host" : "bind_host",
+            "rng-bind-service" : "bind_service",
+            "rng-connect-host" : "connect_host",
+            "rng-connect-service" : "connect_service",
             "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),
+            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)
+            VirtualRNGDevice.get_pretty_backend_type(x),
         }

         is_egd = dev.type == virtinst.VirtualRNGDevice.TYPE_EGD
+        udp = dev.backend_type == virtinst.VirtualRNGDevice.BACKEND_TYPE_UDP
+        bind = virtinst.VirtualRNGDevice.BACKEND_MODE_BIND in dev.backend_mode()
+
         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-mode").set_sensitive(is_egd and not udp)
         self.widget("rng-backend-type").set_sensitive(is_egd)
+        self.widget("rng-connect-host").set_sensitive(is_egd and (udp or not bind))
+        self.widget("rng-connect-service").set_sensitive(is_egd and (udp or not bind))
+        self.widget("rng-bind-host").set_sensitive(is_egd and (udp or bind))
+        self.widget("rng-bind-service").set_sensitive(is_egd and (udp or bind))

         for k, prop in values.items():
             val = "-"
@@ -3244,6 +3249,11 @@ class vmmDetails(vmmGObjectUI):
                 if r:
                     val = r(val)
             self.widget(k).set_text(val)
+        if is_egd and not udp:
+            mode = VirtualRNGDevice.get_pretty_mode(dev.backend_mode()[0])
+            self.widget("rng-mode").set_text(mode)
+        else:
+            self.widget("rng-mode").set_text("-")

     def refresh_char_page(self):
         chardev = self.get_hw_selection(HW_LIST_COL_DEVICE)
-- 
1.8.4.2