From 1010499de016dd5babf375c203baa62d9799e190 Mon Sep 17 00:00:00 2001 Message-ID: <1010499de016dd5babf375c203baa62d9799e190.1739824249.git.jdenemar@redhat.com> From: Laine Stump Date: Fri, 14 Feb 2025 13:10:19 -0500 Subject: [PATCH] qemu: fail validation if a domain def has vhostuser/passt but no shared mem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This can/should also be done for a traditional vhost-user interface (ie not backend type='passt') but that will be a separate change. Signed-off-by: Laine Stump Reviewed-by: Ján Tomko (cherry picked from commit 70bce2e6ee7a6b738d08fa79d14342969f51668b) https://issues.redhat.com/browse/RHEL-69455 Signed-off-by: Laine Stump --- src/qemu/qemu_validate.c | 9 ++- ...vhostuser-passt-no-shmem.x86_64-latest.err | 1 + .../net-vhostuser-passt-no-shmem.xml | 70 +++++++++++++++++++ .../net-vhostuser-passt.x86_64-latest.args | 2 +- .../net-vhostuser-passt.x86_64-latest.xml | 3 + tests/qemuxmlconfdata/net-vhostuser-passt.xml | 3 + tests/qemuxmlconftest.c | 1 + 7 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.x86_64-latest.err create mode 100644 tests/qemuxmlconfdata/net-vhostuser-passt-no-shmem.xml diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index f33c0c07b4..289a3f94cc 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1724,6 +1724,7 @@ qemuValidateDomainDefVhostUserRequireSharedMemory(const virDomainDef *def, static int qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net, + const virDomainDef *def, virQEMUCaps *qemuCaps) { bool hasIPv4 = false; @@ -1804,6 +1805,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", @@ -5400,7 +5407,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 + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + +
+ + + +