domain_conf: Add configs for virtio net RSS and Hash report.

Added "rss" and "rss_hash_report" configuration that should be
used with qemu virtio RSS. Both options are triswitches. Used as
"driver" options and affects only NIC with model type "virtio".
In other patches - options should turn on virtio-net RSS and hash
properties.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Andrew Melnychenko 2022-01-09 23:07:35 +02:00 committed by Michal Privoznik
parent 167ac6354c
commit a8b1cbe77e
8 changed files with 109 additions and 1 deletions

View File

@ -5338,6 +5338,24 @@ following attributes are available for the ``"virtio"`` NIC driver:
only for ``vhostuser`` type. :since:`Since 3.7.0 (QEMU and KVM only)`
**In general you should leave this option alone, unless you are very certain
you know what you are doing.**
``rss``
The ``rss`` option enables in-qemu/ebpf RSS for virtio NIC. RSS works with
virtio and tap backends only. Virtio NIC will be launched with "rss"
property. For now "in-qemu" RSS is supported by libvirt.
QEMU may load eBPF RSS if it has CAP_SYS_ADMIN permissions, which is
not supported by default in libvirt.
**In general you should leave this option alone, unless you are very certain
you know what you are doing. Proper RSS configuration depends from vcpu,
tap, and vhost settings.**
``rss_hash_report``
The ``rss_hash_report`` option enables in-qemu RSS hash report for virtio
NIC. Virtio NIC will be launched with a "hash" property. Network packets provided
to VM will contain a hash of the packet in the virt header. Usually enabled
alongside with ``rss``. Without ``rss`` option, the hash report doesn't affect
steering itself but provides vnet header with a calculated hash.
**In general you should leave this option alone, unless you are very certain
you know what you are doing. Proper RSS configuration depends from vcpu,
tap, and vhost settings.**
virtio options
For virtio interfaces, `Virtio-specific options <#elementsVirtio>`__ can also
be set. ( :since:`Since 3.5.0` )

View File

@ -10777,6 +10777,16 @@ virDomainNetDefParseXML(virDomainXMLOption *xmlopt,
&def->driver.virtio.tx_queue_size) < 0)
goto error;
if (virXMLPropTristateSwitch(driver_node, "rss",
VIR_XML_PROP_NONE,
&def->driver.virtio.rss) < 0)
goto error;
if (virXMLPropTristateSwitch(driver_node, "rss_hash_report",
VIR_XML_PROP_NONE,
&def->driver.virtio.rss_hash_report) < 0)
goto error;
if ((tmpNode = virXPathNode("./driver/host", ctxt))) {
if (virXMLPropTristateSwitch(tmpNode, "csum", VIR_XML_PROP_NONE,
&def->driver.virtio.host.csum) < 0)
@ -24616,6 +24626,14 @@ virDomainVirtioNetDriverFormat(virBuffer *buf,
if (def->driver.virtio.tx_queue_size)
virBufferAsprintf(buf, " tx_queue_size='%u'",
def->driver.virtio.tx_queue_size);
if (def->driver.virtio.rss != VIR_TRISTATE_SWITCH_ABSENT) {
virBufferAsprintf(buf, " rss='%s'",
virTristateSwitchTypeToString(def->driver.virtio.rss));
}
if (def->driver.virtio.rss_hash_report != VIR_TRISTATE_SWITCH_ABSENT) {
virBufferAsprintf(buf, " rss_hash_report='%s'",
virTristateSwitchTypeToString(def->driver.virtio.rss_hash_report));
}
virDomainVirtioOptionsFormat(buf, def->virtio);
}

View File

@ -1069,6 +1069,8 @@ struct _virDomainNetDef {
virTristateSwitch ecn;
virTristateSwitch ufo;
} guest;
virTristateSwitch rss;
virTristateSwitch rss_hash_report;
} virtio;
} driver;
struct {

View File

@ -3603,6 +3603,16 @@
</optional>
</element>
</optional>
<optional>
<attribute name="rss">
<ref name="virOnOff"/>
</attribute>
</optional>
<optional>
<attribute name="rss_hash_report">
<ref name="virOnOff"/>
</attribute>
</optional>
</interleave>
</element>
</optional>

View File

@ -0,0 +1,58 @@
<domain type='qemu'>
<name>QEMUGuest1</name>
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
<memory unit='KiB'>219100</memory>
<currentMemory unit='KiB'>219100</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='i686' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<cpu mode='custom' match='exact' check='none'>
<model fallback='forbid'>qemu64</model>
</cpu>
<clock offset='utc'/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</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' model='piix3-uhci'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'/>
<controller type='ide' index='0'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
<interface type='user'>
<mac address='00:11:22:33:44:55'/>
<model type='virtio'/>
<driver rss='on'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</interface>
<interface type='user'>
<mac address='00:11:22:33:44:66'/>
<model type='virtio'/>
<driver rss_hash_report='on'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<interface type='user'>
<mac address='00:11:22:33:44:77'/>
<model type='virtio'/>
<driver rss='off' rss_hash_report='on'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
</interface>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
<audio id='1' type='none'/>
<memballoon model='virtio'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</memballoon>
</devices>
</domain>

View File

@ -53,7 +53,7 @@
<interface type='user'>
<mac address='52:54:56:58:5a:5c'/>
<model type='virtio'/>
<driver iommu='on' ats='on' packed='on' page_per_vq='on'/>
<driver rss='on' rss_hash_report='on' iommu='on' ats='on' packed='on' page_per_vq='on'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</interface>
<input type='mouse' bus='virtio'>

View File

@ -0,0 +1 @@
../qemuxml2argvdata/net-virtio-rss.xml

View File

@ -487,6 +487,7 @@ mymain(void)
DO_TEST_NOCAPS("net-many-models");
DO_TEST("net-vdpa", QEMU_CAPS_NETDEV_VHOST_VDPA);
DO_TEST("net-vdpa-multiqueue", QEMU_CAPS_NETDEV_VHOST_VDPA);
DO_TEST_CAPS_LATEST("net-virtio-rss");
DO_TEST_NOCAPS("serial-tcp-tlsx509-chardev");
DO_TEST_NOCAPS("serial-tcp-tlsx509-chardev-notls");