diff --git a/ui/vmm-details.ui b/ui/vmm-details.ui index 631d58fe2..99789c211 100644 --- a/ui/vmm-details.ui +++ b/ui/vmm-details.ui @@ -2314,14 +2314,116 @@ I/O: False 6 - - Use host CPU model - False + True - True - False - True - + False + 2 + 2 + 12 + 3 + + + True + False + 0 + Model: + + + GTK_FILL + GTK_FILL + + + + + True + False + + + True + False + + + True + False + True + + + + True + + + + + + + False + False + 1 + + + + + 1 + 2 + GTK_FILL + + + + + True + False + + + + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + False + + + Copy host CPU configuration + True + True + True + + + + False + True + 0 + + + + + True + False + + + + + + True + True + 1 + + + + + 1 + 2 + 1 + 2 + GTK_FILL + + False @@ -2329,53 +2431,6 @@ I/O: 0 - - - True - False - - - True - False - Model: - - - False - False - 0 - - - - - True - False - - - True - False - True - - - - True - - - - - - - False - False - 1 - - - - - False - True - 1 - - True @@ -2423,7 +2478,7 @@ I/O: - False + True True 1 @@ -2444,7 +2499,7 @@ I/O: False True - 2 + 1 diff --git a/virtManager/details.py b/virtManager/details.py index a2b2ca1dd..ec2331528 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -366,6 +366,7 @@ class vmmDetails(vmmGObjectUI): self.ignorePause = False self.ignoreDetails = False + self._cpu_copy_host = False self.console = vmmConsolePages(self.vm, self.builder, self.topwin) @@ -436,7 +437,7 @@ class vmmDetails(vmmGObjectUI): "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_threads_changed": lambda *x: self.enable_apply(x, EDIT_TOPOLOGY), - "on_cpu_host_model_enable_toggled": self.config_cpu_host_model_enable, + "on_cpu_copy_host_clicked": self.config_cpu_copy_host, "on_cpu_topology_enable_toggled": self.config_cpu_topology_enable, "on_config_memory_changed": self.config_memory_changed, @@ -923,8 +924,6 @@ class vmmDetails(vmmGObjectUI): feat_model.append([name, "default"]) # 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") model = Gtk.ListStore(str, object) @@ -1819,11 +1818,17 @@ class vmmDetails(vmmGObjectUI): def config_maxvcpus_changed(self, ignore): self.enable_apply(EDIT_VCPUS) - def config_cpu_host_model_enable(self, src): - do_enable = src.get_active() - self.widget("cpu-model").set_sensitive(not bool(do_enable)) - self.widget("cpu-features").set_sensitive(not bool(do_enable)) - self.enable_apply(EDIT_CPU) + def config_cpu_copy_host(self, src_ignore): + # Update UI with output copied from host + try: + CPU = virtinst.CPU(self.vm.conn.vmm) + CPU.copy_host_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): do_enable = src.get_active() @@ -2118,14 +2123,10 @@ class vmmDetails(vmmGObjectUI): add_hotplug(self.config_vcpu_pin_cpuset, cpuset) 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() features = self.get_config_cpu_features() add_define(self.vm.define_cpu, - model, vendor, from_host, features) + model, vendor, self._cpu_copy_host, features) if self.editted(EDIT_TOPOLOGY): do_top = self.widget("cpu-topology-enable").get_active() @@ -2140,6 +2141,8 @@ class vmmDetails(vmmGObjectUI): add_define(self.vm.define_cpu_topology, sockets, cores, threads) ret = self._change_config_helper(df, da, hf, ha) + if ret: + self._cpu_copy_host = False return ret def config_vcpu_pin(self, src_ignore, path, new_text): @@ -2819,8 +2822,6 @@ class vmmDetails(vmmGObjectUI): def _refresh_cpu_config(self, cpu): feature_ui = self.widget("cpu-features") model = cpu.model or "" - mode = cpu.mode or "" - caps = self.vm.conn.get_capabilities() capscpu = None @@ -2840,11 +2841,6 @@ class vmmDetails(vmmGObjectUI): cores = cpu.cores 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-model").get_child().set_text(model) self.widget("cpu-sockets").set_value(sockets) @@ -2866,6 +2862,7 @@ class vmmDetails(vmmGObjectUI): row[1] = get_feature_policy(row[0]) def refresh_config_cpu(self): + self._cpu_copy_host = False cpu = self.vm.get_cpu_config() self._refresh_cpu_count() diff --git a/virtManager/domain.py b/virtManager/domain.py index 823e17bac..f958c4b97 100644 --- a/virtManager/domain.py +++ b/virtManager/domain.py @@ -468,19 +468,16 @@ class vmmDomain(vmmLibvirtObject): def define_cpu(self, model, vendor, from_host, featurelist): def change(guest): if from_host: - if virtinst.support.check_domain_support(self._backend, - virtinst.support.SUPPORT_DOMAIN_CPU_HOST_MODEL): - guest.cpu.clear_attrs() - guest.cpu.mode = "host-model" - else: - guest.cpu.copy_host_cpu() - return + guest.cpu.copy_host_cpu() + elif guest.cpu.model != model: + # Since we don't expose this in the UI, have host value trump + # caps value + guest.cpu.vendor = vendor guest.cpu.model = model or None - guest.cpu.vendor = vendor or None - if guest.cpu.model is None: - guest.cpu.clear_attrs() + for f in guest.cpu.features: + guest.cpu.remove_feature(f) return origfeatures = guest.cpu.features