mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-04 16:03:49 +00:00
QoS: Set classes and filters in proper direction
Similarly to previous patch, for some types of interface domain and host are on the same side of RX/TX barrier. In that case, we need to set up the QoS differently. Well, swapped. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
d86fd2402e
commit
cea3715b2e
@ -3981,7 +3981,8 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
|||||||
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
||||||
if (actualBandwidth) {
|
if (actualBandwidth) {
|
||||||
if (virNetDevSupportBandwidth(actualType)) {
|
if (virNetDevSupportBandwidth(actualType)) {
|
||||||
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
|
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
|
||||||
|
!virDomainNetTypeSharesHostView(net)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
VIR_WARN("setting bandwidth on interfaces of "
|
VIR_WARN("setting bandwidth on interfaces of "
|
||||||
|
@ -601,7 +601,8 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
|
|||||||
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
||||||
if (actualBandwidth) {
|
if (actualBandwidth) {
|
||||||
if (virNetDevSupportBandwidth(type)) {
|
if (virNetDevSupportBandwidth(type)) {
|
||||||
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
|
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
|
||||||
|
!virDomainNetTypeSharesHostView(net)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
VIR_WARN("setting bandwidth on interfaces of "
|
VIR_WARN("setting bandwidth on interfaces of "
|
||||||
|
@ -2445,7 +2445,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver,
|
|||||||
VIR_FORCE_CLOSE(tapfd);
|
VIR_FORCE_CLOSE(tapfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true) < 0)
|
if (virNetDevBandwidthSet(def->bridge, def->bandwidth, true, true) < 0)
|
||||||
goto err5;
|
goto err5;
|
||||||
|
|
||||||
VIR_FREE(macTapIfName);
|
VIR_FREE(macTapIfName);
|
||||||
|
@ -8578,7 +8578,8 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver,
|
|||||||
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
||||||
if (actualBandwidth) {
|
if (actualBandwidth) {
|
||||||
if (virNetDevSupportBandwidth(actualType)) {
|
if (virNetDevSupportBandwidth(actualType)) {
|
||||||
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
|
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
|
||||||
|
!virDomainNetTypeSharesHostView(net)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
VIR_WARN("setting bandwidth on interfaces of "
|
VIR_WARN("setting bandwidth on interfaces of "
|
||||||
|
@ -11182,11 +11182,13 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
|
|||||||
if (!networkBandwidthChangeAllowed(net, newBandwidth))
|
if (!networkBandwidthChangeAllowed(net, newBandwidth))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virNetDevBandwidthSet(net->ifname, newBandwidth, false) < 0 ||
|
if (virNetDevBandwidthSet(net->ifname, newBandwidth, false,
|
||||||
|
!virDomainNetTypeSharesHostView(net)) < 0 ||
|
||||||
networkBandwidthUpdate(net, newBandwidth) < 0) {
|
networkBandwidthUpdate(net, newBandwidth) < 0) {
|
||||||
ignore_value(virNetDevBandwidthSet(net->ifname,
|
ignore_value(virNetDevBandwidthSet(net->ifname,
|
||||||
net->bandwidth,
|
net->bandwidth,
|
||||||
false));
|
false,
|
||||||
|
!virDomainNetTypeSharesHostView(net)));
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1209,7 +1209,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
||||||
if (actualBandwidth) {
|
if (actualBandwidth) {
|
||||||
if (virNetDevSupportBandwidth(actualType)) {
|
if (virNetDevSupportBandwidth(actualType)) {
|
||||||
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false) < 0)
|
if (virNetDevBandwidthSet(net->ifname, actualBandwidth, false,
|
||||||
|
!virDomainNetTypeSharesHostView(net)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
} else {
|
} else {
|
||||||
VIR_WARN("setting bandwidth on interfaces of "
|
VIR_WARN("setting bandwidth on interfaces of "
|
||||||
@ -3362,7 +3363,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver,
|
|||||||
if (needBandwidthSet) {
|
if (needBandwidthSet) {
|
||||||
if (virNetDevBandwidthSet(newdev->ifname,
|
if (virNetDevBandwidthSet(newdev->ifname,
|
||||||
virDomainNetGetActualBandwidth(newdev),
|
virDomainNetGetActualBandwidth(newdev),
|
||||||
false) < 0)
|
false,
|
||||||
|
!virDomainNetTypeSharesHostView(newdev)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
needReplaceDevDef = true;
|
needReplaceDevDef = true;
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,7 @@ virNetDevBandwidthManipulateFilter(const char *ifname,
|
|||||||
* @ifname: on which interface
|
* @ifname: on which interface
|
||||||
* @bandwidth: rates to set (may be NULL)
|
* @bandwidth: rates to set (may be NULL)
|
||||||
* @hierarchical_class: whether to create hierarchical class
|
* @hierarchical_class: whether to create hierarchical class
|
||||||
|
* @swapped: true if IN/OUT should be set contrariwise
|
||||||
*
|
*
|
||||||
* This function enables QoS on specified interface
|
* This function enables QoS on specified interface
|
||||||
* and set given traffic limits for both, incoming
|
* and set given traffic limits for both, incoming
|
||||||
@ -182,14 +183,23 @@ virNetDevBandwidthManipulateFilter(const char *ifname,
|
|||||||
* hierarchical class. It is used to guarantee minimal
|
* hierarchical class. It is used to guarantee minimal
|
||||||
* throughput ('floor' attribute in NIC).
|
* throughput ('floor' attribute in NIC).
|
||||||
*
|
*
|
||||||
|
* If @swapped is set, the IN part of @bandwidth is set on
|
||||||
|
* @ifname's TX, and vice versa. If it is not set, IN is set on
|
||||||
|
* RX and OUT on TX. This is because for some types of interfaces
|
||||||
|
* domain and the host live on the same side of the interface (so
|
||||||
|
* domain's RX/TX is host's RX/TX), and for some it's swapped
|
||||||
|
* (domain's RX/TX is hosts's TX/RX).
|
||||||
|
*
|
||||||
* Return 0 on success, -1 otherwise.
|
* Return 0 on success, -1 otherwise.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
virNetDevBandwidthSet(const char *ifname,
|
virNetDevBandwidthSet(const char *ifname,
|
||||||
virNetDevBandwidthPtr bandwidth,
|
virNetDevBandwidthPtr bandwidth,
|
||||||
bool hierarchical_class)
|
bool hierarchical_class,
|
||||||
|
bool swapped)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
virNetDevBandwidthRatePtr rx = NULL, tx = NULL; /* From domain POV */
|
||||||
virCommandPtr cmd = NULL;
|
virCommandPtr cmd = NULL;
|
||||||
char *average = NULL;
|
char *average = NULL;
|
||||||
char *peak = NULL;
|
char *peak = NULL;
|
||||||
@ -215,16 +225,24 @@ virNetDevBandwidthSet(const char *ifname,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (swapped) {
|
||||||
|
rx = bandwidth->out;
|
||||||
|
tx = bandwidth->in;
|
||||||
|
} else {
|
||||||
|
rx = bandwidth->in;
|
||||||
|
tx = bandwidth->out;
|
||||||
|
}
|
||||||
|
|
||||||
virNetDevBandwidthClear(ifname);
|
virNetDevBandwidthClear(ifname);
|
||||||
|
|
||||||
if (bandwidth->in && bandwidth->in->average) {
|
if (tx && tx->average) {
|
||||||
if (virAsprintf(&average, "%llukbps", bandwidth->in->average) < 0)
|
if (virAsprintf(&average, "%llukbps", tx->average) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (bandwidth->in->peak &&
|
if (tx->peak &&
|
||||||
(virAsprintf(&peak, "%llukbps", bandwidth->in->peak) < 0))
|
(virAsprintf(&peak, "%llukbps", tx->peak) < 0))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (bandwidth->in->burst &&
|
if (tx->burst &&
|
||||||
(virAsprintf(&burst, "%llukb", bandwidth->in->burst) < 0))
|
(virAsprintf(&burst, "%llukb", tx->burst) < 0))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
cmd = virCommandNew(TC);
|
cmd = virCommandNew(TC);
|
||||||
@ -303,7 +321,7 @@ virNetDevBandwidthSet(const char *ifname,
|
|||||||
virCommandAddArgList(cmd, "class", "add", "dev", ifname, "parent",
|
virCommandAddArgList(cmd, "class", "add", "dev", ifname, "parent",
|
||||||
"1:", "classid", "1:1", "htb", "rate", average,
|
"1:", "classid", "1:1", "htb", "rate", average,
|
||||||
"ceil", peak ? peak : average, NULL);
|
"ceil", peak ? peak : average, NULL);
|
||||||
virNetDevBandwidthCmdAddOptimalQuantum(cmd, bandwidth->in);
|
virNetDevBandwidthCmdAddOptimalQuantum(cmd, tx);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -319,7 +337,7 @@ virNetDevBandwidthSet(const char *ifname,
|
|||||||
if (burst)
|
if (burst)
|
||||||
virCommandAddArgList(cmd, "burst", burst, NULL);
|
virCommandAddArgList(cmd, "burst", burst, NULL);
|
||||||
|
|
||||||
virNetDevBandwidthCmdAddOptimalQuantum(cmd, bandwidth->in);
|
virNetDevBandwidthCmdAddOptimalQuantum(cmd, tx);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -347,11 +365,10 @@ virNetDevBandwidthSet(const char *ifname,
|
|||||||
VIR_FREE(burst);
|
VIR_FREE(burst);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bandwidth->out) {
|
if (rx) {
|
||||||
if (virAsprintf(&average, "%llukbps", bandwidth->out->average) < 0)
|
if (virAsprintf(&average, "%llukbps", rx->average) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if (virAsprintf(&burst, "%llukb", bandwidth->out->burst ?
|
if (virAsprintf(&burst, "%llukb", rx->burst ? rx->burst : rx->average) < 0)
|
||||||
bandwidth->out->burst : bandwidth->out->average) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
|
@ -45,7 +45,8 @@ void virNetDevBandwidthFree(virNetDevBandwidthPtr def);
|
|||||||
|
|
||||||
int virNetDevBandwidthSet(const char *ifname,
|
int virNetDevBandwidthSet(const char *ifname,
|
||||||
virNetDevBandwidthPtr bandwidth,
|
virNetDevBandwidthPtr bandwidth,
|
||||||
bool hierarchical_class)
|
bool hierarchical_class,
|
||||||
|
bool swapped)
|
||||||
ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
int virNetDevBandwidthClear(const char *ifname);
|
int virNetDevBandwidthClear(const char *ifname);
|
||||||
int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest,
|
int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest,
|
||||||
|
@ -81,7 +81,7 @@ testVirNetDevBandwidthSet(const void *data)
|
|||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(&buf, NULL, NULL);
|
||||||
|
|
||||||
if (virNetDevBandwidthSet(iface, band, info->hierarchical_class) < 0)
|
if (virNetDevBandwidthSet(iface, band, info->hierarchical_class, true) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (!(actual_cmd = virBufferContentAndReset(&buf))) {
|
if (!(actual_cmd = virBufferContentAndReset(&buf))) {
|
||||||
|
Loading…
Reference in New Issue
Block a user