]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
net/tap: net_init_tap_one(): move parameter checking earlier
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Thu, 30 Oct 2025 16:40:18 +0000 (19:40 +0300)
committerJason Wang <jasowang@redhat.com>
Fri, 23 Jan 2026 06:41:26 +0000 (14:41 +0800)
Let's keep all similar argument checking in net_init_tap() function.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Maksim Davydov <davydov-max@yandex-team.ru>
Signed-off-by: Jason Wang <jasowang@redhat.com>
net/tap.c

index c162523a03321b943088a550d575419e2c1effc1..abeee6be11d3d68c71fb43f47b540bd7947f303e 100644 (file)
--- a/net/tap.c
+++ b/net/tap.c
@@ -767,9 +767,6 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer,
                        "vhost-net requested but could not be initialized");
             goto failed;
         }
-    } else if (vhostfdname) {
-        error_setg(errp, "vhostfd(s)= is not valid without vhost");
-        goto failed;
     }
 
     return;
@@ -831,6 +828,11 @@ int net_init_tap(const Netdev *netdev, const char *name,
         return -1;
     }
 
+    if (tap->has_vhost && !tap->vhost && (tap->vhostfds || tap->vhostfd)) {
+        error_setg(errp, "vhostfd(s)= is not valid without vhost");
+        return -1;
+    }
+
     if (tap->fd) {
         if (tap->ifname || tap->script || tap->downscript ||
             tap->has_vnet_hdr || tap->helper || tap->has_queues ||