mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
add a checkbox for cpu host-model mode, remove 'copy' button
If the host-model is selected, disable the cpu model drop down and features list. They still show what exact configuration the host-model is using. For the old libvirt which doesn't support <cpu mode='host-model'/> virt-manager still copy cpu configs from caps XML to domain XML. (crobinso: Fix some minor pylint)
This commit is contained in:
committed by
Cole Robinson
parent
e941a9e92b
commit
17f43e47fb
@@ -2314,121 +2314,66 @@ I/O:</property>
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="spacing">6</property>
|
<property name="spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTable" id="table15">
|
<object class="GtkCheckButton" id="cpu-host-model-checkbutton">
|
||||||
|
<property name="label" translatable="yes">Use host CPU model</property>
|
||||||
|
<property name="use_action_appearance">False</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">False</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_cpu_host_model_enable_toggled" swapped="no"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHBox" id="hbox14">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="n_rows">2</property>
|
|
||||||
<property name="n_columns">2</property>
|
|
||||||
<property name="column_spacing">12</property>
|
|
||||||
<property name="row_spacing">3</property>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="label52">
|
<object class="GtkLabel" id="label52">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="xalign">0</property>
|
|
||||||
<property name="label" translatable="yes">Model:</property>
|
<property name="label" translatable="yes">Model:</property>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="expand">False</property>
|
||||||
<property name="y_options">GTK_FILL</property>
|
<property name="fill">False</property>
|
||||||
|
<property name="position">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkHBox" id="hbox21">
|
<object class="GtkAlignment" id="alignment12">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkAlignment" id="alignment33">
|
<object class="GtkComboBox" id="cpu-model">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<child>
|
<property name="has_entry">True</property>
|
||||||
<object class="GtkComboBox" id="cpu-model">
|
<signal name="changed" handler="on_cpu_model_changed" swapped="no"/>
|
||||||
<property name="visible">True</property>
|
<child internal-child="entry">
|
||||||
<property name="can_focus">False</property>
|
<object class="GtkEntry" id="combobox-entry">
|
||||||
<property name="has_entry">True</property>
|
|
||||||
<signal name="changed" handler="on_cpu_model_changed" swapped="no"/>
|
|
||||||
<child internal-child="entry">
|
|
||||||
<object class="GtkEntry" id="combobox-entry">
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="y_options">GTK_FILL</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkAlignment" id="alignment37">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="top_attach">1</property>
|
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
<property name="x_options">GTK_FILL</property>
|
|
||||||
<property name="y_options">GTK_FILL</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkHBox" id="hbox25">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="cpu-copy-host">
|
|
||||||
<property name="label" translatable="yes">Copy host CPU configuration</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="receives_default">True</property>
|
</object>
|
||||||
<signal name="clicked" handler="on_cpu_copy_host_clicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">0</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
<child>
|
|
||||||
<object class="GtkAlignment" id="alignment38">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<child>
|
|
||||||
<placeholder/>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
|
||||||
<property name="expand">True</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="expand">False</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="fill">False</property>
|
||||||
<property name="top_attach">1</property>
|
<property name="position">1</property>
|
||||||
<property name="bottom_attach">2</property>
|
|
||||||
<property name="y_options">GTK_FILL</property>
|
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">0</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@@ -2478,7 +2423,7 @@ I/O:</property>
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">True</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
@@ -2499,7 +2444,7 @@ I/O:</property>
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="position">1</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|||||||
@@ -360,7 +360,6 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
|
|
||||||
self.ignorePause = False
|
self.ignorePause = False
|
||||||
self.ignoreDetails = False
|
self.ignoreDetails = False
|
||||||
self._cpu_copy_host = False
|
|
||||||
|
|
||||||
self.console = vmmConsolePages(self.vm, self.builder, self.topwin)
|
self.console = vmmConsolePages(self.vm, self.builder, self.topwin)
|
||||||
|
|
||||||
@@ -431,7 +430,7 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
"on_cpu_cores_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY),
|
"on_cpu_cores_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY),
|
||||||
"on_cpu_sockets_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY),
|
"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_threads_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY),
|
||||||
"on_cpu_copy_host_clicked": self.config_cpu_copy_host,
|
"on_cpu_host_model_enable_toggled": self.config_cpu_host_model_enable,
|
||||||
"on_cpu_topology_enable_toggled": self.config_cpu_topology_enable,
|
"on_cpu_topology_enable_toggled": self.config_cpu_topology_enable,
|
||||||
|
|
||||||
"on_config_memory_changed": self.config_memory_changed,
|
"on_config_memory_changed": self.config_memory_changed,
|
||||||
@@ -918,6 +917,8 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
feat_model.append([name, "default"])
|
feat_model.append([name, "default"])
|
||||||
|
|
||||||
# CPU model combo
|
# CPU model combo
|
||||||
|
self.widget("cpu-host-model-checkbutton").set_tooltip_text(
|
||||||
|
_("Use CPU model which most closely matches the host. This gives maximum functionality and performance."))
|
||||||
cpu_model = self.widget("cpu-model")
|
cpu_model = self.widget("cpu-model")
|
||||||
|
|
||||||
model = Gtk.ListStore(str, object)
|
model = Gtk.ListStore(str, object)
|
||||||
@@ -1812,17 +1813,11 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
def config_maxvcpus_changed(self, ignore):
|
def config_maxvcpus_changed(self, ignore):
|
||||||
self.enable_apply(EDIT_VCPUS)
|
self.enable_apply(EDIT_VCPUS)
|
||||||
|
|
||||||
def config_cpu_copy_host(self, src_ignore):
|
def config_cpu_host_model_enable(self, src):
|
||||||
# Update UI with output copied from host
|
do_enable = src.get_active()
|
||||||
try:
|
self.widget("cpu-model").set_sensitive(not bool(do_enable))
|
||||||
CPU = virtinst.CPU(self.vm.conn.vmm)
|
self.widget("cpu-features").set_sensitive(not bool(do_enable))
|
||||||
CPU.copy_host_cpu()
|
self.enable_apply(EDIT_CPU)
|
||||||
|
|
||||||
self._refresh_cpu_config(CPU)
|
|
||||||
self._cpu_copy_host = True
|
|
||||||
except Exception, e:
|
|
||||||
self.err.show_err(_("Error copying host CPU: %s") % str(e))
|
|
||||||
return
|
|
||||||
|
|
||||||
def config_cpu_topology_enable(self, src):
|
def config_cpu_topology_enable(self, src):
|
||||||
do_enable = src.get_active()
|
do_enable = src.get_active()
|
||||||
@@ -2117,10 +2112,14 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
add_hotplug(self.config_vcpu_pin_cpuset, cpuset)
|
add_hotplug(self.config_vcpu_pin_cpuset, cpuset)
|
||||||
|
|
||||||
if self.editted(EDIT_CPU):
|
if self.editted(EDIT_CPU):
|
||||||
|
from_host = False
|
||||||
|
if self.widget("cpu-host-model-checkbutton").get_active():
|
||||||
|
from_host = True
|
||||||
|
|
||||||
model, vendor = self.get_config_cpu_model()
|
model, vendor = self.get_config_cpu_model()
|
||||||
features = self.get_config_cpu_features()
|
features = self.get_config_cpu_features()
|
||||||
add_define(self.vm.define_cpu,
|
add_define(self.vm.define_cpu,
|
||||||
model, vendor, self._cpu_copy_host, features)
|
model, vendor, from_host, features)
|
||||||
|
|
||||||
if self.editted(EDIT_TOPOLOGY):
|
if self.editted(EDIT_TOPOLOGY):
|
||||||
do_top = self.widget("cpu-topology-enable").get_active()
|
do_top = self.widget("cpu-topology-enable").get_active()
|
||||||
@@ -2135,8 +2134,6 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
add_define(self.vm.define_cpu_topology, sockets, cores, threads)
|
add_define(self.vm.define_cpu_topology, sockets, cores, threads)
|
||||||
|
|
||||||
ret = self._change_config_helper(df, da, hf, ha)
|
ret = self._change_config_helper(df, da, hf, ha)
|
||||||
if ret:
|
|
||||||
self._cpu_copy_host = False
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def config_vcpu_pin(self, src_ignore, path, new_text):
|
def config_vcpu_pin(self, src_ignore, path, new_text):
|
||||||
@@ -2816,6 +2813,8 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
def _refresh_cpu_config(self, cpu):
|
def _refresh_cpu_config(self, cpu):
|
||||||
feature_ui = self.widget("cpu-features")
|
feature_ui = self.widget("cpu-features")
|
||||||
model = cpu.model or ""
|
model = cpu.model or ""
|
||||||
|
mode = cpu.mode or ""
|
||||||
|
|
||||||
caps = self.vm.conn.get_capabilities()
|
caps = self.vm.conn.get_capabilities()
|
||||||
|
|
||||||
capscpu = None
|
capscpu = None
|
||||||
@@ -2835,6 +2834,11 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
cores = cpu.cores or 1
|
cores = cpu.cores or 1
|
||||||
threads = cpu.threads or 1
|
threads = cpu.threads or 1
|
||||||
|
|
||||||
|
host_model = self.widget("cpu-host-model-checkbutton")
|
||||||
|
active = host_model.get_active()
|
||||||
|
if (not mode and active) or (mode == "host-model" and not active):
|
||||||
|
host_model.set_active(not bool(active))
|
||||||
|
|
||||||
self.widget("cpu-topology-enable").set_active(show_top)
|
self.widget("cpu-topology-enable").set_active(show_top)
|
||||||
self.widget("cpu-model").get_child().set_text(model)
|
self.widget("cpu-model").get_child().set_text(model)
|
||||||
self.widget("cpu-sockets").set_value(sockets)
|
self.widget("cpu-sockets").set_value(sockets)
|
||||||
@@ -2856,7 +2860,6 @@ class vmmDetails(vmmGObjectUI):
|
|||||||
row[1] = get_feature_policy(row[0])
|
row[1] = get_feature_policy(row[0])
|
||||||
|
|
||||||
def refresh_config_cpu(self):
|
def refresh_config_cpu(self):
|
||||||
self._cpu_copy_host = False
|
|
||||||
cpu = self.vm.get_cpu_config()
|
cpu = self.vm.get_cpu_config()
|
||||||
|
|
||||||
self._refresh_cpu_count()
|
self._refresh_cpu_count()
|
||||||
|
|||||||
@@ -468,16 +468,19 @@ class vmmDomain(vmmLibvirtObject):
|
|||||||
def define_cpu(self, model, vendor, from_host, featurelist):
|
def define_cpu(self, model, vendor, from_host, featurelist):
|
||||||
def change(guest):
|
def change(guest):
|
||||||
if from_host:
|
if from_host:
|
||||||
guest.cpu.copy_host_cpu()
|
if virtinst.support.check_domain_support(self._backend,
|
||||||
elif guest.cpu.model != model:
|
virtinst.support.SUPPORT_DOMAIN_CPU_HOST_MODEL):
|
||||||
# Since we don't expose this in the UI, have host value trump
|
guest.cpu.clear_attrs()
|
||||||
# caps value
|
guest.cpu.mode = "host-model"
|
||||||
guest.cpu.vendor = vendor
|
else:
|
||||||
|
guest.cpu.copy_host_cpu()
|
||||||
|
return
|
||||||
|
|
||||||
guest.cpu.model = model or None
|
guest.cpu.model = model or None
|
||||||
|
guest.cpu.vendor = vendor or None
|
||||||
|
|
||||||
if guest.cpu.model is None:
|
if guest.cpu.model is None:
|
||||||
for f in guest.cpu.features:
|
guest.cpu.clear_attrs()
|
||||||
guest.cpu.remove_feature(f)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
origfeatures = guest.cpu.features
|
origfeatures = guest.cpu.features
|
||||||
|
|||||||
Reference in New Issue
Block a user