[libvirt] [PATCH] qemu_driver: Try KVM_CAP_MAX_VCPUS only if defined

Peter Krempa pkrempa at redhat.com
Wed Mar 13 10:42:30 UTC 2013


On 03/13/13 11:35, Michal Privoznik wrote:
> With our recent patch (1715c83b5f) we thrive to get the correct
> number of maximal VCPUs. However, we are using a constant from
> linux/kvm.h which may be not defined in every distro. Hence, we
> should guard usage of the constant with ifdef preprocessor
> directive.
> ---
>   src/qemu/qemu_driver.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index de53a1b..c3a8f24 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -1122,9 +1122,11 @@ kvmGetMaxVCPUs(void) {
>           return -1;
>       }
>
> +#ifdef KVM_CAP_MAX_VCPUS
>       /* at first try KVM_CAP_MAX_VCPUS to determine the maximum count */
>       if ((ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS)) > 0)
>           goto cleanup;
> +#endif /* KVM_CAP_MAX_VCPUS */

Bah. This feature was introduced not so long ago in the linux tree.

commit 8c3ba334f8588e1d5099f8602cf01897720e0eca
Author: Sasha Levin <levinsasha928 at gmail.com>
Date:   Mon Jul 18 17:17:15 2011 +0300

     KVM: x86: Raise the hard VCPU count limit

     The patch raises the hard limit of VCPU count to 254.

     This will allow developers to easily work on scalability
     and will allow users to test high VCPU setups easily without
     patching the kernel.

     To prevent possible issues with current setups, KVM_CAP_NR_VCPUS
     now returns the recommended VCPU limit (which is still 64) - this
     should be a safe value for everybody, while a new KVM_CAP_MAX_VCPUS
     returns the hard limit which is now 254.

$ git desc 8c3ba334f
v3.1-rc7-48-g8c3ba33
>
>       /* as a fallback get KVM_CAP_NR_VCPUS (the recommended maximum number of
>        * vcpus). Note that on most machines this is set to 160. */
>

ACK the fallback paths are designed gracefully in the function.

Peter




More information about the libvir-list mailing list