[RFC PATCH v3 6/6] tests: Added tests for eBPF blob loading.

Andrew Melnychenko posted 6 patches 6 months, 2 weeks ago
There is a newer version of this series
[RFC PATCH v3 6/6] tests: Added tests for eBPF blob loading.
Posted by Andrew Melnychenko 6 months, 2 weeks ago
Added net-virtio-rss-bpf to qemuxmlconf's test.
Synthetically modified caps-9.0.0 with a reply.
Added mock functions for loading eBPF.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 .../caps_9.0.0_x86_64.replies                 | 199 ++++++++++--------
 .../caps_9.0.0_x86_64.xml                     |   4 +
 tests/qemuxml2argvmock.c                      |  21 ++
 .../net-virtio-rss-bpf.x86_64-latest.args     |  37 ++++
 .../net-virtio-rss-bpf.x86_64-latest.xml      |  46 ++++
 tests/qemuxmlconfdata/net-virtio-rss-bpf.xml  |  46 ++++
 tests/qemuxmlconftest.c                       |   4 +
 7 files changed, 265 insertions(+), 92 deletions(-)
 create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
 create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
 create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.xml

diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
index 5d36853ce3..b94625904b 100644
--- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
+++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
@@ -23654,21 +23654,36 @@
 }
 
 {
-  "execute": "query-kvm",
+  "execute": "request-ebpf",
+  "arguments": {
+    "id": "rss"
+  },
+  "id": "libvirt-5"
+}
+
+{
+  "return": {
+    "object": "Test data"
+  },
   "id": "libvirt-5"
 }
 
+{
+  "execute": "query-kvm",
+  "id": "libvirt-6"
+}
+
 {
   "return": {
     "enabled": true,
     "present": true
   },
-  "id": "libvirt-5"
+  "id": "libvirt-6"
 }
 
 {
   "execute": "qom-list-types",
-  "id": "libvirt-6"
+  "id": "libvirt-7"
 }
 
 {
@@ -26378,7 +26393,7 @@
       "parent": "x86_64-cpu"
     }
   ],
-  "id": "libvirt-6"
+  "id": "libvirt-7"
 }
 
 {
@@ -26386,7 +26401,7 @@
   "arguments": {
     "typename": "virtio-blk-pci"
   },
-  "id": "libvirt-7"
+  "id": "libvirt-8"
 }
 
 {
@@ -26801,7 +26816,7 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-7"
+  "id": "libvirt-8"
 }
 
 {
@@ -26809,7 +26824,7 @@
   "arguments": {
     "typename": "virtio-net-pci"
   },
-  "id": "libvirt-8"
+  "id": "libvirt-9"
 }
 
 {
@@ -27268,7 +27283,7 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-8"
+  "id": "libvirt-9"
 }
 
 {
@@ -27276,7 +27291,7 @@
   "arguments": {
     "typename": "virtio-scsi-pci"
   },
-  "id": "libvirt-9"
+  "id": "libvirt-10"
 }
 
 {
@@ -27542,7 +27557,7 @@
       "type": "child<virtio-scsi-device>"
     }
   ],
-  "id": "libvirt-9"
+  "id": "libvirt-10"
 }
 
 {
@@ -27550,11 +27565,11 @@
   "arguments": {
     "typename": "virtio-net-ccw"
   },
-  "id": "libvirt-10"
+  "id": "libvirt-11"
 }
 
 {
-  "id": "libvirt-10",
+  "id": "libvirt-11",
   "error": {
     "class": "DeviceNotFound",
     "desc": "Device 'virtio-net-ccw' not found"
@@ -27566,11 +27581,11 @@
   "arguments": {
     "typename": "virtio-scsi-ccw"
   },
-  "id": "libvirt-11"
+  "id": "libvirt-12"
 }
 
 {
-  "id": "libvirt-11",
+  "id": "libvirt-12",
   "error": {
     "class": "DeviceNotFound",
     "desc": "Device 'virtio-scsi-ccw' not found"
@@ -27582,7 +27597,7 @@
   "arguments": {
     "typename": "vfio-pci"
   },
-  "id": "libvirt-12"
+  "id": "libvirt-13"
 }
 
 {
@@ -27800,7 +27815,7 @@
       "type": "int32"
     }
   ],
-  "id": "libvirt-12"
+  "id": "libvirt-13"
 }
 
 {
@@ -27808,7 +27823,7 @@
   "arguments": {
     "typename": "scsi-hd"
   },
-  "id": "libvirt-13"
+  "id": "libvirt-14"
 }
 
 {
@@ -28009,7 +28024,7 @@
       "type": "int32"
     }
   ],
-  "id": "libvirt-13"
+  "id": "libvirt-14"
 }
 
 {
@@ -28017,7 +28032,7 @@
   "arguments": {
     "typename": "ide-hd"
   },
-  "id": "libvirt-14"
+  "id": "libvirt-15"
 }
 
 {
@@ -28168,7 +28183,7 @@
       "type": "int32"
     }
   ],
-  "id": "libvirt-14"
+  "id": "libvirt-15"
 }
 
 {
@@ -28176,7 +28191,7 @@
   "arguments": {
     "typename": "PIIX4_PM"
   },
-  "id": "libvirt-15"
+  "id": "libvirt-16"
 }
 
 {
@@ -28299,7 +28314,7 @@
       "type": "link<irq>"
     }
   ],
-  "id": "libvirt-15"
+  "id": "libvirt-16"
 }
 
 {
@@ -28307,7 +28322,7 @@
   "arguments": {
     "typename": "usb-redir"
   },
-  "id": "libvirt-16"
+  "id": "libvirt-17"
 }
 
 {
@@ -28363,7 +28378,7 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-16"
+  "id": "libvirt-17"
 }
 
 {
@@ -28371,7 +28386,7 @@
   "arguments": {
     "typename": "usb-storage"
   },
-  "id": "libvirt-17"
+  "id": "libvirt-18"
 }
 
 {
@@ -28486,7 +28501,7 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-17"
+  "id": "libvirt-18"
 }
 
 {
@@ -28494,7 +28509,7 @@
   "arguments": {
     "typename": "kvm-pit"
   },
-  "id": "libvirt-18"
+  "id": "libvirt-19"
 }
 
 {
@@ -28510,7 +28525,7 @@
       "type": "LostTickPolicy"
     }
   ],
-  "id": "libvirt-18"
+  "id": "libvirt-19"
 }
 
 {
@@ -28518,7 +28533,7 @@
   "arguments": {
     "typename": "VGA"
   },
-  "id": "libvirt-19"
+  "id": "libvirt-20"
 }
 
 {
@@ -28640,7 +28655,7 @@
       "type": "uint32"
     }
   ],
-  "id": "libvirt-19"
+  "id": "libvirt-20"
 }
 
 {
@@ -28648,7 +28663,7 @@
   "arguments": {
     "typename": "vmware-svga"
   },
-  "id": "libvirt-20"
+  "id": "libvirt-21"
 }
 
 {
@@ -28723,7 +28738,7 @@
       "type": "uint32"
     }
   ],
-  "id": "libvirt-20"
+  "id": "libvirt-21"
 }
 
 {
@@ -28731,7 +28746,7 @@
   "arguments": {
     "typename": "qxl"
   },
-  "id": "libvirt-21"
+  "id": "libvirt-22"
 }
 
 {
@@ -28871,7 +28886,7 @@
       "type": "int32"
     }
   ],
-  "id": "libvirt-21"
+  "id": "libvirt-22"
 }
 
 {
@@ -28879,7 +28894,7 @@
   "arguments": {
     "typename": "virtio-gpu-pci"
   },
-  "id": "libvirt-22"
+  "id": "libvirt-23"
 }
 
 {
@@ -29141,7 +29156,7 @@
       "type": "child<virtio-gpu-device>"
     }
   ],
-  "id": "libvirt-22"
+  "id": "libvirt-23"
 }
 
 {
@@ -29149,7 +29164,7 @@
   "arguments": {
     "typename": "virtio-gpu-device"
   },
-  "id": "libvirt-23"
+  "id": "libvirt-24"
 }
 
 {
@@ -29249,7 +29264,7 @@
       "type": "size"
     }
   ],
-  "id": "libvirt-23"
+  "id": "libvirt-24"
 }
 
 {
@@ -29257,7 +29272,7 @@
   "arguments": {
     "typename": "ICH9-LPC"
   },
-  "id": "libvirt-24"
+  "id": "libvirt-25"
 }
 
 {
@@ -29515,7 +29530,7 @@
       "type": "link<irq>"
     }
   ],
-  "id": "libvirt-24"
+  "id": "libvirt-25"
 }
 
 {
@@ -29523,7 +29538,7 @@
   "arguments": {
     "typename": "virtio-balloon-pci"
   },
-  "id": "libvirt-25"
+  "id": "libvirt-26"
 }
 
 {
@@ -29778,7 +29793,7 @@
       "type": "child<virtio-balloon-device>"
     }
   ],
-  "id": "libvirt-25"
+  "id": "libvirt-26"
 }
 
 {
@@ -29786,11 +29801,11 @@
   "arguments": {
     "typename": "virtio-balloon-ccw"
   },
-  "id": "libvirt-26"
+  "id": "libvirt-27"
 }
 
 {
-  "id": "libvirt-26",
+  "id": "libvirt-27",
   "error": {
     "class": "DeviceNotFound",
     "desc": "Device 'virtio-balloon-ccw' not found"
@@ -29802,7 +29817,7 @@
   "arguments": {
     "typename": "virtio-balloon-device"
   },
-  "id": "libvirt-27"
+  "id": "libvirt-28"
 }
 
 {
@@ -29906,7 +29921,7 @@
       "type": "guest statistics"
     }
   ],
-  "id": "libvirt-27"
+  "id": "libvirt-28"
 }
 
 {
@@ -29914,7 +29929,7 @@
   "arguments": {
     "typename": "intel-iommu"
   },
-  "id": "libvirt-28"
+  "id": "libvirt-29"
 }
 
 {
@@ -29987,7 +30002,7 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-28"
+  "id": "libvirt-29"
 }
 
 {
@@ -29995,7 +30010,7 @@
   "arguments": {
     "typename": "mch"
   },
-  "id": "libvirt-29"
+  "id": "libvirt-30"
 }
 
 {
@@ -30070,7 +30085,7 @@
       "type": "uint16"
     }
   ],
-  "id": "libvirt-29"
+  "id": "libvirt-30"
 }
 
 {
@@ -30078,7 +30093,7 @@
   "arguments": {
     "typename": "nvdimm"
   },
-  "id": "libvirt-30"
+  "id": "libvirt-31"
 }
 
 {
@@ -30120,7 +30135,7 @@
       "type": "uint64"
     }
   ],
-  "id": "libvirt-30"
+  "id": "libvirt-31"
 }
 
 {
@@ -30128,7 +30143,7 @@
   "arguments": {
     "typename": "pcie-root-port"
   },
-  "id": "libvirt-31"
+  "id": "libvirt-32"
 }
 
 {
@@ -30281,7 +30296,7 @@
       "type": "size"
     }
   ],
-  "id": "libvirt-31"
+  "id": "libvirt-32"
 }
 
 {
@@ -30289,7 +30304,7 @@
   "arguments": {
     "typename": "usb-host"
   },
-  "id": "libvirt-32"
+  "id": "libvirt-33"
 }
 
 {
@@ -30385,7 +30400,7 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-32"
+  "id": "libvirt-33"
 }
 
 {
@@ -30393,7 +30408,7 @@
   "arguments": {
     "typename": "vhost-user-fs-device"
   },
-  "id": "libvirt-33"
+  "id": "libvirt-34"
 }
 
 {
@@ -30479,7 +30494,7 @@
       "type": "int32"
     }
   ],
-  "id": "libvirt-33"
+  "id": "libvirt-34"
 }
 
 {
@@ -30487,7 +30502,7 @@
   "arguments": {
     "typename": "virtio-mem-pci"
   },
-  "id": "libvirt-34"
+  "id": "libvirt-35"
 }
 
 {
@@ -30748,7 +30763,7 @@
       "type": "child<virtio-mem>"
     }
   ],
-  "id": "libvirt-34"
+  "id": "libvirt-35"
 }
 
 {
@@ -30756,7 +30771,7 @@
   "arguments": {
     "typename": "virtio-iommu-pci"
   },
-  "id": "libvirt-35"
+  "id": "libvirt-36"
 }
 
 {
@@ -31000,7 +31015,7 @@
       "type": "child<virtio-iommu-device>"
     }
   ],
-  "id": "libvirt-35"
+  "id": "libvirt-36"
 }
 
 {
@@ -31008,7 +31023,7 @@
   "arguments": {
     "typename": "memory-backend-file"
   },
-  "id": "libvirt-36"
+  "id": "libvirt-37"
 }
 
 {
@@ -31102,7 +31117,7 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-36"
+  "id": "libvirt-37"
 }
 
 {
@@ -31110,7 +31125,7 @@
   "arguments": {
     "typename": "memory-backend-memfd"
   },
-  "id": "libvirt-37"
+  "id": "libvirt-38"
 }
 
 {
@@ -31189,7 +31204,7 @@
       "type": "int"
     }
   ],
-  "id": "libvirt-37"
+  "id": "libvirt-38"
 }
 
 {
@@ -31197,7 +31212,7 @@
   "arguments": {
     "typename": "max-x86_64-cpu"
   },
-  "id": "libvirt-38"
+  "id": "libvirt-39"
 }
 
 {
@@ -33114,12 +33129,12 @@
       "type": "bool"
     }
   ],
-  "id": "libvirt-38"
+  "id": "libvirt-39"
 }
 
 {
   "execute": "query-machines",
-  "id": "libvirt-39"
+  "id": "libvirt-40"
 }
 
 {
@@ -33755,7 +33770,7 @@
       "default-ram-id": "pc.ram"
     }
   ],
-  "id": "libvirt-39"
+  "id": "libvirt-40"
 }
 
 {
@@ -33763,7 +33778,7 @@
   "arguments": {
     "typename": "none-machine"
   },
-  "id": "libvirt-40"
+  "id": "libvirt-41"
 }
 
 {
@@ -33876,12 +33891,12 @@
       "type": "child<container>"
     }
   ],
-  "id": "libvirt-40"
+  "id": "libvirt-41"
 }
 
 {
   "execute": "query-cpu-definitions",
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
@@ -36263,12 +36278,12 @@
       "deprecated": false
     }
   ],
-  "id": "libvirt-41"
+  "id": "libvirt-42"
 }
 
 {
   "execute": "query-tpm-models",
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
@@ -36276,12 +36291,12 @@
     "tpm-crb",
     "tpm-tis"
   ],
-  "id": "libvirt-42"
+  "id": "libvirt-43"
 }
 
 {
   "execute": "query-tpm-types",
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
@@ -36289,12 +36304,12 @@
     "passthrough",
     "emulator"
   ],
-  "id": "libvirt-43"
+  "id": "libvirt-44"
 }
 
 {
   "execute": "query-command-line-options",
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
@@ -37769,12 +37784,12 @@
       "option": "drive"
     }
   ],
-  "id": "libvirt-44"
+  "id": "libvirt-45"
 }
 
 {
   "execute": "query-migrate-capabilities",
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
@@ -37876,16 +37891,16 @@
       "capability": "mapped-ram"
     }
   ],
-  "id": "libvirt-45"
+  "id": "libvirt-46"
 }
 
 {
   "execute": "query-sev-capabilities",
-  "id": "libvirt-46"
+  "id": "libvirt-47"
 }
 
 {
-  "id": "libvirt-46",
+  "id": "libvirt-47",
   "error": {
     "class": "GenericError",
     "desc": "SEV: Failed to open /dev/sev: No such file or directory"
@@ -37894,11 +37909,11 @@
 
 {
   "execute": "query-sgx-capabilities",
-  "id": "libvirt-47"
+  "id": "libvirt-48"
 }
 
 {
-  "id": "libvirt-47",
+  "id": "libvirt-48",
   "error": {
     "class": "GenericError",
     "desc": "SGX is not enabled in KVM"
@@ -37913,7 +37928,7 @@
       "name": "host"
     }
   },
-  "id": "libvirt-48"
+  "id": "libvirt-49"
 }
 
 {
@@ -38281,7 +38296,7 @@
       }
     }
   },
-  "id": "libvirt-48"
+  "id": "libvirt-49"
 }
 
 {
@@ -38295,7 +38310,7 @@
       }
     }
   },
-  "id": "libvirt-49"
+  "id": "libvirt-50"
 }
 
 {
@@ -38663,7 +38678,7 @@
       }
     }
   },
-  "id": "libvirt-49"
+  "id": "libvirt-50"
 }
 
 {
@@ -38678,7 +38693,7 @@
       }
     }
   },
-  "id": "libvirt-50"
+  "id": "libvirt-51"
 }
 
 {
@@ -39152,7 +39167,7 @@
       }
     }
   },
-  "id": "libvirt-50"
+  "id": "libvirt-51"
 }
 
 {
diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml
index 204d243247..eafe2c30f8 100644
--- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml
+++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.xml
@@ -205,6 +205,7 @@
   <flag name='display-reload'/>
   <flag name='usb-mtp'/>
   <flag name='virtio-sound'/>
+  <flag name='virtio-net.ebpf_rss_fds'/>
   <version>9000000</version>
   <microcodeVersion>43100245</microcodeVersion>
   <package>v9.0.0</package>
@@ -3691,4 +3692,7 @@
     <cap name='ipi'/>
     <cap name='avic'/>
   </hypervCapabilities>
+  <ebpf>
+    <object id='rss' data='Test data'/>
+  </ebpf>
 </qemuCaps>
diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
index 9cc97199c4..0d1ebbe5b9 100644
--- a/tests/qemuxml2argvmock.c
+++ b/tests/qemuxml2argvmock.c
@@ -292,3 +292,24 @@ virNetDevSetMTU(const char *ifname G_GNUC_UNUSED,
 {
     return 0;
 }
+
+int
+qemuInterfaceLoadEbpf(__attribute__((unused)) const char *ebpfObject,
+        __attribute__((unused)) void **retLibbpfObj, int *fds, size_t nfds)
+{
+    if (nfds >= 4) {
+        fds[0] = 0x100;
+        fds[1] = 0x101;
+        fds[2] = 0x102;
+        fds[3] = 0x103;
+        return 4;
+    } else {
+        return -1;
+    }
+}
+
+void
+qemuInterfaceCloseEbpf(__attribute__((unused)) void *libbpfObj)
+{
+    return;
+}
diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
new file mode 100644
index 0000000000..b9497e5a73
--- /dev/null
+++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
@@ -0,0 +1,37 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/var/lib/libvirt/qemu/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":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
+-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
+-accel tcg \
+-cpu qemu64 \
+-m size=219136k \
+-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 \
+-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","read-only":false}' \
+-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-storage","id":"ide0-0-0","bootindex":1}' \
+-netdev '{"type":"user","id":"hostnet0"}' \
+-device '{"driver":"virtio-net-pci","rss":true,"ebpf-rss-fds":["256","257","258","259"],"netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}' \
+-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/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
new file mode 100644
index 0000000000..198540380c
--- /dev/null
+++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
@@ -0,0 +1,46 @@
+<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>
+    <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>
diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml b/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
new file mode 100644
index 0000000000..198540380c
--- /dev/null
+++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
@@ -0,0 +1,46 @@
+<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>
+    <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>
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 2842b44b3e..0f53ef0408 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -1785,7 +1785,11 @@ mymain(void)
     DO_TEST_CAPS_LATEST_FAILURE("net-hostdev-fail");
     DO_TEST_CAPS_LATEST("net-vdpa");
     DO_TEST_CAPS_LATEST("net-vdpa-multiqueue");
+
+    driver.config->allowEBPF = false;
     DO_TEST_CAPS_LATEST("net-virtio-rss");
+    driver.config->allowEBPF = true;
+    DO_TEST_CAPS_LATEST("net-virtio-rss-bpf");
 
     DO_TEST_CAPS_LATEST("hostdev-pci-multifunction");
 
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [RFC PATCH v3 6/6] tests: Added tests for eBPF blob loading.
Posted by Michal Prívozník 6 months, 1 week ago
On 5/12/24 21:45, Andrew Melnychenko wrote:
> Added net-virtio-rss-bpf to qemuxmlconf's test.
> Synthetically modified caps-9.0.0 with a reply.
> Added mock functions for loading eBPF.
> 
> Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> ---
>  .../caps_9.0.0_x86_64.replies                 | 199 ++++++++++--------
>  .../caps_9.0.0_x86_64.xml                     |   4 +
>  tests/qemuxml2argvmock.c                      |  21 ++
>  .../net-virtio-rss-bpf.x86_64-latest.args     |  37 ++++
>  .../net-virtio-rss-bpf.x86_64-latest.xml      |  46 ++++
>  tests/qemuxmlconfdata/net-virtio-rss-bpf.xml  |  46 ++++
>  tests/qemuxmlconftest.c                       |   4 +
>  7 files changed, 265 insertions(+), 92 deletions(-)
>  create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
>  create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
>  create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
> 
> diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
> index 5d36853ce3..b94625904b 100644
> --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
> +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies


Changes to this file should be done earlier.

> diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
> index 9cc97199c4..0d1ebbe5b9 100644
> --- a/tests/qemuxml2argvmock.c
> +++ b/tests/qemuxml2argvmock.c
> @@ -292,3 +292,24 @@ virNetDevSetMTU(const char *ifname G_GNUC_UNUSED,
>  {
>      return 0;
>  }
> +
> +int
> +qemuInterfaceLoadEbpf(__attribute__((unused)) const char *ebpfObject,
> +        __attribute__((unused)) void **retLibbpfObj, int *fds, size_t nfds)
> +{
> +    if (nfds >= 4) {
> +        fds[0] = 0x100;
> +        fds[1] = 0x101;
> +        fds[2] = 0x102;
> +        fds[3] = 0x103;
> +        return 4;
> +    } else {
> +        return -1;
> +    }
> +}
> +
> +void
> +qemuInterfaceCloseEbpf(__attribute__((unused)) void *libbpfObj)
> +{
> +    return;
> +}
> diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
> new file mode 100644
> index 0000000000..b9497e5a73
> --- /dev/null
> +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
> @@ -0,0 +1,37 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
> +USER=test \
> +LOGNAME=test \
> +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
> +XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
> +XDG_CONFIG_HOME=/var/lib/libvirt/qemu/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":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
> +-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
> +-accel tcg \
> +-cpu qemu64 \
> +-m size=219136k \
> +-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 \
> +-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","read-only":false}' \
> +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-storage","id":"ide0-0-0","bootindex":1}' \
> +-netdev '{"type":"user","id":"hostnet0"}' \
> +-device '{"driver":"virtio-net-pci","rss":true,"ebpf-rss-fds":["256","257","258","259"],"netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}' \
> +-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/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
> new file mode 100644
> index 0000000000..198540380c
> --- /dev/null
> +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
> @@ -0,0 +1,46 @@
> +<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>
> +    <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>
> diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml b/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
> new file mode 100644
> index 0000000000..198540380c
> --- /dev/null
> +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
> @@ -0,0 +1,46 @@
> +<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>
> +    <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>
> diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
> index 2842b44b3e..0f53ef0408 100644
> --- a/tests/qemuxmlconftest.c
> +++ b/tests/qemuxmlconftest.c
> @@ -1785,7 +1785,11 @@ mymain(void)
>      DO_TEST_CAPS_LATEST_FAILURE("net-hostdev-fail");
>      DO_TEST_CAPS_LATEST("net-vdpa");
>      DO_TEST_CAPS_LATEST("net-vdpa-multiqueue");
> +
> +    driver.config->allowEBPF = false;
>      DO_TEST_CAPS_LATEST("net-virtio-rss");
> +    driver.config->allowEBPF = true;
> +    DO_TEST_CAPS_LATEST("net-virtio-rss-bpf");

What we usually do in this case is something like:

g_setenv("SOME_ENV_VAR", 0, true);
DO_TEST_CAPS_LATEST();
unsetenv("SOME_ENV_VAR");

See TEST_TPM_ENV_VAR for example.

And then the mocked version of qemuInterfaceLoadEbpf() would check for
this envvar and if set/unset do the mocked code or just return 0 or
something.

>  
>      DO_TEST_CAPS_LATEST("hostdev-pci-multifunction");
>  

Michal
Re: [RFC PATCH v3 6/6] tests: Added tests for eBPF blob loading.
Posted by Andrew Melnichenko 6 months ago
Hi all,

On Fri, May 17, 2024 at 5:00 PM Michal Prívozník <mprivozn@redhat.com> wrote:
>
> On 5/12/24 21:45, Andrew Melnychenko wrote:
> > Added net-virtio-rss-bpf to qemuxmlconf's test.
> > Synthetically modified caps-9.0.0 with a reply.
> > Added mock functions for loading eBPF.
> >
> > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > ---
> >  .../caps_9.0.0_x86_64.replies                 | 199 ++++++++++--------
> >  .../caps_9.0.0_x86_64.xml                     |   4 +
> >  tests/qemuxml2argvmock.c                      |  21 ++
> >  .../net-virtio-rss-bpf.x86_64-latest.args     |  37 ++++
> >  .../net-virtio-rss-bpf.x86_64-latest.xml      |  46 ++++
> >  tests/qemuxmlconfdata/net-virtio-rss-bpf.xml  |  46 ++++
> >  tests/qemuxmlconftest.c                       |   4 +
> >  7 files changed, 265 insertions(+), 92 deletions(-)
> >  create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
> >  create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
> >  create mode 100644 tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
> >
> > diff --git a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
> > index 5d36853ce3..b94625904b 100644
> > --- a/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
> > +++ b/tests/qemucapabilitiesdata/caps_9.0.0_x86_64.replies
>
>
> Changes to this file should be done earlier.
>
> > diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c
> > index 9cc97199c4..0d1ebbe5b9 100644
> > --- a/tests/qemuxml2argvmock.c
> > +++ b/tests/qemuxml2argvmock.c
> > @@ -292,3 +292,24 @@ virNetDevSetMTU(const char *ifname G_GNUC_UNUSED,
> >  {
> >      return 0;
> >  }
> > +
> > +int
> > +qemuInterfaceLoadEbpf(__attribute__((unused)) const char *ebpfObject,
> > +        __attribute__((unused)) void **retLibbpfObj, int *fds, size_t nfds)
> > +{
> > +    if (nfds >= 4) {
> > +        fds[0] = 0x100;
> > +        fds[1] = 0x101;
> > +        fds[2] = 0x102;
> > +        fds[3] = 0x103;
> > +        return 4;
> > +    } else {
> > +        return -1;
> > +    }
> > +}
> > +
> > +void
> > +qemuInterfaceCloseEbpf(__attribute__((unused)) void *libbpfObj)
> > +{
> > +    return;
> > +}
> > diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
> > new file mode 100644
> > index 0000000000..b9497e5a73
> > --- /dev/null
> > +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.args
> > @@ -0,0 +1,37 @@
> > +LC_ALL=C \
> > +PATH=/bin \
> > +HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \
> > +USER=test \
> > +LOGNAME=test \
> > +XDG_DATA_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \
> > +XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \
> > +XDG_CONFIG_HOME=/var/lib/libvirt/qemu/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":"/var/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \
> > +-machine pc,usb=off,dump-guest-core=off,memory-backend=pc.ram,acpi=off \
> > +-accel tcg \
> > +-cpu qemu64 \
> > +-m size=219136k \
> > +-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 \
> > +-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","read-only":false}' \
> > +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-storage","id":"ide0-0-0","bootindex":1}' \
> > +-netdev '{"type":"user","id":"hostnet0"}' \
> > +-device '{"driver":"virtio-net-pci","rss":true,"ebpf-rss-fds":["256","257","258","259"],"netdev":"hostnet0","id":"net0","mac":"00:11:22:33:44:55","bus":"pci.0","addr":"0x2"}' \
> > +-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/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
> > new file mode 100644
> > index 0000000000..198540380c
> > --- /dev/null
> > +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.x86_64-latest.xml
> > @@ -0,0 +1,46 @@
> > +<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>
> > +    <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>
> > diff --git a/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml b/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
> > new file mode 100644
> > index 0000000000..198540380c
> > --- /dev/null
> > +++ b/tests/qemuxmlconfdata/net-virtio-rss-bpf.xml
> > @@ -0,0 +1,46 @@
> > +<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>
> > +    <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>
> > diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
> > index 2842b44b3e..0f53ef0408 100644
> > --- a/tests/qemuxmlconftest.c
> > +++ b/tests/qemuxmlconftest.c
> > @@ -1785,7 +1785,11 @@ mymain(void)
> >      DO_TEST_CAPS_LATEST_FAILURE("net-hostdev-fail");
> >      DO_TEST_CAPS_LATEST("net-vdpa");
> >      DO_TEST_CAPS_LATEST("net-vdpa-multiqueue");
> > +
> > +    driver.config->allowEBPF = false;
> >      DO_TEST_CAPS_LATEST("net-virtio-rss");
> > +    driver.config->allowEBPF = true;
> > +    DO_TEST_CAPS_LATEST("net-virtio-rss-bpf");
>
> What we usually do in this case is something like:
>
> g_setenv("SOME_ENV_VAR", 0, true);
> DO_TEST_CAPS_LATEST();
> unsetenv("SOME_ENV_VAR");
>
> See TEST_TPM_ENV_VAR for example.
>
> And then the mocked version of qemuInterfaceLoadEbpf() would check for
> this envvar and if set/unset do the mocked code or just return 0 or
> something.

Thank you, I'll check what I can implement in the next version.

>
> >
> >      DO_TEST_CAPS_LATEST("hostdev-pci-multifunction");
> >
>
> Michal
>