mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
Adjust naming of network device bandwidth management APIs
Rename virBandwidth to virNetDevBandwidth, and virRate to virNetDevBandwidthRate. * src/util/network.c, src/util/network.h: Rename bandwidth structs and APIs * src/conf/domain_conf.c, src/conf/domain_conf.h, src/conf/network_conf.c, src/conf/network_conf.h, src/lxc/lxc_driver.c, src/network/bridge_driver.c, src/qemu/qemu_command.c, src/util/macvtap.c, src/util/macvtap.h, tools/virsh.c: Update for API changes.
This commit is contained in:
parent
4c544e6c61
commit
0eee075dc7
@ -862,7 +862,7 @@ virDomainActualNetDefFree(virDomainActualNetDefPtr def)
|
||||
break;
|
||||
}
|
||||
|
||||
virBandwidthDefFree(def->bandwidth);
|
||||
virNetDevBandwidthFree(def->bandwidth);
|
||||
|
||||
VIR_FREE(def);
|
||||
}
|
||||
@ -921,7 +921,7 @@ void virDomainNetDefFree(virDomainNetDefPtr def)
|
||||
VIR_FREE(def->filter);
|
||||
virNWFilterHashTableFree(def->filterparams);
|
||||
|
||||
virBandwidthDefFree(def->bandwidth);
|
||||
virNetDevBandwidthFree(def->bandwidth);
|
||||
|
||||
VIR_FREE(def);
|
||||
}
|
||||
@ -3120,7 +3120,7 @@ virDomainActualNetDefParseXML(xmlNodePtr node,
|
||||
|
||||
bandwidth_node = virXPathNode("./bandwidth", ctxt);
|
||||
if (bandwidth_node &&
|
||||
!(actual->bandwidth = virBandwidthDefParseNode(bandwidth_node)))
|
||||
!(actual->bandwidth = virNetDevBandwidthParse(bandwidth_node)))
|
||||
goto error;
|
||||
|
||||
*def = actual;
|
||||
@ -3278,7 +3278,7 @@ virDomainNetDefParseXML(virCapsPtr caps,
|
||||
if (virDomainActualNetDefParseXML(cur, ctxt, &actual) < 0)
|
||||
goto error;
|
||||
} else if (xmlStrEqual(cur->name, BAD_CAST "bandwidth")) {
|
||||
if (!(def->bandwidth = virBandwidthDefParseNode(cur)))
|
||||
if (!(def->bandwidth = virNetDevBandwidthParse(cur)))
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
@ -9730,7 +9730,7 @@ virDomainActualNetDefFormat(virBufferPtr buf,
|
||||
}
|
||||
|
||||
virBufferAdjustIndent(buf, 8);
|
||||
if (virBandwidthDefFormat(buf, def->bandwidth) < 0)
|
||||
if (virNetDevBandwidthFormat(def->bandwidth, buf) < 0)
|
||||
goto error;
|
||||
virBufferAdjustIndent(buf, -8);
|
||||
|
||||
@ -9883,7 +9883,7 @@ virDomainNetDefFormat(virBufferPtr buf,
|
||||
virDomainNetInterfaceLinkStateTypeToString(def->linkstate));
|
||||
|
||||
virBufferAdjustIndent(buf, 6);
|
||||
if (virBandwidthDefFormat(buf, def->bandwidth) < 0)
|
||||
if (virNetDevBandwidthFormat(def->bandwidth, buf) < 0)
|
||||
return -1;
|
||||
virBufferAdjustIndent(buf, -6);
|
||||
|
||||
@ -13091,7 +13091,7 @@ virDomainNetGetActualDirectVirtPortProfile(virDomainNetDefPtr iface)
|
||||
return iface->data.network.actual->data.direct.virtPortProfile;
|
||||
}
|
||||
|
||||
virBandwidthPtr
|
||||
virNetDevBandwidthPtr
|
||||
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface)
|
||||
{
|
||||
if ((iface->type == VIR_DOMAIN_NET_TYPE_NETWORK) &&
|
||||
|
@ -511,7 +511,7 @@ struct _virDomainActualNetDef {
|
||||
virVirtualPortProfileParamsPtr virtPortProfile;
|
||||
} direct;
|
||||
} data;
|
||||
virBandwidthPtr bandwidth;
|
||||
virNetDevBandwidthPtr bandwidth;
|
||||
};
|
||||
|
||||
/* Stores the virtual network interface configuration */
|
||||
@ -576,7 +576,7 @@ struct _virDomainNetDef {
|
||||
virDomainDeviceInfo info;
|
||||
char *filter;
|
||||
virNWFilterHashTablePtr filterparams;
|
||||
virBandwidthPtr bandwidth;
|
||||
virNetDevBandwidthPtr bandwidth;
|
||||
int linkstate;
|
||||
};
|
||||
|
||||
@ -1797,7 +1797,7 @@ char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface);
|
||||
int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface);
|
||||
virVirtualPortProfileParamsPtr
|
||||
virDomainNetGetActualDirectVirtPortProfile(virDomainNetDefPtr iface);
|
||||
virBandwidthPtr
|
||||
virNetDevBandwidthPtr
|
||||
virDomainNetGetActualBandwidth(virDomainNetDefPtr iface);
|
||||
|
||||
int virDomainControllerInsert(virDomainDefPtr def,
|
||||
|
@ -92,7 +92,7 @@ virPortGroupDefClear(virPortGroupDefPtr def)
|
||||
{
|
||||
VIR_FREE(def->name);
|
||||
VIR_FREE(def->virtPortProfile);
|
||||
virBandwidthDefFree(def->bandwidth);
|
||||
virNetDevBandwidthFree(def->bandwidth);
|
||||
def->bandwidth = NULL;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ void virNetworkDefFree(virNetworkDefPtr def)
|
||||
|
||||
VIR_FREE(def->virtPortProfile);
|
||||
|
||||
virBandwidthDefFree(def->bandwidth);
|
||||
virNetDevBandwidthFree(def->bandwidth);
|
||||
|
||||
VIR_FREE(def);
|
||||
}
|
||||
@ -797,7 +797,7 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def,
|
||||
|
||||
bandwidth_node = virXPathNode("./bandwidth", ctxt);
|
||||
if (bandwidth_node &&
|
||||
!(def->bandwidth = virBandwidthDefParseNode(bandwidth_node))) {
|
||||
!(def->bandwidth = virNetDevBandwidthParse(bandwidth_node))) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
@ -863,7 +863,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt)
|
||||
def->domain = virXPathString("string(./domain[1]/@name)", ctxt);
|
||||
|
||||
if ((bandwidthNode = virXPathNode("./bandwidth", ctxt)) != NULL &&
|
||||
(def->bandwidth = virBandwidthDefParseNode(bandwidthNode)) == NULL)
|
||||
(def->bandwidth = virNetDevBandwidthParse(bandwidthNode)) == NULL)
|
||||
goto error;
|
||||
|
||||
/* Parse bridge information */
|
||||
@ -1269,7 +1269,7 @@ virPortGroupDefFormat(virBufferPtr buf,
|
||||
virBufferAddLit(buf, ">\n");
|
||||
virBufferAdjustIndent(buf, 4);
|
||||
virVirtualPortProfileFormat(buf, def->virtPortProfile);
|
||||
virBandwidthDefFormat(buf, def->bandwidth);
|
||||
virNetDevBandwidthFormat(def->bandwidth, buf);
|
||||
virBufferAdjustIndent(buf, -4);
|
||||
virBufferAddLit(buf, " </portgroup>\n");
|
||||
}
|
||||
@ -1344,7 +1344,7 @@ char *virNetworkDefFormat(const virNetworkDefPtr def)
|
||||
goto error;
|
||||
|
||||
virBufferAdjustIndent(&buf, 2);
|
||||
if (virBandwidthDefFormat(&buf, def->bandwidth) < 0)
|
||||
if (virNetDevBandwidthFormat(def->bandwidth, &buf) < 0)
|
||||
goto error;
|
||||
virBufferAdjustIndent(&buf, -2);
|
||||
|
||||
|
@ -123,7 +123,7 @@ struct _virPortGroupDef {
|
||||
char *name;
|
||||
bool isDefault;
|
||||
virVirtualPortProfileParamsPtr virtPortProfile;
|
||||
virBandwidthPtr bandwidth;
|
||||
virNetDevBandwidthPtr bandwidth;
|
||||
};
|
||||
|
||||
typedef struct _virNetworkDef virNetworkDef;
|
||||
@ -155,7 +155,7 @@ struct _virNetworkDef {
|
||||
|
||||
size_t nPortGroups;
|
||||
virPortGroupDefPtr portGroups;
|
||||
virBandwidthPtr bandwidth;
|
||||
virNetDevBandwidthPtr bandwidth;
|
||||
};
|
||||
|
||||
typedef struct _virNetworkObj virNetworkObj;
|
||||
|
@ -764,13 +764,13 @@ nlComm;
|
||||
|
||||
|
||||
# network.h
|
||||
virBandwidthCopy;
|
||||
virBandwidthDefFormat;
|
||||
virBandwidthDefFree;
|
||||
virBandwidthDefParseNode;
|
||||
virBandwidthDisable;
|
||||
virBandwidthEnable;
|
||||
virBandwidthEqual;
|
||||
virNetDevBandwidthClear;
|
||||
virNetDevBandwidthCopy;
|
||||
virNetDevBandwidthEqual;
|
||||
virNetDevBandwidthFormat;
|
||||
virNetDevBandwidthFree;
|
||||
virNetDevBandwidthParse;
|
||||
virNetDevBandwidthSet;
|
||||
virSocketAddrBroadcast;
|
||||
virSocketAddrBroadcastByPrefix;
|
||||
virSocketAddrCheckNetmask;
|
||||
|
@ -1275,8 +1275,8 @@ static int lxcSetupInterfaces(virConnectPtr conn,
|
||||
if (vethInterfaceUpOrDown(parentVeth, 1) < 0)
|
||||
goto error_exit;
|
||||
|
||||
if (virBandwidthEnable(virDomainNetGetActualBandwidth(def->nets[i]),
|
||||
def->nets[i]->ifname) < 0) {
|
||||
if (virNetDevBandwidthSet(def->nets[i]->ifname,
|
||||
virDomainNetGetActualBandwidth(def->nets[i])) < 0) {
|
||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot set bandwidth limits on %s"),
|
||||
def->nets[i]->ifname);
|
||||
|
@ -1778,7 +1778,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
|
||||
if (v6present && networkStartRadvd(network) < 0)
|
||||
goto err4;
|
||||
|
||||
if (virBandwidthEnable(network->def->bandwidth, network->def->bridge) < 0) {
|
||||
if (virNetDevBandwidthSet(network->def->bridge, network->def->bandwidth) < 0) {
|
||||
networkReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot set bandwidth limits on %s"),
|
||||
network->def->bridge);
|
||||
@ -1790,10 +1790,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
|
||||
return 0;
|
||||
|
||||
err5:
|
||||
if (virBandwidthDisable(network->def->bridge, true) < 0) {
|
||||
VIR_WARN("Failed to disable QoS on %s",
|
||||
network->def->bridge);
|
||||
}
|
||||
ignore_value(virNetDevBandwidthClear(network->def->bridge));
|
||||
|
||||
err4:
|
||||
if (!save_err)
|
||||
@ -1836,10 +1833,7 @@ networkStartNetworkVirtual(struct network_driver *driver,
|
||||
static int networkShutdownNetworkVirtual(struct network_driver *driver,
|
||||
virNetworkObjPtr network)
|
||||
{
|
||||
if (virBandwidthDisable(network->def->bridge, true) < 0) {
|
||||
VIR_WARN("Failed to disable QoS on %s",
|
||||
network->def->name);
|
||||
}
|
||||
ignore_value(virNetDevBandwidthClear(network->def->bridge));
|
||||
|
||||
if (network->radvdPid > 0) {
|
||||
char *radvdpidbase;
|
||||
@ -2733,10 +2727,9 @@ networkAllocateActualDevice(virDomainNetDefPtr iface)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virBandwidthCopy(&iface->data.network.actual->bandwidth,
|
||||
portgroup->bandwidth) < 0) {
|
||||
if (virNetDevBandwidthCopy(&iface->data.network.actual->bandwidth,
|
||||
portgroup->bandwidth) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
if ((netdef->forwardType == VIR_NETWORK_FORWARD_NONE) ||
|
||||
|
@ -298,8 +298,8 @@ qemuNetworkIfaceConnect(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
if (tapfd >= 0 &&
|
||||
virBandwidthEnable(virDomainNetGetActualBandwidth(net),
|
||||
net->ifname) < 0) {
|
||||
virNetDevBandwidthSet(net->ifname,
|
||||
virDomainNetGetActualBandwidth(net)) < 0) {
|
||||
qemuReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot set bandwidth limits on %s"),
|
||||
net->ifname);
|
||||
|
@ -271,7 +271,7 @@ openMacvtapTap(const char *tgifname,
|
||||
char **res_ifname,
|
||||
enum virVMOperationType vmOp,
|
||||
char *stateDir,
|
||||
virBandwidthPtr bandwidth)
|
||||
virNetDevBandwidthPtr bandwidth)
|
||||
{
|
||||
const char *type = "macvtap";
|
||||
int c, rc;
|
||||
@ -364,7 +364,7 @@ create_name:
|
||||
} else
|
||||
goto disassociate_exit;
|
||||
|
||||
if (virBandwidthEnable(bandwidth, cr_ifname) < 0) {
|
||||
if (virNetDevBandwidthSet(cr_ifname, bandwidth) < 0) {
|
||||
macvtapError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot set bandwidth limits on %s"),
|
||||
cr_ifname);
|
||||
|
@ -63,7 +63,7 @@ int openMacvtapTap(const char *ifname,
|
||||
char **res_ifname,
|
||||
enum virVMOperationType vmop,
|
||||
char *stateDir,
|
||||
virBandwidthPtr bandwidth);
|
||||
virNetDevBandwidthPtr bandwidth);
|
||||
|
||||
void delMacvtap(const char *ifname,
|
||||
const unsigned char *macaddress,
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "util.h"
|
||||
#include "virterror_internal.h"
|
||||
#include "command.h"
|
||||
#include "ignore-value.h"
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
#define virSocketError(code, ...) \
|
||||
@ -918,7 +919,7 @@ virVirtualPortProfileFormat(virBufferPtr buf,
|
||||
}
|
||||
|
||||
static int
|
||||
virBandwidthParseChildDefNode(xmlNodePtr node, virRatePtr rate)
|
||||
virNetDevBandwidthParseRate(xmlNodePtr node, virNetDevBandwidthRatePtr rate)
|
||||
{
|
||||
int ret = -1;
|
||||
char *average = NULL;
|
||||
@ -973,17 +974,17 @@ cleanup:
|
||||
}
|
||||
|
||||
/**
|
||||
* virBandwidthDefParseNode:
|
||||
* virNetDevBandwidthParse:
|
||||
* @node: XML node
|
||||
*
|
||||
* Parse bandwidth XML and return pointer to structure
|
||||
*
|
||||
* Returns !NULL on success, NULL on error.
|
||||
*/
|
||||
virBandwidthPtr
|
||||
virBandwidthDefParseNode(xmlNodePtr node)
|
||||
virNetDevBandwidthPtr
|
||||
virNetDevBandwidthParse(xmlNodePtr node)
|
||||
{
|
||||
virBandwidthPtr def = NULL;
|
||||
virNetDevBandwidthPtr def = NULL;
|
||||
xmlNodePtr cur = node->children;
|
||||
xmlNodePtr in = NULL, out = NULL;
|
||||
|
||||
@ -1028,7 +1029,7 @@ virBandwidthDefParseNode(xmlNodePtr node)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virBandwidthParseChildDefNode(in, def->in) < 0) {
|
||||
if (virNetDevBandwidthParseRate(in, def->in) < 0) {
|
||||
/* helper reported error for us */
|
||||
goto error;
|
||||
}
|
||||
@ -1040,7 +1041,7 @@ virBandwidthDefParseNode(xmlNodePtr node)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virBandwidthParseChildDefNode(out, def->out) < 0) {
|
||||
if (virNetDevBandwidthParseRate(out, def->out) < 0) {
|
||||
/* helper reported error for us */
|
||||
goto error;
|
||||
}
|
||||
@ -1049,12 +1050,12 @@ virBandwidthDefParseNode(xmlNodePtr node)
|
||||
return def;
|
||||
|
||||
error:
|
||||
virBandwidthDefFree(def);
|
||||
virNetDevBandwidthFree(def);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
virBandwidthDefFree(virBandwidthPtr def)
|
||||
virNetDevBandwidthFree(virNetDevBandwidthPtr def)
|
||||
{
|
||||
if (!def)
|
||||
return;
|
||||
@ -1065,9 +1066,9 @@ virBandwidthDefFree(virBandwidthPtr def)
|
||||
}
|
||||
|
||||
static int
|
||||
virBandwidthChildDefFormat(virBufferPtr buf,
|
||||
virRatePtr def,
|
||||
const char *elem_name)
|
||||
virNetDevBandwidthRateFormat(virNetDevBandwidthRatePtr def,
|
||||
virBufferPtr buf,
|
||||
const char *elem_name)
|
||||
{
|
||||
if (!buf || !elem_name)
|
||||
return -1;
|
||||
@ -1090,9 +1091,9 @@ virBandwidthChildDefFormat(virBufferPtr buf,
|
||||
}
|
||||
|
||||
/**
|
||||
* virBandwidthDefFormat:
|
||||
* @buf: Buffer to print to
|
||||
* virNetDevBandwidthDefFormat:
|
||||
* @def: Data source
|
||||
* @buf: Buffer to print to
|
||||
*
|
||||
* Formats bandwidth and prepend each line with @indent.
|
||||
* @buf may use auto-indentation.
|
||||
@ -1100,8 +1101,7 @@ virBandwidthChildDefFormat(virBufferPtr buf,
|
||||
* Returns 0 on success, else -1.
|
||||
*/
|
||||
int
|
||||
virBandwidthDefFormat(virBufferPtr buf,
|
||||
virBandwidthPtr def)
|
||||
virNetDevBandwidthFormat(virNetDevBandwidthPtr def, virBufferPtr buf)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
@ -1114,8 +1114,8 @@ virBandwidthDefFormat(virBufferPtr buf,
|
||||
}
|
||||
|
||||
virBufferAddLit(buf, "<bandwidth>\n");
|
||||
if (virBandwidthChildDefFormat(buf, def->in, "inbound") < 0 ||
|
||||
virBandwidthChildDefFormat(buf, def->out, "outbound") < 0)
|
||||
if (virNetDevBandwidthRateFormat(def->in, buf, "inbound") < 0 ||
|
||||
virNetDevBandwidthRateFormat(def->out, buf, "outbound") < 0)
|
||||
goto cleanup;
|
||||
virBufferAddLit(buf, "</bandwidth>\n");
|
||||
|
||||
@ -1126,9 +1126,9 @@ cleanup:
|
||||
}
|
||||
|
||||
/**
|
||||
* virBandwidthEnable:
|
||||
* @bandwidth: rates to set
|
||||
* @iface: on which interface
|
||||
* virNetDevBandwidthSet:
|
||||
* @ifname: on which interface
|
||||
* @bandwidth: rates to set (may be NULL)
|
||||
*
|
||||
* This function enables QoS on specified interface
|
||||
* and set given traffic limits for both, incoming
|
||||
@ -1138,8 +1138,8 @@ cleanup:
|
||||
* Return 0 on success, -1 otherwise.
|
||||
*/
|
||||
int
|
||||
virBandwidthEnable(virBandwidthPtr bandwidth,
|
||||
const char *iface)
|
||||
virNetDevBandwidthSet(const char *ifname,
|
||||
virNetDevBandwidthPtr bandwidth)
|
||||
{
|
||||
int ret = -1;
|
||||
virCommandPtr cmd = NULL;
|
||||
@ -1147,17 +1147,13 @@ virBandwidthEnable(virBandwidthPtr bandwidth,
|
||||
char *peak = NULL;
|
||||
char *burst = NULL;
|
||||
|
||||
if (!iface)
|
||||
return -1;
|
||||
|
||||
if (!bandwidth) {
|
||||
/* nothing to be enabled */
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virBandwidthDisable(iface, true) < 0)
|
||||
goto cleanup;
|
||||
ignore_value(virNetDevBandwidthClear(ifname));
|
||||
|
||||
if (bandwidth->in) {
|
||||
if (virAsprintf(&average, "%llukbps", bandwidth->in->average) < 0)
|
||||
@ -1170,14 +1166,14 @@ virBandwidthEnable(virBandwidthPtr bandwidth,
|
||||
goto cleanup;
|
||||
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "add", "dev", iface, "root",
|
||||
virCommandAddArgList(cmd, "qdisc", "add", "dev", ifname, "root",
|
||||
"handle", "1:", "htb", "default", "1", NULL);
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
goto cleanup;
|
||||
|
||||
virCommandFree(cmd);
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd,"class", "add", "dev", iface, "parent",
|
||||
virCommandAddArgList(cmd,"class", "add", "dev", ifname, "parent",
|
||||
"1:", "classid", "1:1", "htb", NULL);
|
||||
virCommandAddArgList(cmd, "rate", average, NULL);
|
||||
|
||||
@ -1191,7 +1187,7 @@ virBandwidthEnable(virBandwidthPtr bandwidth,
|
||||
|
||||
virCommandFree(cmd);
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd,"filter", "add", "dev", iface, "parent",
|
||||
virCommandAddArgList(cmd,"filter", "add", "dev", ifname, "parent",
|
||||
"1:0", "protocol", "ip", "handle", "1", "fw",
|
||||
"flowid", "1", NULL);
|
||||
|
||||
@ -1212,7 +1208,7 @@ virBandwidthEnable(virBandwidthPtr bandwidth,
|
||||
|
||||
virCommandFree(cmd);
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "add", "dev", iface,
|
||||
virCommandAddArgList(cmd, "qdisc", "add", "dev", ifname,
|
||||
"ingress", NULL);
|
||||
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
@ -1220,7 +1216,7 @@ virBandwidthEnable(virBandwidthPtr bandwidth,
|
||||
|
||||
virCommandFree(cmd);
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "filter", "add", "dev", iface, "parent",
|
||||
virCommandAddArgList(cmd, "filter", "add", "dev", ifname, "parent",
|
||||
"ffff:", "protocol", "ip", "u32", "match", "ip",
|
||||
"src", "0.0.0.0/0", "police", "rate", average,
|
||||
"burst", burst, "mtu", burst, "drop", "flowid",
|
||||
@ -1241,9 +1237,8 @@ cleanup:
|
||||
}
|
||||
|
||||
/**
|
||||
* virBandwidthDisable:
|
||||
* @iface: on which interface
|
||||
* @may_fail: should be unsuccessful disable considered fatal?
|
||||
* virNetDevBandwidthClear:
|
||||
* @ifname: on which interface
|
||||
*
|
||||
* This function tries to disable QoS on specified interface
|
||||
* by deleting root and ingress qdisc. However, this may fail
|
||||
@ -1252,59 +1247,43 @@ cleanup:
|
||||
* Return 0 on success, -1 otherwise.
|
||||
*/
|
||||
int
|
||||
virBandwidthDisable(const char *iface,
|
||||
bool may_fail)
|
||||
virNetDevBandwidthClear(const char *ifname)
|
||||
{
|
||||
int ret = -1;
|
||||
int status;
|
||||
int ret = 0;
|
||||
virCommandPtr cmd = NULL;
|
||||
|
||||
if (!iface)
|
||||
return -1;
|
||||
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "del", "dev", iface, "root", NULL);
|
||||
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "root", NULL);
|
||||
|
||||
if ((virCommandRun(cmd, &status) < 0) ||
|
||||
(!may_fail && status))
|
||||
goto cleanup;
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
ret = -1;
|
||||
|
||||
virCommandFree(cmd);
|
||||
|
||||
cmd = virCommandNew(TC);
|
||||
virCommandAddArgList(cmd, "qdisc", "del", "dev", iface, "ingress", NULL);
|
||||
virCommandAddArgList(cmd, "qdisc", "del", "dev", ifname, "ingress", NULL);
|
||||
|
||||
if ((virCommandRun(cmd, &status) < 0) ||
|
||||
(!may_fail && status))
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (virCommandRun(cmd, NULL) < 0)
|
||||
ret = -1;
|
||||
virCommandFree(cmd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* virBandwidthCopy:
|
||||
* virNetDevBandwidthCopy:
|
||||
* @dest: destination
|
||||
* @src: source
|
||||
* @src: source (may be NULL)
|
||||
*
|
||||
* Returns -1 on OOM error (which gets reported),
|
||||
* 0 otherwise.
|
||||
*/
|
||||
int
|
||||
virBandwidthCopy(virBandwidthPtr *dest,
|
||||
const virBandwidthPtr src)
|
||||
virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest,
|
||||
const virNetDevBandwidthPtr src)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!dest) {
|
||||
virSocketError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("invalid argument supplied"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
*dest = NULL;
|
||||
if (!src) {
|
||||
/* nothing to be copied */
|
||||
@ -1337,15 +1316,15 @@ virBandwidthCopy(virBandwidthPtr *dest,
|
||||
|
||||
cleanup:
|
||||
if (ret < 0) {
|
||||
virBandwidthDefFree(*dest);
|
||||
virNetDevBandwidthFree(*dest);
|
||||
*dest = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool
|
||||
virBandwidthEqual(virBandwidthPtr a,
|
||||
virBandwidthPtr b)
|
||||
virNetDevBandwidthEqual(virNetDevBandwidthPtr a,
|
||||
virNetDevBandwidthPtr b)
|
||||
{
|
||||
if (!a && !b)
|
||||
return true;
|
||||
|
@ -48,19 +48,19 @@ typedef struct {
|
||||
|
||||
typedef virSocketAddr *virSocketAddrPtr;
|
||||
|
||||
typedef struct {
|
||||
typedef struct _virNetDevBandwidthRate virNetDevBandwidthRate;
|
||||
typedef virNetDevBandwidthRate *virNetDevBandwidthRatePtr;
|
||||
struct _virNetDevBandwidthRate {
|
||||
unsigned long long average; /* kbytes/s */
|
||||
unsigned long long peak; /* kbytes/s */
|
||||
unsigned long long burst; /* kbytes */
|
||||
} virRate;
|
||||
};
|
||||
|
||||
typedef virRate *virRatePtr;
|
||||
|
||||
typedef struct {
|
||||
virRatePtr in, out;
|
||||
} virBandwidth;
|
||||
|
||||
typedef virBandwidth *virBandwidthPtr;
|
||||
typedef struct _virNetDevBandwidth virNetDevBandwidth;
|
||||
typedef virNetDevBandwidth *virNetDevBandwidthPtr;
|
||||
struct _virNetDevBandwidth {
|
||||
virNetDevBandwidthRatePtr in, out;
|
||||
};
|
||||
|
||||
int virSocketAddrParse(virSocketAddrPtr addr,
|
||||
const char *val,
|
||||
@ -152,16 +152,21 @@ virVirtualPortProfileFormat(virBufferPtr buf,
|
||||
bool virVirtualPortProfileEqual(virVirtualPortProfileParamsPtr a,
|
||||
virVirtualPortProfileParamsPtr b);
|
||||
|
||||
virBandwidthPtr virBandwidthDefParseNode(xmlNodePtr node);
|
||||
void virBandwidthDefFree(virBandwidthPtr def);
|
||||
int virBandwidthDefFormat(virBufferPtr buf,
|
||||
virBandwidthPtr def);
|
||||
virNetDevBandwidthPtr virNetDevBandwidthParse(xmlNodePtr node)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||
void virNetDevBandwidthFree(virNetDevBandwidthPtr def);
|
||||
int virNetDevBandwidthFormat(virNetDevBandwidthPtr def,
|
||||
virBufferPtr buf)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int virBandwidthEnable(virBandwidthPtr bandwidth, const char *iface);
|
||||
int virBandwidthDisable(const char *iface, bool may_fail);
|
||||
int virBandwidthCopy(virBandwidthPtr *dest, const virBandwidthPtr src);
|
||||
int virNetDevBandwidthSet(const char *ifname, virNetDevBandwidthPtr bandwidth)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||
int virNetDevBandwidthClear(const char *ifname)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||
int virNetDevBandwidthCopy(virNetDevBandwidthPtr *dest, const virNetDevBandwidthPtr src)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
|
||||
|
||||
bool virBandwidthEqual(virBandwidthPtr a, virBandwidthPtr b);
|
||||
bool virNetDevBandwidthEqual(virNetDevBandwidthPtr a, virNetDevBandwidthPtr b);
|
||||
|
||||
|
||||
#endif /* __VIR_NETWORK_H__ */
|
||||
|
@ -11250,7 +11250,7 @@ static const vshCmdOptDef opts_attach_interface[] = {
|
||||
/* parse inbound and outbound which are in the format of
|
||||
* 'average,peak,burst', in which peak and burst are optional,
|
||||
* thus 'average,,burst' and 'average,peak' are also legal. */
|
||||
static int parseRateStr(const char *rateStr, virRatePtr rate)
|
||||
static int parseRateStr(const char *rateStr, virNetDevBandwidthRatePtr rate)
|
||||
{
|
||||
const char *average = NULL;
|
||||
char *peak = NULL, *burst = NULL;
|
||||
@ -11289,7 +11289,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
|
||||
const char *mac = NULL, *target = NULL, *script = NULL,
|
||||
*type = NULL, *source = NULL, *model = NULL,
|
||||
*inboundStr = NULL, *outboundStr = NULL;
|
||||
virRate inbound, outbound;
|
||||
virNetDevBandwidthRate inbound, outbound;
|
||||
int typ;
|
||||
int ret;
|
||||
bool functionReturn = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user