From 4e4def21d3744cb4b8a46ffcd3c9e299bc8c8e12 Mon Sep 17 00:00:00 2001 From: Andrew Melnychenko Date: Sun, 9 Jan 2022 23:07:37 +0200 Subject: [PATCH] qemu_command: Generate cmd line for virtio-net.rss hash properties Also, validate that the requested feature is supported by QEMU. Signed-off-by: Andrew Melnychenko Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- src/qemu/qemu_command.c | 2 + src/qemu/qemu_validate.c | 14 ++++++ .../net-virtio-rss.x86_64-latest.args | 43 +++++++++++++++++++ .../virtio-options.x86_64-latest.args | 2 +- tests/qemuxml2argvtest.c | 1 + 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/net-virtio-rss.x86_64-latest.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1f2212469c..bb45954108 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4149,6 +4149,8 @@ qemuBuildNicDevProps(virDomainDef *def, "P:vectors", vectors, "p:rx_queue_size", net->driver.virtio.rx_queue_size, "p:tx_queue_size", net->driver.virtio.tx_queue_size, + "T:rss", net->driver.virtio.rss, + "T:hash", net->driver.virtio.rss_hash_report, "p:host_mtu", net->mtu, "T:failover", failover, NULL) < 0) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 0ffe02be5b..96f5427678 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1750,6 +1750,20 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net, } } + if (net->driver.virtio.rss && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RSS)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio rss is not supported with this QEMU binary")); + return -1; + } + + if (net->driver.virtio.rss_hash_report && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_RSS)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("virtio rss hash report is not supported with this QEMU binary")); + return -1; + } + if (net->mtu && !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/tests/qemuxml2argvdata/net-virtio-rss.x86_64-latest.args b/tests/qemuxml2argvdata/net-virtio-rss.x86_64-latest.args new file mode 100644 index 0000000000..cabea93ba9 --- /dev/null +++ b/tests/qemuxml2argvdata/net-virtio-rss.x86_64-latest.args @@ -0,0 +1,43 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/tmp/lib/domain--1-QEMUGuest1 \ +USER=test \ +LOGNAME=test \ +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=QEMUGuest1,debug-threads=on \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 214 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \ +-overcommit mem-lock=off \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-boot strict=on \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0x2"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-format","id":"ide0-0-0","bootindex":1}' \ +-netdev user,id=hostnet0 \ +-device '{"driver":"virtio-net-pci","rss":true,"netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}' \ +-netdev user,id=hostnet1 \ +-device '{"driver":"virtio-net-pci","hash":true,"netdev":"hostnet1","id":"net1","mac":"00:11:22:33:44:66","bus":"pci.0","addr":"0x3"}' \ +-netdev user,id=hostnet2 \ +-device '{"driver":"virtio-net-pci","rss":false,"hash":true,"netdev":"hostnet2","id":"net2","mac":"00:11:22:33:44:77","bus":"pci.0","addr":"0x4"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x5"}' \ +-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \ +-msg timestamp=on diff --git a/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args b/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args index 48f6b23c0d..ff21b4bf4a 100644 --- a/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args +++ b/tests/qemuxml2argvdata/virtio-options.x86_64-latest.args @@ -38,7 +38,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \ -fsdev local,security_model=mapped,writeout=immediate,id=fsdev-fs1,path=/export/fs2 \ -device '{"driver":"virtio-9p-pci","iommu_platform":true,"ats":true,"packed":true,"page-per-vq":true,"id":"fs1","fsdev":"fsdev-fs1","mount_tag":"fs2","bus":"pci.0","addr":"0x4"}' \ -netdev user,id=hostnet0 \ --device '{"driver":"virtio-net-pci","iommu_platform":true,"ats":true,"packed":true,"page-per-vq":true,"netdev":"hostnet0","id":"net0","mac":"52:54:56:58:5a:5c","bus":"pci.0","addr":"0x6"}' \ +-device '{"driver":"virtio-net-pci","iommu_platform":true,"ats":true,"packed":true,"page-per-vq":true,"rss":true,"hash":true,"netdev":"hostnet0","id":"net0","mac":"52:54:56:58:5a:5c","bus":"pci.0","addr":"0x6"}' \ -device '{"driver":"virtio-mouse-pci","iommu_platform":true,"ats":true,"packed":true,"page-per-vq":true,"id":"input0","bus":"pci.0","addr":"0xe"}' \ -device '{"driver":"virtio-keyboard-pci","iommu_platform":true,"ats":true,"packed":true,"page-per-vq":true,"id":"input1","bus":"pci.0","addr":"0x10"}' \ -device '{"driver":"virtio-tablet-pci","iommu_platform":true,"ats":true,"packed":true,"page-per-vq":true,"id":"input2","bus":"pci.0","addr":"0x11"}' \ diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index a840fa6853..ed41b7a7a2 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1594,6 +1594,7 @@ mymain(void) QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST_CAPS_LATEST("net-vdpa"); DO_TEST_CAPS_LATEST("net-vdpa-multiqueue"); + DO_TEST_CAPS_LATEST("net-virtio-rss"); DO_TEST("hostdev-pci-multifunction", QEMU_CAPS_KVM,