QEMU configuration

Important

  1. Start a vhost-user netdevice with QEMU:

    -chardev socket,id=vhostusernet0,path=/tmp/vhost_sock0[,server] \
    -netdev type=vhost-user,id=vhostusernet0,chardev=vhostuserchr0,queues=8 \
    -device virtio-net-pci,netdev=vhostusernet0,ioeventfd=on,vectors=17,mq=on
    
    path

    Path to the vhost-user socket.

    server

    Create the vhost-user socket in server mode. This option needs to be set if the Virtio Host PMD socket is configured in client mode.

    queues=x

    Number of queue pairs seen by the driver on the guest. This requires a patch in QEMU, provided in librte_pmd_vhost/patches/qemu-2.x.

    vectors=x

    Required for multiqueue; should be NQ * 2 + 1.

    mq=on

    Enables multiqueue.

    ioeventfd=on

    Should increase notification performance when the guest driver is a Linux driver

  2. [Optional] Modify the set of negotiated features.

    By default, QEMU automatically enables all options supported by both sides (checksum offloading, GSO, mergeable buffers, and so on). To modify the set of negotiated features, you can edit the following parameters:

    guest_csum=on/off

    Offload l4 checksum from host to guest (default: on)

    guest_tso4=on/off

    Forward TSO4 packets from host to guest (default: on)

    guest_tso6=on/off

    Forward TSO6 packets from host to guest (default: on)

    csum=on/off

    Offload l4 checksum from guest to host (default: on)

    host_tso4=on/off

    Forward TSO4 packets from guest to host (default: on)

    host_tso6=on/off

    Forward TSO6 packets from guest to host (default: on)

    mrg_rxbuf=on/off

    Support mergeable buffers in host (default: on)

  3. Display negotiated features via the QEMU monitor:

    (qemu) info qtree
    bus: main-system-bus
      type System
      dev: hpet, id ""
        gpio-in "" 2
        gpio-out "" 1
        timers = 3 (0x3)
        msi = false
        hpet-intcap = 4 (0x4)
        irq 32
        mmio 00000000fed00000/0000000000000400
      dev: kvm-ioapic, id ""
        gpio-in "" 24
        gsi_base = 0 (0x0)
        irq 0
        mmio 00000000fec00000/0000000000001000
      dev: i440FX-pcihost, id ""
        pci-hole64-size = 18446744073709551615 (16 EiB)
        short_root_bus = 0 (0x0)
        irq 0
        bus: pci.0
          type PCI
          dev: virtio-net-pci, id ""
            ioeventfd = true
            vectors = 3 (0x3)
            any_layout = false
            csum = true
            guest_csum = true
            gso = false
            guest_tso4 = true
            guest_tso6 = true
            guest_ecn = false
            guest_ufo = false
            guest_announce = true
            host_tso4 = true
            host_tso6 = true
            host_ecn = false
            host_ufo = false
            mrg_rxbuf = true
            status = true
            ctrl_vq = true
            ctrl_rx = true
            ctrl_vlan = false
            ctrl_rx_extra = false
            ctrl_mac_addr = true
            ctrl_guest_offloads = false
            mq = false
            mac = "02:11:22:00:06:00"
            vlan = <null>
            netdev = "vhostusernet0"
            bootindex = -1 (0xffffffffffffffff)
            x-txtimer = 150000 (0x249f0)
            x-txburst = 256 (0x100)
            tx = ""
            indirect_desc = false
            event_idx = false
            addr = 04.0
            romfile = "efi-virtio.rom"
            rombar = 1 (0x1)
            multifunction = false
            command_serr_enable = true
            class Ethernet controller, addr 00:04.0, pci id 1af4:1000 (sub 1af4:0001)
            bar 0: i/o at 0xc100 [0xc11f]
            bar 1: mem at 0xfebd1000 [0xfebd1fff]
            bar 6: mem at 0xffffffffffffffff [0x3fffe]
            bus: virtio-bus
              type virtio-pci-bus
              dev: virtio-net-device, id ""
                mac = "02:11:22:00:06:00"
                vlan = <null>
                netdev = "vhostusernet0"
                bootindex = -1 (0xffffffffffffffff)
                x-txtimer = 150000 (0x249f0)
                x-txburst = 256 (0x100)
                tx = ""
          dev: ne2k_pci, id ""
            mac = "de:ad:de:01:02:03"
            vlan = <null>
            netdev = "user.0"
            bootindex = -1 (0xffffffffffffffff)
            addr = 03.0
            romfile = "efi-ne2k_pci.rom"
            rombar = 1 (0x1)
            multifunction = false
            command_serr_enable = true
            class Ethernet controller, addr 00:03.0, pci id 10ec:8029 (sub 1af4:1100)
            bar 0: i/o at 0xc000 [0xc0ff]
            bar 6: mem at 0xffffffffffffffff [0x3fffe]
            ...