Skip to contentSkip to conversation

ppc/kvm: Tell the user what might be wrong when using bad CPU types with kvm-hv

PATCH Applied Thomas Huth 3 participants 3 messages Feb 18, 2016 – Feb 19, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppc/kvm: Tell the user what might be wrong when using bad CPU types with kvm-hv

Using a CPU type that does not match the host is not possible when using the kvm-hv kernel module - the PVR is checked in the kernel function kvm_arch_vcpu_ioctl_set_sregs_hv() and rejected with -EINVAL if it does not match the host.
However, when the user tries to specify a non-matching CPU type, QEMU currently only reports "kvm_init_vcpu failed: Invalid argument", and this is of course not very helpful for the user to solve the problem. So this patch adds a more descriptive error message that tells the user to specify "-cpu host" instead.

---
 target-ppc/kvm.c | 4 ++++
 1 file changed, 4 insertions(+)
target-ppc/kvm.c +4 -0
index 762d6cf..6545fbe 100644
@@ -513,6 +513,10 @@ int kvm_arch_init_vcpu(CPUState *cs)
     /* Synchronize sregs with kvm */
     ret = kvm_arch_sync_sregs(cpu);
     if (ret) {
+        if (ret == -EINVAL) {
+            error_report("Register sync failed... If you're using kvm-hv.ko,"
+                         " only \"-cpu host\" is possible!");
+        }
         return ret;
     }
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 20 lines · Thomas Huth

Using a CPU type that does not match the host is not possible when using the kvm-hv kernel module - the PVR is checked in the kernel function kvm_arch_vcpu_ioctl_set_sregs_hv() and rejected with -EINVAL if it does not match the host.
However, when the user tries to specify a non-matching CPU type, QEMU currently only reports "kvm_init_vcpu failed: Invalid argument", and this is of course not very helpful for the user to solve the problem. So this patch adds a more descriptive error message that tells the user to specify "-cpu host" instead.

---
 target-ppc/kvm.c | 4 ++++
 1 file changed, 4 insertions(+)
target-ppc/kvm.c +0 -0
index 762d6cf..6545fbe 100644

target-ppc/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 518

Quoted 6 lines
target-ppc/kvm.c +3 -0
@@ -513,6 +513,10 @@ int kvm_arch_init_vcpu(CPUState *cs)
     /* Synchronize sregs with kvm */
     ret = kvm_arch_sync_sregs(cpu);
     if (ret) {
+        if (ret == -EINVAL) {
+            error_report("Register sync failed... If you're using kvm-hv.ko,"
+                         " only \"-cpu host\" is possible!");

No need to shout at the user; drop the trailing !

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Applied
#2 lore raw
Quoted 16 lines · Eric Blake
Quoted 15 lines · Thomas Huth

Using a CPU type that does not match the host is not possible when using the kvm-hv kernel module - the PVR is checked in the kernel function kvm_arch_vcpu_ioctl_set_sregs_hv() and rejected with -EINVAL if it does not match the host.
However, when the user tries to specify a non-matching CPU type, QEMU currently only reports "kvm_init_vcpu failed: Invalid argument", and this is of course not very helpful for the user to solve the problem. So this patch adds a more descriptive error message that tells the user to specify "-cpu host" instead.

---
 target-ppc/kvm.c | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 13 lines

target-ppc/kvm.c int kvm_arch_init_vcpu(CPUState *cs) · line 518

Quoted 11 lines
target-ppc/kvm.c +3 -0
index 762d6cf..6545fbe 100644
@@ -513,6 +513,10 @@ int kvm_arch_init_vcpu(CPUState *cs)
     /* Synchronize sregs with kvm */
     ret = kvm_arch_sync_sregs(cpu);
     if (ret) {
+        if (ret == -EINVAL) {
+            error_report("Register sync failed... If you're using kvm-hv.ko,"
+                         " only \"-cpu host\" is possible!");

No need to shout at the user; drop the trailing !

Applied to ppc-for-2.6 with ! removed. Thanks.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson