}
/* update rate for non guaranteed NICs */
new_rate -= net->floor_sum;
- if (virNetDevBandwidthUpdateRate(net->def->bridge, "1:2",
+ if (virNetDevBandwidthUpdateRate(net->def->bridge, 2,
net->def->bandwidth, new_rate) < 0)
VIR_WARN("Unable to update rate for 1:2 class on %s bridge",
net->def->bridge);
}
/* update rate for non guaranteed NICs */
new_rate -= net->floor_sum;
- if (virNetDevBandwidthUpdateRate(net->def->bridge, "1:2",
+ if (virNetDevBandwidthUpdateRate(net->def->bridge, 2,
net->def->bandwidth, new_rate) < 0)
VIR_WARN("Unable to update rate for 1:2 class on %s bridge",
net->def->bridge);
/**
* virNetDevBandwidthUpdateRate:
* @ifname: interface name
- * @classid: ID of class to update
+ * @id: unique identifier
+ * @bandwidth: used to derive 'ceil' of class with @id
* @new_rate: new rate
*
* This function updates the 'rate' attribute of HTB class.
*/
int
virNetDevBandwidthUpdateRate(const char *ifname,
- const char *class_id,
+ unsigned int id,
virNetDevBandwidthPtr bandwidth,
unsigned long long new_rate)
{
int ret = -1;
virCommandPtr cmd = NULL;
+ char *class_id = NULL;
char *rate = NULL;
char *ceil = NULL;
- if (virAsprintf(&rate, "%llukbps", new_rate) < 0 ||
+ if (virAsprintf(&class_id, "1:%x", id) < 0 ||
+ virAsprintf(&rate, "%llukbps", new_rate) < 0 ||
virAsprintf(&ceil, "%llukbps", bandwidth->in->peak ?
bandwidth->in->peak :
bandwidth->in->average) < 0)
cleanup:
virCommandFree(cmd);
+ VIR_FREE(class_id);
VIR_FREE(rate);
VIR_FREE(ceil);
return ret;
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevBandwidthUpdateRate(const char *ifname,
- const char *class_id,
+ unsigned int id,
virNetDevBandwidthPtr bandwidth,
unsigned long long new_rate)
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
- ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
int virNetDevBandwidthUpdateFilter(const char *ifname,
const virMacAddr *ifmac_ptr,