提交 122cd169 编写于 作者: M Michal Privoznik

Revert "networkAllocateActualDevice: Set QoS for bridgeless networks too"

This reverts commit 2996e6be
and some parts of 2636dc8c.

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.
上级 7bcbb53e
......@@ -1470,7 +1470,6 @@ virNetDevBandwidthClear;
virNetDevBandwidthCopy;
virNetDevBandwidthEqual;
virNetDevBandwidthFree;
virNetDevBandwidthMinimal;
virNetDevBandwidthPlug;
virNetDevBandwidthSet;
virNetDevBandwidthUnplug;
......
......@@ -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)
......
......@@ -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;
}
......@@ -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__ */
......@@ -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("<bandwidth>"
" <inbound average='1000' peak='5000' burst='5120'/>"
" <outbound average='128' peak='256' burst='256'/>"
"</bandwidth>",
.band1 = "<bandwidth>"
" <inbound average='1000' peak='5000' burst='5120'/>"
" <outbound average='128' peak='256' burst='256'/>"
"</bandwidth>");
DO_TEST_MINIMAL("<bandwidth>"
" <inbound average='1000' peak='5000' burst='5120'/>"
" <outbound average='128' peak='256' burst='256'/>"
"</bandwidth>",
.band2 = "<bandwidth>"
" <inbound average='1000' peak='5000' burst='5120'/>"
" <outbound average='128' peak='256' burst='256'/>"
"</bandwidth>");
DO_TEST_MINIMAL("<bandwidth>"
" <inbound average='1' peak='2' floor='3' burst='4'/>"
" <outbound average='5' peak='6' burst='7'/>"
"</bandwidth>",
"<bandwidth>"
" <inbound average='1' peak='2' burst='4'/>"
" <outbound average='0' burst='7'/>"
"</bandwidth>",
"<bandwidth>"
" <inbound average='1' peak='2' floor='3'/>"
" <outbound average='5' peak='6'/>"
"</bandwidth>");
DO_TEST_SET(("<bandwidth>"
" <inbound average='1' peak='2' floor='3' burst='4'/>"
" <outbound average='5' peak='6' burst='7'/>"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册