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

Re: [libvirt] [PATCH] Fix initialization of current vcpus in libxl driver



Eric Blake wrote:
> On 05/24/2011 10:33 AM, Jim Fehlig wrote:
>   
>> This works in the libxl driver since cur_vcpus is an int.  But
>> vcpu_avail is a long in xenxs/xen_sxpr.c and I'm hoping there is
>> something better than the following approach
>>
>> diff --git a/src/xenxs/xen_sxpr.c b/src/xenxs/xen_sxpr.c
>> index 4cebb21..dc000a8 100644
>> --- a/src/xenxs/xen_sxpr.c
>> +++ b/src/xenxs/xen_sxpr.c
>> @@ -2006,9 +2006,14 @@ xenFormatSxpr(virConnectPtr conn,
>>      virBufferAsprintf(&buf, "(vcpus %u)", def->maxvcpus);
>>      /* Computing the vcpu_avail bitmask works because MAX_VIRT_CPUS is
>>         either 32, or 64 on a platform where long is big enough.  */
>> -    if (def->vcpus < def->maxvcpus)
>> -        virBufferAsprintf(&buf, "(vcpu_avail %lu)",
>> -                          def->vcpus == 32 ? 1 << 31 : (1UL <<
>> def->vcpus) - 1);
>>     
>
>
>   
>> +    if (def->vcpus < def->maxvcpus) {
>>     
>
> If def->maxvcpus is 32, then:
>
>   
>> +        if (sizeof(long) == 4 && def->vcpus == 32)
>>     
>
> this conditional will never be reached (def->vcpus is less than
> def->maxvcpus).
>
> So the existing ((1UL << def->vcpus) -1) never calls the non-portable
> 1UL<<32 (or 1UL<<64); so it never overflows.
>   

Ok, so I just need to handle this in the libxl driver.  I'll post a V2.

Regards,
Jim


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