Skip to contentSkip to conversation

SAMBA support in QEMU

Qemu-devel Fabrice Bellard 14 participants 30 messages Sep 5, 2004 – Dec 21, 2004

lore
Share & tools
lore
#0 lore raw

Hi,

I just commited a simple solution to enable direct access to host files from Windows guests with user mode networking and with almost no set up. It is currently very experimental but it works, at least for Windows 98 with the Samba server from Red Hat 9. Any suggestion is welcome.

How to use it:

* host config:
qemu -user-net -smb /myhostdir ...

* guest config:

Add the line:

10.0.2.4 smbserver

in the file C:\WINDOWS\LMHOSTS (for windows 9x)

Then /myhostdir can be accessed in '\\smbserver\qemu'. No network drive can be mapped to it, so it is better to add a short cut to this link.

Ignore the messages saying that the network directory cannot be reached.

Fabrice.

#1 lore raw

Le Mon, 06 Sep 2004 01:24:08 +0200, Fabrice Bellard a écrit :

Quoted 7 lines

Hi,

I just commited a simple solution to enable direct access to host files from Windows guests with user mode networking and with almost no set up. It is currently very experimental but it works, at least for Windows 98 with the Samba server from Red Hat 9. Any suggestion is welcome.

Just a small fix to make it build for windows.

vl.c 2004-09-06 02:22:41.086234244 +0200 renamed from vl.c.old 2004-09-06 02:25:03.958702256 +0200 +8 -1
@@ -29,6 +29,7 @@
 #include <time.h>
 #include <errno.h>
 #include <sys/time.h>
+#include <dirent.h>
 
 #ifndef _WIN32
 #include <sys/times.h>
@@ -38,7 +39,6 @@
 #include <sys/mman.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <dirent.h>
 #ifdef _BSD
 #include <sys/stat.h>
 #ifndef __APPLE__
@@ -1493,10 +1493,17 @@
 
     /* XXX: better tmp dir construction */
     snprintf(smb_dir, sizeof(smb_dir), "/tmp/qemu-smb.%d", getpid());
+       #ifdef _WIN32
+       if (mkdir(smb_dir) < 0) {
+               fprintf(stderr, "qemu: could not create samba server dir '%s'\n", smb_dir);
+               exit(1);
+                                   }
+       #else
     if (mkdir(smb_dir, 0700) < 0) {
         fprintf(stderr, "qemu: could not create samba server dir '%s'\n", smb_dir);
         exit(1);
     }
+    #endif
     snprintf(smb_conf, sizeof(smb_conf), "%s/%s", smb_dir, "smb.conf");
 
     f = fopen(smb_conf, "w");
#2 lore raw

Le Mon, 06 Sep 2004 02:30:50 +0200, Ronald a écrit :

Quoted 2 lines

Just a small fix to make it build for windows.

Perhaps the following could be more usefull.
Not sure if this is correct and even work.

vl.c 2004-09-06 18:51:54.751498634 +0200 renamed from vl.c.old 2004-09-06 18:55:04.524395364 +0200 +7 -2
@@ -29,6 +29,7 @@
 #include <time.h>
 #include <errno.h>
 #include <sys/time.h>
+#include <dirent.h>
 
 #ifndef _WIN32
 #include <sys/times.h>
@@ -38,7 +39,6 @@
 #include <sys/mman.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <dirent.h>
 #ifdef _BSD
 #include <sys/stat.h>
 #ifndef __APPLE__
@@ -1493,7 +1493,11 @@
     }
 
     /* XXX: better tmp dir construction */
-    snprintf(smb_dir, sizeof(smb_dir), "/tmp/qemu-smb.%d", getpid());
+       #ifdef _WIN32
+       snprintf(smb_cmdline, sizeof(smb_cmdline), "net share qemu=%s", exported_dir);
+       atexit(snprintf(smb_cmdline, sizeof(smb_cmdline), "net share qemu=%s /DELETE", exported_dir));
+       #else
+       snprintf(smb_dir, sizeof(smb_dir), "/tmp/qemu-smb.%d", getpid());
     if (mkdir(smb_dir, 0700) < 0) {
         fprintf(stderr, "qemu: could not create samba server dir '%s'\n", smb_dir);
         exit(1);
@@ -1526,6 +1530,7 @@
     atexit(smb_exit);
 
     snprintf(smb_cmdline, sizeof(smb_cmdline), "/usr/sbin/smbd -s %s", smb_conf);
+#endif
 
     slirp_add_exec(0, smb_cmdline, 4, 139);
 }
#3 lore raw

Le Mon, 06 Sep 2004 19:02:07 +0200, Ronald a écrit :

+ atexit(snprintf(smb_cmdline, sizeof(smb_cmdline),

Quoted 1 line

"net share qemu=%s /DELETE", exported_dir));

That will not work.

#4 lore raw
In reply to Ronald

Le Mon, 06 Sep 2004 19:02:07 +0200, Ronald a écrit :

Quoted 9 lines

Le Mon, 06 Sep 2004 02:30:50 +0200, Ronald a écrit :

Quoted 3 lines

Just a small fix to make it build for windows.

Perhaps the following could be more usefull. Not sure if this is correct and even work.

No, the whole thing don't work, although the build goes fine and qemu don't crash, the process is not launched when using slirp_add_exec, something related to unimplemented fork_exec for win32? So I've just put some #ifndef around the smb related parts in vl.c to build latest cvs.

vl.c 2004-09-10 14:44:01.049726726 +0200 renamed from vl.c.old 2004-09-06 18:55:04.524395364 +0200 +6 -2
@@ -1454,6 +1454,8 @@
     fprintf(stderr, "qemu: syntax: -redir [tcp|udp]:host-port:[guest-host]:guest-port\n");
     exit(1);
 }
+
+#ifndef _WIN32
 
 char smb_dir[1024];
 
@@ -1526,10 +1528,10 @@
     atexit(smb_exit);
 
     snprintf(smb_cmdline, sizeof(smb_cmdline), "/usr/sbin/smbd -s %s", smb_conf);
-
+
     slirp_add_exec(0, smb_cmdline, 4, 139);
 }
-
+#endif /* ifndef _WIN32 */
 #endif /* CONFIG_SLIRP */
 
 #if !defined(_WIN32)
@@ -2913,8 +2915,10 @@
             case QEMU_OPTION_tftp:
                tftp_prefix = optarg;
                 break;
+#ifndef _WIN32
             case QEMU_OPTION_smb:
                net_slirp_smb(optarg);
+#endif
                 break;
             case QEMU_OPTION_user_net:
                 net_if_type = NET_IF_USER;
#5 lore raw

Hi,

Quoted 4 lines · Ronald

No, the whole thing don't work, although the build goes fine and qemu don't crash, the process is not launched when using slirp_add_exec, something related to unimplemented fork_exec for win32? So I've just put some #ifndef around the smb related parts in vl.c to build latest cvs.

You are building with MinGW? I don't know if qemu compiles using cygwin:
fork() is POSIX, which win32 doesn't comply to, so cygwin implements it. AFAIK MinGW doesn't do that.

Ciao,
Dscho

#6 lore raw

Le Fri, 10 Sep 2004 16:37:56 +0200, Johannes Schindelin a écrit :

Quoted 9 lines

Hi,

Quoted 4 lines · Ronald

No, the whole thing don't work, although the build goes fine and qemu don't crash, the process is not launched when using slirp_add_exec, something related to unimplemented fork_exec for win32? So I've just put some #ifndef around the smb related parts in vl.c to build latest cvs.

You are building with MinGW?

Yes, I am building on a linux box.

Quoted 4 lines

I don't know if qemu compiles using cygwin:
fork() is POSIX, which win32 doesn't comply to, so cygwin implements it. AFAIK MinGW doesn't do that.

The closest to fork function I have found for the win32api is CreateProcess, but I am afraid it's beyond my current abilities to do a minimal windows version of fork_exec (if this is really this function which is responsible for the child process not running).

#7 lore raw
In reply to Fabrice Bellard
Quoted 18 lines · Fabrice Bellard

Hi,

I just commited a simple solution to enable direct access to host files from Windows guests with user mode networking and with almost no set up. It is currently very experimental but it works, at least for Windows 98 with the Samba server from Red Hat 9. Any suggestion is welcome.

How to use it:

* host config:
qemu -user-net -smb /myhostdir ...

* guest config:

Add the line:

10.0.2.4 smbserver

Quoted 9 lines

in the file C:\WINDOWS\LMHOSTS (for windows 9x)

Then /myhostdir can be accessed in '\\smbserver\qemu'. No network drive can be mapped to it, so it is better to add a short cut to this link.

Ignore the messages saying that the network directory cannot be reached.

Fabrice.

Curious, why the LMHOSTS change? Is name resolution not working across the NAT? I think that's just an issue of port forwarding of NetBT (RFC 1001, 1002) ports. Possibly may need to write some extra NAT code too (it's been a while since I had to deal with NATing SMB).

-- John.

#8 lore raw
In reply to Fabrice Bellard

Works on SuSE 9.1 (Samba 3.0.2a) with Win98 as guest. But: the user who starts qemu needs read/write access to /etc/secrets.tdb, which I think is A Bad Idea (TM) ;-)
Perhaps this is on SuSE only? Or did I miss a samba configuration option to store secrets.tdb in smb_dir ?

Mapping works (net use x: \\smbserver\qemu). Drive is available until next reboot (Win 98!).

Mikesch

P.S.: Performance HOST->GUEST is ok, GUEST->HOST could be better...

#9 lore raw
Quoted 1 line · Mikesch Nepomuk

Mapping works (net use x: \\smbserver\qemu). Drive is available until next reboot (Win 98!).

You can even make the mapping permanent with regedit:
(only tested with W98SE as client)

save the following lines to a file "qemu.reg" and enter "regedit qemu.reg"

-8<-----------------------------
REGEDIT4

[HKEY_CURRENT_USER\Network\Persistent\X]
"ProviderName"="Microsoft Network"
"UserName"="QEMU"
"RemotePath"="\\\\SMBSERVER\\QEMU"
-8<-----------------------------

look out for correct (DOS) line endings.

Groeten,
Mark.
--
:wq

#10 lore raw
Quoted 1 line

Mapping works (net use x:

\\smbserver\qemu). Drive is
available until next

Quoted 1 line

reboot (Win 98!).

Doesn't Win98 have the
"/PERSISTENT:YES" option for
"net use" ? This will make
the drive staying there at the
next boot.

Andreas

#11 lore raw
In reply to Fabrice Bellard
Quoted 4 lines · Fabrice Bellard

Hi,

I just commited a simple solution to enable direct access to host files from Windows guests with user mode networking and with almost no set up. It is currently very experimental but it works, at least for Windows 98 with the Samba server from Red Hat 9. Any suggestion is welcome.

Fabrice,

Even without your latest patch, I have been able to mount SAMBA shares from the host to the guest with user-net. The only thing I had missed is that in order to have it work without a DNS on the network, I needed to create a LMHOSTS file. Thanks for the tip. However, I have had to patch slirp.c in order to continue when there is no network (patch included)

Host : Mac OSX 10.3.5
Guest : W98
SAMBA : The server included in 10.3.5
LMHOSTS : "SMBSERVER 10.0.2.2"
Mount shares as E: -> \\SBMSERVER\HOMES (if you have created a user as needed)

				F: -> \\SMBSERVER\SHARED

I guess that that way, I might even be able to use SAMBA to print. I have Internet connectivity and SMB access to host. I'm happy.

Since I generated the patch the wrong way, you need to patch -R.
You also need the patch posted by Mark Jonckheere on Aug 31st (Message-Id: <[email protected]>).

*** qemu/slirp/slirp.c Sun Sep 5 16:28:27 2004
--- qemu-0.6.0/slirp/slirp.c Sat Jul 10 20:20:09 2004
***************
*** 85,95 ****

      struct in_addr tmp_addr;
      
      f = fopen("/etc/resolv.conf", "r");

! if (!f){
! //return -1;
! tmp_addr = our_addr;
! *pdns_addr = tmp_addr;

! 	  }else{
      lprint("IP address of your DNS(s): ");
      while (fgets(buff, 512, f) != NULL) {
          if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
--- 43,51 ----
      struct in_addr tmp_addr;
      
      f = fopen("/etc/resolv.conf", "r");
!     if (!f)
!         return -1;
! 
      lprint("IP address of your DNS(s): ");
      while (fgets(buff, 512, f) != NULL) {
          if (sscanf(buff, "nameserver%*[ \t]%256s", buff2) == 1) {
***************
*** 110,123 ****
          }
      }
      fclose(f);

! }
! if (!found){
! //return -1;
! tmp_addr = our_addr;
! *pdns_addr = tmp_addr;
! }

      return 0;

}

  #endif

--- 66,75 ----

          }
      }
      fclose(f);
!     if (!found)
!         return -1;
      return 0;

}

  #endif

Lga.

#12 lore raw
In reply to Fabrice Bellard
Quoted 1 line · Fabrice Bellard

I just commited a simple solution to enable direct access to host files from Windows guests with user mode networking and with almost no set up. It is currently very experimental but it works, at least for Windows 98 with the Samba server from Red Hat 9. Any suggestion is welcome.

It's not working :( And "ps -A | grep smbd" gives me nothing. "/usr/sbin/smbd -i" (-i - interactive) prints something like that:

bash-2.05b$ /usr/sbin/smbd -i
smbd version 3.0.8 started.
Copyright Andrew Tridgell and the Samba Team 1992-2004
file_init: Information only: requested 10000 open files, 1004 are available.
ERROR: Failed to initialise messages database

Is there some method to see what happened? log file?

#13 lore raw

Hi,

Quoted 5 lines · Adrian Smarzewski

bash-2.05b$ /usr/sbin/smbd -i
smbd version 3.0.8 started.
Copyright Andrew Tridgell and the Samba Team 1992-2004
file_init: Information only: requested 10000 open files, 1004 are available.
ERROR: Failed to initialise messages database

Sounds to me as if you had to run it as 'root' just once to initialise the messages database...

Hth,
Dscho

#14 lore raw
In reply to Adrian Smarzewski
Quoted 10 lines · Adrian Smarzewski

It's not working :( And "ps -A | grep smbd" gives me nothing. "/usr/sbin/smbd -i" (-i - interactive) prints something like that:

bash-2.05b$ /usr/sbin/smbd -i
smbd version 3.0.8 started.
Copyright Andrew Tridgell and the Samba Team 1992-2004
file_init: Information only: requested 10000 open files, 1004 are available.
ERROR: Failed to initialise messages database

Is there some method to see what happened? log file?

I can run it as root only. What files must be writable for user to run smbd via qemu?

#15 lore raw
Quoted 1 line · Adrian Smarzewski

I can run it as root only. What files must be writable for user to run smbd via qemu?

Should "ps" command show me smbd process when I'm using "qemu -smb"?

#16 lore raw
Quoted 4 lines
Quoted 2 lines

I can run it as root only. What files must be writable for user to run smbd via qemu?

Should "ps" command show me smbd process when I'm using "qemu -smb"?

yes

Jens

#17 lore raw
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

I can run it as root only. What files must be writable for user to run smbd via qemu?

Should "ps" command show me smbd process when I'm using "qemu -smb"?

yes

pstree shows for me:

qemu---2*[smbd]

The 2 is because I have rebooted the OS in Qemu
Fabrice is it OK that then there are two smbd ?

Jens

#18 lore raw
Quoted 7 lines · Jens Arm
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I can run it as root only. What files must be writable for user to run smbd via qemu?

Should "ps" command show me smbd process when I'm using "qemu -smb"?

yes

Quoted 6 lines

pstree shows for me:

qemu---2*[smbd]

The 2 is because I have rebooted the OS in Qemu
Fabrice is it OK that then there are two smbd ?

No, but this is a known bug: when the socket connection to smbd is closed, the process is not killed. It could be a performance issue, but it does not prevent smbd from working correctly.

Fabrice.

#19 lore raw
In reply to Adrian Smarzewski
Quoted 1 line · Adrian Smarzewski

I can run it as root only. What files must be writable for user to run smbd via qemu?

bash-2.05b$ /usr/sbin/smbd -i
smbd version 3.0.8 started.
Copyright Andrew Tridgell and the Samba Team 1992-2004
file_init: Information only: requested 10000 open files, 1004 are available. bind failed on port 445 socket_addr = 0.0.0.0.

I think smb support is "root-only" or is near it :( Any ideas?

#20 lore raw
Quoted 8 lines · Adrian Smarzewski

Adrian Smarzewski wrote:

Copyright Andrew Tridgell and the Samba Team 1992-2004
file_init: Information only: requested 10000 open files, 1004 are available. bind failed on port 445 socket_addr = 0.0.0.0.

I think smb support is "root-only" or is near it :( Any ideas?

Using sudo comes to mind. The docs already suggest it's use for configuring the tun interfaces when not using -user-net. It might rise some security issues if not properly configured ( sudo + smbd I mean) though.

Anyway, I don't think the auto-smb-config is such a terribly good idea. I'd just better define some properly secured shares in the main samba smb.conf for the computer.

As for the tun config, btw, maybe it'd make more sense using the patches for specifying the tun interfaces to use in the command line that Lars Munch posted a couple of weeks ago.

#21 lore raw
In reply to Adrian Smarzewski
Quoted 5 lines · Adrian Smarzewski
Quoted 1 line · Adrian Smarzewski

I can run it as root only. What files must be writable for user to run smbd via qemu?

Quoted 8 lines

bash-2.05b$ /usr/sbin/smbd -i
smbd version 3.0.8 started.
Copyright Andrew Tridgell and the Samba Team 1992-2004
file_init: Information only: requested 10000 open files, 1004 are available. bind failed on port 445 socket_addr = 0.0.0.0.

I think smb support is "root-only" or is near it :( Any ideas?

QEMU gives specific commands to smbd so that it can be run as non root (in particular, it uses stdio to communicate with smbd instead of a priviledged socket with a port < 1024). I think your problem comes from the fact that you use smbd version 3. I only tested QEMU with the version 2.

The solution would be either to support version 3 or to include the smbd code in QEMU so that we can be sure it behaves as expected.

Fabrice.

#22 lore raw
Quoted 8 lines

-- Messaggio Originale --
Date: Wed, 08 Dec 2004 22:59:29 +0100
From: Fabrice Bellard <[email protected]>
To: [email protected]
Subject: Re: [Qemu-devel] SAMBA support in QEMU
Reply-To: [email protected]

Quoted 9 lines

I think your problem comes from
the fact that you use smbd version 3. I only tested QEMU with the version 2.

The solution would be either to support version 3 or to include the smbd code in QEMU so that we can be sure it behaves as expected.

Fabrice.

Do you think that adding support to SAMBA 3.x would be a big task? I could try to contribute, if you can give me some hint on where to start and if time
is not a problem...

Carlo

__________________________________________________________________
Tiscali Adsl 2 Mega Free: l'adsl piu' veloce e' gratis! Naviga libero dai costi fissi con Tiscali Adsl 2 Mega Free, l'adsl Free piu' veloce in Italia. In piu', se ti abboni entro il 13 dicembre 2004, navighi gratis fino al 31 marzo 2005 e non paghi il costo di adesione.
http://abbonati.tiscali.it/adsl/

#23 lore raw
In reply to Fabrice Bellard

This could also be why SAMBA support does not appear to work on Mac OS X. Version 10.3.6 appears to use SAMBA version 3.0.5.

- Dave

Quoted 25 lines · Fabrice Bellard
Quoted 9 lines · Adrian Smarzewski
Quoted 1 line · Adrian Smarzewski

I can run it as root only. What files must be writable for user to run smbd via qemu?

bash-2.05b$ /usr/sbin/smbd -i
smbd version 3.0.8 started.
Copyright Andrew Tridgell and the Samba Team 1992-2004
file_init: Information only: requested 10000 open files, 1004 are available. bind failed on port 445 socket_addr = 0.0.0.0.
I think smb support is "root-only" or is near it :(
Any ideas?

QEMU gives specific commands to smbd so that it can be run as non root (in particular, it uses stdio to communicate with smbd instead of a priviledged socket with a port < 1024). I think your problem comes from the fact that you use smbd version 3. I only tested QEMU with the version 2.

The solution would be either to support version 3 or to include the smbd code in QEMU so that we can be sure it behaves as expected.

Fabrice.

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#24 lore raw
Quoted 1 line · David Still

This could also be why SAMBA support does not appear to work on Mac OS X. Version 10.3.6 appears to use SAMBA version 3.0.5.

3.0 was released more than year ago I think... Maybe It's more important to support 3.0.x than 2.x now.

Signature · 3 lines
Pozdrowienia
Adrian Smarzewski
http://kadu.net/~adrian
#25 lore raw

Hello,

With this little changes to the samba configuration file I was able to access the share from the guest os (winxp-oem-german-nosp, samba 3.0.2a-SUSE)

Don't know how it would affect some samba 2.x installations ...

The entry smb ports is because smbd wants to open port 445 (an I'm not allowed to as user).

Regards,
Bernhard

Am Donnerstag, 9. Dezember 2004 22:34 schrieb Adrian Smarzewski:

Quoted 6 lines
Quoted 2 lines · David Still

This could also be why SAMBA support does not appear to work on Mac OS X. Version 10.3.6 appears to use SAMBA version 3.0.5.

3.0 was released more than year ago I think... Maybe It's more important to support 3.0.x than 2.x now.

bernhard@wombl:~/projekte/software/qemu> diff -Nru orig/qemu-cvs/qemu/vl.c qemu-cvs/qemu/vl.c

qemu/vl.c 2004-12-19 15:44:27.501826076 +0100 renamed from qemu-cvs/qemu/vl.c 2004-12-17 21:10:34.000000000 +0100 +4 -0
@@ -1535,6 +1535,9 @@
     }
     fprintf(f,
             "[global]\n"
+            "private dir=%s\n"
+            "smb ports=2445 2139\n"
+            "socket address=127.0.0.1\n"
             "pid directory=%s\n"
             "lock directory=%s\n"
             "log file=%s/log.smbd\n"
@@ -1548,6 +1551,7 @@
             smb_dir,
             smb_dir,
             smb_dir,
+            smb_dir,
             exported_dir
             );
     fclose(f);
#26 lore raw

Hi,

It would be cleaner to find a way to disable the access to the port 445 (it seems to be an uneeded feature for QEMU and your patch may not work if several instances of QEMU are launched). Can you look at the SAMBA documentation to see if there is an option to do that ?

Fabrice.

Quoted 55 lines · Bernhard Huafbauer

Hello,

With this little changes to the samba configuration file I was able to access the share from the guest os (winxp-oem-german-nosp, samba 3.0.2a-SUSE)

Don't know how it would affect some samba 2.x installations ...

The entry smb ports is because smbd wants to open port 445 (an I'm not allowed to as user).

Regards,
Bernhard

Am Donnerstag, 9. Dezember 2004 22:34 schrieb Adrian Smarzewski:

Quoted 7 lines
Quoted 1 line · David Still

This could also be why SAMBA support does not appear to work on Mac OS X. Version 10.3.6 appears to use SAMBA version 3.0.5.

3.0 was released more than year ago I think... Maybe It's more important to support 3.0.x than 2.x now.

bernhard@wombl:~/projekte/software/qemu> diff -Nru orig/qemu-cvs/qemu/vl.c qemu-cvs/qemu/vl.c

qemu/vl.c 2004-12-19 15:44:27.501826076 +0100 renamed from qemu-cvs/qemu/vl.c 2004-12-17 21:10:34.000000000 +0100 +4 -0
@@ -1535,6 +1535,9 @@
     }
     fprintf(f,
             "[global]\n"
+            "private dir=%s\n"
+            "smb ports=2445 2139\n"
+            "socket address=127.0.0.1\n"
             "pid directory=%s\n"
             "lock directory=%s\n"
             "log file=%s/log.smbd\n"
@@ -1548,6 +1551,7 @@
             smb_dir,
             smb_dir,
             smb_dir,
+            smb_dir,
             exported_dir
             );
     fclose(f);

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#27 lore raw

Hello,
I found nothing about disabling the opening of the ports in the man page of the smb.conf.
The only thing I have found to prevent smbd to open a port is to give a config file with one of these lines:

smb ports=" "
smb ports=' '
smb ports=0

the samba source file /source/smbd/server.c line 242 (version 3.0.2a-SUSE) look like this:
...

			for (ptr=ports; next_token(&ptr, tok, NULL, sizeof(tok)); ) {
				unsigned port = atoi(tok);
				if (port == 0) continue;
				s = fd_listenset[num_sockets] = open_socket_in(SOCK_STREAM, port, 0, ifip->s_addr, True);
...
...
		for (ptr=ports; next_token(&ptr, tok, NULL, sizeof(tok)); ) {
			unsigned port = atoi(tok);
			if (port == 0) continue;
			/* open an incoming socket */
			s = open_socket_in(SOCK_STREAM, port, 0,

...

Interesting the comparison to 0 and the continue ... so setting it to 0 would be best the way?

with this setting a smbd called by hand doesn't open any port except this DGRAM thing

	bernhard@wombl:/tmp/qemu-smb.8091> ps aux | grep smbd | grep -v grep
	bernhard 10087  0.0  0.5  9912 2800 ?        Ss   21:16   0:00 /usr/sbin/smbd -s /tmp/qemu-smb.8091/smb.conf

	bernhard@wombl:/tmp/qemu-smb.8091> netstat -anp | grep 10087
	unix  2      [ ]         DGRAM                    23644  10087/smbd

when running qemu with this setting and accessing \\10.0.2.4\qemu

	bernhard@wombl:/tmp> ps aux | grep smbd
	bernhard 11976  0.0  0.0     0    0 ?        Z    22:02   0:00 [smbd] <defunct>
	bernhard 12012  0.0  0.0     0    0 ?        Z    22:03   0:00 [smbd] <defunct>
	bernhard 12045  0.1  0.6 10984 3492 ?        S    22:03   0:00 /usr/sbin/smbd -s /tmp/qemu-smb.11876/smb.conf
	bernhard 12064  0.0  0.1  2648  736 pts/1    S+   22:04   0:00 grep smbd

and sometimes somthing like this (?):

	bernhard@wombl:/tmp> netstat -anp | grep 12045
	tcp        0      0 127.0.0.1:1357          127.0.0.1:1356          VERBUNDEN   12045/smbd
	udp        0      0 127.0.0.1:1156          0.0.0.0:*                           12045/smbd

(As a sidenote:
the smb_exit cleans not all of the temp directory there is still a directory printing so the last rmdir call fails and a /tmp/qemu-smb.10542/printing/ remains.)

Regards
Bernhard

Am Montag, 20. Dezember 2004 00:40 schrieb Fabrice Bellard:

Quoted 74 lines

Hi,

It would be cleaner to find a way to disable the access to the port 445 (it seems to be an uneeded feature for QEMU and your patch may not work if several instances of QEMU are launched). Can you look at the SAMBA documentation to see if there is an option to do that ?

Fabrice.

Quoted 49 lines · Bernhard Huafbauer

Hello,

With this little changes to the samba configuration file I was able to access the share from the guest os (winxp-oem-german-nosp, samba 3.0.2a-SUSE)

Don't know how it would affect some samba 2.x installations ...

The entry smb ports is because smbd wants to open port 445 (an I'm not allowed to as user).

Regards,
Bernhard

Am Donnerstag, 9. Dezember 2004 22:34 schrieb Adrian Smarzewski:

Quoted 8 lines
Quoted 2 lines · David Still

This could also be why SAMBA support does not appear to work on Mac OS X. Version 10.3.6 appears to use SAMBA version 3.0.5.

3.0 was released more than year ago I think... Maybe It's more important to support 3.0.x than 2.x now.

bernhard@wombl:~/projekte/software/qemu> diff -Nru orig/qemu-cvs/qemu/vl.c qemu-cvs/qemu/vl.c

qemu/vl.c 2004-12-19 15:44:27.501826076 +0100 renamed from qemu-cvs/qemu/vl.c 2004-12-17 21:10:34.000000000 +0100 +4 -0
@@ -1535,6 +1535,9 @@
     }
     fprintf(f,
             "[global]\n"
+            "private dir=%s\n"
+            "smb ports=2445 2139\n"
+            "socket address=127.0.0.1\n"
             "pid directory=%s\n"
             "lock directory=%s\n"
             "log file=%s/log.smbd\n"
@@ -1548,6 +1551,7 @@
             smb_dir,
             smb_dir,
             smb_dir,
+            smb_dir,
             exported_dir
             );
     fclose(f);
Quoted 7 lines

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#28 lore raw

OK. 'smb ports=0' seems a good idea. Can you find why there is still a datagram connection opened ?

I still wonder if the best solution would be to ship a specific smbd version with QEMU...

Fabrice.

Quoted 141 lines · Bernhard Huafbauer

Hello,
I found nothing about disabling the opening of the ports
in the man page of the smb.conf.
The only thing I have found to prevent smbd to open a port is to give a config file with one of these lines:

smb ports=" "
smb ports=' '
smb ports=0

the samba source file /source/smbd/server.c line 242 (version 3.0.2a-SUSE) look like this:
...

			for (ptr=ports; next_token(&ptr, tok, NULL, sizeof(tok)); ) {
				unsigned port = atoi(tok);
				if (port == 0) continue;
				s = fd_listenset[num_sockets] = open_socket_in(SOCK_STREAM, port, 0, ifip->s_addr, True);
...
...
		for (ptr=ports; next_token(&ptr, tok, NULL, sizeof(tok)); ) {
			unsigned port = atoi(tok);
			if (port == 0) continue;
			/* open an incoming socket */
			s = open_socket_in(SOCK_STREAM, port, 0,

...

Interesting the comparison to 0 and the continue ... so setting it to 0 would be best the way?

with this setting a smbd called by hand doesn't open any port except this DGRAM thing

	bernhard@wombl:/tmp/qemu-smb.8091> ps aux | grep smbd | grep -v grep
	bernhard 10087  0.0  0.5  9912 2800 ?        Ss   21:16   0:00 /usr/sbin/smbd -s /tmp/qemu-smb.8091/smb.conf

	bernhard@wombl:/tmp/qemu-smb.8091> netstat -anp | grep 10087
	unix  2      [ ]         DGRAM                    23644  10087/smbd

when running qemu with this setting and accessing \\10.0.2.4\qemu

	bernhard@wombl:/tmp> ps aux | grep smbd
	bernhard 11976  0.0  0.0     0    0 ?        Z    22:02   0:00 [smbd] <defunct>
	bernhard 12012  0.0  0.0     0    0 ?        Z    22:03   0:00 [smbd] <defunct>
	bernhard 12045  0.1  0.6 10984 3492 ?        S    22:03   0:00 /usr/sbin/smbd -s /tmp/qemu-smb.11876/smb.conf
	bernhard 12064  0.0  0.1  2648  736 pts/1    S+   22:04   0:00 grep smbd

and sometimes somthing like this (?):

	bernhard@wombl:/tmp> netstat -anp | grep 12045
	tcp        0      0 127.0.0.1:1357          127.0.0.1:1356          VERBUNDEN   12045/smbd
	udp        0      0 127.0.0.1:1156          0.0.0.0:*                           12045/smbd

(As a sidenote:
the smb_exit cleans not all of the temp directory there is still a directory printing so the last rmdir call fails and a /tmp/qemu-smb.10542/printing/ remains.)

Regards
Bernhard

Am Montag, 20. Dezember 2004 00:40 schrieb Fabrice Bellard:

Quoted 58 lines

Hi,

It would be cleaner to find a way to disable the access to the port 445 (it seems to be an uneeded feature for QEMU and your patch may not work if several instances of QEMU are launched). Can you look at the SAMBA documentation to see if there is an option to do that ?

Fabrice.

Quoted 50 lines · Bernhard Huafbauer

Hello,

With this little changes to the samba configuration file I was able to access the share from the guest os (winxp-oem-german-nosp, samba 3.0.2a-SUSE)

Don't know how it would affect some samba 2.x installations ...

The entry smb ports is because smbd wants to open port 445 (an I'm not allowed to as user).

Regards,
Bernhard

Am Donnerstag, 9. Dezember 2004 22:34 schrieb Adrian Smarzewski:

Quoted 8 lines
Quoted 1 line · David Still

This could also be why SAMBA support does not appear to work on Mac OS X. Version 10.3.6 appears to use SAMBA version 3.0.5.

3.0 was released more than year ago I think... Maybe It's more important to support 3.0.x than 2.x now.

bernhard@wombl:~/projekte/software/qemu> diff -Nru orig/qemu-cvs/qemu/vl.c qemu-cvs/qemu/vl.c

qemu/vl.c 2004-12-19 15:44:27.501826076 +0100 renamed from qemu-cvs/qemu/vl.c 2004-12-17 21:10:34.000000000 +0100 +4 -0
@@ -1535,6 +1535,9 @@
    }
    fprintf(f,
            "[global]\n"
+            "private dir=%s\n"
+            "smb ports=2445 2139\n"
+            "socket address=127.0.0.1\n"
            "pid directory=%s\n"
            "lock directory=%s\n"
            "log file=%s/log.smbd\n"
@@ -1548,6 +1551,7 @@
            smb_dir,
            smb_dir,
            smb_dir,
+            smb_dir,
            exported_dir
            );
    fclose(f);
Quoted 15 lines
Quoted 7 lines

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

#29 lore raw

Hello,
think I found it ... (wasn't as easy as the port thing) short before going crazy I called smbd with strace it showed me two socket funcion calls - the first with a matching close

	...
	16790 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
	16790 ioctl(4, 0x8912, 0xbfffbdf8)      = 0
	16790 ioctl(4, 0x8915, 0xbfffbe20)      = 0
	16790 ioctl(4, 0x8913, 0xbfffbe20)      = 0
	16790 ioctl(4, 0x891b, 0xbfffbe20)      = 0
	16790 ioctl(4, 0x8915, 0xbfffbe00)      = 0
	16790 ioctl(4, 0x8913, 0xbfffbe00)      = 0
	16790 ioctl(4, 0x891b, 0xbfffbe00)      = 0
	16790 close(4)                          = 0
	...
the second not
	...
	16790 socket(PF_UNIX, SOCK_DGRAM, 0)    = 6
	...
so I called smbd with gdb and set a
breakpoint to socket - continued the first time and the second
time the backtrace looked like this:
	Breakpoint 2, 0x4035ff90 in socket () from /lib/tls/libc.so.6
	(gdb) bt
	#0  0x4035ff90 in socket () from /lib/tls/libc.so.6
	#1  0x4035b12c in openlog_internal () from /lib/tls/libc.so.6
	#2  0x4035b6cb in vsyslog () from /lib/tls/libc.so.6
	#3  0x4035b24f in syslog () from /lib/tls/libc.so.6
	#4  0x081da12c in Debug1 ()
	#5  0x081da476 in dbghdr ()
	#6  0x08267784 in main ()
	(gdb) kill

by searching Debug1 in samba source I found
that by starting samba with option -i (interactive)
this syslog calls are not done and no datagram connection is opened - but I cannot access now my share from the guest os - not so good ...

then another way - setting in the config file a entry "syslog = 0" helps so my function "net_slirp_smb" looks now like this (and I can access \\10.0.2.4\qemu):

    fprintf(f, 
            "[global]\n"
            "private dir=%s\n"
            "smb ports=0\n"
            "socket address=127.0.0.1\n"
            "syslog = 0\n"
            "pid directory=%s\n"
            "lock directory=%s\n"
            "log file=%s/log.smbd\n"
            "smb passwd file=%s/smbpasswd\n"
            "security = share\n"
            "[qemu]\n"
            "path=%s\n"
            "read only=no\n"
            "guest ok=yes\n",
            smb_dir,
            smb_dir,
            smb_dir,
            smb_dir,
            smb_dir,
            exported_dir
            );

(To my sidenote from my last mail:
This will delete this "printing" directory in the /tmp/qemu-smb.xxx directory

in smb_exit before "rmdir(smb_dir);":

    snprintf(filename, sizeof(filename), "%s/%s",
             smb_dir, "printing");
    rmdir(filename);

)

Regards
Bernhard

Am Dienstag, 21. Dezember 2004 00:14 schrieb Fabrice Bellard:

Quoted 163 lines

OK. 'smb ports=0' seems a good idea. Can you find why there is still a datagram connection opened ?

I still wonder if the best solution would be to ship a specific smbd version with QEMU...

Fabrice.

Quoted 139 lines · Bernhard Huafbauer

Hello,
I found nothing about disabling the opening of the ports in the man page of the smb.conf.
The only thing I have found to prevent smbd to open a port is to give a config file with one of these lines:

smb ports=" "
smb ports=' '
smb ports=0

the samba source file /source/smbd/server.c line 242 (version 3.0.2a-SUSE) look like this:
...

			for (ptr=ports; next_token(&ptr, tok, NULL, sizeof(tok)); ) {
				unsigned port = atoi(tok);
				if (port == 0) continue;
				s = fd_listenset[num_sockets] = open_socket_in(SOCK_STREAM, port, 0, ifip->s_addr, True);
...
...
		for (ptr=ports; next_token(&ptr, tok, NULL, sizeof(tok)); ) {
			unsigned port = atoi(tok);
			if (port == 0) continue;
			/* open an incoming socket */
			s = open_socket_in(SOCK_STREAM, port, 0,

...

Interesting the comparison to 0 and the continue ... so setting it to 0 would be best the way?

with this setting a smbd called by hand doesn't open any port except this DGRAM thing

	bernhard@wombl:/tmp/qemu-smb.8091> ps aux | grep smbd | grep -v grep
	bernhard 10087  0.0  0.5  9912 2800 ?        Ss   21:16   0:00 /usr/sbin/smbd -s /tmp/qemu-smb.8091/smb.conf

	bernhard@wombl:/tmp/qemu-smb.8091> netstat -anp | grep 10087
	unix  2      [ ]         DGRAM                    23644  10087/smbd

when running qemu with this setting and accessing \\10.0.2.4\qemu

	bernhard@wombl:/tmp> ps aux | grep smbd
	bernhard 11976  0.0  0.0     0    0 ?        Z    22:02   0:00 [smbd] <defunct>
	bernhard 12012  0.0  0.0     0    0 ?        Z    22:03   0:00 [smbd] <defunct>
	bernhard 12045  0.1  0.6 10984 3492 ?        S    22:03   0:00 /usr/sbin/smbd -s /tmp/qemu-smb.11876/smb.conf
	bernhard 12064  0.0  0.1  2648  736 pts/1    S+   22:04   0:00 grep smbd

and sometimes somthing like this (?):

	bernhard@wombl:/tmp> netstat -anp | grep 12045
	tcp        0      0 127.0.0.1:1357          127.0.0.1:1356          VERBUNDEN   12045/smbd
	udp        0      0 127.0.0.1:1156          0.0.0.0:*                           12045/smbd

(As a sidenote:
the smb_exit cleans not all of the temp directory there is still a directory printing so the last rmdir call fails and a /tmp/qemu-smb.10542/printing/ remains.)

Regards
Bernhard

Am Montag, 20. Dezember 2004 00:40 schrieb Fabrice Bellard:

Quoted 62 lines

Hi,

It would be cleaner to find a way to disable the access to the port 445 (it seems to be an uneeded feature for QEMU and your patch may not work if several instances of QEMU are launched). Can you look at the SAMBA documentation to see if there is an option to do that ?

Fabrice.

Quoted 51 lines · Bernhard Huafbauer

Hello,

With this little changes to the samba configuration file I was able to access the share from the guest os (winxp-oem-german-nosp, samba 3.0.2a-SUSE)

Don't know how it would affect some samba 2.x installations ...

The entry smb ports is because smbd wants to open port 445 (an I'm not allowed to as user).

Regards,
Bernhard

Am Donnerstag, 9. Dezember 2004 22:34 schrieb Adrian Smarzewski:

Quoted 9 lines
Quoted 2 lines · David Still

This could also be why SAMBA support does not appear to work on Mac OS X. Version 10.3.6 appears to use SAMBA version 3.0.5.

3.0 was released more than year ago I think... Maybe It's more important to support 3.0.x than 2.x now.

bernhard@wombl:~/projekte/software/qemu> diff -Nru orig/qemu-cvs/qemu/vl.c qemu-cvs/qemu/vl.c

qemu/vl.c 2004-12-19 15:44:27.501826076 +0100 renamed from qemu-cvs/qemu/vl.c 2004-12-17 21:10:34.000000000 +0100 +4 -0
@@ -1535,6 +1535,9 @@
    }
    fprintf(f,
            "[global]\n"
+            "private dir=%s\n"
+            "smb ports=2445 2139\n"
+            "socket address=127.0.0.1\n"
            "pid directory=%s\n"
            "lock directory=%s\n"
            "log file=%s/log.smbd\n"
@@ -1548,6 +1551,7 @@
            smb_dir,
            smb_dir,
            smb_dir,
+            smb_dir,
            exported_dir
            );
    fclose(f);
Quoted 15 lines
Quoted 7 lines

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Quoted 7 lines

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel