render / rpms / libvirt

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