]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
KVM: PPC: Add KVM_CAP_NR_VCPUS and KVM_CAP_MAX_VCPUS
authorMatt Evans <matt@ozlabs.org>
Wed, 7 Dec 2011 16:55:57 +0000 (16:55 +0000)
committerAvi Kivity <avi@redhat.com>
Mon, 5 Mar 2012 12:52:38 +0000 (14:52 +0200)
PPC KVM lacks these two capabilities, and as such a userland system must assume
a max of 4 VCPUs (following api.txt).  With these, a userland can determine
a more realistic limit.

Signed-off-by: Matt Evans <matt@ozlabs.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/powerpc/kvm/powerpc.c

index 25171037a36cdb5455dcc484c968752da269a767..f4380cb264e093b668f9646b61a046b7f31a9335 100644 (file)
@@ -249,6 +249,22 @@ int kvm_dev_ioctl_check_extension(long ext)
                r = cpu_has_feature(CPU_FTR_ARCH_206) ? 1 : 0;
                break;
 #endif
+       case KVM_CAP_NR_VCPUS:
+               /*
+                * Recommending a number of CPUs is somewhat arbitrary; we
+                * return the number of present CPUs for -HV (since a host
+                * will have secondary threads "offline"), and for other KVM
+                * implementations just count online CPUs.
+                */
+#ifdef CONFIG_KVM_BOOK3S_64_HV
+               r = num_present_cpus();
+#else
+               r = num_online_cpus();
+#endif
+               break;
+       case KVM_CAP_MAX_VCPUS:
+               r = KVM_MAX_VCPUS;
+               break;
        default:
                r = 0;
                break;