|
|
7a3408 |
From 36a6bec33e026d7a66edfe95e640562fc7b49aaf Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <36a6bec33e026d7a66edfe95e640562fc7b49aaf@dist-git>
|
|
|
7a3408 |
From: Michal Privoznik <mprivozn@redhat.com>
|
|
|
7a3408 |
Date: Fri, 14 Aug 2015 16:06:30 +0200
|
|
|
7a3408 |
Subject: [PATCH] virNetDevBandwidthUpdateRate: turn class_id into integer
|
|
|
7a3408 |
|
|
|
7a3408 |
https://bugzilla.redhat.com/show_bug.cgi?id=1252473
|
|
|
7a3408 |
|
|
|
7a3408 |
This is no functional change. It's just that later in the series we
|
|
|
7a3408 |
will need to pass class_id as an integer.
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
7a3408 |
(cherry picked from commit 45090449c476d328541225f79d040345a781121a)
|
|
|
7a3408 |
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
src/network/bridge_driver.c | 4 ++--
|
|
|
7a3408 |
src/util/virnetdevbandwidth.c | 10 +++++++---
|
|
|
7a3408 |
src/util/virnetdevbandwidth.h | 5 ++---
|
|
|
7a3408 |
3 files changed, 11 insertions(+), 8 deletions(-)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
|
|
|
7a3408 |
index 3d6721b..17fc430 100644
|
|
|
7a3408 |
--- a/src/network/bridge_driver.c
|
|
|
7a3408 |
+++ b/src/network/bridge_driver.c
|
|
|
7a3408 |
@@ -4840,7 +4840,7 @@ networkPlugBandwidth(virNetworkObjPtr net,
|
|
|
7a3408 |
}
|
|
|
7a3408 |
/* update rate for non guaranteed NICs */
|
|
|
7a3408 |
new_rate -= net->floor_sum;
|
|
|
7a3408 |
- if (virNetDevBandwidthUpdateRate(net->def->bridge, "1:2",
|
|
|
7a3408 |
+ if (virNetDevBandwidthUpdateRate(net->def->bridge, 2,
|
|
|
7a3408 |
net->def->bandwidth, new_rate) < 0)
|
|
|
7a3408 |
VIR_WARN("Unable to update rate for 1:2 class on %s bridge",
|
|
|
7a3408 |
net->def->bridge);
|
|
|
7a3408 |
@@ -4891,7 +4891,7 @@ networkUnplugBandwidth(virNetworkObjPtr net,
|
|
|
7a3408 |
}
|
|
|
7a3408 |
/* update rate for non guaranteed NICs */
|
|
|
7a3408 |
new_rate -= net->floor_sum;
|
|
|
7a3408 |
- if (virNetDevBandwidthUpdateRate(net->def->bridge, "1:2",
|
|
|
7a3408 |
+ if (virNetDevBandwidthUpdateRate(net->def->bridge, 2,
|
|
|
7a3408 |
net->def->bandwidth, new_rate) < 0)
|
|
|
7a3408 |
VIR_WARN("Unable to update rate for 1:2 class on %s bridge",
|
|
|
7a3408 |
net->def->bridge);
|
|
|
7a3408 |
diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c
|
|
|
7a3408 |
index 6ae0877..da3a0d3 100644
|
|
|
7a3408 |
--- a/src/util/virnetdevbandwidth.c
|
|
|
7a3408 |
+++ b/src/util/virnetdevbandwidth.c
|
|
|
7a3408 |
@@ -638,7 +638,8 @@ virNetDevBandwidthUnplug(const char *brname,
|
|
|
7a3408 |
/**
|
|
|
7a3408 |
* virNetDevBandwidthUpdateRate:
|
|
|
7a3408 |
* @ifname: interface name
|
|
|
7a3408 |
- * @classid: ID of class to update
|
|
|
7a3408 |
+ * @id: unique identifier
|
|
|
7a3408 |
+ * @bandwidth: used to derive 'ceil' of class with @id
|
|
|
7a3408 |
* @new_rate: new rate
|
|
|
7a3408 |
*
|
|
|
7a3408 |
* This function updates the 'rate' attribute of HTB class.
|
|
|
7a3408 |
@@ -650,16 +651,18 @@ virNetDevBandwidthUnplug(const char *brname,
|
|
|
7a3408 |
*/
|
|
|
7a3408 |
int
|
|
|
7a3408 |
virNetDevBandwidthUpdateRate(const char *ifname,
|
|
|
7a3408 |
- const char *class_id,
|
|
|
7a3408 |
+ unsigned int id,
|
|
|
7a3408 |
virNetDevBandwidthPtr bandwidth,
|
|
|
7a3408 |
unsigned long long new_rate)
|
|
|
7a3408 |
{
|
|
|
7a3408 |
int ret = -1;
|
|
|
7a3408 |
virCommandPtr cmd = NULL;
|
|
|
7a3408 |
+ char *class_id = NULL;
|
|
|
7a3408 |
char *rate = NULL;
|
|
|
7a3408 |
char *ceil = NULL;
|
|
|
7a3408 |
|
|
|
7a3408 |
- if (virAsprintf(&rate, "%llukbps", new_rate) < 0 ||
|
|
|
7a3408 |
+ if (virAsprintf(&class_id, "1:%x", id) < 0 ||
|
|
|
7a3408 |
+ virAsprintf(&rate, "%llukbps", new_rate) < 0 ||
|
|
|
7a3408 |
virAsprintf(&ceil, "%llukbps", bandwidth->in->peak ?
|
|
|
7a3408 |
bandwidth->in->peak :
|
|
|
7a3408 |
bandwidth->in->average) < 0)
|
|
|
7a3408 |
@@ -677,6 +680,7 @@ virNetDevBandwidthUpdateRate(const char *ifname,
|
|
|
7a3408 |
|
|
|
7a3408 |
cleanup:
|
|
|
7a3408 |
virCommandFree(cmd);
|
|
|
7a3408 |
+ VIR_FREE(class_id);
|
|
|
7a3408 |
VIR_FREE(rate);
|
|
|
7a3408 |
VIR_FREE(ceil);
|
|
|
7a3408 |
return ret;
|
|
|
7a3408 |
diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h
|
|
|
7a3408 |
index 9b1d2a6..bceac2e 100644
|
|
|
7a3408 |
--- a/src/util/virnetdevbandwidth.h
|
|
|
7a3408 |
+++ b/src/util/virnetdevbandwidth.h
|
|
|
7a3408 |
@@ -68,11 +68,10 @@ int virNetDevBandwidthUnplug(const char *brname,
|
|
|
7a3408 |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
|
|
7a3408 |
|
|
|
7a3408 |
int virNetDevBandwidthUpdateRate(const char *ifname,
|
|
|
7a3408 |
- const char *class_id,
|
|
|
7a3408 |
+ unsigned int id,
|
|
|
7a3408 |
virNetDevBandwidthPtr bandwidth,
|
|
|
7a3408 |
unsigned long long new_rate)
|
|
|
7a3408 |
- ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
|
|
|
7a3408 |
- ATTRIBUTE_RETURN_CHECK;
|
|
|
7a3408 |
+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
|
|
7a3408 |
|
|
|
7a3408 |
int virNetDevBandwidthUpdateFilter(const char *ifname,
|
|
|
7a3408 |
const virMacAddr *ifmac_ptr,
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.5.0
|
|
|
7a3408 |
|