]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
vmbus: Print a warning when enabled without the recommended set of features
authorMaciej S. Szmigiero <maciej.szmigiero@oracle.com>
Thu, 25 Jan 2024 14:12:41 +0000 (15:12 +0100)
committerMaciej S. Szmigiero <maciej.szmigiero@oracle.com>
Fri, 8 Mar 2024 13:18:56 +0000 (14:18 +0100)
Some Windows versions crash at boot or fail to enable the VMBus device if
they don't see the expected set of Hyper-V features (enlightenments).

Since this provides poor user experience let's warn user if the VMBus
device is enabled without the recommended set of Hyper-V features.

The recommended set is the minimum set of Hyper-V features required to make
the VMBus device work properly in Windows Server versions 2016, 2019 and
2022.

Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Maciej S. Szmigiero <maciej.szmigiero@oracle.com>
hw/hyperv/hyperv.c
hw/hyperv/vmbus.c
include/hw/hyperv/hyperv.h
target/i386/kvm/hyperv-stub.c
target/i386/kvm/hyperv.c
target/i386/kvm/hyperv.h
target/i386/kvm/kvm.c

index 6c4a18dd0e2ab71c38acb93482901105cc040b2c..3ea54ba818b2813fc9d9b77e5412c0be94af12df 100644 (file)
@@ -951,3 +951,15 @@ uint64_t hyperv_syndbg_query_options(void)
 
     return msg.u.query_options.options;
 }
+
+static bool vmbus_recommended_features_enabled;
+
+bool hyperv_are_vmbus_recommended_features_enabled(void)
+{
+    return vmbus_recommended_features_enabled;
+}
+
+void hyperv_set_vmbus_recommended_features_enabled(void)
+{
+    vmbus_recommended_features_enabled = true;
+}
index 380239af2c7ba8f55b8f35e5af13d4cb0491d005..f33afeeea27d4e46da64c991001bf356d51f2227 100644 (file)
@@ -2631,6 +2631,12 @@ static void vmbus_bridge_realize(DeviceState *dev, Error **errp)
         return;
     }
 
+    if (!hyperv_are_vmbus_recommended_features_enabled()) {
+        warn_report("VMBus enabled without the recommended set of Hyper-V features: "
+                    "hv-stimer, hv-vapic and hv-runtime. "
+                    "Some Windows versions might not boot or enable the VMBus device");
+    }
+
     bridge->bus = VMBUS(qbus_new(TYPE_VMBUS, dev, "vmbus"));
 }
 
index 015c3524b1c2e19a77c501fe8e9a69799543a1ba..d717b4e13d40d3ee6f7351038538545c202f9210 100644 (file)
@@ -139,4 +139,8 @@ typedef struct HvSynDbgMsg {
 } HvSynDbgMsg;
 typedef uint16_t (*HvSynDbgHandler)(void *context, HvSynDbgMsg *msg);
 void hyperv_set_syndbg_handler(HvSynDbgHandler handler, void *context);
+
+bool hyperv_are_vmbus_recommended_features_enabled(void);
+void hyperv_set_vmbus_recommended_features_enabled(void);
+
 #endif
index 778ed782e6fc87a7e1ae46535039dbd3fb68d56b..3263dcf05d312636e46ae2769eef48bde4f56aa2 100644 (file)
@@ -52,3 +52,7 @@ void hyperv_x86_synic_reset(X86CPU *cpu)
 void hyperv_x86_synic_update(X86CPU *cpu)
 {
 }
+
+void hyperv_x86_set_vmbus_recommended_features_enabled(void)
+{
+}
index 6825c89af374ab7319a1bc10724068fffe16e306..f2a3fe650a186d8e02870338d0e251fd1f67a27a 100644 (file)
@@ -149,3 +149,8 @@ int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit)
         return -1;
     }
 }
+
+void hyperv_x86_set_vmbus_recommended_features_enabled(void)
+{
+    hyperv_set_vmbus_recommended_features_enabled();
+}
index 67543296c3a4e12bc382ea2177bb609c72aac1cb..e3982c8f4dd1b5751454eeb1d90a3077144b85b1 100644 (file)
@@ -26,4 +26,6 @@ int hyperv_x86_synic_add(X86CPU *cpu);
 void hyperv_x86_synic_reset(X86CPU *cpu);
 void hyperv_x86_synic_update(X86CPU *cpu);
 
+void hyperv_x86_set_vmbus_recommended_features_enabled(void);
+
 #endif
index 42970ab046fac152abdfbccb8fca226f6e90bca5..e68cbe92930291ea62d5ead4a557b0f69c0ec3e1 100644 (file)
@@ -1650,6 +1650,13 @@ static int hyperv_init_vcpu(X86CPU *cpu)
         }
     }
 
+    /* Skip SynIC and VP_INDEX since they are hard deps already */
+    if (hyperv_feat_enabled(cpu, HYPERV_FEAT_STIMER) &&
+        hyperv_feat_enabled(cpu, HYPERV_FEAT_VAPIC) &&
+        hyperv_feat_enabled(cpu, HYPERV_FEAT_RUNTIME)) {
+        hyperv_x86_set_vmbus_recommended_features_enabled();
+    }
+
     return 0;
 }