Skip to contentSkip to conversation

xenconfig: support parsing and formatting vif bandwidth

PATCH In review Jim Fehlig 2 participants 7 messages Dec 29, 2015 – Jan 8, 2016 5 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jim Fehlig

author
#1 lore raw

PATCH 1/2 xenconfig: support parsing and formatting vif bandwidth

Both xm and xl config have long supported specifying vif rate limiting, e.g.

vif = [ 'mac=00:16:3E:74:3d:76,bridge=br0,rate=10MB/s' ]

Add support for mapping rate to and from <bandwidth> in the xenconfig parser and formatter. rate is mapped to the required 'average' attribute of the <outbound> element, e.g.

<interface type='bridge'>

    ...
    <bandwidth>
      <outbound average='10240'/>
    </bandwidth>

</interface>

Also add a unit test to check the conversion logic.

---

I used a bit of code from libxlu_vif.c to implement xenParseVifRate() instead of using the libxlutil lib directly, since in theory rate limiting applies to the old xen driver (no libxl) as well.

 src/xenconfig/xen_common.c           | 77 ++++++++++++++++++++++++++++++++++++
 tests/xlconfigdata/test-vif-rate.cfg | 26 ++++++++++++
 tests/xlconfigdata/test-vif-rate.xml | 57 ++++++++++++++++++++++++++
 tests/xlconfigtest.c                 |  1 +
 4 files changed, 161 insertions(+)
src/xenconfig/xen_common.c +77 -0
index 54f5791..b9f0344 100644
@@ -28,6 +28,8 @@
 
 #include <config.h>
 
+#include <regex.h>
+
 #include "internal.h"
 #include "virerror.h"
 #include "virconf.h"
@@ -803,6 +805,46 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def)
 }
 
 
+static const char *vif_bytes_per_sec_re = "^[0-9]+[GMK]?[Bb]/s$";
+
+static int
+xenParseVifRate(char *rate, unsigned long long *kbytes_per_sec)
+{
+    regex_t rec;
+    char *suffix;
+    unsigned long long tmp;
+    int ret = -1;
+
+    regcomp(&rec, vif_bytes_per_sec_re, REG_EXTENDED|REG_NOSUB);
+    if (regexec(&rec, rate, 0, NULL, 0)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Invalid rate '%s' specified"), rate);
+        goto cleanup;
+    }
+
+    if (virStrToLong_ull(rate, &suffix, 10, &tmp)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Failed to parse rate '%s'"), rate);
+        goto cleanup;
+    }
+
+    if (*suffix == 'G')
+       tmp *= 1024 * 1024;
+    else if (*suffix == 'M')
+       tmp *= 1024;
+
+    if (*suffix == 'b' || *(suffix + 1) == 'b')
+       tmp /= 8;
+
+    *kbytes_per_sec = tmp;
+    ret = 0;
+
+ cleanup:
+    regfree(&rec);
+    return ret;
+}
+
+
 static int
 xenParseVif(virConfPtr conf, virDomainDefPtr def)
 {
@@ -819,6 +861,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)
             char mac[18];
             char bridge[50];
             char vifname[50];
+            char rate[50];
             char *key;
 
             bridge[0] = '\0';
@@ -827,6 +870,7 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)
             model[0] = '\0';
             type[0] = '\0';
             vifname[0] = '\0';
+            rate[0] = '\0';
 
             if ((list->type != VIR_CONF_STRING) || (list->str == NULL))
                 goto skipnic;
@@ -892,6 +936,13 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)
                                        _("IP %s too big for destination"), data);
                         goto skipnic;
                     }
+                } else if (STRPREFIX(key, "rate=")) {
+                    int len = nextkey ? (nextkey - data) : sizeof(rate) - 1;
+                    if (virStrncpy(rate, data, len, sizeof(rate)) == NULL) {
+                        virReportError(VIR_ERR_INTERNAL_ERROR,
+                                       _("rate %s too big for destination"), data);
+                        goto skipnic;
+                    }
                 }
 
                 while (nextkey && (nextkey[0] == ',' ||
@@ -942,6 +993,29 @@ xenParseVif(virConfPtr conf, virDomainDefPtr def)
                 VIR_STRDUP(net->ifname, vifname) < 0)
                 goto cleanup;
 
+            if (rate[0]) {
+                char *p;
+                virNetDevBandwidthPtr bandwidth;
+                unsigned long long kbytes_per_sec;
+
+                p = strchr(rate, '@');
+                if (p != NULL)
+                    *p = 0;
+
+                if (xenParseVifRate(rate, &kbytes_per_sec) < 0)
+                    goto cleanup;
+
+                if (VIR_ALLOC(bandwidth) < 0)
+                    goto cleanup;
+                if (VIR_ALLOC(bandwidth->out) < 0) {
+                    VIR_FREE(bandwidth);
+                    goto cleanup;
+                }
+
+                bandwidth->out->average = kbytes_per_sec;
+                net->bandwidth = bandwidth;
+            }
+
             if (VIR_APPEND_ELEMENT(def->nets, def->nnets, net) < 0)
                 goto cleanup;
 
@@ -1184,6 +1258,9 @@ xenFormatNet(virConnectPtr conn,
         virBufferAsprintf(&buf, ",vifname=%s",
                           net->ifname);
 
+    if (net->bandwidth && net->bandwidth->out && net->bandwidth->out->average)
+        virBufferAsprintf(&buf, ",rate=%lluKB/s", net->bandwidth->out->average);
+
     if (virBufferCheckError(&buf) < 0)
         goto cleanup;
 
tests/xlconfigdata/test-vif-rate.cfg new file +26 -0
new file mode 100644
index 0000000..c5484dc
@@ -0,0 +1,26 @@
+name = "XenGuest2"
+uuid = "c7a5fdb2-cdaf-9455-926a-d65c16db1809"
+maxmem = 579
+memory = 394
+vcpus = 1
+pae = 1
+acpi = 1
+apic = 1
+hap = 0
+viridian = 0
+rtc_timeoffset = 0
+localtime = 0
+on_poweroff = "destroy"
+on_reboot = "restart"
+on_crash = "restart"
+device_model = "/usr/lib/xen/bin/qemu-dm"
+sdl = 0
+vnc = 1
+vncunused = 1
+vnclisten = "127.0.0.1"
+vif = [ "mac=00:16:3e:66:92:9c,bridge=xenbr1,script=vif-bridge,model=e1000,rate=10240KB/s" ]
+parallel = "none"
+serial = "none"
+builder = "hvm"
+boot = "d"
+disk = [ "/dev/HostVG/XenGuest2,raw,hda,w,backendtype=phy", "/var/lib/libvirt/images/XenGuest2-home,qcow2,hdb,w,backendtype=qdisk", "/root/boot.iso,raw,hdc,r,backendtype=qdisk,devtype=cdrom" ]
tests/xlconfigdata/test-vif-rate.xml new file +57 -0

57 lines not on this page · raw message

tests/xlconfigtest.c +1 -0
index 1db11e7..e997009 100644
@@ -196,6 +196,7 @@ mymain(void)
     DO_TEST("new-disk");
     DO_TEST("spice");
     DO_TEST("spice-features");
+    DO_TEST("vif-rate");
 
 #ifdef LIBXL_HAVE_BUILDINFO_USBDEVICE_LIST
     DO_TEST("fullvirt-multiusb");
Signature · 1 line
2.1.4
author
#2 lore raw

PATCH 2/2 libxl: support vif outgoing bandwidth QoS

In reply to a message not in the archive

The libxl_device_nic structure supports specifying an outgoing rate limit based on a time interval and bytes allowed per interval. In xl config a rate limit is specified as "<RATE>/s@<INTERVAL>". INTERVAL is optional and defaults to 50ms.

libvirt expresses outgoing limits by average (required), peak, burst, and floor attributes in units of KB/s. This patch supports the outgoing bandwidth limit by converting the average KB/s to bytes per interval based on the same default interval (50ms) used by xl.

---
 src/libxl/libxl_conf.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
src/libxl/libxl_conf.c +39 -0
index 23c74e7..6320421 100644
@@ -1093,6 +1093,7 @@ libxlMakeNic(virDomainDefPtr def,
 {
     bool ioemu_nic = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     virDomainNetType actual_type = virDomainNetGetActualType(l_nic);
+    virNetDevBandwidthPtr actual_bw;
 
     /* TODO: Where is mtu stored?
      *
@@ -1206,6 +1207,44 @@ libxlMakeNic(virDomainDefPtr def,
 #endif
     }
 
+    /*
+     * Set bandwidth.
+     * From $xen-sources/docs/misc/xl-network-configuration.markdown:
+     *
+     *
+     * Specifies the rate at which the outgoing traffic will be limited to.
+     * The default if this keyword is not specified is unlimited.
+     *
+     * The rate may be specified as "<RATE>/s" or optionally "<RATE>/s@<INTERVAL>".
+     *
+     * `RATE` is in bytes and can accept suffixes:
+     *     GB, MB, KB, B for bytes.
+     *     Gb, Mb, Kb, b for bits.
+     * `INTERVAL` is in microseconds and can accept suffixes: ms, us, s.
+     *     It determines the frequency at which the vif transmission credit
+     *     is replenished. The default is 50ms.
+
+     * Vif rate limiting is credit-based. It means that for "1MB/s@20ms",
+     * the available credit will be equivalent of the traffic you would have
+     * done at "1MB/s" during 20ms. This will results in a credit of 20,000
+     * bytes replenished every 20,000 us.
+     *
+     *
+     * libvirt doesn't support the notion of rate limiting over an interval.
+     * Similar to xl's behavior when interval is not specified, set a default
+     * interval of 50ms and calculate the number of bytes per interval based
+     * on the specified average bandwidth.
+     */
+    actual_bw = virDomainNetGetActualBandwidth(l_nic);
+    if (actual_bw && actual_bw->out && actual_bw->out->average) {
+        uint64_t bytes_per_sec = actual_bw->out->average * 1024;
+        uint64_t bytes_per_interval =
+            (((uint64_t) bytes_per_sec * 50000UL) / 1000000UL);
+
+        x_nic->rate_bytes_per_interval = bytes_per_interval;
+        x_nic->rate_interval_usecs =  50000UL;
+    }
+
     return 0;
 }
 
Signature · 1 line
2.1.4
#3 lore raw

Re: [libvirt] [PATCH 2/2] libxl: support vif outgoing bandwidth QoS

Quoted 59 lines · Jim Fehlig

The libxl_device_nic structure supports specifying an outgoing rate limit based on a time interval and bytes allowed per interval. In xl config a rate limit is specified as "<RATE>/s@<INTERVAL>". INTERVAL is optional and defaults to 50ms.

libvirt expresses outgoing limits by average (required), peak, burst, and floor attributes in units of KB/s. This patch supports the outgoing bandwidth limit by converting the average KB/s to bytes per interval based on the same default interval (50ms) used by xl.

---
 src/libxl/libxl_conf.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
src/libxl/libxl_conf.c +29 -0
index 23c74e7..6320421 100644
@@ -1093,6 +1093,7 @@ libxlMakeNic(virDomainDefPtr def,
 {
     bool ioemu_nic = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     virDomainNetType actual_type = virDomainNetGetActualType(l_nic);
+    virNetDevBandwidthPtr actual_bw;
 
     /* TODO: Where is mtu stored?
      *
@@ -1206,6 +1207,44 @@ libxlMakeNic(virDomainDefPtr def,
 #endif
     }
 
+    /*
+     * Set bandwidth.
+     * From $xen-sources/docs/misc/xl-network-configuration.markdown:
+     *
+     *
+     * Specifies the rate at which the outgoing traffic will be limited to.
+     * The default if this keyword is not specified is unlimited.
+     *
+     * The rate may be specified as "<RATE>/s" or optionally "<RATE>/s@<INTERVAL>".
+     *
+     * `RATE` is in bytes and can accept suffixes:
+     *     GB, MB, KB, B for bytes.
+     *     Gb, Mb, Kb, b for bits.
+     * `INTERVAL` is in microseconds and can accept suffixes: ms, us, s.
+     *     It determines the frequency at which the vif transmission credit
+     *     is replenished. The default is 50ms.
+
+     * Vif rate limiting is credit-based. It means that for "1MB/s@20ms",
+     * the available credit will be equivalent of the traffic you would have
+     * done at "1MB/s" during 20ms. This will results in a credit of 20,000
+     * bytes replenished every 20,000 us.
+     *
+     *
+     * libvirt doesn't support the notion of rate limiting over an interval.
+     * Similar to xl's behavior when interval is not specified, set a default
+     * interval of 50ms and calculate the number of bytes per interval based
+     * on the specified average bandwidth.
+     */

src/libxl/libxl_conf.c libxlMakeNic(virDomainDefPtr def, · line 1247

Quoted 10 lines
src/libxl/libxl_conf.c +10 -0
+    actual_bw = virDomainNetGetActualBandwidth(l_nic);
+    if (actual_bw && actual_bw->out && actual_bw->out->average) {
+        uint64_t bytes_per_sec = actual_bw->out->average * 1024;
+        uint64_t bytes_per_interval =
+            (((uint64_t) bytes_per_sec * 50000UL) / 1000000UL);
+
+        x_nic->rate_bytes_per_interval = bytes_per_interval;
+        x_nic->rate_interval_usecs =  50000UL;
+    }
+

Interesting. I'd expect:

x_nic->rate_bytes_per_interval = bytes_per_sec;
x_nic->rate_interval_usecs = 1000*1000;

I mean, if I understood the xl way of rate limiting correctly, one says how much bytes can be sent for how long. so for 1MB/s I'd expect to send 1024*1024 bytes each second.

Or am I missing something?

Michal

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#5 lore raw

Re: [libvirt] [PATCH 2/2] libxl: support vif outgoing bandwidth QoS

Quoted 72 lines · Michal Privoznik
Quoted 59 lines · Jim Fehlig

The libxl_device_nic structure supports specifying an outgoing rate limit based on a time interval and bytes allowed per interval. In xl config a rate limit is specified as "<RATE>/s@<INTERVAL>". INTERVAL is optional and defaults to 50ms.

libvirt expresses outgoing limits by average (required), peak, burst, and floor attributes in units of KB/s. This patch supports the outgoing bandwidth limit by converting the average KB/s to bytes per interval based on the same default interval (50ms) used by xl.

---
 src/libxl/libxl_conf.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
src/libxl/libxl_conf.c +29 -0
index 23c74e7..6320421 100644
@@ -1093,6 +1093,7 @@ libxlMakeNic(virDomainDefPtr def,
 {
     bool ioemu_nic = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     virDomainNetType actual_type = virDomainNetGetActualType(l_nic);
+    virNetDevBandwidthPtr actual_bw;
 
     /* TODO: Where is mtu stored?
      *
@@ -1206,6 +1207,44 @@ libxlMakeNic(virDomainDefPtr def,
 #endif
     }
 
+    /*
+     * Set bandwidth.
+     * From $xen-sources/docs/misc/xl-network-configuration.markdown:
+     *
+     *
+     * Specifies the rate at which the outgoing traffic will be limited to.
+     * The default if this keyword is not specified is unlimited.
+     *
+     * The rate may be specified as "<RATE>/s" or optionally "<RATE>/s@<INTERVAL>".
+     *
+     * `RATE` is in bytes and can accept suffixes:
+     *     GB, MB, KB, B for bytes.
+     *     Gb, Mb, Kb, b for bits.
+     * `INTERVAL` is in microseconds and can accept suffixes: ms, us, s.
+     *     It determines the frequency at which the vif transmission credit
+     *     is replenished. The default is 50ms.
+
+     * Vif rate limiting is credit-based. It means that for "1MB/s@20ms",
+     * the available credit will be equivalent of the traffic you would have
+     * done at "1MB/s" during 20ms. This will results in a credit of 20,000
+     * bytes replenished every 20,000 us.
+     *
+     *
+     * libvirt doesn't support the notion of rate limiting over an interval.
+     * Similar to xl's behavior when interval is not specified, set a default
+     * interval of 50ms and calculate the number of bytes per interval based
+     * on the specified average bandwidth.
+     */

src/libxl/libxl_conf.c libxlMakeNic(virDomainDefPtr def, · line 1247

Quoted 10 lines
src/libxl/libxl_conf.c +10 -0
+    actual_bw = virDomainNetGetActualBandwidth(l_nic);
+    if (actual_bw && actual_bw->out && actual_bw->out->average) {
+        uint64_t bytes_per_sec = actual_bw->out->average * 1024;
+        uint64_t bytes_per_interval =
+            (((uint64_t) bytes_per_sec * 50000UL) / 1000000UL);
+
+        x_nic->rate_bytes_per_interval = bytes_per_interval;
+        x_nic->rate_interval_usecs =  50000UL;
+    }
+

Interesting. I'd expect:

Quoted 2 lines

x_nic->rate_bytes_per_interval = bytes_per_sec;
x_nic->rate_interval_usecs = 1000*1000;

For the most part I mimicked the Xen code and wanted to stick with the default interval of 50ms, which has been the default for a long time. It is even mentioned in some old RHEL5 docs

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Virtualization/sect-Virtualization-Tips_and_tricks-Limit_network_bandwidth_for_a_Xen_guest.html

BTW, here is the Xen code that inspired this logic

http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxl/libxlu_vif.c;h=0665e624dc178a6ca8058e04a7baacaf1475bd37;hb=HEAD#l131

rate_bytes_per_interval is set to (bytes/s * interval us)/1000000us

I guess we are saying the same thing, you're just setting interval to 1s (thus rate_bytes_per_interval == bytes_per_sec) instead of the historical 50ms :-).

Quoted 6 lines

I mean, if I understood the xl way of rate limiting correctly, one says how much bytes can be sent for how long. so for 1MB/s I'd expect to send 1024*1024 bytes each second.

Or am I missing something?

Does the above explanation make sense? I might be missing something :-). CC'd a few Xen tools maintainer just in case.

Regards,
Jim

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Re: [libvirt] [PATCH 2/2] libxl: support vif outgoing bandwidth QoS

Quoted 92 lines · Jim Fehlig
Quoted 72 lines · Michal Privoznik
Quoted 59 lines · Jim Fehlig

The libxl_device_nic structure supports specifying an outgoing rate limit based on a time interval and bytes allowed per interval. In xl config a rate limit is specified as "<RATE>/s@<INTERVAL>". INTERVAL is optional and defaults to 50ms.

libvirt expresses outgoing limits by average (required), peak, burst, and floor attributes in units of KB/s. This patch supports the outgoing bandwidth limit by converting the average KB/s to bytes per interval based on the same default interval (50ms) used by xl.

---
 src/libxl/libxl_conf.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
src/libxl/libxl_conf.c +29 -0
index 23c74e7..6320421 100644
@@ -1093,6 +1093,7 @@ libxlMakeNic(virDomainDefPtr def,
 {
     bool ioemu_nic = def->os.type == VIR_DOMAIN_OSTYPE_HVM;
     virDomainNetType actual_type = virDomainNetGetActualType(l_nic);
+    virNetDevBandwidthPtr actual_bw;
 
     /* TODO: Where is mtu stored?
      *
@@ -1206,6 +1207,44 @@ libxlMakeNic(virDomainDefPtr def,
 #endif
     }
 
+    /*
+     * Set bandwidth.
+     * From $xen-sources/docs/misc/xl-network-configuration.markdown:
+     *
+     *
+     * Specifies the rate at which the outgoing traffic will be limited to.
+     * The default if this keyword is not specified is unlimited.
+     *
+     * The rate may be specified as "<RATE>/s" or optionally "<RATE>/s@<INTERVAL>".
+     *
+     * `RATE` is in bytes and can accept suffixes:
+     *     GB, MB, KB, B for bytes.
+     *     Gb, Mb, Kb, b for bits.
+     * `INTERVAL` is in microseconds and can accept suffixes: ms, us, s.
+     *     It determines the frequency at which the vif transmission credit
+     *     is replenished. The default is 50ms.
+
+     * Vif rate limiting is credit-based. It means that for "1MB/s@20ms",
+     * the available credit will be equivalent of the traffic you would have
+     * done at "1MB/s" during 20ms. This will results in a credit of 20,000
+     * bytes replenished every 20,000 us.
+     *
+     *
+     * libvirt doesn't support the notion of rate limiting over an interval.
+     * Similar to xl's behavior when interval is not specified, set a default
+     * interval of 50ms and calculate the number of bytes per interval based
+     * on the specified average bandwidth.
+     */

src/libxl/libxl_conf.c libxlMakeNic(virDomainDefPtr def, · line 1247

Quoted 10 lines
src/libxl/libxl_conf.c +10 -0
+    actual_bw = virDomainNetGetActualBandwidth(l_nic);
+    if (actual_bw && actual_bw->out && actual_bw->out->average) {
+        uint64_t bytes_per_sec = actual_bw->out->average * 1024;
+        uint64_t bytes_per_interval =
+            (((uint64_t) bytes_per_sec * 50000UL) / 1000000UL);
+
+        x_nic->rate_bytes_per_interval = bytes_per_interval;
+        x_nic->rate_interval_usecs =  50000UL;
+    }
+

Interesting. I'd expect:

Quoted 2 lines

x_nic->rate_bytes_per_interval = bytes_per_sec;
x_nic->rate_interval_usecs = 1000*1000;

For the most part I mimicked the Xen code and wanted to stick with the default interval of 50ms, which has been the default for a long time. It is even mentioned in some old RHEL5 docs

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Virtualization/sect-Virtualization-Tips_and_tricks-Limit_network_bandwidth_for_a_Xen_guest.html

BTW, here is the Xen code that inspired this logic

http://xenbits.xen.org/gitweb/?p=xen.git;a=blob;f=tools/libxl/libxlu_vif.c;h=0665e624dc178a6ca8058e04a7baacaf1475bd37;hb=HEAD#l131

rate_bytes_per_interval is set to (bytes/s * interval us)/1000000us

I guess we are saying the same thing, you're just setting interval to 1s (thus rate_bytes_per_interval == bytes_per_sec) instead of the historical 50ms :-).

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

I mean, if I understood the xl way of rate limiting correctly, one says how much bytes can be sent for how long. so for 1MB/s I'd expect to send 1024*1024 bytes each second.

Or am I missing something?

Does the above explanation make sense? I might be missing something :-). CC'd a few Xen tools maintainer just in case.

Yep, it makes sense now. So let me review v2.

Michal

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 25 lines · Jim Fehlig

Both xm and xl config have long supported specifying vif rate limiting, e.g.

vif = [ 'mac=00:16:3E:74:3d:76,bridge=br0,rate=10MB/s' ]

Add support for mapping rate to and from <bandwidth> in the xenconfig parser and formatter. rate is mapped to the required 'average' attribute of the <outbound> element, e.g.

<interface type='bridge'>

    ...
    <bandwidth>
      <outbound average='10240'/>
    </bandwidth>

</interface>

Also add a unit test to check the conversion logic.

---

I used a bit of code from libxlu_vif.c to implement xenParseVifRate() instead of using the libxlutil lib directly, since in theory rate limiting applies to the old xen driver (no libxl) as well.

Quoted 5 lines
 src/xenconfig/xen_common.c           | 77 ++++++++++++++++++++++++++++++++++++
 tests/xlconfigdata/test-vif-rate.cfg | 26 ++++++++++++
 tests/xlconfigdata/test-vif-rate.xml | 57 ++++++++++++++++++++++++++
 tests/xlconfigtest.c                 |  1 +
 4 files changed, 161 insertions(+)

ACK

Michal

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#11 lore raw
Quoted 26 lines · Michal Privoznik
Quoted 25 lines · Jim Fehlig

Both xm and xl config have long supported specifying vif rate limiting, e.g.

vif = [ 'mac=00:16:3E:74:3d:76,bridge=br0,rate=10MB/s' ]

Add support for mapping rate to and from <bandwidth> in the xenconfig parser and formatter. rate is mapped to the required 'average' attribute of the <outbound> element, e.g.

<interface type='bridge'>

    ...
    <bandwidth>
      <outbound average='10240'/>
    </bandwidth>

</interface>

Also add a unit test to check the conversion logic.

---

I used a bit of code from libxlu_vif.c to implement xenParseVifRate() instead of using the libxlutil lib directly, since in theory rate limiting applies to the old xen driver (no libxl) as well.

Quoted 6 lines
Quoted 5 lines
 src/xenconfig/xen_common.c           | 77 ++++++++++++++++++++++++++++++++++++
 tests/xlconfigdata/test-vif-rate.cfg | 26 ++++++++++++
 tests/xlconfigdata/test-vif-rate.xml | 57 ++++++++++++++++++++++++++
 tests/xlconfigtest.c                 |  1 +
 4 files changed, 161 insertions(+)

ACK

Hi Michal,

Thanks a lot for taking a look at this series! Note that I posted a V2 earlier this week which includes support for parsing/formatting vif bandwidth in sexpr config too

https://www.redhat.com/archives/libvir-list/2016-January/msg00045.html

Unfortunately it results in some changes to this patch, so I think it would be best to peek at the V2 series before pushing it.

Regards,
Jim