qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: print a more actionable error when slirp is not found
@ 2022-09-29 16:32 marcandre.lureau
  2022-09-30 19:47 ` Christian Schoenebeck
  0 siblings, 1 reply; 4+ messages in thread
From: marcandre.lureau @ 2022-09-29 16:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: jb-gnumlists, thuth, jasowang, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

If slirp is not found during compile-time, and not manually disabled,
print a friendly error message, as suggested in the "If your networking
is failing after updating to the latest git version of QEMU..." thread
by various people.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 meson.build |  4 ++++
 net/net.c   | 19 +++++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index 8dc661363f..4f69d7d0b4 100644
--- a/meson.build
+++ b/meson.build
@@ -657,6 +657,10 @@ if not get_option('slirp').auto() or have_system
   endif
 endif
 
+if get_option('slirp').disabled()
+  config_host_data.set('CONFIG_SLIRP_DISABLED', true)
+endif
+
 vde = not_found
 if not get_option('vde').auto() or have_system or have_tools
   vde = cc.find_library('vdeplug', has_headers: ['libvdeplug.h'],
diff --git a/net/net.c b/net/net.c
index 2db160e063..e6072a5ddd 100644
--- a/net/net.c
+++ b/net/net.c
@@ -990,14 +990,29 @@ static int net_init_nic(const Netdev *netdev, const char *name,
     return idx;
 }
 
+#if (defined(CONFIG_SLIRP) || !defined(CONFIG_SLIRP_DISABLED))
+static int net_init_user(const Netdev *netdev, const char *name,
+                         NetClientState *peer, Error **errp)
+{
+#ifdef CONFIG_SLIRP
+    return net_init_slirp(netdev, name, peer, errp);
+#else
+    error_setg(errp,
+               "Type 'user' is not a supported netdev backend by this QEMU build "
+               "because the libslirp development files were not found during build "
+               "of QEMU.");
+#endif
+    return -1;
+}
+#endif
 
 static int (* const net_client_init_fun[NET_CLIENT_DRIVER__MAX])(
     const Netdev *netdev,
     const char *name,
     NetClientState *peer, Error **errp) = {
         [NET_CLIENT_DRIVER_NIC]       = net_init_nic,
-#ifdef CONFIG_SLIRP
-        [NET_CLIENT_DRIVER_USER]      = net_init_slirp,
+#if (defined(CONFIG_SLIRP) || !defined(CONFIG_SLIRP_DISABLED))
+        [NET_CLIENT_DRIVER_USER]      = net_init_user,
 #endif
         [NET_CLIENT_DRIVER_TAP]       = net_init_tap,
         [NET_CLIENT_DRIVER_SOCKET]    = net_init_socket,
-- 
2.37.3



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

end of thread, other threads:[~2022-10-13 10:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-29 16:32 [PATCH] net: print a more actionable error when slirp is not found marcandre.lureau
2022-09-30 19:47 ` Christian Schoenebeck
2022-10-02 13:49   ` Marc-André Lureau
2022-10-13 10:14     ` Jakob Bohm

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).