Re: [PATCH v1 04/11] bandwidth: Create rate update function

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

 



On 30.11.2012 18:56, Laine Stump wrote:
> On 11/19/2012 11:51 AM, Michal Privoznik wrote:
>> This will be used whenever a NIC with guaranteed throughput is to
>> be plugged into a bridge. It will adjust the average throughput of
>> non guaranteed NICs (classid 1:2) to meet new requirements.
>> ---
>>  src/util/virnetdevbandwidth.c |   49 +++++++++++++++++++++++++++++++++++++++++
>>  src/util/virnetdevbandwidth.h |    6 +++++
>>  2 files changed, 55 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
>> index 9597dcd..3abe7e2 100644
>> --- a/src/util/virnetdevbandwidth.c
>> +++ b/src/util/virnetdevbandwidth.c
>> @@ -463,3 +463,52 @@ cleanup:
>>      virCommandFree(cmd);
>>      return ret;
>>  }
>> +
>> +/**
>> + * virNetDevBandwidthUpdateRate:
>> + * @ifname: interface name
>> + * @classid: ID of class to update
>> + * @new_rate: new rate
>> + *
>> + * This function updates the 'rate' attribute of HTB class.
>> + * It can be used whenever a new interface is plugged to a
>> + * bridge to adjust average throughput of non guaranteed
>> + * NICs.
> 
> So it's changing the "average" for that NIC to something other than what
> was configured? Is a record of this kept anywhere? (or maybe it's not
> necessary).

Right, but it will be used only for changing the average of the first
child class on the bridge, that is 1:2 which is the class where all not
guaranteed traffic is sent. And yeah - I keep track of it in the next
patches - it's called floor_sum.

> 
>> + *
>> + * Returns 0 on success, -1 otherwise.
>> + */
>> +int
>> +virNetDevBandwidthUpdateRate(const char *ifname,
>> +                             const char *class_id,
>> +                             virNetDevBandwidthPtr bandwidth,
>> +                             unsigned long long new_rate)
>> +{
>> +    int ret = -1;
>> +    virCommandPtr cmd = NULL;
>> +    char *rate = NULL;
>> +    char *ceil = NULL;
>> +
>> +    if (virAsprintf(&rate, "%llukbps", new_rate) < 0 ||
>> +        virAsprintf(&ceil, "%llukbps", bandwidth->in->peak ?
>> +                    bandwidth->in->peak :
>> +                    bandwidth->in->average) < 0) {
>> +        virReportOOMError();
>> +        goto cleanup;
>> +    }
>> +
>> +    cmd = virCommandNew(TC);
>> +    virCommandAddArgList(cmd, "class", "change", "dev", ifname,
>> +                         "classid", class_id, "htb", "rate", rate,
>> +                         "ceil", ceil, NULL);
>> +
>> +    if (virCommandRun(cmd, NULL) < 0)
>> +        goto cleanup;
>> +
>> +    ret = 0;
>> +
>> +cleanup:
>> +    virCommandFree(cmd);
>> +    VIR_FREE(rate);
>> +    VIR_FREE(ceil);
>> +    return ret;
>> +}
>> diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h
>> index 19eb418..a5d595e 100644
>> --- a/src/util/virnetdevbandwidth.h
>> +++ b/src/util/virnetdevbandwidth.h
>> @@ -67,4 +67,10 @@ int virNetDevBandwidthUnplug(const char *brname,
>>                               unsigned int id)
>>      ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
>>  
>> +int virNetDevBandwidthUpdateRate(const char *ifname,
>> +                                 const char *class_id,
>> +                                 virNetDevBandwidthPtr bandwidth,
>> +                                 unsigned long long new_rate)
>> +    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
>> +    ATTRIBUTE_RETURN_CHECK;
>>  #endif /* __VIR_NETDEV_BANDWIDTH_H__ */
> 
> ACK.
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list
> 

--
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]