qemu: add multiqueue vhost-user support

This patch adds the support of queues attribute of the driver element
for vhost-user interface type. Example:

<interface type='vhostuser'>
      <mac address='52:54:00:ee:96:6d'/>
      <source type='unix' path='/tmp/vhost2.sock' mode='client'/>
      <model type='virtio'/>
      <driver queues='4'/>
</interface>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1207692

Signed-off-by: Maxime Leroy <maxime.leroy@6wind.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Maxime Leroy 2015-02-26 12:45:57 +01:00 committed by Martin Kletzander
parent 7971723b98
commit 366c22f2bc
5 changed files with 97 additions and 8 deletions

View File

@ -4254,13 +4254,16 @@ qemu-kvm -net nic,model=? /dev/null
</dd>
<dt><code>queues</code></dt>
<dd>
The optional <code>queues</code> attribute controls the number of
queues to be used for the<a href="http://www.linux-kvm.org/page/Multiqueue">
Multiqueue virtio-net</a> feature. If the interface has <code>&lt;model
type='virtio'/&gt;</code>, multiple packet processing queues can be
created; each queue will potentially be handled by a different
The optional <code>queues</code> attribute controls the number
of queues to be used for either
<a href="http://www.linux-kvm.org/page/Multiqueue"> Multiqueue
virtio-net</a> or <a href="#elementVhostuser">vhost-user</a> network
interfaces. Use of multiple packet processing queues requires the
interface having the <code>&lt;model type='virtio'/&gt;</code>
element. Each queue will potentially be handled by a different
processor, resulting in much higher throughput.
<span class="since">Since 1.0.6 (QEMU and KVM only)</span>
<span class="since">virtio-net since 1.0.6 (QEMU and KVM only)</span>
<span class="since">vhost-user since 1.2.17 (QEMU and KVM only)</span>
</dd>
<dt><code>host</code> offloading options</dt>
<dd>
@ -4581,9 +4584,15 @@ qemu-kvm -net nic,model=? /dev/null
&lt;devices&gt;
&lt;interface type='vhostuser'&gt;
&lt;mac address='52:54:00:3b:83:1a'/&gt;
&lt;source type='unix' path='/tmp/vhost.sock' mode='server'/&gt;
&lt;source type='unix' path='/tmp/vhost1.sock' mode='server'/&gt;
&lt;model type='virtio'/&gt;
&lt;/interface&gt;
&lt;interface type='vhostuser'&gt;
&lt;mac address='52:54:00:3b:83:1b'/&gt;
&lt;source type='unix' path='/tmp/vhost2.sock' mode='client'/&gt;
&lt;model type='virtio'/&gt;
&lt;driver queues='5'/&gt;
&lt;/interface&gt;
&lt;/devices&gt;
...</pre>

View File

@ -8102,6 +8102,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
{
virBuffer chardev_buf = VIR_BUFFER_INITIALIZER;
virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
unsigned int queues = net->driver.virtio.queues;
char *nic = NULL;
if (!qemuDomainSupportsNetdev(def, qemuCaps, net)) {
@ -8139,13 +8140,24 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
virBufferAsprintf(&netdev_buf, "type=vhost-user,id=host%s,chardev=char%s",
net->info.alias, net->info.alias);
if (queues > 1) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQ)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("multi-queue is not supported for vhost-user "
"with this QEMU binary"));
goto error;
}
virBufferAsprintf(&netdev_buf, ",queues=%u", queues);
}
virCommandAddArg(cmd, "-chardev");
virCommandAddArgBuffer(cmd, &chardev_buf);
virCommandAddArg(cmd, "-netdev");
virCommandAddArgBuffer(cmd, &netdev_buf);
if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex, 0, qemuCaps))) {
if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex,
queues, qemuCaps))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Error generating NIC -device string"));
goto error;

View File

@ -0,0 +1,16 @@
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
/usr/bin/qemu -S -M \
pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,nowait \
-no-acpi -boot c -usb -hda /dev/HostVG/QEMUGuest1 \
-chardev socket,id=charnet0,path=/tmp/vhost0.sock,server \
-netdev type=vhost-user,id=hostnet0,chardev=charnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,addr=0x3 \
-chardev socket,id=charnet1,path=/tmp/vhost1.sock \
-netdev type=vhost-user,id=hostnet1,chardev=charnet1 \
-device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,addr=0x4 \
-netdev socket,listen=:2015,id=hostnet2 \
-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,addr=0x5 \
-chardev socket,id=charnet3,path=/tmp/vhost2.sock \
-netdev type=vhost-user,id=hostnet3,chardev=charnet3,queues=4 \
-device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,mac=52:54:00:ee:96:6d,\
bus=pci.0,addr=0x6

View File

@ -0,0 +1,49 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219136</memory>
<currentMemory unit='KiB'>219136</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu</emulator>
<disk type='block' device='disk'>
<driver name='qemu' type='raw'/>
<source dev='/dev/HostVG/QEMUGuest1'/>
<target dev='hda' bus='ide'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
</disk>
<controller type='usb' index='0'/>
<controller type='ide' index='0'/>
<controller type='pci' index='0' model='pci-root'/>
<interface type='vhostuser'>
<mac address='52:54:00:ee:96:6b'/>
<source type='unix' path='/tmp/vhost0.sock' mode='server'/>
<model type='virtio'/>
</interface>
<interface type='vhostuser'>
<mac address='52:54:00:ee:96:6c'/>
<source type='unix' path='/tmp/vhost1.sock' mode='client'/>
<model type='virtio'/>
</interface>
<interface type='server'>
<mac address='52:54:00:95:db:c0'/>
<source port='2015'/>
<model type='rtl8139'/>
</interface>
<interface type='vhostuser'>
<mac address='52:54:00:ee:96:6d'/>
<source type='unix' path='/tmp/vhost2.sock' mode='client'/>
<model type='virtio'/>
<driver queues='4'/>
</interface>
<memballoon model='none'/>
</devices>
</domain>

View File

@ -980,6 +980,9 @@ mymain(void)
DO_TEST("misc-uuid", QEMU_CAPS_NAME, QEMU_CAPS_UUID);
DO_TEST_PARSE_ERROR("vhost_queues-invalid", NONE);
DO_TEST("net-vhostuser", QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV);
DO_TEST("net-vhostuser-multiq",
QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV, QEMU_CAPS_VHOSTUSER_MULTIQ);
DO_TEST_FAILURE("net-vhostuser-multiq", QEMU_CAPS_DEVICE, QEMU_CAPS_NETDEV);
DO_TEST("net-user", NONE);
DO_TEST("net-virtio", NONE);
DO_TEST("net-virtio-device",