slirp: add configure option to disable smbd

Replace Windows specific macro with a more generic feature detection
macro. Allows slirp smb feature to be disabled manually as well.

Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Joelle van Dyne <j@getutm.app>
Message-Id: <20210315180341.31638-5-j@getutm.app>
[Use $default_feature as the default. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Joelle van Dyne 2021-03-15 11:03:41 -07:00 committed by Paolo Bonzini
parent 4951967d84
commit b8e0c4938b
3 changed files with 32 additions and 12 deletions

View file

@ -27,7 +27,7 @@
#include "net/slirp.h"
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
#include <pwd.h>
#include <sys/wait.h>
#endif
@ -91,7 +91,7 @@ typedef struct SlirpState {
Slirp *slirp;
Notifier poll_notifier;
Notifier exit_notifier;
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
gchar *smb_dir;
#endif
GSList *fwd;
@ -104,7 +104,7 @@ static QTAILQ_HEAD(, SlirpState) slirp_stacks =
static int slirp_hostfwd(SlirpState *s, const char *redir_str, Error **errp);
static int slirp_guestfwd(SlirpState *s, const char *config_str, Error **errp);
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
static int slirp_smb(SlirpState *s, const char *exported_dir,
struct in_addr vserver_addr, Error **errp);
static void slirp_smb_cleanup(SlirpState *s);
@ -377,7 +377,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
struct in6_addr ip6_prefix;
struct in6_addr ip6_host;
struct in6_addr ip6_dns;
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
struct in_addr smbsrv = { .s_addr = 0 };
#endif
NetClientState *nc;
@ -487,7 +487,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
return -1;
}
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
if (vsmbserver && !inet_aton(vsmbserver, &smbsrv)) {
error_setg(errp, "Failed to parse SMB address");
return -1;
@ -602,7 +602,7 @@ static int net_slirp_init(NetClientState *peer, const char *model,
}
}
}
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
if (smb_export) {
if (slirp_smb(s, smb_export, smbsrv, errp) < 0) {
goto error;
@ -794,7 +794,7 @@ void hmp_hostfwd_add(Monitor *mon, const QDict *qdict)
}
#ifndef _WIN32
#if defined(CONFIG_SLIRP_SMBD)
/* automatic user mode samba server configuration */
static void slirp_smb_cleanup(SlirpState *s)
@ -909,7 +909,7 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
return 0;
}
#endif /* !defined(_WIN32) */
#endif /* defined(CONFIG_SLIRP_SMBD) */
static int guestfwd_can_read(void *opaque)
{