net: simplify net_init_tap_one logic
PATCH 1/1 net: simplify net_init_tap_one logic
net_init_tap_one receives in vhostfdname a fd name from vhostfd= or vhostfds=, or NULL if there is no vhostfd=/vhostfds=. It is simpler to just check vhostfdname, than it is to check for vhostfd= or vhostfds=. This also calms down Coverity, which otherwise thinks that monitor_fd_param could dereference a NULL vhostfdname.
--- net/tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tap.c +2 -2
@@ -662,7 +662,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, options.backend_type =VHOST_BACKEND_TYPE_KERNEL ; options.net_backend = &s->nc; -if (tap->has_vhostfd || tap->has_vhostfds) { +if (vhostfdname) { vhostfd =monitor_fd_param (cur_mon, vhostfdname, &err);if (vhostfd ==-1 ) {error_propagate (errp, err);
@@ -684,7 +684,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, "vhost-net requested but could not be initialized");return ; } - }else if (tap->has_vhostfd || tap->has_vhostfds) { + }else if (vhostfdname) {error_setg (errp,"vhostfd= is not valid without vhost" ); } }
Signature · 1 line
2.5.0
Jason Wang
AppliedQuoted 25 lines · Paolo Bonzini
net_init_tap_onereceives in vhostfdname a fd name from vhostfd= or vhostfds=, or NULL if there is no vhostfd=/vhostfds=. It is simpler to just check vhostfdname, than it is to check for vhostfd= or vhostfds=. This also calms down Coverity, which otherwise thinks thatmonitor_fd_paramcould dereference a NULL vhostfdname.Signed-off-by Paolo Bonzini <[email protected]>--- net/tap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)net/tap.c +1
-1@@ -662,7 +662,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, options.backend_type =VHOST_BACKEND_TYPE_KERNEL ; options.net_backend = &s->nc; -if (tap->has_vhostfd || tap->has_vhostfds) { +if (vhostfdname) { vhostfd =monitor_fd_param (cur_mon, vhostfdname, &err);if (vhostfd ==-1 ) {error_propagate (errp, err);
net/tap.c static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, · line 690
Quoted 8 lines
net/tap.c +1
-1@@ -684,7 +684,7 @@ static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, "vhost-net requested but could not be initialized");return ; } - }else if (tap->has_vhostfd || tap->has_vhostfds) { + }else if (vhostfdname) {error_setg (errp,"vhostfd= is not valid without vhost" ); } }
Applied to -net.
Thanks