Re: [PATCH v5 3/5] domain: Introduce virDomainIOThreadsPin{Add|Del}

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

 




On 03/09/2015 03:43 PM, Pavel Hrdina wrote:
> On Fri, Mar 06, 2015 at 09:05:43AM -0500, John Ferlan wrote:
>> https://bugzilla.redhat.com/show_bug.cgi?id=1135491
>>
>> More or less a virtual copy of the existing virDomainVcpuPin{Add|Del} API's.
>>
>> NB: The IOThreads implementation "reused" the virDomainVcpuPinDefPtr
>> since it provided everything necessary - an "id" and a "map" for each
>> thread id configured.
>>
>> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
>> ---
>>  src/conf/domain_conf.c   | 64 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  src/conf/domain_conf.h   | 10 ++++++++
>>  src/libvirt_private.syms |  2 ++
>>  3 files changed, 76 insertions(+)
>>
>> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>> index 01a3fbc..fe0c443 100644
>> --- a/src/conf/domain_conf.c
>> +++ b/src/conf/domain_conf.c
>> @@ -16798,6 +16798,70 @@ virDomainEmulatorPinDel(virDomainDefPtr def)
>>      return 0;
>>  }
>>  
>> +int
>> +virDomainIOThreadsPinAdd(virDomainVcpuPinDefPtr **iothreadspin_list,
>> +                         size_t *niothreadspin,
>> +                         unsigned char *cpumap,
>> +                         int maplen,
>> +                         int iothread_val)
>> +{
> 
> I would use iothread_id instead and probably change it to unsigned int as the
> public API also uses unsigned int for iothread_id.  Which reminds me, why not
> use unsigned int for maplen too as it must be 1 or more?  Before pushing the
> first two patches, please reconsider using unsigned int for maplen.

w/r/t: iothread_val - right I had made that change in qemu_driver, but
since these functions didn't change I never stopped here again...

w/r/t: maplen - monkey see, monkey do - maplen is an 'int' for vcpu's
and emulator as well

John
> 
>> +    /* IOThreads share the virDomainVcpuPinDefPtr */
>> +    virDomainVcpuPinDefPtr iothreadpin = NULL;
>> +
>> +    if (!iothreadspin_list)
>> +        return -1;
>> +
>> +    iothreadpin = virDomainVcpuPinFindByVcpu(*iothreadspin_list,
>> +                                             *niothreadspin,
>> +                                             iothread_val);
>> +    if (iothreadpin) {
>> +        iothreadpin->vcpuid = iothread_val;
>> +        virBitmapFree(iothreadpin->cpumask);
>> +        iothreadpin->cpumask = virBitmapNewData(cpumap, maplen);
>> +        if (!iothreadpin->cpumask)
>> +            return -1;
>> +
>> +        return 0;
>> +    }
>> +
>> +    /* No existing iothreadpin matches iothread_val, adding a new one */
>> +
>> +    if (VIR_ALLOC(iothreadpin) < 0)
>> +        goto error;
>> +
>> +    iothreadpin->vcpuid = iothread_val;
>> +    iothreadpin->cpumask = virBitmapNewData(cpumap, maplen);
>> +    if (!iothreadpin->cpumask)
>> +        goto error;
>> +
>> +    if (VIR_APPEND_ELEMENT(*iothreadspin_list, *niothreadspin, iothreadpin) < 0)
>> +        goto error;
>> +
>> +    return 0;
>> +
>> + error:
>> +    virDomainVcpuPinDefFree(iothreadpin);
>> +    return -1;
>> +}
>> +
>> +void
>> +virDomainIOThreadsPinDel(virDomainDefPtr def,
>> +                         int iothread_val)
> 
> Same here, better to go with iothread_id.
> 
>> +{
>> +    size_t i;
>> +    /* IOThreads share the virDomainVcpuPinDefPtr */
>> +    virDomainVcpuPinDefPtr *iothreadspin_list = def->cputune.iothreadspin;
>> +
>> +    for (i = 0; i < def->cputune.niothreadspin; i++) {
>> +        if (iothreadspin_list[i]->vcpuid == iothread_val) {
>> +            virBitmapFree(iothreadspin_list[i]->cpumask);
>> +            VIR_DELETE_ELEMENT(def->cputune.iothreadspin, i,
>> +                               def->cputune.niothreadspin);
>> +            return;
>> +        }
>> +    }
>> +}
>> +
>>  static int
>>  virDomainEventActionDefFormat(virBufferPtr buf,
>>                                int type,
> 
> ACK
> 
> Pavel
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]