Skip to contentSkip to conversation

qapi/net: gate user/vde/netmap netdev backends behind their CONFIG symbols

PATCH In review Rohitashv Kumar 2 participants 2 messages Jul 28 – Aug 20 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qapi/net: gate user/vde/netmap netdev backends behind their CONFIG symbols

From: Rohitashv Kumar <[email protected]>

Their NetClientDriver enum members and Netdev union branches were unconditional, so query-qmp-schema advertised them even when built without CONFIG_SLIRP/CONFIG_VDE/CONFIG_NETMAP. Gate them, and guard the matching NET_CLIENT_DRIVER_USER/_VDE case labels in net/hub.c.

---
 net/hub.c     |  4 ++++
 qapi/net.json | 19 +++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)
net/hub.c +4 -0
index ee5881f6d5..2a7c2bc6d7 100644
@@ -294,12 +294,16 @@ void net_hub_check_clients(void)
 #ifdef CONFIG_PASST
             case NET_CLIENT_DRIVER_PASST:
 #endif
+#ifdef CONFIG_SLIRP
             case NET_CLIENT_DRIVER_USER:
+#endif
             case NET_CLIENT_DRIVER_TAP:
             case NET_CLIENT_DRIVER_SOCKET:
             case NET_CLIENT_DRIVER_STREAM:
             case NET_CLIENT_DRIVER_DGRAM:
+#ifdef CONFIG_VDE
             case NET_CLIENT_DRIVER_VDE:
+#endif
             case NET_CLIENT_DRIVER_VHOST_USER:
                 has_host_dev = 1;
                 break;
qapi/net.json +13 -6
index 1a6382825c..e9f1300629 100644
@@ -922,9 +922,13 @@
 # Since: 2.7
 ##
 { 'enum': 'NetClientDriver',
-  'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'stream',
-            'dgram', 'vde', 'bridge', 'hubport', 'netmap', 'vhost-user',
-            'vhost-vdpa',
+  'data': [ 'none', 'nic',
+            { 'name': 'user', 'if': 'CONFIG_SLIRP' },
+            'tap', 'l2tpv3', 'socket', 'stream', 'dgram',
+            { 'name': 'vde', 'if': 'CONFIG_VDE' },
+            'bridge', 'hubport',
+            { 'name': 'netmap', 'if': 'CONFIG_NETMAP' },
+            'vhost-user', 'vhost-vdpa',
             { 'name': 'passt', 'if': 'CONFIG_PASST' },
             { 'name': 'af-xdp', 'if': 'CONFIG_AF_XDP' },
             { 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' },
@@ -949,16 +953,19 @@
     'nic':      'NetLegacyNicOptions',
     'passt':    { 'type': 'NetdevPasstOptions',
                   'if': 'CONFIG_PASST' },
-    'user':     'NetdevUserOptions',
+    'user':     { 'type': 'NetdevUserOptions',
+                  'if': 'CONFIG_SLIRP' },
     'tap':      'NetdevTapOptions',
     'l2tpv3':   'NetdevL2TPv3Options',
     'socket':   'NetdevSocketOptions',
     'stream':   'NetdevStreamOptions',
     'dgram':    'NetdevDgramOptions',
-    'vde':      'NetdevVdeOptions',
+    'vde':      { 'type': 'NetdevVdeOptions',
+                  'if': 'CONFIG_VDE' },
     'bridge':   'NetdevBridgeOptions',
     'hubport':  'NetdevHubPortOptions',
-    'netmap':   'NetdevNetmapOptions',
+    'netmap':   { 'type': 'NetdevNetmapOptions',
+                  'if': 'CONFIG_NETMAP' },
     'af-xdp':   { 'type': 'NetdevAFXDPOptions',
                   'if': 'CONFIG_AF_XDP' },
     'vhost-user': 'NetdevVhostUserOptions',
Signature · 1 line
2.50.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 68 lines · Rohitashv Kumar

From: Rohitashv Kumar <[email protected]>

Their NetClientDriver enum members and Netdev union branches were unconditional, so query-qmp-schema advertised them even when built without CONFIG_SLIRP/CONFIG_VDE/CONFIG_NETMAP. Gate them, and guard the matching NET_CLIENT_DRIVER_USER/_VDE case labels in net/hub.c.

---
 net/hub.c     |  4 ++++
 qapi/net.json | 19 +++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)
net/hub.c +4 -0
index ee5881f6d5..2a7c2bc6d7 100644
@@ -294,12 +294,16 @@ void net_hub_check_clients(void)
 #ifdef CONFIG_PASST
             case NET_CLIENT_DRIVER_PASST:
 #endif
+#ifdef CONFIG_SLIRP
             case NET_CLIENT_DRIVER_USER:
+#endif
             case NET_CLIENT_DRIVER_TAP:
             case NET_CLIENT_DRIVER_SOCKET:
             case NET_CLIENT_DRIVER_STREAM:
             case NET_CLIENT_DRIVER_DGRAM:
+#ifdef CONFIG_VDE
             case NET_CLIENT_DRIVER_VDE:
+#endif
             case NET_CLIENT_DRIVER_VHOST_USER:
                 has_host_dev = 1;
                 break;
qapi/net.json +9 -5
index 1a6382825c..e9f1300629 100644
@@ -922,9 +922,13 @@
 # Since: 2.7
 ##
 { 'enum': 'NetClientDriver',
-  'data': [ 'none', 'nic', 'user', 'tap', 'l2tpv3', 'socket', 'stream',
-            'dgram', 'vde', 'bridge', 'hubport', 'netmap', 'vhost-user',
-            'vhost-vdpa',
+  'data': [ 'none', 'nic',
+            { 'name': 'user', 'if': 'CONFIG_SLIRP' },
+            'tap', 'l2tpv3', 'socket', 'stream', 'dgram',
+            { 'name': 'vde', 'if': 'CONFIG_VDE' },
+            'bridge', 'hubport',
+            { 'name': 'netmap', 'if': 'CONFIG_NETMAP' },
+            'vhost-user', 'vhost-vdpa',
             { 'name': 'passt', 'if': 'CONFIG_PASST' },
             { 'name': 'af-xdp', 'if': 'CONFIG_AF_XDP' },
             { 'name': 'vmnet-host', 'if': 'CONFIG_VMNET' },
@@ -949,16 +953,19 @@
     'nic':      'NetLegacyNicOptions',
     'passt':    { 'type': 'NetdevPasstOptions',
                   'if': 'CONFIG_PASST' },
-    'user':     'NetdevUserOptions',
+    'user':     { 'type': 'NetdevUserOptions',
+                  'if': 'CONFIG_SLIRP' },
     'tap':      'NetdevTapOptions',
     'l2tpv3':   'NetdevL2TPv3Options',
     'socket':   'NetdevSocketOptions',
     'stream':   'NetdevStreamOptions',
     'dgram':    'NetdevDgramOptions',
-    'vde':      'NetdevVdeOptions',

qapi/net.json line 971

Quoted 10 lines
qapi/net.json +4 -1
+    'vde':      { 'type': 'NetdevVdeOptions',
+                  'if': 'CONFIG_VDE' },
     'bridge':   'NetdevBridgeOptions',
     'hubport':  'NetdevHubPortOptions',
-    'netmap':   'NetdevNetmapOptions',
+    'netmap':   { 'type': 'NetdevNetmapOptions',
+                  'if': 'CONFIG_NETMAP' },
     'af-xdp':   { 'type': 'NetdevAFXDPOptions',
                   'if': 'CONFIG_AF_XDP' },
     'vhost-user': 'NetdevVhostUserOptions',

Any occurence of NET_CLIENT_DRIVER_USER, NET_CLIENT_DRIVER_VDE, NET_CLIENT_DRIVER_NETMAP must now be properly guarded the same way.

The patch fixes up the ones in net/hub.c.

Checking the other ones:

* all three in net/net.c: already guarded by the same #ifdef

* _USER in net/slirp.c: net/meson.build compiles it only when: slirp

* _VDE in net/vde.c: net/meson.build compiles it only when: vde

* _NETMAP in net/netmap.c: net/meson.build compiles it only if have_netmap

Good.