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