[virt-tools-list] [virt-manager PATCH 1/3] virt-install: add support for SMM feature

Pavel Hrdina phrdina at redhat.com
Wed May 31 15:36:03 UTC 2017


Signed-off-by: Pavel Hrdina <phrdina at 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 7bc528ed..fa88fbda 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 e329e670..04438ea3 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 0e490446..4b0eec7c 100755
--- a/virt-install
+++ b/virt-install
@@ -634,6 +634,16 @@ def build_guest_instance(conn, options):
             logging.warning("Couldn't configure UEFI: %s", e)
             logging.warning("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 52f91063..57e6404d 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -1680,6 +1680,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)
@@ -1704,6 +1710,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 270f63a5..e4f3165b 100644
--- a/virtinst/domainfeatures.py
+++ b/virtinst/domainfeatures.py
@@ -54,3 +54,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 1899125f..9d81a03f 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




More information about the virt-tools-list mailing list