|
|
e4cbec |
From 1b24900787b6b6cb52dae323ed0c6cff7492f66a Mon Sep 17 00:00:00 2001
|
|
|
e4cbec |
Message-Id: <1b24900787b6b6cb52dae323ed0c6cff7492f66a@dist-git>
|
|
|
e4cbec |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
e4cbec |
Date: Thu, 4 Oct 2018 14:19:32 -0400
|
|
|
e4cbec |
Subject: [PATCH] virt-manager: Wire up support for default mode=host-model
|
|
|
e4cbec |
|
|
|
e4cbec |
From: Cole Robinson <crobinso@redhat.com>
|
|
|
e4cbec |
|
|
|
e4cbec |
Simplify things a long the way
|
|
|
e4cbec |
|
|
|
e4cbec |
(cherry picked from commit 9edca3486abd76e9a7c2c2fe3ad12ae32fc65733)
|
|
|
e4cbec |
|
|
|
e4cbec |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1525337
|
|
|
e4cbec |
|
|
|
e4cbec |
Conflicts:
|
|
|
e4cbec |
- CPU class is renamed to DomainCpu in upstream
|
|
|
e4cbec |
|
|
|
e4cbec |
Reviewed-by: Cole Robinson <crobinso@redhat.com>
|
|
|
e4cbec |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
e4cbec |
---
|
|
|
e4cbec |
virtManager/config.py | 20 +++-----------------
|
|
|
e4cbec |
virtManager/create.py | 3 +--
|
|
|
e4cbec |
virtManager/details.py | 8 ++++----
|
|
|
e4cbec |
virtManager/domain.py | 2 +-
|
|
|
e4cbec |
virtManager/preferences.py | 16 ++++++++++------
|
|
|
e4cbec |
virtinst/cli.py | 2 +-
|
|
|
e4cbec |
virtinst/cpu.py | 19 ++++++++++---------
|
|
|
e4cbec |
7 files changed, 30 insertions(+), 40 deletions(-)
|
|
|
e4cbec |
|
|
|
e4cbec |
diff --git a/virtManager/config.py b/virtManager/config.py
|
|
|
e4cbec |
index 4d47b477..a3daf341 100644
|
|
|
e4cbec |
--- a/virtManager/config.py
|
|
|
e4cbec |
+++ b/virtManager/config.py
|
|
|
e4cbec |
@@ -198,7 +198,6 @@ class vmmConfig(object):
|
|
|
e4cbec |
self.hv_packages = ["qemu-kvm"]
|
|
|
e4cbec |
|
|
|
e4cbec |
self.default_storage_format_from_config = "qcow2"
|
|
|
e4cbec |
- self.cpu_default_from_config = CPU.SPECIAL_MODE_HOST_MODEL_ONLY
|
|
|
e4cbec |
self.default_console_resizeguest = 0
|
|
|
e4cbec |
self.default_add_spice_usbredir = "yes"
|
|
|
e4cbec |
|
|
|
e4cbec |
@@ -531,24 +530,11 @@ class vmmConfig(object):
|
|
|
e4cbec |
def set_storage_format(self, typ):
|
|
|
e4cbec |
self.conf.set("/new-vm/storage-format", typ.lower())
|
|
|
e4cbec |
|
|
|
e4cbec |
- def get_default_cpu_setting(self, raw=False, for_cpu=False):
|
|
|
e4cbec |
+ def get_default_cpu_setting(self):
|
|
|
e4cbec |
ret = self.conf.get("/new-vm/cpu-default")
|
|
|
e4cbec |
- whitelist = [CPU.SPECIAL_MODE_HOST_MODEL_ONLY,
|
|
|
e4cbec |
- CPU.SPECIAL_MODE_HOST_MODEL,
|
|
|
e4cbec |
- CPU.SPECIAL_MODE_HV_DEFAULT]
|
|
|
e4cbec |
-
|
|
|
e4cbec |
- if ret not in whitelist:
|
|
|
e4cbec |
- ret = "default"
|
|
|
e4cbec |
- if ret == "default" and not raw:
|
|
|
e4cbec |
- ret = self.cpu_default_from_config
|
|
|
e4cbec |
- if ret not in whitelist:
|
|
|
e4cbec |
- ret = whitelist[0]
|
|
|
e4cbec |
-
|
|
|
e4cbec |
- if for_cpu and ret == CPU.SPECIAL_MODE_HOST_MODEL:
|
|
|
e4cbec |
- # host-model has known issues, so use our 'copy cpu'
|
|
|
e4cbec |
- # behavior until host-model does what we need
|
|
|
e4cbec |
- ret = CPU.SPECIAL_MODE_HOST_COPY
|
|
|
e4cbec |
|
|
|
e4cbec |
+ if ret not in CPU.SPECIAL_MODES:
|
|
|
e4cbec |
+ ret = CPU.SPECIAL_MODE_APP_DEFAULT
|
|
|
e4cbec |
return ret
|
|
|
e4cbec |
def set_default_cpu_setting(self, val):
|
|
|
e4cbec |
self.conf.set("/new-vm/cpu-default", val.lower())
|
|
|
e4cbec |
diff --git a/virtManager/create.py b/virtManager/create.py
|
|
|
e4cbec |
index d5d1d5a0..3e1fc624 100644
|
|
|
e4cbec |
--- a/virtManager/create.py
|
|
|
e4cbec |
+++ b/virtManager/create.py
|
|
|
e4cbec |
@@ -1880,8 +1880,7 @@ class vmmCreate(vmmGObjectUI):
|
|
|
e4cbec |
guest.skip_default_sound = not self.config.get_new_vm_sound()
|
|
|
e4cbec |
guest.skip_default_usbredir = (
|
|
|
e4cbec |
self.config.get_add_spice_usbredir() == "no")
|
|
|
e4cbec |
- guest.x86_cpu_default = self.config.get_default_cpu_setting(
|
|
|
e4cbec |
- for_cpu=True)
|
|
|
e4cbec |
+ guest.x86_cpu_default = self.config.get_default_cpu_setting()
|
|
|
e4cbec |
|
|
|
e4cbec |
guest.add_default_devices()
|
|
|
e4cbec |
except Exception as e:
|
|
|
e4cbec |
diff --git a/virtManager/details.py b/virtManager/details.py
|
|
|
e4cbec |
index ebe010b5..be0f25c9 100644
|
|
|
e4cbec |
--- a/virtManager/details.py
|
|
|
e4cbec |
+++ b/virtManager/details.py
|
|
|
e4cbec |
@@ -972,7 +972,8 @@ class vmmDetails(vmmGObjectUI):
|
|
|
e4cbec |
cpu_model.set_entry_text_column(0)
|
|
|
e4cbec |
cpu_model.set_row_separator_func(sep_func, None)
|
|
|
e4cbec |
model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
|
|
|
e4cbec |
- model.append([_("Application Default"), "1", "appdefault", False])
|
|
|
e4cbec |
+ model.append([_("Application Default"), "1",
|
|
|
e4cbec |
+ virtinst.CPU.SPECIAL_MODE_APP_DEFAULT, False])
|
|
|
e4cbec |
model.append([_("Hypervisor Default"), "2",
|
|
|
e4cbec |
virtinst.CPU.SPECIAL_MODE_HV_DEFAULT, False])
|
|
|
e4cbec |
model.append([_("Clear CPU configuration"), "3",
|
|
|
e4cbec |
@@ -1572,12 +1573,11 @@ class vmmDetails(vmmGObjectUI):
|
|
|
e4cbec |
if text == row[0]:
|
|
|
e4cbec |
key = row[2]
|
|
|
e4cbec |
break
|
|
|
e4cbec |
-
|
|
|
e4cbec |
if not key:
|
|
|
e4cbec |
return text
|
|
|
e4cbec |
|
|
|
e4cbec |
- if key == "appdefault":
|
|
|
e4cbec |
- return self.config.get_default_cpu_setting(for_cpu=True)
|
|
|
e4cbec |
+ if key == virtinst.CPU.SPECIAL_MODE_APP_DEFAULT:
|
|
|
e4cbec |
+ return self.config.get_default_cpu_setting()
|
|
|
e4cbec |
return key
|
|
|
e4cbec |
|
|
|
e4cbec |
def inspection_refresh(self, src_ignore):
|
|
|
e4cbec |
diff --git a/virtManager/domain.py b/virtManager/domain.py
|
|
|
e4cbec |
index ed94cf16..50ccbdb1 100644
|
|
|
e4cbec |
--- a/virtManager/domain.py
|
|
|
e4cbec |
+++ b/virtManager/domain.py
|
|
|
e4cbec |
@@ -663,7 +663,7 @@ class vmmDomain(vmmLibvirtObject):
|
|
|
e4cbec |
|
|
|
e4cbec |
if model != _SENTINEL:
|
|
|
e4cbec |
if model in guest.cpu.SPECIAL_MODES:
|
|
|
e4cbec |
- guest.cpu.set_special_mode(model)
|
|
|
e4cbec |
+ guest.cpu.set_special_mode(guest, model)
|
|
|
e4cbec |
else:
|
|
|
e4cbec |
guest.cpu.model = model
|
|
|
e4cbec |
self._redefine_xmlobj(guest)
|
|
|
e4cbec |
diff --git a/virtManager/preferences.py b/virtManager/preferences.py
|
|
|
e4cbec |
index bf67590f..5739af29 100644
|
|
|
e4cbec |
--- a/virtManager/preferences.py
|
|
|
e4cbec |
+++ b/virtManager/preferences.py
|
|
|
e4cbec |
@@ -23,6 +23,8 @@ import logging
|
|
|
e4cbec |
from gi.repository import Gtk
|
|
|
e4cbec |
from gi.repository import Gdk
|
|
|
e4cbec |
|
|
|
e4cbec |
+from virtinst import CPU
|
|
|
e4cbec |
+
|
|
|
e4cbec |
from . import uiutil
|
|
|
e4cbec |
from .baseclass import vmmGObjectUI
|
|
|
e4cbec |
|
|
|
e4cbec |
@@ -160,11 +162,13 @@ class vmmPreferences(vmmGObjectUI):
|
|
|
e4cbec |
combo = self.widget("prefs-cpu-default")
|
|
|
e4cbec |
# [gsettings value, string]
|
|
|
e4cbec |
model = Gtk.ListStore(str, str)
|
|
|
e4cbec |
- for row in [["default", _("System default (%s)") %
|
|
|
e4cbec |
- self.config.cpu_default_from_config],
|
|
|
e4cbec |
- ["hv-default", _("Hypervisor default")],
|
|
|
e4cbec |
- ["host-model-only", _("Nearest host CPU model")],
|
|
|
e4cbec |
- ["host-model", _("Copy host CPU definition")]]:
|
|
|
e4cbec |
+ for row in [
|
|
|
e4cbec |
+ [CPU.SPECIAL_MODE_APP_DEFAULT, _("Application default")],
|
|
|
e4cbec |
+ [CPU.SPECIAL_MODE_HV_DEFAULT, _("Hypervisor default")],
|
|
|
e4cbec |
+ [CPU.SPECIAL_MODE_HOST_MODEL_ONLY,
|
|
|
e4cbec |
+ _("Nearest host CPU model")],
|
|
|
e4cbec |
+ [CPU.SPECIAL_MODE_HOST_MODEL,
|
|
|
e4cbec |
+ _("Copy host CPU definition")]]:
|
|
|
e4cbec |
model.append(row)
|
|
|
e4cbec |
combo.set_model(model)
|
|
|
e4cbec |
uiutil.init_combo_text_column(combo, 1)
|
|
|
e4cbec |
@@ -211,7 +215,7 @@ class vmmPreferences(vmmGObjectUI):
|
|
|
e4cbec |
uiutil.set_list_selection(combo, val)
|
|
|
e4cbec |
def refresh_cpu_default(self):
|
|
|
e4cbec |
combo = self.widget("prefs-cpu-default")
|
|
|
e4cbec |
- val = self.config.get_default_cpu_setting(raw=True)
|
|
|
e4cbec |
+ val = self.config.get_default_cpu_setting()
|
|
|
e4cbec |
uiutil.set_list_selection(combo, val)
|
|
|
e4cbec |
|
|
|
e4cbec |
def refresh_cpu_poll(self):
|
|
|
e4cbec |
diff --git a/virtinst/cli.py b/virtinst/cli.py
|
|
|
e4cbec |
index 3d3ac0ac..7e8ab536 100644
|
|
|
e4cbec |
--- a/virtinst/cli.py
|
|
|
e4cbec |
+++ b/virtinst/cli.py
|
|
|
e4cbec |
@@ -1484,7 +1484,7 @@ class ParserCPU(VirtCLIParser):
|
|
|
e4cbec |
val = inst.SPECIAL_MODE_CLEAR
|
|
|
e4cbec |
|
|
|
e4cbec |
if val in inst.SPECIAL_MODES:
|
|
|
e4cbec |
- inst.set_special_mode(val)
|
|
|
e4cbec |
+ inst.set_special_mode(self.guest, val)
|
|
|
e4cbec |
else:
|
|
|
e4cbec |
inst.model = val
|
|
|
e4cbec |
|
|
|
e4cbec |
diff --git a/virtinst/cpu.py b/virtinst/cpu.py
|
|
|
e4cbec |
index 2de08145..356df206 100644
|
|
|
e4cbec |
--- a/virtinst/cpu.py
|
|
|
e4cbec |
+++ b/virtinst/cpu.py
|
|
|
e4cbec |
@@ -100,7 +100,15 @@ class CPU(XMLBuilder):
|
|
|
e4cbec |
SPECIAL_MODE_HOST_COPY, SPECIAL_MODE_HOST_MODEL,
|
|
|
e4cbec |
SPECIAL_MODE_HOST_PASSTHROUGH, SPECIAL_MODE_CLEAR,
|
|
|
e4cbec |
SPECIAL_MODE_APP_DEFAULT]
|
|
|
e4cbec |
- def set_special_mode(self, val):
|
|
|
e4cbec |
+ def set_special_mode(self, guest, val):
|
|
|
e4cbec |
+ if val == self.SPECIAL_MODE_APP_DEFAULT:
|
|
|
e4cbec |
+ # If libvirt is new enough to support reliable mode=host-model
|
|
|
e4cbec |
+ # then use it, otherwise use previous default HOST_MODEL_ONLY
|
|
|
e4cbec |
+ domcaps = guest.lookup_domcaps()
|
|
|
e4cbec |
+ val = self.SPECIAL_MODE_HOST_MODEL_ONLY
|
|
|
e4cbec |
+ if domcaps.supports_safe_host_model():
|
|
|
e4cbec |
+ val = self.SPECIAL_MODE_HOST_MODEL
|
|
|
e4cbec |
+
|
|
|
e4cbec |
if (val == self.SPECIAL_MODE_HOST_MODEL or
|
|
|
e4cbec |
val == self.SPECIAL_MODE_HOST_PASSTHROUGH):
|
|
|
e4cbec |
self.model = None
|
|
|
e4cbec |
@@ -264,15 +272,8 @@ class CPU(XMLBuilder):
|
|
|
e4cbec |
return
|
|
|
e4cbec |
|
|
|
e4cbec |
mode = guest.x86_cpu_default
|
|
|
e4cbec |
- if mode == self.SPECIAL_MODE_APP_DEFAULT:
|
|
|
e4cbec |
- # If libvirt is new enough to support reliable mode=host-model
|
|
|
e4cbec |
- # then use it, otherwise use previous default HOST_MODEL_ONLY
|
|
|
e4cbec |
- domcaps = guest.lookup_domcaps()
|
|
|
e4cbec |
- mode = self.SPECIAL_MODE_HOST_MODEL_ONLY
|
|
|
e4cbec |
- if domcaps.supports_safe_host_model():
|
|
|
e4cbec |
- mode = self.SPECIAL_MODE_HOST_MODEL
|
|
|
e4cbec |
|
|
|
e4cbec |
- self.set_special_mode(mode)
|
|
|
e4cbec |
+ self.set_special_mode(guest, mode)
|
|
|
e4cbec |
if mode == self.SPECIAL_MODE_HOST_MODEL_ONLY:
|
|
|
e4cbec |
self._validate_default_host_model_only(guest)
|
|
|
e4cbec |
|
|
|
e4cbec |
--
|
|
|
e4cbec |
2.20.1
|
|
|
e4cbec |
|