On 30 July 2012 19:22,  <riegama...@gmail.com> 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

Reply via email to