[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [RFC PATCH] Add machine type option in virt-manager



This patch adds the machine type combo callback
functions. When machine type is selected, and
click apply button, the details of overview page
are refreshed, and machine type value is set.

Signed-off-by: Li Zhang <zhlcindy linux vnet ibm com>
---
 src/virtManager/details.py |   33 ++++++++++++++++++++++++++++++++-
 src/virtManager/domain.py  |    7 +++++++
 2 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/src/virtManager/details.py b/src/virtManager/details.py
index 92a13d8..e2fbf42 100644
--- a/src/virtManager/details.py
+++ b/src/virtManager/details.py
@@ -38,10 +38,11 @@ from virtManager import util as util
 import virtinst
 
 # Parameters that can be editted in the details window
-EDIT_TOTAL = 36
+EDIT_TOTAL = 37
 (EDIT_NAME,
 EDIT_ACPI,
 EDIT_APIC,
+EDIT_MACHTYPE,
 EDIT_CLOCK,
 EDIT_SECURITY,
 EDIT_DESC,
@@ -380,6 +381,7 @@ class vmmDetails(vmmGObjectUI):
             "on_overview_name_changed": (self.enable_apply, EDIT_NAME),
             "on_overview_acpi_changed": self.config_acpi_changed,
             "on_overview_apic_changed": self.config_apic_changed,
+            "on_machine_type_changed": (self.enable_apply, EDIT_MACTYPE),
             "on_overview_clock_changed": (self.enable_apply, EDIT_CLOCK),
             "on_security_label_changed": (self.enable_apply, EDIT_SECURITY),
             "on_security_type_changed": self.security_type_changed,
@@ -733,6 +735,27 @@ class vmmDetails(vmmGObjectUI):
         clock_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
         for offset in ["localtime", "utc"]:
             clock_model.append([offset])
+        
+        caps = self.vm.conn.get_capabilities()
+        machines = []
+
+        if len(caps.guests) > 0: 
+            for guest in caps.guests:
+                if len(guest.domains) > 0:
+                    for domain in guest.domains:
+                        machines = list(set(machines + domain.machines))
+                          
+        machtyp_combo = self.widget("machine-type-combo")
+        machtyp_model = gtk.ListStore(str)
+        machtyp_combo.set_model(mactype_model)
+        text = gtk.CellRendererText()
+        mactype_combo.pack_start(text, True)
+        mactype_combo.add_attribute(text, 'text', 0)
+        mactype_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
+        
+        if len(machines) > 0:
+           for machine in machines: 
+               mactype_model.append([machine])
 
         # Security info tooltips
         util.tooltip_wrapper(self.widget("security-static-info"),
@@ -1967,6 +1990,10 @@ class vmmDetails(vmmGObjectUI):
             clock = self.get_combo_label_value("overview-clock")
             add_define(self.vm.define_clock, clock)
 
+        if self.editted(EDIT_MACTYPE):
+            mactype = self.get_combo_label_value("machine-type")
+            add_define(self.vm.define_mactype, mactype)
+
         if self.editted(EDIT_SECURITY):
             semodel = None
             setype = "static"
@@ -2532,6 +2559,7 @@ class vmmDetails(vmmGObjectUI):
         acpi = self.vm.get_acpi()
         apic = self.vm.get_apic()
         clock = self.vm.get_clock()
+        mactype = self.vm.get_mactype()
 
         # Hack in a way to represent 'default' acpi/apic for customize dialog
         self.widget("overview-acpi").set_active(bool(acpi))
@@ -2545,6 +2573,9 @@ class vmmDetails(vmmGObjectUI):
             clock = _("Same as host")
         self.set_combo_label("overview-clock", clock)
 
+        if mactype is not None:
+            self.set_combo_label("machine-type", mactype)
+
         # Security details
         semodel, ignore, vmlabel = self.vm.get_seclabel()
         caps = self.vm.conn.get_capabilities()
diff --git a/src/virtManager/domain.py b/src/virtManager/domain.py
index e29a1c0..6c30162 100644
--- a/src/virtManager/domain.py
+++ b/src/virtManager/domain.py
@@ -512,6 +512,11 @@ class vmmDomain(vmmLibvirtObject):
             guest.features["apic"] = newvalue
         return self._redefine_guest(change)
 
+    def define_mactype(self, newvalue):
+        def change(guest):
+            guest.installer.machine = newvalue
+        return self._redefine_guest(change)
+
     def define_clock(self, newvalue):
         def change(guest):
             guest.clock.offset = newvalue
@@ -840,6 +845,8 @@ class vmmDomain(vmmLibvirtObject):
         return self._get_guest().features["acpi"]
     def get_apic(self):
         return self._get_guest().features["apic"]
+    def get_mactype(self):
+        return self._get_guest().installer.machine
     def get_clock(self):
         return self._get_guest().clock.offset
 
-- 
1.7.7


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]