Search code examples
qemukvmtap

How to create a multiqueue tap device in Linux?


I've tried with the following command to create a tap device tap0 for my virtual machine vm1:

$ tunctl -t tap0 -u root
$ brctl addif br0 tap0
$ ifconfig tap0 up

When check its channels I got the following error:

$ ethtool -l tap0
Cannot get device channel parameters
: Operation not supported

I thought maybe the method I create tap0 is incorrect but I don't know the correct way.

Any help is appreciated.


Solution

  • About the question, I still don't know how to achieve it. But I found another way to create multiqueue tap devices for VM with qemu-kvm. Here is my script:

    #!/bin/bash
    
    qemu-kvm -name vm1 -smp cpus=8 -m 8192 \
            -drive file=/opt/kvm/vm1.qcow2,if=virtio \
            -netdev tap,id=dev0,script=no,downscript=no,ifname=tap0,vhost=on,queues=8 \
            -device virtio-net-pci,netdev=dev0,mac=52:54:00:56:78:90,mq=on,vectors=18 \
            -daemonize
    
    if [ $? -eq 0 ];then
            sleep 5
            brctl addif br1 tap0
            ifconfig tap0 up
    fi
    

    The script creates a tap device tap0 with 8 queues, adds tap0 to bridge br0, and sets tap0 up.

    You can use ethtool -l [ifname] in your VM, here is my output:

    $ ethtool -l eth0
    Pre-set maximums:
    RX:             0
    TX:             0
    Other:          0
    Combined:       8
    Current hardware settings:
    RX:             0
    TX:             0
    Other:          0
    Combined:       8         # current has 8 queues enabled
    

    Done.