99cbc7
From 1802d115cf79cf7d122d0864ec4add10eafc294d Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <1802d115cf79cf7d122d0864ec4add10eafc294d@dist-git>
99cbc7
From: Andrea Bolognani <abologna@redhat.com>
99cbc7
Date: Tue, 3 Jul 2018 15:25:17 +0200
99cbc7
Subject: [PATCH] qemu: Format the HTM pSeries feature
99cbc7
99cbc7
This makes the feature fully operational.
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1525599
99cbc7
99cbc7
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
99cbc7
Reviewed-by: John Ferlan <jferlan@redhat.com>
99cbc7
99cbc7
(cherry picked from commit d4c11171076edfb2e603804e79edf7ccc3cce5dc)
99cbc7
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
99cbc7
Acked-by: David Gibson <dgibson@redhat.com>
99cbc7
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
---
99cbc7
 src/qemu/qemu_command.c                      | 20 ++++++++++++++++++++
99cbc7
 src/qemu/qemu_domain.c                       | 14 +++++++++++++-
99cbc7
 tests/qemuxml2argvdata/pseries-features.args |  2 +-
99cbc7
 3 files changed, 34 insertions(+), 2 deletions(-)
99cbc7
99cbc7
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
99cbc7
index c1eefca639..4120e4f983 100644
99cbc7
--- a/src/qemu/qemu_command.c
99cbc7
+++ b/src/qemu/qemu_command.c
99cbc7
@@ -7327,6 +7327,26 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
99cbc7
         }
99cbc7
     }
99cbc7
 
99cbc7
+    if (def->features[VIR_DOMAIN_FEATURE_HTM] != VIR_TRISTATE_SWITCH_ABSENT) {
99cbc7
+        const char *str;
99cbc7
+
99cbc7
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_CAP_HTM)) {
99cbc7
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
99cbc7
+                           _("HTM configuration is not supported by this "
99cbc7
+                             "QEMU binary"));
99cbc7
+            goto cleanup;
99cbc7
+        }
99cbc7
+
99cbc7
+        str = virTristateSwitchTypeToString(def->features[VIR_DOMAIN_FEATURE_HTM]);
99cbc7
+        if (!str) {
99cbc7
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
99cbc7
+                           _("Invalid setting for HTM state"));
99cbc7
+            goto cleanup;
99cbc7
+        }
99cbc7
+
99cbc7
+        virBufferAsprintf(&buf, ",cap-htm=%s", str);
99cbc7
+    }
99cbc7
+
99cbc7
     if (cpu && cpu->model &&
99cbc7
         cpu->mode == VIR_CPU_MODE_HOST_MODEL &&
99cbc7
         qemuDomainIsPSeries(def) &&
99cbc7
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
99cbc7
index 0eacad1e44..3f3bb94685 100644
99cbc7
--- a/src/qemu/qemu_domain.c
99cbc7
+++ b/src/qemu/qemu_domain.c
99cbc7
@@ -3852,6 +3852,19 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
99cbc7
             }
99cbc7
             break;
99cbc7
 
99cbc7
+        case VIR_DOMAIN_FEATURE_HTM:
99cbc7
+            if (def->features[i] != VIR_TRISTATE_SWITCH_ABSENT &&
99cbc7
+                !qemuDomainIsPSeries(def)) {
99cbc7
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
99cbc7
+                               _("The '%s' feature is not supported for "
99cbc7
+                                 "architecture '%s' or machine type '%s'"),
99cbc7
+                               featureName,
99cbc7
+                               virArchToString(def->os.arch),
99cbc7
+                               def->os.machine);
99cbc7
+                return -1;
99cbc7
+            }
99cbc7
+            break;
99cbc7
+
99cbc7
         case VIR_DOMAIN_FEATURE_ACPI:
99cbc7
         case VIR_DOMAIN_FEATURE_APIC:
99cbc7
         case VIR_DOMAIN_FEATURE_PAE:
99cbc7
@@ -3865,7 +3878,6 @@ qemuDomainDefValidateFeatures(const virDomainDef *def,
99cbc7
         case VIR_DOMAIN_FEATURE_PMU:
99cbc7
         case VIR_DOMAIN_FEATURE_VMPORT:
99cbc7
         case VIR_DOMAIN_FEATURE_VMCOREINFO:
99cbc7
-        case VIR_DOMAIN_FEATURE_HTM:
99cbc7
         case VIR_DOMAIN_FEATURE_LAST:
99cbc7
             break;
99cbc7
         }
99cbc7
diff --git a/tests/qemuxml2argvdata/pseries-features.args b/tests/qemuxml2argvdata/pseries-features.args
99cbc7
index 12c14715c6..226d43df44 100644
99cbc7
--- a/tests/qemuxml2argvdata/pseries-features.args
99cbc7
+++ b/tests/qemuxml2argvdata/pseries-features.args
99cbc7
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
99cbc7
 -name guest \
99cbc7
 -S \
99cbc7
 -machine pseries,accel=tcg,usb=off,dump-guest-core=off,resize-hpt=required,\
99cbc7
-cap-hpt-max-page-size=1048576k \
99cbc7
+cap-hpt-max-page-size=1048576k,cap-htm=on \
99cbc7
 -m 512 \
99cbc7
 -smp 1,sockets=1,cores=1,threads=1 \
99cbc7
 -uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
99cbc7
-- 
99cbc7
2.18.0
99cbc7