Re: [Qemu-devel] [PATCH] kvm: Check if smp_cpus exceeds max cpus supported by kvm

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

 



On 30 July 2012 19:22,  <riegamaths@xxxxxxxxx> wrote:
> +static int kvm_max_vcpus(KVMState *s)
> +{
> +    int max_vcpus = 4;
> +    int ret;
> +    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
> +    if (ret) {
> +        max_vcpus = ret;
> +    } else {
> +       ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
> +        if (ret) {
> +            max_vcpus = ret;
> +        }
> +   }
> +
> +    return max_vcpus;
> +}

A small thing, but I think having code flow like:

    /* Find number of supported CPUs using the recommended
     * procedure from the kernel API documentation to cope with
     * older kernels that may be missing capabilities.
     */
    ret = kvm_check_extension(s, KVM_CAP_MAX_VCPUS);
    if (ret) {
        return ret;
    }
    ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
    if (ret) {
        return ret;
    }
    return 4;

would be clearer.

(also I think a comment helps suggest that 4 isn't a magic
number we made up ourselves :-))

-- PMM
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux