]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu_driver: Try KVM_CAP_MAX_VCPUS only if defined
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 13 Mar 2013 10:29:38 +0000 (11:29 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 13 Mar 2013 13:31:29 +0000 (14:31 +0100)
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. This was introduced in kernel:

    commit 8c3ba334f8588e1d5099f8602cf01897720e0eca
    Author: Sasha Levin <levinsasha928@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

src/qemu/qemu_driver.c

index de53a1babcf2919f705a4f669c63cc5002fd7a05..c3a8f24edf9f6842cee06438339bf79e0094e0af 100644 (file)
@@ -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 */
 
     /* as a fallback get KVM_CAP_NR_VCPUS (the recommended maximum number of
      * vcpus). Note that on most machines this is set to 160. */