render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
edecca
From eaa86279ad7a2a0e341b5270060f250e24d47af4 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <eaa86279ad7a2a0e341b5270060f250e24d47af4@dist-git>
edecca
From: Andrea Bolognani <abologna@redhat.com>
edecca
Date: Tue, 4 Dec 2018 16:46:20 +0100
edecca
Subject: [PATCH] qemu: Format nested-hv feature on the command line
edecca
MIME-Version: 1.0
edecca
Content-Type: text/plain; charset=UTF-8
edecca
Content-Transfer-Encoding: 8bit
edecca
edecca
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
edecca
(cherry picked from commit c54d3d00ae1f9cd3f983d8e8c1def551d6ddf9b7)
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1647822
edecca
edecca
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
edecca
Reviewed-by: Ján Tomko <jtomko@redhat.com>
edecca
---
edecca
 src/qemu/qemu_command.c                      | 20 ++++++++++++++++++++
edecca
 tests/qemuxml2argvdata/pseries-features.args |  2 +-
edecca
 2 files changed, 21 insertions(+), 1 deletion(-)
edecca
edecca
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
edecca
index 320ecd902c..c706a4b095 100644
edecca
--- a/src/qemu/qemu_command.c
edecca
+++ b/src/qemu/qemu_command.c
edecca
@@ -7399,6 +7399,26 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
edecca
         virBufferAsprintf(&buf, ",cap-htm=%s", str);
edecca
     }
edecca
 
edecca
+    if (def->features[VIR_DOMAIN_FEATURE_NESTED_HV] != VIR_TRISTATE_SWITCH_ABSENT) {
edecca
+        const char *str;
edecca
+
edecca
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV)) {
edecca
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
edecca
+                           _("Nested HV configuration is not supported by "
edecca
+                             "this QEMU binary"));
edecca
+            goto cleanup;
edecca
+        }
edecca
+
edecca
+        str = virTristateSwitchTypeToString(def->features[VIR_DOMAIN_FEATURE_NESTED_HV]);
edecca
+        if (!str) {
edecca
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
edecca
+                           _("Invalid setting for nested HV state"));
edecca
+            goto cleanup;
edecca
+        }
edecca
+
edecca
+        virBufferAsprintf(&buf, ",cap-nested-hv=%s", str);
edecca
+    }
edecca
+
edecca
     if (cpu && cpu->model &&
edecca
         cpu->mode == VIR_CPU_MODE_HOST_MODEL &&
edecca
         qemuDomainIsPSeries(def) &&
edecca
diff --git a/tests/qemuxml2argvdata/pseries-features.args b/tests/qemuxml2argvdata/pseries-features.args
edecca
index 226d43df44..2b0a2aa93b 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,cap-htm=on \
edecca
+cap-hpt-max-page-size=1048576k,cap-htm=on,cap-nested-hv=off \
edecca
 -m 512 \
edecca
 -smp 1,sockets=1,cores=1,threads=1 \
edecca
 -uuid 1ccfd97d-5eb4-478a-bbe6-88d254c16db7 \
edecca
-- 
edecca
2.20.1
edecca