qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] net: simplify net_init_tap_one logic
@ 2016-02-25 23:05 Paolo Bonzini
  2016-02-26  7:13 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Bonzini @ 2016-02-25 23:05 UTC (permalink / raw)
  To: qemu-devel; +Cc: jasowang

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.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 net/tap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/tap.c b/net/tap.c
index cfb6831..cd7a7fc 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -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");
     }
 }
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] net: simplify net_init_tap_one logic
  2016-02-25 23:05 [Qemu-devel] [PATCH] net: simplify net_init_tap_one logic Paolo Bonzini
@ 2016-02-26  7:13 ` Jason Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2016-02-26  7:13 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel



On 02/26/2016 07:05 AM, Paolo Bonzini wrote:
> 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.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  net/tap.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/tap.c b/net/tap.c
> index cfb6831..cd7a7fc 100644
> --- a/net/tap.c
> +++ b/net/tap.c
> @@ -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");
>      }
>  }

Applied to -net.

Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-26  7:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-25 23:05 [Qemu-devel] [PATCH] net: simplify net_init_tap_one logic Paolo Bonzini
2016-02-26  7:13 ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).