render / rpms / libvirt

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