Blob Blame History Raw
From 3338d2ca3f36c9f9546cbcd436c344c8a3c97285 Mon Sep 17 00:00:00 2001
Message-Id: <3338d2ca3f36c9f9546cbcd436c344c8a3c97285@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 7 Feb 2020 10:41:42 +0100
Subject: [PATCH] qemu: Prefer dashes for hyperv features
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Starting with QEMU 4.1, we're using the canonical feature names on the
command line and avoid aliases to prepare for possible deprecation of
all aliases in QEMU. But we do so only for features from our CPU map,
hyperv features defined in the code were unchanged and this patch fixes
it. Some features use "hv-" prefix unconditionally because they were
introduced recently enough to always support spelling with a dash.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Tested-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit d99e8f01c7f9b5a0f384ccaac40187091a4e6c6c)

https://bugzilla.redhat.com/show_bug.cgi?id=1794868

Conflicts:
	tests/qemuxml2argvdata/hyperv.args
            - a few extra hyperv features upstream

Since "unavailable-features" QOM property was backported to QEMU 2.12,
we would effectively start using "hv-" prefix (instead of "hv_") for all
hyperv features. This is fine because the downstream version of QEMU
with "unavailable-features" backported defines all supported hyperv
features with dashes.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <57ee0267b028177420edeae0edcf479de3f52820.1581064395.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/qemu/qemu_command.c                         | 17 ++++++++++++-----
 .../clock-timer-hyperv-rtc.args                 |  2 +-
 tests/qemuxml2argvdata/hyperv-panic.args        |  2 +-
 tests/qemuxml2argvdata/hyperv.args              |  4 ++--
 tests/qemuxml2argvdata/panic-double.args        |  2 +-
 5 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2b885e98dd..0289a907a1 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6995,7 +6995,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
                                 !!timer->present);
         } else if (timer->name == VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK &&
                    timer->present == 1) {
-            virBufferAddLit(&buf, ",hv_time");
+            virBufferAddLit(&buf, ",hv-time");
         } else if (timer->name == VIR_DOMAIN_TIMER_NAME_TSC &&
                    timer->frequency > 0) {
             virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency);
@@ -7013,6 +7013,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
     }
 
     if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) {
+        const char *hvPrefix = "hv-";
+
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES))
+            hvPrefix = "hv_";
+
         for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) {
             switch ((virDomainHyperv) i) {
             case VIR_DOMAIN_HYPERV_RELAXED:
@@ -7026,19 +7031,21 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
             case VIR_DOMAIN_HYPERV_REENLIGHTENMENT:
             case VIR_DOMAIN_HYPERV_TLBFLUSH:
                 if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
-                    virBufferAsprintf(&buf, ",hv_%s",
+                    virBufferAsprintf(&buf, ",%s%s",
+                                      hvPrefix,
                                       virDomainHypervTypeToString(i));
                 break;
 
             case VIR_DOMAIN_HYPERV_SPINLOCKS:
                 if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
-                    virBufferAsprintf(&buf, ",hv_spinlocks=0x%x",
+                    virBufferAsprintf(&buf, ",%s=0x%x",
+                                      VIR_CPU_x86_KVM_HV_SPINLOCKS,
                                       def->hyperv_spinlocks);
                 break;
 
             case VIR_DOMAIN_HYPERV_VENDOR_ID:
                 if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON)
-                    virBufferAsprintf(&buf, ",hv_vendor_id=%s",
+                    virBufferAsprintf(&buf, ",hv-vendor-id=%s",
                                       def->hyperv_vendor_id);
                 break;
 
@@ -7051,7 +7058,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
 
     for (i = 0; i < def->npanics; i++) {
         if (def->panics[i]->model == VIR_DOMAIN_PANIC_MODEL_HYPERV) {
-            virBufferAddLit(&buf, ",hv_crash");
+            virBufferAddLit(&buf, ",hv-crash");
             break;
         }
     }
diff --git a/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args b/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args
index 6045fbdbf2..1e36d139f9 100644
--- a/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args
+++ b/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
 -name QEMUGuest1 \
 -S \
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
--cpu qemu32,hv_time \
+-cpu qemu32,hv-time \
 -m 214 \
 -smp 6,sockets=6,cores=1,threads=1 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/hyperv-panic.args b/tests/qemuxml2argvdata/hyperv-panic.args
index fca46d7371..627fb09502 100644
--- a/tests/qemuxml2argvdata/hyperv-panic.args
+++ b/tests/qemuxml2argvdata/hyperv-panic.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
 -name QEMUGuest1 \
 -S \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu qemu32,hv_crash \
+-cpu qemu32,hv-crash \
 -m 214 \
 -smp 6,sockets=6,cores=1,threads=1 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args
index 6ee6198fb0..a5fc6a1121 100644
--- a/tests/qemuxml2argvdata/hyperv.args
+++ b/tests/qemuxml2argvdata/hyperv.args
@@ -8,8 +8,8 @@ QEMU_AUDIO_DRV=none \
 -name QEMUGuest1 \
 -S \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu 'qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,\
-hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies,\
+-cpu 'qemu32,hv_relaxed,hv_vapic,hv-spinlocks=0x2fff,hv_vpindex,hv_runtime,\
+hv_synic,hv_stimer,hv_reset,hv-vendor-id=KVM Hv,hv_frequencies,\
 hv_reenlightenment,hv_tlbflush' \
 -m 214 \
 -smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/panic-double.args b/tests/qemuxml2argvdata/panic-double.args
index 7acee1ae29..8a632477b1 100644
--- a/tests/qemuxml2argvdata/panic-double.args
+++ b/tests/qemuxml2argvdata/panic-double.args
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
 -name QEMUGuest1 \
 -S \
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu qemu32,hv_crash \
+-cpu qemu32,hv-crash \
 -m 214 \
 -smp 6,sockets=6,cores=1,threads=1 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-- 
2.25.0