From: Vladimir Sementsov-Ogievskiy Date: Thu, 30 Oct 2025 16:40:18 +0000 (+0300) Subject: net/tap: net_init_tap_one(): move parameter checking earlier X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fec61d48d1a4552710259be30c90c8bd4f46e8c3;p=thirdparty%2Fqemu.git net/tap: net_init_tap_one(): move parameter checking earlier Let's keep all similar argument checking in net_init_tap() function. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Maksim Davydov Signed-off-by: Jason Wang --- diff --git a/net/tap.c b/net/tap.c index c162523a03..abeee6be11 100644 --- 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 ||