From: Laine Stump
Date: Thu, 3 Feb 2011 20:20:01 +0000 (-0500)
Subject: Add txmode attribute to interface XML for virtio backend
X-Git-Tag: CVE-2011-1146~157
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9bd5c0e248aaa73db4d26ed4abf27acc6f93cc8;p=thirdparty%2Flibvirt.git
Add txmode attribute to interface XML for virtio backend
This is in response to:
https://bugzilla.redhat.com/show_bug.cgi?id=629662
Explanation
qemu's virtio-net-pci driver allows setting the algorithm used for tx
packets to either "bh" or "timer". This is done by adding ",tx=bh" or
",tx=timer" to the "-device virtio-net-pci" commandline option.
'bh' stands for 'bottom half'; when this is set, packet tx is all done
in an iothread in the bottom half of the driver. (In libvirt, this
option is called the more descriptive "iothread".)
'timer' means that tx work is done in qemu, and if there is more tx
data than can be sent at the present time, a timer is set before qemu
moves on to do other things; when the timer fires, another attempt is
made to send more data. (libvirt retains the name "timer" for this
option.)
The resulting difference, according to the qemu developer who added
the option is:
bh makes tx more asynchronous and reduces latency, but potentially
causes more processor bandwidth contention since the cpu doing the
tx isn't necessarily the cpu where the guest generated the
packets.
Solution
This patch provides a libvirt domain xml knob to change the option on
the qemu commandline, by adding a new attribute "txmode" to the
element that can be placed inside any element in
a domain definition. It's use would be something like this:
...
...
I chose to put this setting as an attribute to rather than as
a sub-element to because it is specific to the virtio-net
driver, not something that is generally usable by all network drivers.
(note that this is the same placement as the "driver name=..."
attribute used to choose kernel vs. userland backend for the
virtio-net driver.)
Actually adding the tx=xxx option to the qemu commandline is only done
if the version of qemu being used advertises it in the output of
qemu -device virtio-net-pci,?
If a particular txmode is requested in the XML, and the option isn't
listed in that help output, an UNSUPPORTED_CONFIG error is logged, and
the domain fails to start.
---
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 9f7a1133d1..84b1cab84f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1378,6 +1378,56 @@ qemu-kvm -net nic,model=? /dev/null
ne2k_isa i82551 i82557b i82559er ne2k_pci pcnet rtl8139 e1000 virtio
+ Some NICs may have tunable driver-specific options. These are
+ set as attributes of the driver sub-element of the
+ interface definition. Currently the following attributes are
+ available for the "virtio" NIC driver:
+
+
+
+
txmode
+
+ The txmode attribute specifies how to handle
+ transmission of packets when the transmit buffer is full. The
+ value can be either 'iothread' or 'timer'.
+ Since 0.8.8 (QEMU and KVM only)
+
+ If set to 'iothread', packet tx is all done in an iothread in
+ the bottom half of the driver (this option translates into
+ adding "tx=bh" to the qemu commandline -device virtio-net-pci
+ option).
+
+ If set to 'timer', tx work is done in qemu, and if there is
+ more tx data than can be sent at the present time, a timer is
+ set before qemu moves on to do other things; when the timer
+ fires, another attempt is made to send more data.
+
+ The resulting difference, according to the qemu developer who
+ added the option is: "bh makes tx more asynchronous and reduces
+ latency, but potentially causes more processor bandwidth
+ contention since the cpu doing the tx isn't necessarily the
+ cpu where the guest generated the packets."
+
+ In general you should leave this option alone, unless you
+ are very certain you know what you are doing.
+