[PATCH v3 04/19] net/tap: net_init_tap_one(): move parameter checking earlier

Vladimir Sementsov-Ogievskiy posted 19 patches 3 days, 1 hour ago
[PATCH v3 04/19] net/tap: net_init_tap_one(): move parameter checking earlier
Posted by Vladimir Sementsov-Ogievskiy 3 days, 1 hour ago
Let's keep all similar argument checking in net_init_tap() function.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Tested-by: Lei Yang <leiyang@redhat.com>
---
 net/tap.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/tap.c b/net/tap.c
index 78ddd3d0cd..40ee48e91c 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -752,9 +752,6 @@ static int 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 0;
@@ -816,6 +813,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 ||
-- 
2.48.1