[libvirt] [PATCH v2 4/4] qemu: add multiqueue vhost-user support

John Ferlan jferlan at redhat.com
Thu Jun 11 12:12:10 UTC 2015



On 06/04/2015 01:04 PM, Martin Kletzander wrote:
> From: Maxime Leroy <maxime.leroy at 6wind.com>
> 
> 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 at 6wind.com>
> Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
> ---
>  docs/formatdomain.html.in                                  | 11 +++++++++--
>  src/qemu/qemu_command.c                                    | 14 +++++++++++++-
>  ...ostuser.args => qemuxml2argv-net-vhostuser-multiq.args} |  6 +++++-
>  ...vhostuser.xml => qemuxml2argv-net-vhostuser-multiq.xml} |  6 ++++++
>  tests/qemuxml2argvtest.c                                   |  3 +++
>  5 files changed, 36 insertions(+), 4 deletions(-)
>  copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.args => qemuxml2argv-net-vhostuser-multiq.args} (75%)
>  copy tests/qemuxml2argvdata/{qemuxml2argv-net-vhostuser.xml => qemuxml2argv-net-vhostuser-multiq.xml} (87%)
> 
> diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
> index 72ad54cee188..85238a16af8d 100644
> --- a/docs/formatdomain.html.in
> +++ b/docs/formatdomain.html.in
> @@ -4260,7 +4260,8 @@ qemu-kvm -net nic,model=? /dev/null
>          type='virtio'/></code>, multiple packet processing queues can be
>          created; 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">Since 1.0.6 (QEMU and KVM only) and for vhost-user
> +          since 1.2.17</span>

This read a bit strangely - so I went looking at the context which
describes the feature for the "Multiqueue virtio-net feature" which has
a "Service Temporarily Unavailable" link.

So rather than just adding a mostly cryptic conjunction, how about:

"The optional queues 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 <model type='virtio'/> element. Each queue will
potentially be handled by a different processor, resulting in much
higher throughput.
<span class="since">virtio-net since 1.0.6 (QEMU and KVM only).</span>
<span class="since">vhost-user since 1.2.17.</span>

John
>        </dd>
>        <dt><code>host</code> offloading options</dt>
>        <dd>
> @@ -4581,9 +4582,15 @@ qemu-kvm -net nic,model=? /dev/null
>    <devices>
>      <interface type='vhostuser'>
>        <mac address='52:54:00:3b:83:1a'/>
> -      <source type='unix' path='/tmp/vhost.sock' mode='server'/>
> +      <source type='unix' path='/tmp/vhost1.sock' mode='server'/>
>        <model type='virtio'/>
>      </interface>
> +    <interface type='vhostuser'>
> +      <mac address='52:54:00:3b:83:1b'/>
> +      <source type='unix' path='/tmp/vhost2.sock' mode='client'/>
> +      <model type='virtio'/>
> +      <driver queues='5'/>
> +    </interface>
>    </devices>
>    ...</pre>
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 61faa576e11b..862729f01352 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -8089,6 +8089,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)) {
> @@ -8126,13 +8127,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;
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
> similarity index 75%
> copy from tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
> copy to tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
> index ac43630979ad..8affb53b3958 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.args
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
> @@ -9,4 +9,8 @@ pc -m 214 -smp 1 -nographic -nodefaults -monitor unix:/tmp/test-monitor,server,n
>  -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
> +-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
> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
> similarity index 87%
> copy from tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
> copy to tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
> index fa09157cd570..422fa920513c 100644
> --- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser.xml
> +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
> @@ -38,6 +38,12 @@
>        <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>
> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
> index 11e09ce10d43..26c05452511b 100644
> --- a/tests/qemuxml2argvtest.c
> +++ b/tests/qemuxml2argvtest.c
> @@ -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",
> 




More information about the libvir-list mailing list