edecca
From cb462f891f39ff47179e6fe65437450f9d8c7824 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <cb462f891f39ff47179e6fe65437450f9d8c7824@dist-git>
edecca
From: Andrea Bolognani <abologna@redhat.com>
edecca
Date: Tue, 3 Jul 2018 15:25:16 +0200
edecca
Subject: [PATCH] conf: Parse and format the HTM pSeries feature
edecca
edecca
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
edecca
Reviewed-by: John Ferlan <jferlan@redhat.com>
edecca
edecca
(cherry picked from commit 9f3b9100f33036cb14296aa0a788788743b75a23)
edecca
https: //bugzilla.redhat.com/show_bug.cgi?id=1525599
edecca
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
edecca
Acked-by: David Gibson <dgibson@redhat.com>
edecca
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
edecca
---
edecca
 docs/formatdomain.html.in                     |  8 ++++++++
edecca
 docs/schemas/domaincommon.rng                 |  5 +++++
edecca
 src/conf/domain_conf.c                        | 19 +++++++++++++++++++
edecca
 src/conf/domain_conf.h                        |  1 +
edecca
 src/qemu/qemu_domain.c                        |  1 +
edecca
 tests/qemuxml2argvdata/pseries-features.xml   |  1 +
edecca
 tests/qemuxml2argvtest.c                      |  1 +
edecca
 tests/qemuxml2xmloutdata/pseries-features.xml |  1 +
edecca
 tests/qemuxml2xmltest.c                       |  1 +
edecca
 9 files changed, 38 insertions(+)
edecca
edecca
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
edecca
index 0d68596991..a3afe137bf 100644
edecca
--- a/docs/formatdomain.html.in
edecca
+++ b/docs/formatdomain.html.in
edecca
@@ -1929,6 +1929,7 @@
edecca
   <smm state='on'>
edecca
     <tseg unit='MiB'>48</tseg>
edecca
   </smm>
edecca
+  <htm state='on'/>
edecca
 </features>
edecca
 ...
edecca
 
edecca
@@ -2162,6 +2163,13 @@
edecca
       
Enable QEMU vmcoreinfo device to let the guest kernel save debug
edecca
           details. Since 4.4.0 (QEMU only)
edecca
       
edecca
+      
htm
edecca
+      
Configure HTM (Hardware Transational Memory) availability for
edecca
+          pSeries guests. Possible values for the state attribute
edecca
+          are on and off. If the attribute is not
edecca
+          defined, the hypervisor default will be used.
edecca
+          Since 4.6.0 (QEMU/KVM only)
edecca
+      
edecca
     
edecca
 
edecca
     

Time keeping

edecca
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
edecca
index f46145cf9b..bd687ce9d3 100644
edecca
--- a/docs/schemas/domaincommon.rng
edecca
+++ b/docs/schemas/domaincommon.rng
edecca
@@ -4907,6 +4907,11 @@
edecca
           <optional>
edecca
             <ref name="vmcoreinfo"/>
edecca
           </optional>
edecca
+          <optional>
edecca
+            <element name="htm">
edecca
+              <ref name="featurestate"/>
edecca
+            </element>
edecca
+          </optional>
edecca
         </interleave>
edecca
       </element>
edecca
     </optional>
edecca
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
edecca
index b8b53450fa..f4e59f6c91 100644
edecca
--- a/src/conf/domain_conf.c
edecca
+++ b/src/conf/domain_conf.c
edecca
@@ -152,6 +152,7 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST,
edecca
               "ioapic",
edecca
               "hpt",
edecca
               "vmcoreinfo",
edecca
+              "htm",
edecca
 );
edecca
 
edecca
 VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST,
edecca
@@ -19827,6 +19828,22 @@ virDomainDefParseXML(xmlDocPtr xml,
edecca
             }
edecca
             break;
edecca
 
edecca
+        case VIR_DOMAIN_FEATURE_HTM:
edecca
+            if (!(tmp = virXMLPropString(nodes[i], "state"))) {
edecca
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
edecca
+                               _("missing state attribute '%s' of feature '%s'"),
edecca
+                               tmp, virDomainFeatureTypeToString(val));
edecca
+                goto error;
edecca
+            }
edecca
+            if ((def->features[val] = virTristateSwitchTypeFromString(tmp)) < 0) {
edecca
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
edecca
+                               _("unknown state attribute '%s' of feature '%s'"),
edecca
+                               tmp, virDomainFeatureTypeToString(val));
edecca
+                goto error;
edecca
+            }
edecca
+            VIR_FREE(tmp);
edecca
+            break;
edecca
+
edecca
         /* coverity[dead_error_begin] */
edecca
         case VIR_DOMAIN_FEATURE_LAST:
edecca
             break;
edecca
@@ -21961,6 +21978,7 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src,
edecca
         case VIR_DOMAIN_FEATURE_VMPORT:
edecca
         case VIR_DOMAIN_FEATURE_SMM:
edecca
         case VIR_DOMAIN_FEATURE_VMCOREINFO:
edecca
+        case VIR_DOMAIN_FEATURE_HTM:
edecca
             if (src->features[i] != dst->features[i]) {
edecca
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
edecca
                                _("State of feature '%s' differs: "
edecca
@@ -27626,6 +27644,7 @@ virDomainDefFormatInternal(virDomainDefPtr def,
edecca
             case VIR_DOMAIN_FEATURE_PMU:
edecca
             case VIR_DOMAIN_FEATURE_PVSPINLOCK:
edecca
             case VIR_DOMAIN_FEATURE_VMPORT:
edecca
+            case VIR_DOMAIN_FEATURE_HTM:
edecca
                 switch ((virTristateSwitch) def->features[i]) {
edecca
                 case VIR_TRISTATE_SWITCH_LAST:
edecca
                 case VIR_TRISTATE_SWITCH_ABSENT:
edecca
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
edecca
index 71437dc485..41d27482fb 100644
edecca
--- a/src/conf/domain_conf.h
edecca
+++ b/src/conf/domain_conf.h
edecca
@@ -1771,6 +1771,7 @@ typedef enum {
edecca
     VIR_DOMAIN_FEATURE_IOAPIC,
edecca
     VIR_DOMAIN_FEATURE_HPT,
edecca
     VIR_DOMAIN_FEATURE_VMCOREINFO,
edecca
+    VIR_DOMAIN_FEATURE_HTM,
edecca
 
edecca
     VIR_DOMAIN_FEATURE_LAST
edecca
 } virDomainFeature;
edecca
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
edecca
index 4c2a162b85..0eacad1e44 100644
edecca
--- a/src/qemu/qemu_domain.c
edecca
+++ b/src/qemu/qemu_domain.c
edecca
@@ -3865,6 +3865,7 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
edecca
         case VIR_DOMAIN_FEATURE_PMU:
edecca
         case VIR_DOMAIN_FEATURE_VMPORT:
edecca
         case VIR_DOMAIN_FEATURE_VMCOREINFO:
edecca
+        case VIR_DOMAIN_FEATURE_HTM:
edecca
         case VIR_DOMAIN_FEATURE_LAST:
edecca
             break;
edecca
         }
edecca
diff --git a/tests/qemuxml2argvdata/pseries-features.xml b/tests/qemuxml2argvdata/pseries-features.xml
edecca
index 30cee5b81c..5c842fe87b 100644
edecca
--- a/tests/qemuxml2argvdata/pseries-features.xml
edecca
+++ b/tests/qemuxml2argvdata/pseries-features.xml
edecca
@@ -10,6 +10,7 @@
edecca
     <hpt resizing='required'>
edecca
       <maxpagesize unit='GiB'>1</maxpagesize>
edecca
     </hpt>
edecca
+    <htm state='on'/>
edecca
   </features>
edecca
   <devices>
edecca
     <emulator>/usr/bin/qemu-system-ppc64</emulator>
edecca
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
edecca
index c279ac4975..d6911f9344 100644
edecca
--- a/tests/qemuxml2argvtest.c
edecca
+++ b/tests/qemuxml2argvtest.c
edecca
@@ -1850,6 +1850,7 @@ mymain(void)
edecca
     DO_TEST("pseries-features",
edecca
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
edecca
             QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
edecca
+            QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
edecca
             QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
edecca
     DO_TEST_FAILURE("pseries-features",
edecca
                     QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE);
edecca
diff --git a/tests/qemuxml2xmloutdata/pseries-features.xml b/tests/qemuxml2xmloutdata/pseries-features.xml
edecca
index f36705f011..55a44c75a0 100644
edecca
--- a/tests/qemuxml2xmloutdata/pseries-features.xml
edecca
+++ b/tests/qemuxml2xmloutdata/pseries-features.xml
edecca
@@ -12,6 +12,7 @@
edecca
     <hpt resizing='required'>
edecca
       <maxpagesize unit='KiB'>1048576</maxpagesize>
edecca
     </hpt>
edecca
+    <htm state='on'/>
edecca
   </features>
edecca
   <clock offset='utc'/>
edecca
   <on_poweroff>destroy</on_poweroff>
edecca
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
edecca
index eac6d5b073..bbb995656e 100644
edecca
--- a/tests/qemuxml2xmltest.c
edecca
+++ b/tests/qemuxml2xmltest.c
edecca
@@ -620,6 +620,7 @@ mymain(void)
edecca
     DO_TEST("pseries-features",
edecca
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
edecca
             QEMU_CAPS_MACHINE_PSERIES_CAP_HPT_MAX_PAGE_SIZE,
edecca
+            QEMU_CAPS_MACHINE_PSERIES_CAP_HTM,
edecca
             QEMU_CAPS_MACHINE_PSERIES_RESIZE_HPT);
edecca
 
edecca
     DO_TEST("pseries-serial-native",
edecca
-- 
edecca
2.18.0
edecca