mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
details: Show a list of valid CPU models
This commit is contained in:
parent
ecb104dbfb
commit
f99e4e188c
@ -681,6 +681,27 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
no_default = not self.is_customize_dialog
|
||||
|
||||
# CPU model combo
|
||||
caps = self.vm.get_connection().get_capabilities()
|
||||
cpu_values = None
|
||||
cpu_names = []
|
||||
|
||||
try:
|
||||
cpu_values = caps.get_cpu_values(self.vm.get_arch())
|
||||
cpu_names = sorted(map(lambda c: c.model, cpu_values.cpus),
|
||||
key=str.lower)
|
||||
except:
|
||||
logging.exception("Error populating CPU model list")
|
||||
|
||||
cpu_model = self.window.get_widget("cpu-model")
|
||||
|
||||
model = gtk.ListStore(str, object)
|
||||
cpu_model.set_model(model)
|
||||
cpu_model.set_text_column(0)
|
||||
model.set_sort_column_id(0, gtk.SORT_ASCENDING)
|
||||
for name in cpu_names:
|
||||
model.append([name, cpu_values.get_cpu(name)])
|
||||
|
||||
# Disk cache combo
|
||||
disk_cache = self.window.get_widget("disk-cache-combo")
|
||||
uihelpers.build_cache_combo(self.vm, disk_cache)
|
||||
@ -1226,6 +1247,16 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
return devs
|
||||
|
||||
def get_config_cpu_model(self):
|
||||
cpu_list = self.window.get_widget("cpu-model")
|
||||
model = cpu_list.child.get_text()
|
||||
|
||||
for row in cpu_list.get_model():
|
||||
if model == row[0]:
|
||||
return model, row[1].vendor
|
||||
|
||||
return model, None
|
||||
|
||||
##############################
|
||||
# Details/Hardware listeners #
|
||||
##############################
|
||||
@ -1537,7 +1568,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
sockets = self.window.get_widget("cpu-sockets").get_value()
|
||||
cores = self.window.get_widget("cpu-cores").get_value()
|
||||
threads = self.window.get_widget("cpu-threads").get_value()
|
||||
model = self.window.get_widget("cpu-model").get_text() or None
|
||||
model, vendor = self.get_config_cpu_model()
|
||||
|
||||
logging.info("Setting vcpus for %s to %s, cpuset is %s" %
|
||||
(self.vm.get_name(), str(vcpus), cpuset))
|
||||
@ -1553,7 +1584,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
self.vm.define_cpu_topology]
|
||||
define_args = [(vcpus,),
|
||||
(cpuset,),
|
||||
(model, self._cpu_copy_host),
|
||||
(model, vendor, self._cpu_copy_host),
|
||||
(sockets, cores, threads)]
|
||||
|
||||
ret = self._change_config_helper(define_funcs, define_args,
|
||||
@ -2033,7 +2064,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
threads = cpu.threads or 1
|
||||
|
||||
self.window.get_widget("cpu-topology-enable").set_active(show_top)
|
||||
self.window.get_widget("cpu-model").set_text(model)
|
||||
self.window.get_widget("cpu-model").child.set_text(model)
|
||||
self.window.get_widget("cpu-sockets").set_value(sockets)
|
||||
self.window.get_widget("cpu-cores").set_value(cores)
|
||||
self.window.get_widget("cpu-threads").set_value(threads)
|
||||
|
@ -308,10 +308,14 @@ class vmmDomainBase(vmmLibvirtObject):
|
||||
cpu.cores = cores
|
||||
cpu.threads = threads
|
||||
return self._redefine_guest(change)
|
||||
def define_cpu(self, model, from_host):
|
||||
def define_cpu(self, model, vendor, from_host):
|
||||
def change(guest):
|
||||
if from_host:
|
||||
guest.cpu.copy_host_cpu()
|
||||
else:
|
||||
# Since we don't expose this in the UI, have host value trump
|
||||
# caps value
|
||||
guest.cpu.vendor = vendor
|
||||
guest.cpu.model = model
|
||||
return self._redefine_guest(change)
|
||||
|
||||
|
@ -2078,11 +2078,8 @@ I/O:</property>
|
||||
<widget class="GtkHBox" id="hbox21">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkEntry" id="cpu-model">
|
||||
<widget class="GtkComboBoxEntry" id="cpu-model">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="width_chars">15</property>
|
||||
<signal name="changed" handler="on_cpu_model_changed"/>
|
||||
</widget>
|
||||
<packing>
|
||||
@ -2208,9 +2205,9 @@ I/O:</property>
|
||||
<widget class="GtkCheckButton" id="cpu-topology-enable">
|
||||
<property name="label" translatable="yes">Manually set CPU topology</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="active">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="active">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_cpu_topology_enable_toggled"/>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user