diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index 92e745cea1..3e3e368da3 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1739,6 +1739,7 @@ qemuValidateDomainDefVhostUserRequireSharedMemory(const virDomainDef *def,
static int
qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
+ const virDomainDef *def,
virQEMUCaps *qemuCaps)
{
bool hasIPv4 = false;
@@ -1819,6 +1820,12 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
return -1;
}
+ if (net->type == VIR_DOMAIN_NET_TYPE_VHOSTUSER &&
+ net->backend.type == VIR_DOMAIN_NET_BACKEND_PASST) {
+ if (qemuValidateDomainDefVhostUserRequireSharedMemory(def, "interface type=\"vhostuser\" backend type=\"passt\"") < 0)
+ return -1;
+ }
+
if (net->type == VIR_DOMAIN_NET_TYPE_VDPA) {
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_NETDEV_VHOST_VDPA)) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
@@ -5443,7 +5450,7 @@ qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
switch (dev->type) {
case VIR_DOMAIN_DEVICE_NET:
- return qemuValidateDomainDeviceDefNetwork(dev->data.net, qemuCaps);
+ return qemuValidateDomainDeviceDefNetwork(dev->data.net, def, qemuCaps);
case VIR_DOMAIN_DEVICE_CHR:
return qemuValidateDomainChrDef(dev->data.chr, def, qemuCaps);
diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.x86_64-latest.err b/tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.x86_64-latest.err
new file mode 100644
index 0000000000..274af5c722
--- /dev/null
+++ b/tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.x86_64-latest.err
@@ -0,0 +1 @@
+unsupported configuration: 'interface type="vhostuser" backend type="passt"' requires shared memory
diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.xml b/tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.xml
new file mode 100644
index 0000000000..e44c91e541
--- /dev/null
+++ b/tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.xml
@@ -0,0 +1,70 @@
+
+ QEMUGuest1
+ c7a5fdbd-edaf-9455-926a-d65c16db1809
+ 219136
+ 219136
+ 1
+
+ hvm
+
+
+
+ destroy
+ restart
+ destroy
+
+ /usr/bin/qemu-system-x86_64
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.args b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.args
index 21d78d6072..7c030d7067 100644
--- a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.args
+++ b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.args
@@ -14,7 +14,7 @@ XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \
-accel tcg \
-cpu qemu64 \
-m size=219136k \
--object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-object '{"qom-type":"memory-backend-file","id":"pc.ram","mem-path":"/var/lib/libvirt/qemu/ram/-1-QEMUGuest1/pc.ram","share":true,"x-use-canonical-path-for-ramblock-id":false,"size":224395264}' \
-overcommit mem-lock=off \
-smp 1,sockets=1,cores=1,threads=1 \
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml
index 26aa4c8d05..a1f9366722 100644
--- a/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml
+++ b/tests/qemuxmlconfdata/net-vhostuser-passt.x86_64-latest.xml
@@ -3,6 +3,9 @@
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
219136
+
+
+
1
hvm
diff --git a/tests/qemuxmlconfdata/net-vhostuser-passt.xml b/tests/qemuxmlconfdata/net-vhostuser-passt.xml
index e44c91e541..71b845329b 100644
--- a/tests/qemuxmlconfdata/net-vhostuser-passt.xml
+++ b/tests/qemuxmlconfdata/net-vhostuser-passt.xml
@@ -3,6 +3,9 @@
c7a5fdbd-edaf-9455-926a-d65c16db1809
219136
219136
+
+
+
1
hvm
diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c
index 34674551a4..c271170d25 100644
--- a/tests/qemuxmlconftest.c
+++ b/tests/qemuxmlconftest.c
@@ -1794,6 +1794,7 @@ mymain(void)
DO_TEST_CAPS_VER("net-user-passt", "7.2.0");
DO_TEST_CAPS_LATEST_PARSE_ERROR("net-user-slirp-portforward");
DO_TEST_CAPS_LATEST("net-vhostuser-passt");
+ DO_TEST_CAPS_LATEST_PARSE_ERROR("net-vhostuser-passt-no-shmem");
DO_TEST_CAPS_LATEST("net-virtio");
DO_TEST_CAPS_LATEST("net-virtio-device");
DO_TEST_CAPS_LATEST("net-virtio-disable-offloads");