Skip to content

Commit b543403

Browse files
evansm7avikivity
authored andcommitted
KVM: PPC: Add KVM_CAP_NR_VCPUS and KVM_CAP_MAX_VCPUS
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 <[email protected]> Signed-off-by: Alexander Graf <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent 03cdab5 commit b543403

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

arch/powerpc/kvm/powerpc.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,22 @@ int kvm_dev_ioctl_check_extension(long ext)
249249
r = cpu_has_feature(CPU_FTR_ARCH_206) ? 1 : 0;
250250
break;
251251
#endif
252+
case KVM_CAP_NR_VCPUS:
253+
/*
254+
* Recommending a number of CPUs is somewhat arbitrary; we
255+
* return the number of present CPUs for -HV (since a host
256+
* will have secondary threads "offline"), and for other KVM
257+
* implementations just count online CPUs.
258+
*/
259+
#ifdef CONFIG_KVM_BOOK3S_64_HV
260+
r = num_present_cpus();
261+
#else
262+
r = num_online_cpus();
263+
#endif
264+
break;
265+
case KVM_CAP_MAX_VCPUS:
266+
r = KVM_MAX_VCPUS;
267+
break;
252268
default:
253269
r = 0;
254270
break;

0 commit comments

Comments
 (0)