[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus

From: Peter Maydell
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v2] vl.c: Fix max_cpus
Date: Mon, 30 Jul 2012 17:39:50 +0100

On 25 July 2012 12:11,  <address@hidden> wrote:
> From: Dunrong Huang <address@hidden>
> The VCPU count limit in kernel now is 254, defined by KVM_MAX_VCPUS
> in kernel's header files. But the count limit in QEMU is 255,
> so QEMU will failed to start if user passes "-enable-kvm" and "-smp 255"
> to it.
> Exit QEMU with an error if KVM is enabled and number of SMP cpus requested
> exceeds KVM_MAX_VCPUS.

I think this is the wrong approach:
 * KVM_MAX_VCPUS isn't a constant that the kernel exposes to userspace
 * it is different on different host architectures (254 happens to
   be the x86 value at the moment)
 * on PPC it is set to NR_CPUS so the maximum value will depend on
   the host system
 * it might change in the future, perhaps

If we want to identify the maximum possible number of CPUs under
KVM in advance of trying to create them all, the kernel documentation
specifies how to do this properly:

# The maximum possible value for max_vcpus can be retrieved using the
# KVM_CAP_MAX_VCPUS of the KVM_CHECK_EXTENSION ioctl() at run-time.
# If the KVM_CAP_NR_VCPUS does not exist, you should assume that
# max_vcpus is 4 cpus max.
# If the KVM_CAP_MAX_VCPUS does not exist, you should assume that
# max_vcpus is the same as the value returned from KVM_CAP_NR_VCPUS.

You could just implement this check in kvm-all.c:kvm_init(), in fact,
since smp_cpus has been set up by that point. Then you can print a
useful message and we'll fail nicely.

-- PMM

reply via email to

[Prev in Thread] Current Thread [Next in Thread]