[PATCH 3/6] qemu: only limit IPv4 prefix for slirp

Laine Stump via Devel posted 6 patches 6 days, 19 hours ago
[PATCH 3/6] qemu: only limit IPv4 prefix for slirp
Posted by Laine Stump via Devel 6 days, 19 hours ago
From: Laine Stump <laine@redhat.com>

The slirp backend is limited in what the netmask/prefix of a
user-specified IP address can be, but passt doesn't have these
artificial limitations - any valid prefix is okay with passt, so we
shouldn't reject them

Signed-off-by: Laine Stump <laine@redhat.com>
---
 src/qemu/qemu_validate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
index a0ddf512f1..1c6662751b 100644
--- a/src/qemu/qemu_validate.c
+++ b/src/qemu/qemu_validate.c
@@ -1926,8 +1926,9 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
             }
             hasV4Addr = true;
 
-            if (ip->prefix > 0 &&
-                (ip->prefix < 4 || ip->prefix > 27)) {
+            if (net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST &&
+                (ip->prefix > 0 &&
+                 (ip->prefix < 4 || ip->prefix > 27))) {
                 virReportError(VIR_ERR_XML_ERROR, "%s",
                                _("invalid prefix, must be in range of 4-27"));
                 return -1;
-- 
2.52.0
Re: [PATCH 3/6] qemu: only limit IPv4 prefix for slirp
Posted by Michal Prívozník via Devel 6 days, 13 hours ago
On 2/24/26 08:52, Laine Stump via Devel wrote:
> From: Laine Stump <laine@redhat.com>
> 
> The slirp backend is limited in what the netmask/prefix of a
> user-specified IP address can be, but passt doesn't have these
> artificial limitations - any valid prefix is okay with passt, so we
> shouldn't reject them
> 
> Signed-off-by: Laine Stump <laine@redhat.com>
> ---
>  src/qemu/qemu_validate.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c
> index a0ddf512f1..1c6662751b 100644
> --- a/src/qemu/qemu_validate.c
> +++ b/src/qemu/qemu_validate.c
> @@ -1926,8 +1926,9 @@ qemuValidateDomainDeviceDefNetwork(const virDomainNetDef *net,
>              }
>              hasV4Addr = true;
>  
> -            if (ip->prefix > 0 &&
> -                (ip->prefix < 4 || ip->prefix > 27)) {
> +            if (net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST &&
> +                (ip->prefix > 0 &&
> +                 (ip->prefix < 4 || ip->prefix > 27))) {
>                  virReportError(VIR_ERR_XML_ERROR, "%s",
>                                 _("invalid prefix, must be in range of 4-27"));
>                  return -1;

This block of code starts with:

    for (i = 0; i < net->guestIP.nips; i++) {
        const virNetDevIPAddr *ip = net->guestIP.ips[i];

        if (net->type != VIR_DOMAIN_NET_TYPE_USER &&
            net->backend.type != VIR_DOMAIN_NET_BACKEND_PASST) {
            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                           _("Invalid attempt to set network interface guest-side IP address info, not supported for this interface type/backend"));
            return -1;
        }

IOW this patch is a dead code, effectively.

Michal