From d6cebdddb4aea48498a328bb6e35a3ed1eb40b19 Mon Sep 17 00:00:00 2001
From: Pavel Hrdina <phrdina@redhat.com>
Date: Thu, 26 Jan 2017 15:08:36 +0100
Subject: virt-install: add support for SMM feature
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit f38c56c971d8b04bdee41ecba96f3f6d921a4aa7)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1387479
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
man/virt-install.pod | 6 +++++
.../compare/virt-install-features-smm.xml | 29 ++++++++++++++++++++++
tests/clitest.py | 9 +++++++
virt-install | 10 ++++++++
virtinst/cli.py | 8 ++++++
virtinst/domainfeatures.py | 2 ++
virtinst/support.py | 1 +
7 files changed, 65 insertions(+)
create mode 100644 tests/cli-test-xml/compare/virt-install-features-smm.xml
diff --git a/man/virt-install.pod b/man/virt-install.pod
index 3ae133ec..7ed69031 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -280,6 +280,12 @@ Notify the guest that the host supports paravirtual spinlocks for example by exp
This is relevant only for ARM architectures. Possible values are "host" or
version number.
+=item B<--features smm=on>
+
+This enables System Management Mode of hypervisor. Some UEFI firmwares may
+require this feature to be present. (QEMU supports SMM only with q35 machine
+type.)
+
=back
Use --features=? to see a list of all available sub options. Complete details at L<http://libvirt.org/formatdomain.html#elementsFeatures>
diff --git a/tests/cli-test-xml/compare/virt-install-features-smm.xml b/tests/cli-test-xml/compare/virt-install-features-smm.xml
new file mode 100644
index 00000000..2f78ad88
--- /dev/null
+++ b/tests/cli-test-xml/compare/virt-install-features-smm.xml
@@ -0,0 +1,29 @@
+<domain type="test">
+ <name>foobar</name>
+ <uuid>00000000-1111-2222-3333-444444444444</uuid>
+ <memory>65536</memory>
+ <currentMemory>65536</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch="i686" machine="q35">hvm</type>
+ <boot dev="hd"/>
+ </os>
+ <features>
+ <pae/>
+ <smm state="on"/>
+ </features>
+ <clock offset="utc"/>
+ <pm>
+ <suspend-to-mem enabled="no"/>
+ <suspend-to-disk enabled="no"/>
+ </pm>
+ <devices>
+ <emulator>/usr/bin/test-hv</emulator>
+ <controller type="usb" index="0" model="none"/>
+ <interface type="user">
+ <mac address="00:11:22:33:44:55"/>
+ </interface>
+ <input type="mouse" bus="ps2"/>
+ <console type="pty"/>
+ </devices>
+</domain>
diff --git a/tests/clitest.py b/tests/clitest.py
index 5bfa2799..e5fcc6d8 100644
--- a/tests/clitest.py
+++ b/tests/clitest.py
@@ -552,6 +552,15 @@ c.add_compare(""" \
""", "spice-gl", compare_check=support.SUPPORT_CONN_VMPORT)
+############################
+# Features install options #
+############################
+
+c = vinst.add_category("features", "--nographics --noautoconsole --import --disk none --controller usb,model=none")
+c.add_compare("--features smm=on", "features-smm")
+c.add_invalid("--features smm=on --machine pc")
+
+
######################################
# Memory hot(un)plug install options #
######################################
diff --git a/virt-install b/virt-install
index f1da1000..c5ad38b9 100755
--- a/virt-install
+++ b/virt-install
@@ -633,6 +633,16 @@ def build_guest_instance(conn, options):
logging.warn("Couldn't configure UEFI: %s", e)
logging.warn("Your aarch64 VM may not boot successfully.")
+ # Check usability of SMM feature
+ if guest.features.smm:
+ if not guest.os.is_x86():
+ fail(_("SMM feature is valid only for x86 architecture."))
+
+ if guest.os.machine is None:
+ guest.os.machine = "q35"
+ elif not guest.os.is_q35():
+ fail(_("SMM feature is valid only for q35 machine type"))
+
# Various little validations about option collisions. Need to do
# this after setting guest.installer at least
check_option_collisions(options, guest)
diff --git a/virtinst/cli.py b/virtinst/cli.py
index 2fadcf17..1abf5fc1 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1678,6 +1678,12 @@ class ParserFeatures(VirtCLIParser):
cli_arg_name = "features"
objclass = DomainFeatures
+ def set_smm_cb(self, inst, val, virtarg):
+ if not inst.conn.check_support(inst.conn.SUPPORT_DOMAIN_FEATURE_SMM):
+ raise RuntimeError("smm is not supported by libvirt")
+ inst.smm = val
+ return val
+
_register_virt_parser(ParserFeatures)
ParserFeatures.add_arg("acpi", "acpi", is_onoff=True)
ParserFeatures.add_arg("apic", "apic", is_onoff=True)
@@ -1700,6 +1706,8 @@ ParserFeatures.add_arg("pvspinlock", "pvspinlock", is_onoff=True)
ParserFeatures.add_arg("gic_version", "gic_version")
+ParserFeatures.add_arg("smm", "smm", is_onoff=True, cb=ParserFeatures.set_smm_cb)
+
###################
# --clock parsing #
diff --git a/virtinst/domainfeatures.py b/virtinst/domainfeatures.py
index 81135680..84711a78 100644
--- a/virtinst/domainfeatures.py
+++ b/virtinst/domainfeatures.py
@@ -52,3 +52,5 @@ class DomainFeatures(XMLBuilder):
default_name="default", default_cb=lambda s: False)
kvm_hidden = XMLProperty("./kvm/hidden/@state", is_onoff=True)
pvspinlock = XMLProperty("./pvspinlock/@state", is_onoff=True)
+
+ smm = XMLProperty("./smm/@state", is_onoff=True)
diff --git a/virtinst/support.py b/virtinst/support.py
index 880e4b7b..e71b4403 100644
--- a/virtinst/support.py
+++ b/virtinst/support.py
@@ -361,6 +361,7 @@ SUPPORT_DOMAIN_MEMORY_STATS = _make(
SUPPORT_DOMAIN_STATE = _make(function="virDomain.state", run_args=())
SUPPORT_DOMAIN_OPEN_GRAPHICS = _make(function="virDomain.openGraphicsFD",
version="1.2.8", hv_version={"qemu": 0})
+SUPPORT_DOMAIN_FEATURE_SMM = _make(version="2.1.0")
###############
--
2.13.0