[libvirt] [PATCH 2/6] port allocator: remove range on manual port reserving

Nikolay Shirokovskiy nshirokovskiy at virtuozzo.com
Thu Feb 1 07:56:35 UTC 2018



On 29.01.2018 09:09, Michal Privoznik wrote:
> On 12/20/2017 07:35 AM, Nikolay Shirokovskiy wrote:
>> Range check in virPortAllocatorSetUsed is not useful anymore
>> when we manage ports for entire unsigned short range values.
>> ---
>>  src/bhyve/bhyve_command.c   |  4 +---
>>  src/bhyve/bhyve_process.c   |  4 +---
>>  src/qemu/qemu_process.c     | 41 +++++++++++------------------------------
>>  src/util/virportallocator.c |  9 +--------
>>  src/util/virportallocator.h |  4 +---
>>  5 files changed, 15 insertions(+), 47 deletions(-)
>>
> 
>> diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
>> index cd64356..76346c7 100644
>> --- a/src/util/virportallocator.c
>> +++ b/src/util/virportallocator.c
>> @@ -293,8 +293,7 @@ int virPortAllocatorRelease(virPortRangePtr range,
>>      return ret;
>>  }
>>  
>> -int virPortAllocatorSetUsed(virPortRangePtr range,
>> -                            unsigned short port,
>> +int virPortAllocatorSetUsed(unsigned short port,
>>                              bool value)
>>  {
>>      int ret = -1;
>> @@ -305,12 +304,6 @@ int virPortAllocatorSetUsed(virPortRangePtr range,
>>  
>>      virObjectLock(pa);
>>  
>> -    if (port < range->start ||
>> -        port > range->end) {
>> -        ret = 0;
>> -        goto cleanup;
>> -    }
>> -
> 
> 
> 1: ^^^
> 
>>      if (value) {
>>          if (virBitmapIsBitSet(pa->bitmap, port) ||
>>              virBitmapSetBit(pa->bitmap, port) < 0) {
>> diff --git a/src/util/virportallocator.h b/src/util/virportallocator.h
>> index e9b9038..8511eca 100644
>> --- a/src/util/virportallocator.h
>> +++ b/src/util/virportallocator.h
>> @@ -45,8 +45,6 @@ int virPortAllocatorAcquire(virPortRangePtr range,
>>  int virPortAllocatorRelease(virPortRangePtr range,
>>                              unsigned short port);
>>  
>> -int virPortAllocatorSetUsed(virPortRangePtr range,
>> -                            unsigned short port,
>> -                            bool value);
>> +int virPortAllocatorSetUsed(unsigned short port, bool value);
> 
> I'm not a big fan of this. Since virPortRange (or whatever name you'll
> give it) is going to have a pointer to virPortAllocator object I rather
> leave this signature as is. The idea (hunk 1) makes sense though
> 

So this depends on how we get virPortAllocator object reference. Let's discuss later
after we come to agreement on previous patch.

Nikolay




More information about the libvir-list mailing list