From 122cd16982b30dfd54731dd9f353e54f0e5628b8 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 29 Jan 2014 18:38:54 +0100 Subject: [PATCH] Revert "networkAllocateActualDevice: Set QoS for bridgeless networks too" This reverts commit 2996e6be19a13199ded7c2aa21039cca97318e01 and some parts of 2636dc8c4de83cd37bc0680a6fbc3f6d25023bd7. The former one tried to implement QoS setting on bridgeless networks. However, as discussed upstream [1], the patch is far away from being useful in even a single case. The whole idea of network QoS is to have aggregated limits over several interfaces. This patch is doing completely the opposite when merging two QoS settings (from the network and the domain interface) into one which is then set at the domain interface itself, not the network. The latter one is the test for the previous one. Now none of them makes sense. 1: https://www.redhat.com/archives/libvir-list/2014-January/msg01441.html Conflicts: tests/virnetdevbandwidthtest.c: New test has been introduced since then. --- src/libvirt_private.syms | 1 - src/network/bridge_driver.c | 25 +--------- src/util/virnetdevbandwidth.c | 84 ------------------------------- src/util/virnetdevbandwidth.h | 6 --- tests/virnetdevbandwidthtest.c | 91 ---------------------------------- 5 files changed, 2 insertions(+), 205 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7655247846..45f31171cc 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1470,7 +1470,6 @@ virNetDevBandwidthClear; virNetDevBandwidthCopy; virNetDevBandwidthEqual; virNetDevBandwidthFree; -virNetDevBandwidthMinimal; virNetDevBandwidthPlug; virNetDevBandwidthSet; virNetDevBandwidthUnplug; diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 6bdd1d66dd..0b43a67e8c 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -3284,30 +3284,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface) else if (portgroup && portgroup->bandwidth) bandwidth = portgroup->bandwidth; - /* For bridgeless networks we must take into account any QoS set to them. - * This is, however, a bit tricky. With bridged network there are two - * points where QoS can be set: domain's interface and the bridge. The - * limits on those differ (in general) in which case the lower limit gets - * into effect. For example, if domain's interface average is 10Mbps but - * the network's is just 1Mbps, the domain will not be able to send data - * any faster than 1Mbps. However, on bridgeless networks we can't just set - * those two points and let kernel do its job since we have only single - * point. Therefore, we must combine the QoS settings from both domain's - * interface and network and choose the minimal value from pairs. - */ - if (netdef->forward.type == VIR_NETWORK_FORWARD_PRIVATE || - netdef->forward.type == VIR_NETWORK_FORWARD_VEPA || - netdef->forward.type == VIR_NETWORK_FORWARD_PASSTHROUGH || - netdef->forward.type == VIR_NETWORK_FORWARD_HOSTDEV) { - if (virNetDevBandwidthMinimal(&iface->data.network.actual->bandwidth, - bandwidth, - netdef->bandwidth) < 0) - goto error; - } else if (bandwidth && - virNetDevBandwidthCopy(&iface->data.network.actual->bandwidth, - bandwidth) < 0) { + if (bandwidth && virNetDevBandwidthCopy(&iface->data.network.actual->bandwidth, + bandwidth) < 0) goto error; - } /* copy appropriate vlan info to actualNet */ if (iface->vlan.nTags > 0) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index 273c2db8c8..ed6a19d7fa 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -27,7 +27,6 @@ #include "viralloc.h" #include "virerror.h" #include "virstring.h" -#include "virutil.h" #define VIR_FROM_THIS VIR_FROM_NONE @@ -589,86 +588,3 @@ cleanup: VIR_FREE(ceil); return ret; } - -static void -virNetDevBandwidthRateMinimal(virNetDevBandwidthRatePtr result, - virNetDevBandwidthRatePtr band1, - virNetDevBandwidthRatePtr band2) -{ - if (!band1 || !band2) { - memcpy(result, band1 ? band1 : band2, sizeof(*result)); - return; - } - - /* We can't do a simple MIN() here, because zero value doesn't mean the - * narrowest limit, but an unset value. Hence we need symmetric F(a, b) - * so that: - * F(a, 0) = F(0, a) = a; special corner case: F(0, 0) = 0 - * F(a, b) = MIN(a, b) for a != 0 and b != 0 - */ -#define NON_ZERO_MIN(a, b) \ - ((a) && (b) ? MIN(a, b) : (a) ? (a) : (b)) - - result->average = NON_ZERO_MIN(band1->average, band2->average); - result->peak = NON_ZERO_MIN(band1->peak, band2->peak); - result->floor = NON_ZERO_MIN(band1->floor, band2->floor); - result->burst = NON_ZERO_MIN(band1->burst, band2->burst); -} - -/** - * virNetDevBandwidthMinimal: - * @result: the minimal intersect of @band1 and @band2 - * @band1: the first bandwidth - * @band2: the second bandwidth - * - * Combine the two bandwidths into one with choosing the minimal value for each - * pair of items within bandwidth structure. The resulting bandwidth is stored - * into @result. In case of both @band1 and @band2 being NULL pointers, the - * @ret is set to NULL as well as there's no bandwidth to calculate (this is - * not considered an error). The caller is responsible for freeing @result when - * no longer needed. - * - * Returns 0 on success, -1 otherwise. - */ -int -virNetDevBandwidthMinimal(virNetDevBandwidthPtr *result, - virNetDevBandwidthPtr band1, - virNetDevBandwidthPtr band2) -{ - int ret = -1; - - if (!band1 && !band2) { - /* Nothing to compute */ - *result = NULL; - return 0; - } - - if (!band1 || !band2) { - /* Sweet, one of the args is NULL. The non-NULL one - * is our minimum then. */ - return virNetDevBandwidthCopy(result, band1 ? band1 : band2); - } - - if (VIR_ALLOC(*result) < 0) - goto cleanup; - - if (band1->in || band2->in) { - if (VIR_ALLOC((*result)->in) < 0) - goto cleanup; - - virNetDevBandwidthRateMinimal((*result)->in, band1->in, band2->in); - } - - if (band1->out || band2->out) { - if (VIR_ALLOC((*result)->out) < 0) - goto cleanup; - - virNetDevBandwidthRateMinimal((*result)->out, band1->out, band2->out); - } - - ret = 0; -cleanup: - if (ret < 0) - VIR_FREE(*result); - return ret; -} diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h index ea40df461f..4606a07526 100644 --- a/src/util/virnetdevbandwidth.h +++ b/src/util/virnetdevbandwidth.h @@ -74,10 +74,4 @@ int virNetDevBandwidthUpdateRate(const char *ifname, unsigned long long new_rate) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; - -int -virNetDevBandwidthMinimal(virNetDevBandwidthPtr *result, - virNetDevBandwidthPtr band1, - virNetDevBandwidthPtr band2) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK; #endif /* __VIR_NETDEV_BANDWIDTH_H__ */ diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 345a0dd61a..609deb80d1 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -61,56 +61,6 @@ struct testSetStruct { goto cleanup; \ } while (0) -static int -testVirNetDevBandwidthMinimal(const void *data) -{ - int ret = -1; - const struct testMinimalStruct *info = data; - virNetDevBandwidthPtr expected_result = NULL, result = NULL, - band1 = NULL, band2 = NULL; - - - /* Parse given XMLs */ - PARSE(info->expected_result, expected_result); - PARSE(info->band1, band1); - PARSE(info->band2, band2); - - if (virNetDevBandwidthMinimal(&result, band1, band2) < 0) - goto cleanup; - - if (!virNetDevBandwidthEqual(expected_result, result)) { - virBuffer exp_buf = VIR_BUFFER_INITIALIZER, - res_buf = VIR_BUFFER_INITIALIZER; - char *exp = NULL, *res = NULL; - - fprintf(stderr, "expected_result != result"); - - if (virNetDevBandwidthFormat(expected_result, &exp_buf) < 0 || - virNetDevBandwidthFormat(result, &res_buf) < 0 || - !(exp = virBufferContentAndReset(&exp_buf)) || - !(res = virBufferContentAndReset(&res_buf))) { - fprintf(stderr, "Failed to fail"); - virBufferFreeAndReset(&exp_buf); - virBufferFreeAndReset(&res_buf); - VIR_FREE(exp); - VIR_FREE(res); - goto cleanup; - } - - virtTestDifference(stderr, exp, res); - VIR_FREE(exp); - VIR_FREE(res); - } - - ret = 0; -cleanup: - virNetDevBandwidthFree(expected_result); - virNetDevBandwidthFree(result); - virNetDevBandwidthFree(band1); - virNetDevBandwidthFree(band2); - return ret; -} - static int testVirNetDevBandwidthSet(const void *data) { @@ -159,15 +109,6 @@ mymain(void) { int ret = 0; -#define DO_TEST_MINIMAL(r, ...) \ - do { \ - struct testMinimalStruct data = {r, __VA_ARGS__}; \ - if (virtTestRun("virNetDevBandwidthMinimal", \ - testVirNetDevBandwidthMinimal, \ - &data) < 0) \ - ret = -1; \ - } while (0) - #define DO_TEST_SET(Band, Exp_cmd, ...) \ do { \ struct testSetStruct data = {.band = Band, \ @@ -180,38 +121,6 @@ mymain(void) } while (0) - DO_TEST_MINIMAL(NULL, NULL, NULL); - - DO_TEST_MINIMAL("" - " " - " " - "", - .band1 = "" - " " - " " - ""); - - DO_TEST_MINIMAL("" - " " - " " - "", - .band2 = "" - " " - " " - ""); - DO_TEST_MINIMAL("" - " " - " " - "", - "" - " " - " " - "", - "" - " " - " " - ""); - DO_TEST_SET(("" " " " "