[virt-tools-list] [PATCH virt-manager v3] add button to remove cpu feature

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Tue Dec 3 02:46:47 UTC 2013


From: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>

We could copy host CPU config by
button 'Copy host CPU configuration'.
If we regret to do this or the host CPU config
caused VM starting failure, we need a button to
help us clear CPU feature.

Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
v3: user xmlbuilder clear method
v2: amend huge button issue

 ui/details.ui          | 16 ++++++++++++----
 virtManager/details.py | 11 +++++++++++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/ui/details.ui b/ui/details.ui
index 88ad9e1..05cfdb9 100644
--- a/ui/details.ui
+++ b/ui/details.ui
@@ -437,7 +437,6 @@
                   </object>
                   <packing>
                     <property name="expand">False</property>
-                    <property name="homogeneous">False</property>
                   </packing>
                 </child>
                 <child>
@@ -750,7 +749,6 @@
                                           <object class="GtkAlignment" id="alignment14">
                                             <property name="visible">True</property>
                                             <property name="can_focus">False</property>
-                                            <property name="hexpand">False</property>
                                             <child>
                                               <placeholder/>
                                             </child>
@@ -2096,6 +2094,7 @@
                                               <object class="GtkHBox" id="hbox25">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">False</property>
+                                                <property name="spacing">20</property>
                                                 <child>
                                                   <object class="GtkButton" id="cpu-copy-host">
                                                     <property name="label" translatable="yes">Copy host CPU configuration</property>
@@ -2115,15 +2114,24 @@
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">False</property>
                                                     <child>
-                                                      <placeholder/>
+                                                      <object class="GtkButton" id="cpu-clear">
+                                                        <property name="label" translatable="yes">Clear CPU configuration</property>
+                                                        <property name="visible">True</property>
+                                                        <property name="can_focus">True</property>
+                                                        <property name="receives_default">True</property>
+                                                        <signal name="clicked" handler="on_cpu_clear_clicked" swapped="no"/>
+                                                      </object>
                                                     </child>
                                                   </object>
                                                   <packing>
-                                                    <property name="expand">True</property>
+                                                    <property name="expand">False</property>
                                                     <property name="fill">True</property>
                                                     <property name="position">1</property>
                                                   </packing>
                                                 </child>
+                                                <child>
+                                                  <placeholder/>
+                                                </child>
                                               </object>
                                               <packing>
                                                 <property name="left_attach">1</property>
diff --git a/virtManager/details.py b/virtManager/details.py
index bb280bf..d5d84f0 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -455,6 +455,7 @@ class vmmDetails(vmmGObjectUI):
             "on_cpu_sockets_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY),
             "on_cpu_threads_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY),
             "on_cpu_copy_host_clicked": self.config_cpu_copy_host,
+            "on_cpu_clear_clicked": self.config_cpu_clear,
             "on_cpu_topology_enable_toggled": self.config_cpu_topology_enable,
 
             "on_config_memory_changed": self.config_memory_changed,
@@ -1713,6 +1714,16 @@ class vmmDetails(vmmGObjectUI):
             self.err.show_err(_("Error copying host CPU: %s") % str(e))
             return
 
+    def config_cpu_clear(self, src_ignore):
+        try:
+            CPU = virtinst.CPU(self.vm.conn.get_backend())
+            CPU.clear()
+
+            self._refresh_cpu_config(CPU)
+        except Exception, e:
+            self.err.show_err(_("Error clear CPU config: %s") % str(e))
+            return
+
     def config_cpu_topology_enable(self, src):
         do_enable = src.get_active()
         self.widget("cpu-topology-table").set_sensitive(do_enable)
-- 
1.8.2.1




More information about the virt-tools-list mailing list