virNetDevSetPromiscuous;
virNetDevSetRcvAllMulti;
virNetDevSetRcvMulti;
-virNetDevSetRootQDisc;
virNetDevSetupControl;
virNetDevSysfsFile;
virNetDevValidateConfig;
virNetDevBandwidthFree;
virNetDevBandwidthPlug;
virNetDevBandwidthSet;
+virNetDevBandwidthSetRootQDisc;
virNetDevBandwidthUnplug;
virNetDevBandwidthUpdateFilter;
virNetDevBandwidthUpdateRate;
#include "domain_event.h"
#include "domain_validate.h"
#include "virtime.h"
+#include "virnetdevbandwidth.h"
#include "virnetdevopenvswitch.h"
#include "virstoragefile.h"
#include "storage_source.h"
actualType == VIR_DOMAIN_NET_TYPE_NETWORK ||
actualType == VIR_DOMAIN_NET_TYPE_BRIDGE ||
actualType == VIR_DOMAIN_NET_TYPE_DIRECT) {
- if (virNetDevSetRootQDisc(net->ifname, "noqueue") < 0)
+ if (virNetDevBandwidthSetRootQDisc(net->ifname, "noqueue") < 0)
return -1;
}
}
-/**
- * virNetDevSetRootQDisc:
- * @ifname: the interface name
- * @qdisc: queueing discipline to set
- *
- * For given interface @ifname set its root queueing discipline
- * to @qdisc. This can be used to replace the default qdisc
- * (usually pfifo_fast or whatever is set in
- * /proc/sys/net/core/default_qdisc) with different qdisc.
- *
- * Returns: 0 on success,
- * -1 if failed to exec tc (with error reported)
- * -2 if tc failed (with no error reported)
- */
-int
-virNetDevSetRootQDisc(const char *ifname,
- const char *qdisc)
-{
- g_autoptr(virCommand) cmd = NULL;
- g_autofree char *outbuf = NULL;
- g_autofree char *errbuf = NULL;
- int status;
-
- /* Ideally, we would have a netlink implementation and just
- * call it here. But honestly, I tried and failed miserably.
- * Fallback to spawning tc. */
- cmd = virCommandNewArgList(TC, "qdisc", "add", "dev", ifname,
- "root", "handle", "0:", qdisc,
- NULL);
-
- virCommandAddEnvString(cmd, "LC_ALL=C");
- virCommandSetOutputBuffer(cmd, &outbuf);
- virCommandSetErrorBuffer(cmd, &errbuf);
-
- if (virCommandRun(cmd, &status) < 0)
- return -1;
-
- if (status != 0) {
- VIR_DEBUG("Setting qdisc failed: output='%s' err='%s'", outbuf, errbuf);
- return -2;
- }
-
- return 0;
-}
-
-
/**
* virNetDevReserveName:
* @name: name of an existing network device
int virNetDevRunEthernetScript(const char *ifname, const char *script)
G_GNUC_NO_INLINE;
-int virNetDevSetRootQDisc(const char *ifname,
- const char *qdisc)
- G_GNUC_NO_INLINE;
-
int virNetDevVFInterfaceStats(virPCIDeviceAddress *vfAddr,
virDomainInterfaceStatsPtr stats)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
#include "vircommand.h"
#include "viralloc.h"
#include "virerror.h"
+#include "virlog.h"
#include "virstring.h"
#include "virutil.h"
#define VIR_FROM_THIS VIR_FROM_NONE
+VIR_LOG_INIT("util.netdevbandwidth");
+
void
virNetDevBandwidthFree(virNetDevBandwidth *def)
{
VIR_FREE(class_id);
return ret;
}
+
+
+
+/**
+ * virNetDevBandwidthSetRootQDisc:
+ * @ifname: the interface name
+ * @qdisc: queueing discipline to set
+ *
+ * For given interface @ifname set its root queueing discipline
+ * to @qdisc. This can be used to replace the default qdisc
+ * (usually pfifo_fast or whatever is set in
+ * /proc/sys/net/core/default_qdisc) with different qdisc.
+ *
+ * Returns: 0 on success,
+ * -1 if failed to exec tc (with error reported)
+ * -2 if tc failed (with no error reported)
+ */
+int
+virNetDevBandwidthSetRootQDisc(const char *ifname,
+ const char *qdisc)
+{
+ g_autoptr(virCommand) cmd = NULL;
+ g_autofree char *outbuf = NULL;
+ g_autofree char *errbuf = NULL;
+ int status;
+
+ /* Ideally, we would have a netlink implementation and just
+ * call it here. But honestly, I tried and failed miserably.
+ * Fallback to spawning tc. */
+ cmd = virCommandNewArgList(TC, "qdisc", "add", "dev", ifname,
+ "root", "handle", "0:", qdisc,
+ NULL);
+
+ virCommandAddEnvString(cmd, "LC_ALL=C");
+ virCommandSetOutputBuffer(cmd, &outbuf);
+ virCommandSetErrorBuffer(cmd, &errbuf);
+
+ if (virCommandRun(cmd, &status) < 0)
+ return -1;
+
+ if (status != 0) {
+ VIR_DEBUG("Setting qdisc failed: output='%s' err='%s'", outbuf, errbuf);
+ return -2;
+ }
+
+ return 0;
+}
unsigned int id)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
G_GNUC_WARN_UNUSED_RESULT;
+
+int virNetDevBandwidthSetRootQDisc(const char *ifname,
+ const char *qdisc)
+ G_GNUC_NO_INLINE;
#include "virmock.h"
#include "virlog.h"
#include "virnetdev.h"
+#include "virnetdevbandwidth.h"
#include "virnetdevip.h"
#include "virnetdevtap.h"
#include "virnetdevopenvswitch.h"
int
-virNetDevSetRootQDisc(const char *ifname G_GNUC_UNUSED,
- const char *qdisc G_GNUC_UNUSED)
+virNetDevBandwidthSetRootQDisc(const char *ifname G_GNUC_UNUSED,
+ const char *qdisc G_GNUC_UNUSED)
{
return 0;
}