Recent autotest/virt-test testing on f20 discovered an anomaly in how the bandwidth options are documented and used. This was discovered due to a bug fix in the /sbin/tc utility found in iproute-3.11.0.1 (on f20) in which overflow was actually caught and returned as an error. The fix was first introduced in iproute-3.10 (search on iproute2 commit 'a303853e'). The autotest/virt-test test for virsh domiftune was attempting to send the largest unsigned integer value (4294967295) for maximum value testing. The libvirt xml implementation was designed to manage values in kibibytes (eg, 1024 blocks of bytes), thus when this value was passed to /sbin/tc, it (now) properly rejected the 4294967295kbps value. Investigation of the problem discovered that formatdomain.html.in and formatnetwork.html.in described the elements and property types slightly differently, although they use the same code - virNetDevBandwidthParseRate() (shared by portgroups, domains, and networks xml parsers). Rather than have the descriptions in two places, this patch will combine and reword the description under formatnetwork.html.in and have formatdomain.html.in link to that description. This documentation faux pas was continued into the virsh man page where the bandwidth description for both 'attach-interface' and 'domiftune' did not indicate the scope of each value, thus leading to the test using largest unsigned integer value, which ultimately will be wrong. Additionally, modified the virnetdevbandwidth.h to use kibibytes instead of kbytes (to be more clear). Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- docs/formatdomain.html.in | 35 +++---------------- docs/formatnetwork.html.in | 81 ++++++++++++++++++++++++++++++++----------- src/util/virnetdevbandwidth.h | 8 ++--- tools/virsh.pod | 10 ++++-- 4 files changed, 77 insertions(+), 57 deletions(-) diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 4660983..ea1a97b 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3750,37 +3750,10 @@ qemu-kvm -net nic,model=? /dev/null <p> This part of interface XML provides setting quality of service. Incoming - and outgoing traffic can be shaped independently. The - <code>bandwidth</code> element can have at most one <code>inbound</code> - and at most one <code>outbound</code> child elements. Leaving any of these - children element out result in no QoS applied on that traffic direction. - So, when you want to shape only domain's incoming traffic, use - <code>inbound</code> only, and vice versa. Each of these elements have one - mandatory attribute <code>average</code> (or <code>floor</code> as - described below). <code>average</code> specifies average bit rate on - the interface being shaped. Then there are two optional attributes: - <code>peak</code>, which specifies maximum rate at which interface can send - data, and <code>burst</code>, amount of bytes that can be burst at - <code>peak</code> speed. Accepted values for attributes are integer - numbers. The units for <code>average</code> and <code>peak</code> attributes - are kilobytes per second, and for the <code>burst</code> just kilobytes. - Note the limitation of implementation: the <code>peak</code> attribute in - <code>outbound</code> element is ignored (as linux ingress filters don't - know it yet). <span class="since">Since 0.9.4</span> The <code>inbound</code> can - optionally have <code>floor</code> attribute. This is there for - guaranteeing minimal throughput for shaped interfaces. This, however, - requires that all traffic goes through one point where QoS decisions can - take place. That's why this attribute works only for virtual networks for - now (that is <code><interface type='network'/></code> with a - forward type of route, nat, or no forward at all). Moreover, the - virtual network the interface is connected to is required to have at least - inbound QoS set (<code>average</code> at least). Moreover, with - <code>floor</code> attribute users don't need to specify - <code>average</code>. However, <code>peak</code> and <code>burst</code> - attributes still require <code>average</code>. Currently, linux kernel - doesn't allow ingress qdiscs to have any classes therefore - <code>floor</code> can be applied only on <code>inbound</code> and not - <code>outbound</code>. <span class="since">Since 1.0.1</span> + and outgoing traffic can be shaped independently. + The <code>bandwidth</code> element and its child elements are described + in the <a href="formatnetwork.html#elementQoS">QoS</a> section of + the Network XML. </p> <h5><a name="elementVlanTag">Setting VLAN tag (on supported network types only)</a></h5> diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in index 1ca1bec..de71ebf 100644 --- a/docs/formatnetwork.html.in +++ b/docs/formatnetwork.html.in @@ -412,40 +412,81 @@ <p> The <code><bandwidth></code> element allows setting - quality of service for a particular network. - <span class="since">Since 0.9.4</span> The limits specified + quality of service for a particular network + (<span class="since">since 0.9.4</span>). For a <code>domain</code> + object, the limits specified are applied to the domain traffic. + For a <code>network</code> object, the limits specified are applied to the aggregate of all traffic to/from all guest interfaces attached to that network, <b>not</b> to each guest - interface individually. Setting <code>bandwidth</code> for a + interface individually. Setting <code>bandwidth</code> for a network is supported only for networks with a <code><forward></code> mode of <code>route</code>, <code>nat</code>, or no mode at all - (i.e. an "isolated" network). <code>bandwidth</code> setting + (i.e. an "isolated" network). Setting <code>bandwidth</code> is <b>not</b> supported for forward modes of <code>bridge</code>, <code>passthrough</code>, <code>private</code>, or <code>hostdev</code>, and attempts to do this will lead to - a failure to define the network (or to create a transient - network). + a failure to define the network (or to create a transient network). </p> <p> Incoming and outgoing traffic can be shaped independently. The - <code>bandwidth</code> element can have at most - one <code>inbound</code> and at most one <code>outbound</code> + <code>bandwidth</code> element can have at most one + <code>inbound</code> and at most one <code>outbound</code> child element. Leaving either of these children elements out results in no QoS applied for that traffic direction. So, - when you want to shape only a network's incoming traffic, use + when you want to shape only incoming traffic, use <code>inbound</code> only, and vice versa. Each of these - elements have one mandatory attribute - <code>average</code>, - which specifies the desired average bit rate for the interface - being shaped (in kibibytes/second). There are also two - optional attributes: <code>peak</code>, which specifies the - maximum rate at which the bridge can send data (again in - kibibytes/second), and <code>burst</code> - the amount of - bytes that can be transmitted in a single burst at - <code>peak</code> speed (in kibibytes). Accepted values for - attributes are integer numbers. The allotted bandwidth is - shared equally between domains connected to the network. + elements have one mandatory attribute - <code>average</code> (or + <code>floor</code> as described below). The attributes are as follows, + where accepted values for each attribute is an integer number. </p> + <dl> + <dt><code>average</code></dt> + <dd> + Specifies the desired average bit rate for the interface + being shaped (in kibibytes/second). + </dd> + <dt><code>peak</code></dt> + <dd> + Optional attribute which specifies the maximum rate at + which the bridge can send data (in kibibytes/second). + Note the limitation of implementation: this attribute in the + <code>outbound</code> element is ignored (as Linux ingress + filters don't know it yet). + </dd> + <dt><code>burst</code></dt> + <dd> + Optional attribute which specifies the amount of kibibytes that + can be transmitted in a single burst at <code>peak</code> speed. + </dd> + <dt><code>floor</code></dt> + <dd> + Optional attribute available only for the <code>inbound</code> + element. This attribute guarantees minimal throughput for + shaped interfaces. This, however, requires that all traffic + goes through one point where QoS decisions can take place, hence + why this attribute works only for virtual networks for now + (that is <code><interface type='network'/></code> with a + forward type of route, nat, or no forward at all). Moreover, the + virtual network the interface is connected to is required to have + at least inbound QoS set (<code>average</code> at least). If + using the <code>floor</code> attribute users don't need to specify + <code>average</code>. However, <code>peak</code> and + <code>burst</code> attributes still require <code>average</code>. + Currently, the Linux kernel doesn't allow ingress qdiscs to have + any classes therefore <code>floor</code> can be applied only + on <code>inbound</code> and not <code>outbound</code>. + </dd> + </dl> + + <p> + Note that a kibibyte is a block of 1024 bytes. Attributes + <code>average</code>, <code>peak</code>, and <code>burst</code> + are available <span class="since">since 0.9.4</span>, while + the <code>floor</code> attribute is only available + <span class="since">since 1.0.1</span>. + </p> + <p> A <code><portgroup></code> element can also include a <code><bandwidth></code> element. In that case, the @@ -561,7 +602,7 @@ network), and each portgroup has a name, as well as various subelements associated with it. The currently supported subelements are <code><bandwidth></code> - (documented <a href="formatdomain.html#elementQoS">here</a>) + (described <a href="formatnetwork.html#elementQoS">here</a>) and <code><virtualport></code> (documented <a href="formatdomain.html#elementsNICSDirect">here</a>). If a domain interface definition specifies a portgroup (by diff --git a/src/util/virnetdevbandwidth.h b/src/util/virnetdevbandwidth.h index 4606a07..2a22820 100644 --- a/src/util/virnetdevbandwidth.h +++ b/src/util/virnetdevbandwidth.h @@ -29,10 +29,10 @@ typedef struct _virNetDevBandwidthRate virNetDevBandwidthRate; typedef virNetDevBandwidthRate *virNetDevBandwidthRatePtr; struct _virNetDevBandwidthRate { - unsigned long long average; /* kbytes/s */ - unsigned long long peak; /* kbytes/s */ - unsigned long long floor; /* kbytes/s */ - unsigned long long burst; /* kbytes */ + unsigned long long average; /* kibibytes/s */ + unsigned long long peak; /* kibibytes/s */ + unsigned long long floor; /* kibibytes/s */ + unsigned long long burst; /* kibibytes */ }; typedef struct _virNetDevBandwidth virNetDevBandwidth; diff --git a/tools/virsh.pod b/tools/virsh.pod index f221475..2cf58a6 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -680,7 +680,11 @@ or the MAC address. If no I<--inbound> or I<--outbound> is specified, this command will query and show the bandwidth settings. Otherwise, it will set the inbound or outbound bandwidth. I<average,peak,burst> is the same as -in command I<attach-interface>. +in command I<attach-interface>. Values for I<average>, I<peak>, and +I<burst> are expressed in kibibytes (blocks of 1024 bytes) as described +in the Network XML documentation at +L<http://libvirt.org/formatnetwork.html#elementQoS>. + If I<--live> is specified, affect a running guest. If I<--config> is specified, affect the next boot of a persistent guest. @@ -2019,7 +2023,9 @@ of the network interface. I<script> allows to specify a path to a script handling a bridge instead of the default one. I<model> allows to specify the model type. I<inbound> and I<outbound> control the bandwidth of the interface. I<peak> and I<burst> are optional, so "average,peak", "average,,burst" and -"average" are also legal. +"average" are also legal. Values for I<average>, I<peak>, and I<burst> are +expressed in kibibytes (blocks of 1024 bytes) as described in the Network +XML documentation at L<http://libvirt.org/formatnetwork.html#elementQoS>. If I<--live> is specified, affect a running domain. If I<--config> is specified, affect the next startup of a persistent domain. -- 1.8.4.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list