Skip to contentSkip to conversation

kvm max vcpu limit fixes

PATCH Applied Marcelo Tosatti 2 participants 6 messages Aug 12, 2013 – Aug 20, 2013 KVM

lore
Share & tools
lore
#0 lore raw

cover kvm max vcpu limit fixes

1) Use recommended vcpu limit instead of max vcpu limit
2) Do not allow max_cpus > max_vcpus

#1 lore raw

PATCH 1/2 kvm-all.c: use recommended max vcpus limit

Commit 8c3ba334f8588e1d5099f8602cf01897720e0eca, "KVM: x86: Raise the hard VCPU count limit", upstream introduced the notion of a recommended vcpu max limit.

Switch the order so the recommended vcpu max limit is used instead of the actual max vcpu limit.

kvm-all.c +2 -2
Index: qemu/kvm-all.c
===================================================================
@@ -1321,11 +1321,11 @@ static int kvm_max_vcpus(KVMState *s)
      * procedure from the kernel API documentation to cope with
      * older kernels that may be missing capabilities.
      */
-    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
+    ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
     if (ret) {
         return ret;
     }
-    ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
+    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
     if (ret) {
         return ret;
     }
maintainer
#2 lore raw

Re: [uq/master patch 1/2] kvm-all.c: use recommended max vcpus limit

Il 12/08/2013 21:56, Marcelo Tosatti ha scritto:

Quoted 19 lines

Commit 8c3ba334f8588e1d5099f8602cf01897720e0eca, "KVM: x86: Raise the hard VCPU count limit", upstream introduced the notion of a recommended vcpu max limit.

Switch the order so the recommended vcpu max limit is used instead of the actual max vcpu limit.

Index: qemu/kvm-all.c
===================================================================

kvm-all.c +0 -0
@@ -1321,11 +1321,11 @@ static int kvm_max_vcpus(KVMState *s)
      * procedure from the kernel API documentation to cope with
      * older kernels that may be missing capabilities.
      */

kvm-all.c static int kvm_max_vcpus(KVMState *s) · line 1331

Quoted 10 lines
kvm-all.c +2 -2
-    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
+    ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
     if (ret) {
         return ret;
     }
-    ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
+    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
     if (ret) {
         return ret;
     }

This would break "working" configurations. Perhaps we should just warn if the VCPU limit exceeds KVM_CAP_NR_VCPUS, and fail if the VCPU limit exceeds KVM_CAP_MAX_VCPUS.

Patch 2 is fine, ok to apply it (since it fixes a real bug) and then you can work on top of it?

Paolo

#3 lore raw

Re: [uq/master patch 1/2] kvm-all.c: use recommended max vcpus limit

Quoted 35 lines · Paolo Bonzini

Il 12/08/2013 21:56, Marcelo Tosatti ha scritto:

Quoted 19 lines

Commit 8c3ba334f8588e1d5099f8602cf01897720e0eca, "KVM: x86: Raise the hard VCPU count limit", upstream introduced the notion of a recommended vcpu max limit.

Switch the order so the recommended vcpu max limit is used instead of the actual max vcpu limit.

Index: qemu/kvm-all.c
===================================================================

kvm-all.c +0 -0
@@ -1321,11 +1321,11 @@ static int kvm_max_vcpus(KVMState *s)
      * procedure from the kernel API documentation to cope with
      * older kernels that may be missing capabilities.
      */

kvm-all.c static int kvm_max_vcpus(KVMState *s) · line 1331

Quoted 10 lines
kvm-all.c +2 -2
-    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
+    ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
     if (ret) {
         return ret;
     }
-    ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
+    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
     if (ret) {
         return ret;
     }

This would break "working" configurations. Perhaps we should just warn if the VCPU limit exceeds KVM_CAP_NR_VCPUS, and fail if the VCPU limit exceeds KVM_CAP_MAX_VCPUS.

Quoted 2 lines

Patch 2 is fine, ok to apply it (since it fixes a real bug) and then you can work on top of it?

OK, please apply patch 2.

#4 lore raw

PATCH 2/2 kvm-all.c: max_cpus should not exceed KVM vcpu limit

In reply to Marcelo Tosatti

maxcpus, which specifies the maximum number of hotpluggable CPUs, should not exceed KVM's vcpu limit.

kvm-all.c +7 -0
Index: qemu/kvm-all.c
===================================================================
@@ -1391,6 +1391,13 @@ int kvm_init(void)
         goto err;
     }
 
+    if (max_cpus > max_vcpus) {
+        ret = -EINVAL;
+        fprintf(stderr, "Number of max_cpus requested (%d) exceeds max cpus "
+                "supported by KVM (%d)\n", max_cpus, max_vcpus);
+        goto err;
+    }
+
     s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
     if (s->vmfd < 0) {
 #ifdef TARGET_S390X
maintainer Applied
#5 lore raw

Re: [uq/master patch 2/2] kvm-all.c: max_cpus should not exceed KVM vcpu limit

Il 12/08/2013 21:56, Marcelo Tosatti ha scritto:

Quoted 26 lines

maxcpus, which specifies the maximum number of hotpluggable CPUs, should not exceed KVM's vcpu limit.

Index: qemu/kvm-all.c
===================================================================

kvm-all.c +7 -1
@@ -1391,6 +1391,13 @@ int kvm_init(void)
         goto err;
     }
 
+    if (max_cpus > max_vcpus) {
+        ret = -EINVAL;
+        fprintf(stderr, "Number of max_cpus requested (%d) exceeds max cpus "
+                "supported by KVM (%d)\n", max_cpus, max_vcpus);
+        goto err;
+    }
+
     s->vmfd = kvm_ioctl(s, KVM_CREATE_VM, 0);
     if (s->vmfd < 0) {
 #ifdef TARGET_S390X
 
 
--
Quoted 4 lines

To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

I applied this patch to uq/master. Thanks,

Paolo