hyperv: cpu hotplug fix with HyperV enabled
PATCH 1/1 hyperv: cpu hotplug fix with HyperV enabled
From: "Alexey V. Kostyushko" <[email protected]>
With Hyper-V enabled CPU hotplug stops working. The CPU appears in device manager on Windows but does not appear in peformance monitor and control panel.
The root of the problem is the following. Windows checks HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE bit in CPUID. The presence of this bit is enough to cure the situation.
Add option 'hv-cpuhotplug' to control this behavior.
--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/kvm.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-)
target-i386/cpu-qom.h +1 -0
@@ -96,6 +96,7 @@ typedef struct X86CPU {bool hyperv_runtime;bool hyperv_synic;bool hyperv_stimer; +bool hyperv_cpuhotplug;bool check_cpuid;bool enforce_cpuid;bool expose_kvm;
target-i386/cpu.c +1 -0
@@ -3172,6 +3172,7 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("hv-runtime" ,X86CPU , hyperv_runtime, false),DEFINE_PROP_BOOL ("hv-synic" ,X86CPU , hyperv_synic, false),DEFINE_PROP_BOOL ("hv-stimer" ,X86CPU , hyperv_stimer, false), +DEFINE_PROP_BOOL ("hv-cpuhotplug" ,X86CPU , hyperv_cpuhotplug, false),DEFINE_PROP_BOOL ("check" ,X86CPU , check_cpuid, true),DEFINE_PROP_BOOL ("enforce" ,X86CPU , enforce_cpuid, false), DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true),
target-i386/kvm.c +5 -1
@@ -529,7 +529,8 @@ static bool hyperv_enabled(X86CPU *cpu) cpu->hyperv_vpindex || cpu->hyperv_runtime || cpu->hyperv_synic || - cpu->hyperv_stimer); + cpu->hyperv_stimer || + cpu->hyperv_cpuhotplug); }static int kvm_arch_set_tsc_khz (CPUState *cs)
@@ -636,6 +637,9 @@ int kvm_arch_init_vcpu(CPUState *cs) c->eax |=0x200 ; has_msr_hv_tsc = true; } +if (cpu->hyperv_cpuhotplug) { + c->edx |=HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLE ; + }if (cpu->hyperv_crash && has_msr_hv_crash) { c->edx |=HV_X64_GUEST_CRASH_MSR_AVAILABLE ; }
Signature · 1 line
2.1.4
Am 11.02.2016 um 21:19 schrieb Denis V. Lunev:
Quoted 41 lines
From: "Alexey V. Kostyushko" <[email protected]>
With Hyper-V enabled CPU hotplug stops working. The CPU appears in device manager on Windows but does not appear in peformance monitor and control panel.
The root of the problem is the following. Windows checks
HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLEbit in CPUID. The presence of this bit is enough to cure the situation.Add option 'hv-cpuhotplug' to control this behavior.
Signed-off-by Alexey V. Kostyushko <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>CC Paolo Bonzini <[email protected]>CC Richard Henderson <[email protected]>CC Eduardo Habkost <[email protected]>CC "Andreas Färber" <[email protected]>--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/kvm.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-)target-i386/cpu-qom.h +1
-0@@ -96,6 +96,7 @@ typedef struct X86CPU {bool hyperv_runtime;bool hyperv_synic;bool hyperv_stimer; +bool hyperv_cpuhotplug;bool check_cpuid;bool enforce_cpuid;bool expose_kvm;target-i386/cpu.c +0
-0
target-i386/cpu.c static Property x86_cpu_properties[] = { · line 3175
Quoted 4 lines
target-i386/cpu.c +1
-0@@ -3172,6 +3172,7 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("hv-runtime" ,X86CPU , hyperv_runtime, false),DEFINE_PROP_BOOL ("hv-synic" ,X86CPU , hyperv_synic, false),DEFINE_PROP_BOOL ("hv-stimer" ,X86CPU , hyperv_stimer, false), + DEFINE_PROP_BOOL("hv-cpuhotplug", X86CPU, hyperv_cpuhotplug, false),
Is "cpuhotplug" some fixed HyperV name? Otherwise we generally use a dashes convention for QOM properties, i.e. "hv-cpu-hotplug".
Regards,
Andreas
Quoted 3 lines
target-i386/cpu.c +0
-0DEFINE_PROP_BOOL ("check" ,X86CPU , check_cpuid, true),DEFINE_PROP_BOOL ("enforce" ,X86CPU , enforce_cpuid, false), DEFINE_PROP_BOOL("kvm", X86CPU, expose_kvm, true),
[snip]
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Quoted 49 lines · Andreas Färber
Am 11.02.2016 um 21:19 schrieb Denis V. Lunev:
Quoted 41 lines
From: "Alexey V. Kostyushko" <[email protected]>
With Hyper-V enabled CPU hotplug stops working. The CPU appears in device manager on Windows but does not appear in peformance monitor and control panel.
The root of the problem is the following. Windows checks
HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLEbit in CPUID. The presence of this bit is enough to cure the situation.Add option 'hv-cpuhotplug' to control this behavior.
Signed-off-by Alexey V. Kostyushko <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>CC Paolo Bonzini <[email protected]>CC Richard Henderson <[email protected]>CC Eduardo Habkost <[email protected]>CC "Andreas Färber" <[email protected]>--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/kvm.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-)target-i386/cpu-qom.h +1
-0@@ -96,6 +96,7 @@ typedef struct X86CPU {bool hyperv_runtime;bool hyperv_synic;bool hyperv_stimer; +bool hyperv_cpuhotplug;bool check_cpuid;bool enforce_cpuid;bool expose_kvm;target-i386/cpu.c +0
-0target-i386/cpu.c static Property x86_cpu_properties[] = { · line 3175
Quoted 4 lines
target-i386/cpu.c +1
-0@@ -3172,6 +3172,7 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("hv-runtime" ,X86CPU , hyperv_runtime, false),DEFINE_PROP_BOOL ("hv-synic" ,X86CPU , hyperv_synic, false),DEFINE_PROP_BOOL ("hv-stimer" ,X86CPU , hyperv_stimer, false), + DEFINE_PROP_BOOL("hv-cpuhotplug", X86CPU, hyperv_cpuhotplug, false),Is "cpuhotplug" some fixed HyperV name? Otherwise we generally use a dashes convention for QOM properties, i.e. "hv-cpu-hotplug".
Quoted 2 lines
Regards,
Andreas
This name is for libvirt. We can take one one. This is not a problem.
Roman Kagan has proposed verbally a bit different approach. He suggests not to introduce the option but
check here that HyperV is enabled (any single option is enough to face the problem) and CPU hotplug is enabled and automatically enable this bit.
Paolo, Andreas, is there any opinion on this?
As far as I can see for the time being we lend such decisions to libvirt. But this bit does not require any processing.
Den
Am 12.02.2016 um 12:08 schrieb Denis V. Lunev:
Quoted 56 lines · Andreas Färber
Quoted 51 lines
Am 11.02.2016 um 21:19 schrieb Denis V. Lunev:
Quoted 42 lines
From: "Alexey V. Kostyushko" <[email protected]>
With Hyper-V enabled CPU hotplug stops working. The CPU appears in device
manager on Windows but does not appear in peformance monitor and control panel.The root of the problem is the following. Windows checks
HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLEbit in CPUID. The presence of this bit is enough to cure the situation.Add option 'hv-cpuhotplug' to control this behavior.
Signed-off-by Alexey V. Kostyushko <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>CC Paolo Bonzini <[email protected]>CC Richard Henderson <[email protected]>CC Eduardo Habkost <[email protected]>CC "Andreas Färber" <[email protected]>--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/kvm.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-)target-i386/cpu-qom.h +1
-0@@ -96,6 +96,7 @@ typedef struct X86CPU {bool hyperv_runtime;bool hyperv_synic;bool hyperv_stimer; +bool hyperv_cpuhotplug;bool check_cpuid;bool enforce_cpuid;bool expose_kvm;target-i386/cpu.c +0
-0target-i386/cpu.c static Property x86_cpu_properties[] = { · line 3176
Quoted 5 lines
target-i386/cpu.c +1
-0@@ -3172,6 +3172,7 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("hv-runtime" ,X86CPU , hyperv_runtime, false),DEFINE_PROP_BOOL ("hv-synic" ,X86CPU , hyperv_synic, false),DEFINE_PROP_BOOL ("hv-stimer" ,X86CPU , hyperv_stimer, false), +DEFINE_PROP_BOOL ("hv-cpuhotplug" ,X86CPU , hyperv_cpuhotplug, false),Is "cpuhotplug" some fixed HyperV name? Otherwise we generally use a dashes convention for QOM properties, i.e. "hv-cpu-hotplug".
Quoted 2 lines
Regards,
AndreasThis name is for libvirt. We can take one one. This is not a problem.
Quoted 7 lines
Roman Kagan has proposed verbally a bit different approach. He suggests not to introduce the option but
check here that HyperV is enabled (any single option is enough to face the problem) and CPU hotplug is enabled and automatically enable this bit.Paolo, Andreas, is there any opinion on this?
That implicit proposal sounds even more appealing to me, yes.
You could still additionally do a dynamic property though, in case you want to inspect or toggle it at runtime (no clue when Windows reads it).
Andreas
Quoted 4 lines
As far as I can see for the time being we lend such decisions to libvirt. But this bit does not require any processing.
Den
Signature · 2 lines
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Quoted 63 lines · Andreas Färber
Am 12.02.2016 um 12:08 schrieb Denis V. Lunev:
Quoted 62 lines · Andreas Färber
Quoted 51 lines
Am 11.02.2016 um 21:19 schrieb Denis V. Lunev:
Quoted 42 lines
From: "Alexey V. Kostyushko" <[email protected]>
With Hyper-V enabled CPU hotplug stops working. The CPU appears in device
manager on Windows but does not appear in peformance monitor and control panel.The root of the problem is the following. Windows checks
HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLEbit in CPUID. The presence of this bit is enough to cure the situation.Add option 'hv-cpuhotplug' to control this behavior.
Signed-off-by Alexey V. Kostyushko <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>CC Paolo Bonzini <[email protected]>CC Richard Henderson <[email protected]>CC Eduardo Habkost <[email protected]>CC "Andreas Färber" <[email protected]>--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/kvm.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-)target-i386/cpu-qom.h +1
-0@@ -96,6 +96,7 @@ typedef struct X86CPU {bool hyperv_runtime;bool hyperv_synic;bool hyperv_stimer; +bool hyperv_cpuhotplug;bool check_cpuid;bool enforce_cpuid;bool expose_kvm;target-i386/cpu.c +0
-0target-i386/cpu.c static Property x86_cpu_properties[] = { · line 3176
Quoted 5 lines
target-i386/cpu.c +1
-0@@ -3172,6 +3172,7 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("hv-runtime" ,X86CPU , hyperv_runtime, false),DEFINE_PROP_BOOL ("hv-synic" ,X86CPU , hyperv_synic, false),DEFINE_PROP_BOOL ("hv-stimer" ,X86CPU , hyperv_stimer, false), +DEFINE_PROP_BOOL ("hv-cpuhotplug" ,X86CPU , hyperv_cpuhotplug, false),Is "cpuhotplug" some fixed HyperV name? Otherwise we generally use a dashes convention for QOM properties, i.e. "hv-cpu-hotplug".
Quoted 2 lines
Regards,
AndreasThis name is for libvirt. We can take one one. This is not a problem.
Roman Kagan has proposed verbally a bit different approach. He suggests not to introduce the option but
check here that HyperV is enabled (any single option is enough to face the problem) and CPU hotplug is enabled and automatically enable this bit.
Quoted 5 lines
Quoted 1 line
Paolo, Andreas, is there any opinion on this?
That implicit proposal sounds even more appealing to me, yes.
You could still additionally do a dynamic property though, in case you want to inspect or toggle it at runtime (no clue when Windows reads it).
no. this will not work. I should setup CPUID at the beginning (before boot) and keep it persistent. Thus either option coming from libvirt or this bit would be automatically calculated by QEMU.
I'll check that we could create read-only property to export the value.
OK. I'll redo this tomorrow if nobody will explicitly say 'no' today :)
Den
Quoted 74 lines · On Fri, 12 Feb 2016 14:27:25 +0300 "Denis V. Lunev" <[email protected]> wrote:
Quoted 63 lines · Andreas Färber
Am 12.02.2016 um 12:08 schrieb Denis V. Lunev:
Quoted 62 lines · Andreas Färber
Quoted 51 lines
Am 11.02.2016 um 21:19 schrieb Denis V. Lunev:
Quoted 42 lines
From: "Alexey V. Kostyushko" <[email protected]>
With Hyper-V enabled CPU hotplug stops working. The CPU appears in device
manager on Windows but does not appear in peformance monitor and control panel.The root of the problem is the following. Windows checks
HV_X64_CPU_DYNAMIC_PARTITIONING_AVAILABLEbit in CPUID. The presence of this bit is enough to cure the situation.Add option 'hv-cpuhotplug' to control this behavior.
Signed-off-by Alexey V. Kostyushko <[email protected]>Signed-off-by Denis V. Lunev <[email protected]>CC Paolo Bonzini <[email protected]>CC Richard Henderson <[email protected]>CC Eduardo Habkost <[email protected]>CC "Andreas Färber" <[email protected]>--- target-i386/cpu-qom.h | 1 + target-i386/cpu.c | 1 + target-i386/kvm.c | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-)target-i386/cpu-qom.h +1
-0@@ -96,6 +96,7 @@ typedef struct X86CPU {bool hyperv_runtime;bool hyperv_synic;bool hyperv_stimer; +bool hyperv_cpuhotplug;bool check_cpuid;bool enforce_cpuid;bool expose_kvm;target-i386/cpu.c +0
-0target-i386/cpu.c static Property x86_cpu_properties[] = { · line 3176
Quoted 5 lines
target-i386/cpu.c +1
-0@@ -3172,6 +3172,7 @@ static Property x86_cpu_properties[] = {DEFINE_PROP_BOOL ("hv-runtime" ,X86CPU , hyperv_runtime, false),DEFINE_PROP_BOOL ("hv-synic" ,X86CPU , hyperv_synic, false),DEFINE_PROP_BOOL ("hv-stimer" ,X86CPU , hyperv_stimer, false), +DEFINE_PROP_BOOL ("hv-cpuhotplug" ,X86CPU , hyperv_cpuhotplug, false),Is "cpuhotplug" some fixed HyperV name? Otherwise we generally use a dashes convention for QOM properties, i.e. "hv-cpu-hotplug".
Quoted 2 lines
Regards,
AndreasThis name is for libvirt. We can take one one. This is not a problem.
Roman Kagan has proposed verbally a bit different approach. He suggests not to introduce the option but
check here that HyperV is enabled (any single option is enough to face the problem) and CPU hotplug is enabled and automatically enable this bit.Quoted 5 lines
Quoted 1 line
Paolo, Andreas, is there any opinion on this?
That implicit proposal sounds even more appealing to me, yes.
You could still additionally do a dynamic property though, in case you want to inspect or toggle it at runtime (no clue when Windows reads it).
no. this will not work. I should setup CPUID at the beginning (before boot) and keep it persistent. Thus either option coming from libvirt or this bit would be automatically calculated by QEMU.
Quoted 5 lines
I'll check that we could create read-only property to export the value.
OK. I'll redo this tomorrow if nobody will explicitly say 'no' today :)
+to Anreas suggestion and readonly prop
there is not need to create a field for it in CPU structure, just checking for present hyperv flags should be sufficient.
Quoted 3 lines
Den