Re: [PATCH v2 4/4] slirp: feature detection for smbd

2021-03-09 Thread Samuel Thibault
Joelle van Dyne, le mar. 09 mars 2021 10:11:31 -0800, a ecrit:
> On Tue, Mar 9, 2021 at 6:09 AM Philippe Mathieu-Daudé  
> wrote:
> > On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> > > Replace Windows specific macro with a more generic feature detection
> > > macro. Allows slirp smb feature to be disabled manually as well.
> > >
> > > Signed-off-by: Joelle van Dyne 
> > > ---
> > >  configure   | 26 +++---
> > >  meson.build |  2 +-
> > >  net/slirp.c | 16 
> > >  3 files changed, 32 insertions(+), 12 deletions(-)
> >
> > Hmm v1 had: Acked-by: Samuel Thibault 
> > did you change something to not include Samuel A-b tag?
> 
> Sorry, I must have missed it!

NP :)

Samuel



Re: [PATCH v2 4/4] slirp: feature detection for smbd

2021-03-09 Thread Joelle van Dyne
On Tue, Mar 9, 2021 at 6:09 AM Philippe Mathieu-Daudé  wrote:
>
> Hi Joelle,
>
> On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> > Replace Windows specific macro with a more generic feature detection
> > macro. Allows slirp smb feature to be disabled manually as well.
> >
> > Signed-off-by: Joelle van Dyne 
> > ---
> >  configure   | 26 +++---
> >  meson.build |  2 +-
> >  net/slirp.c | 16 
> >  3 files changed, 32 insertions(+), 12 deletions(-)
>
> Hmm v1 had: Acked-by: Samuel Thibault 
> did you change something to not include Samuel A-b tag?
>

Sorry, I must have missed it!

-j



Re: [PATCH v2 4/4] slirp: feature detection for smbd

2021-03-09 Thread Philippe Mathieu-Daudé
Hi Joelle,

On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> Replace Windows specific macro with a more generic feature detection
> macro. Allows slirp smb feature to be disabled manually as well.
> 
> Signed-off-by: Joelle van Dyne 
> ---
>  configure   | 26 +++---
>  meson.build |  2 +-
>  net/slirp.c | 16 
>  3 files changed, 32 insertions(+), 12 deletions(-)

Hmm v1 had: Acked-by: Samuel Thibault 
did you change something to not include Samuel A-b tag?




Re: [PATCH v2 4/4] slirp: feature detection for smbd

2021-03-09 Thread Philippe Mathieu-Daudé
On 3/9/21 1:27 AM, Joelle van Dyne wrote:
> Replace Windows specific macro with a more generic feature detection
> macro. Allows slirp smb feature to be disabled manually as well.
> 
> Signed-off-by: Joelle van Dyne 

Reviewed-by: Philippe Mathieu-Daudé 

> ---
>  configure   | 26 +++---
>  meson.build |  2 +-
>  net/slirp.c | 16 
>  3 files changed, 32 insertions(+), 12 deletions(-)
> 
> diff --git a/configure b/configure
> index 34fccaa2ba..8335a3e6a0 100755
> --- a/configure
> +++ b/configure
> @@ -465,6 +465,7 @@ fuse_lseek="auto"
>  multiprocess="auto"
>  
>  malloc_trim="auto"
> +slirp_smbd="auto"
>  
>  # parse CC options second
>  for opt do
> @@ -834,8 +835,6 @@ do
>  fi
>  done
>  
> -: ${smbd=${SMBD-/usr/sbin/smbd}}
> -
>  # Default objcc to clang if available, otherwise use CC
>  if has clang; then
>objcc=clang
> @@ -1560,6 +1559,10 @@ for opt do
>;;
>--disable-multiprocess) multiprocess="disabled"
>;;
> +  --enable-slirp-smbd) slirp_smbd=yes
> +  ;;
> +  --disable-slirp-smbd) slirp_smbd=no
> +  ;;
>*)
>echo "ERROR: unknown option $opt"
>echo "Try '$0 --help' for more information"
> @@ -1913,6 +1916,7 @@ disabled with --disable-FEATURE, default is enabled if 
> available
>fuseFUSE block device export
>fuse-lseek  SEEK_HOLE/SEEK_DATA support for FUSE exports
>multiprocessOut of process device emulation support
> +  slirp-smbd  use smbd (at path --smbd=*) in slirp networking
>  
>  NOTE: The object files are built at the place where configure is launched
>  EOF
> @@ -5252,6 +5256,19 @@ case "$slirp" in
>  ;;
>  esac
>  
> +# Check for slirp smbd dupport
> +: ${smbd=${SMBD-/usr/sbin/smbd}}
> +if test "$slirp_smbd" != "no" ; then
> +  if test "$mingw32" = "yes" ; then
> +if test "$slirp_smbd" = "yes" ; then
> +  error_exit "Host smbd not supported on this platform."
> +fi
> +slirp_smbd=no
> +  else
> +slirp_smbd=yes
> +  fi
> +fi
> +
>  ##
>  # check for usable __NR_keyctl syscall
>  
> @@ -5527,7 +5544,10 @@ fi
>  if test "$guest_agent" = "yes" ; then
>echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
>  fi
> -echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
> +if test "$slirp_smbd" = "yes" ; then
> +  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
> +  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
> +fi
>  if test "$vde" = "yes" ; then
>echo "CONFIG_VDE=y" >> $config_host_mak
>echo "VDE_LIBS=$vde_libs" >> $config_host_mak
> diff --git a/meson.build b/meson.build
> index ba0db9fa1f..cad70a8fc5 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -2424,7 +2424,7 @@ summary_info += {'genisoimage':   
> config_host['GENISOIMAGE']}
>  if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
>summary_info += {'wixl':wixl.found() ? wixl.full_path() : 
> false}
>  endif
> -if slirp_opt != 'disabled'
> +if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
>summary_info += {'smbd':config_host['CONFIG_SMBD_COMMAND']}
>  endif
>  summary(summary_info, bool_yn: true, section: 'Host binaries')
> diff --git a/net/slirp.c b/net/slirp.c
> index be914c0be0..b3ded2aac1 100644
> --- a/net/slirp.c
> +++ b/net/slirp.c
> @@ -27,7 +27,7 @@
>  #include "net/slirp.h"
>  
>  
> -#ifndef _WIN32
> +#if defined(CONFIG_SLIRP_SMBD)
>  #include 
>  #include 
>  #endif
> @@ -90,7 +90,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;
> @@ -103,7 +103,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);
> @@ -367,7 +367,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;
> @@ -477,7 +477,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;
> @@ -592,7 +592,7 @@ static int net_slirp_init(NetClientState *peer, const 
> char *model,
>  }
>  }
>  }
> -#ifndef _WIN32
> +#if defined(CON

Re: [PATCH v2 4/4] slirp: feature detection for smbd

2021-03-09 Thread Peter Maydell
On Tue, 9 Mar 2021 at 00:30, Joelle van Dyne  wrote:
>
> Replace Windows specific macro with a more generic feature detection
> macro. Allows slirp smb feature to be disabled manually as well.
>
> Signed-off-by: Joelle van Dyne 
> ---
Reviewed-by: Peter Maydell 

thanks
-- PMM



[PATCH v2 4/4] slirp: feature detection for smbd

2021-03-08 Thread Joelle van Dyne
Replace Windows specific macro with a more generic feature detection
macro. Allows slirp smb feature to be disabled manually as well.

Signed-off-by: Joelle van Dyne 
---
 configure   | 26 +++---
 meson.build |  2 +-
 net/slirp.c | 16 
 3 files changed, 32 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index 34fccaa2ba..8335a3e6a0 100755
--- a/configure
+++ b/configure
@@ -465,6 +465,7 @@ fuse_lseek="auto"
 multiprocess="auto"
 
 malloc_trim="auto"
+slirp_smbd="auto"
 
 # parse CC options second
 for opt do
@@ -834,8 +835,6 @@ do
 fi
 done
 
-: ${smbd=${SMBD-/usr/sbin/smbd}}
-
 # Default objcc to clang if available, otherwise use CC
 if has clang; then
   objcc=clang
@@ -1560,6 +1559,10 @@ for opt do
   ;;
   --disable-multiprocess) multiprocess="disabled"
   ;;
+  --enable-slirp-smbd) slirp_smbd=yes
+  ;;
+  --disable-slirp-smbd) slirp_smbd=no
+  ;;
   *)
   echo "ERROR: unknown option $opt"
   echo "Try '$0 --help' for more information"
@@ -1913,6 +1916,7 @@ disabled with --disable-FEATURE, default is enabled if 
available
   fuseFUSE block device export
   fuse-lseek  SEEK_HOLE/SEEK_DATA support for FUSE exports
   multiprocessOut of process device emulation support
+  slirp-smbd  use smbd (at path --smbd=*) in slirp networking
 
 NOTE: The object files are built at the place where configure is launched
 EOF
@@ -5252,6 +5256,19 @@ case "$slirp" in
 ;;
 esac
 
+# Check for slirp smbd dupport
+: ${smbd=${SMBD-/usr/sbin/smbd}}
+if test "$slirp_smbd" != "no" ; then
+  if test "$mingw32" = "yes" ; then
+if test "$slirp_smbd" = "yes" ; then
+  error_exit "Host smbd not supported on this platform."
+fi
+slirp_smbd=no
+  else
+slirp_smbd=yes
+  fi
+fi
+
 ##
 # check for usable __NR_keyctl syscall
 
@@ -5527,7 +5544,10 @@ fi
 if test "$guest_agent" = "yes" ; then
   echo "CONFIG_GUEST_AGENT=y" >> $config_host_mak
 fi
-echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
+if test "$slirp_smbd" = "yes" ; then
+  echo "CONFIG_SLIRP_SMBD=y" >> $config_host_mak
+  echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak
+fi
 if test "$vde" = "yes" ; then
   echo "CONFIG_VDE=y" >> $config_host_mak
   echo "VDE_LIBS=$vde_libs" >> $config_host_mak
diff --git a/meson.build b/meson.build
index ba0db9fa1f..cad70a8fc5 100644
--- a/meson.build
+++ b/meson.build
@@ -2424,7 +2424,7 @@ summary_info += {'genisoimage':   
config_host['GENISOIMAGE']}
 if targetos == 'windows' and config_host.has_key('CONFIG_GUEST_AGENT')
   summary_info += {'wixl':wixl.found() ? wixl.full_path() : false}
 endif
-if slirp_opt != 'disabled'
+if slirp_opt != 'disabled' and 'CONFIG_SLIRP_SMBD' in config_host
   summary_info += {'smbd':config_host['CONFIG_SMBD_COMMAND']}
 endif
 summary(summary_info, bool_yn: true, section: 'Host binaries')
diff --git a/net/slirp.c b/net/slirp.c
index be914c0be0..b3ded2aac1 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -27,7 +27,7 @@
 #include "net/slirp.h"
 
 
-#ifndef _WIN32
+#if defined(CONFIG_SLIRP_SMBD)
 #include 
 #include 
 #endif
@@ -90,7 +90,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;
@@ -103,7 +103,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);
@@ -367,7 +367,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;
@@ -477,7 +477,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;
@@ -592,7 +592,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;
@@ -784,7 +784,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)
@@ -899,7 +899,7 @@ static int slirp_smb(S