mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: openvswitch: split out virNetDevOpenvswitchInterfaceSetRxQos
The virNetDevOpenvswitchInterfaceSetQos function is uneven because setting the Rx Qos is open-coded, while clearing it is sepearated in another function. Separate the setting too. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
be82600128
commit
5d55546e0f
@ -836,6 +836,29 @@ virNetDevOpenvswitchInterfaceSetTxQos(const char *ifname,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
virNetDevOpenvswitchInterfaceSetRxQos(const char *ifname,
|
||||||
|
const virNetDevBandwidthRate *rx)
|
||||||
|
{
|
||||||
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
|
||||||
|
cmd = virNetDevOpenvswitchCreateCmd();
|
||||||
|
virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
|
||||||
|
virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu",
|
||||||
|
rx->average * VIR_NETDEV_RX_TO_OVS);
|
||||||
|
if (rx->burst)
|
||||||
|
virCommandAddArgFormat(cmd, "ingress_policing_burst=%llu",
|
||||||
|
rx->burst * VIR_NETDEV_RX_TO_OVS);
|
||||||
|
|
||||||
|
if (virCommandRun(cmd, NULL) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Unable to set vlan configuration on port %s"), ifname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virNetDevOpenvswitchInterfaceSetQos:
|
* virNetDevOpenvswitchInterfaceSetQos:
|
||||||
* @ifname: on which interface
|
* @ifname: on which interface
|
||||||
@ -907,21 +930,8 @@ virNetDevOpenvswitchInterfaceSetQos(const char *ifname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rx) {
|
if (rx) {
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
if (virNetDevOpenvswitchInterfaceSetRxQos(ifname, rx) < 0)
|
||||||
|
|
||||||
cmd = virNetDevOpenvswitchCreateCmd();
|
|
||||||
virCommandAddArgList(cmd, "set", "Interface", ifname, NULL);
|
|
||||||
virCommandAddArgFormat(cmd, "ingress_policing_rate=%llu",
|
|
||||||
rx->average * VIR_NETDEV_RX_TO_OVS);
|
|
||||||
if (rx->burst)
|
|
||||||
virCommandAddArgFormat(cmd, "ingress_policing_burst=%llu",
|
|
||||||
rx->burst * VIR_NETDEV_RX_TO_OVS);
|
|
||||||
|
|
||||||
if (virCommandRun(cmd, NULL) < 0) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Unable to set vlan configuration on port %s"), ifname);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (virNetDevOpenvswitchInterfaceClearRxQos(ifname) < 0) {
|
if (virNetDevOpenvswitchInterfaceClearRxQos(ifname) < 0) {
|
||||||
VIR_WARN("Clean rx qos for interface %s failed", ifname);
|
VIR_WARN("Clean rx qos for interface %s failed", ifname);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user