Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1F8kDD-0000C9-7d for qemu-devel@nongnu.org; Mon, 13 Feb 2006 15:22:19 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1F8kD9-00005n-9t for qemu-devel@nongnu.org; Mon, 13 Feb 2006 15:22:18 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1F8kD9-00005U-3q for qemu-devel@nongnu.org; Mon, 13 Feb 2006 15:22:15 -0500 Received: from [69.56.188.178] (helo=server01.killobyte.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1F8kHf-0005Nn-3c for qemu-devel@nongnu.org; Mon, 13 Feb 2006 15:26:55 -0500 Received: from [12.35.64.42] (helo=[10.210.16.112]) by server01.killobyte.com with esmtp (Exim 4.52) id 1F8kD4-00043e-MW for qemu-devel@nongnu.org; Mon, 13 Feb 2006 12:22:10 -0800 Mime-Version: 1.0 (Apple Message framework v623) Message-Id: <3a6e4623bd4f4e59715993ee465792a0@triplecatproductions.com> Content-Type: multipart/mixed; boundary=Apple-Mail-1-493640628 From: Stealth Dave Date: Mon, 13 Feb 2006 12:21:54 -0800 Subject: [Qemu-devel] [PATCH] SAMBA multi-share support Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU --Apple-Mail-1-493640628 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Apparently it was an easier itch to scratch than I thought it would be! :) Attached is a patch which allows multiple samba shares to be loaded within the qemu virtual machine. The old syntax is still supported and is completely backwards compatible. Each folder and share name is separated by a colon (:), and each folder/share pair is separated by a comman. To share multiple folders, use the following syntax: qemu hd.img -smb /path/to/dir1:share1,/path/to/dir2:share2 dir1 can be mounted as "share1", dir2 as "share2", etc. The number of shares is limited by a total of 1024 characters, but is otherwise unlimited. There is no sanity checking, as an error would simply cause the smb daemon to not launch but otherwise not affect the running of qemu. Using the old syntax: qemu hd.img -smb /path/to/dir will fall back to the old behavior of being shared at "qemu". The attached patch applies cleanly to current CVS, and updates vl.c and qemu-doc.texi (documentation update). - Dave P.S. - Anyone want to tackle that compressed vm file? :D --Apple-Mail-1-493640628 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="smb-multishare.patch" Content-Disposition: attachment; filename=smb-multishare.patch diff -BurN qemu/CVS/Entries qemu-smb/CVS/Entries --- qemu/CVS/Entries Mon Feb 13 12:09:02 2006 +++ qemu-smb/CVS/Entries Mon Feb 13 11:34:09 2006 @@ -63,6 +63,7 @@ /ppc-dis.c/1.7/Sat Jul 23 22:39:53 2005// /ppc.ld/1.2/Sun Jun 5 15:57:04 2005// /qemu-binfmt-conf.sh/1.4/Tue Dec 6 21:43:35 2005// +/qemu-doc.texi/1.80/Sun Feb 5 04:14:41 2006// /qemu-img.c/1.8/Sun Jul 24 18:44:55 2005// /qemu-img.texi/1.2/Sat Jul 23 17:43:14 2005// /qemu-tech.texi/1.8/Sat Jul 23 14:27:54 2005// @@ -98,5 +99,4 @@ D/target-ppc//// D/target-sparc//// D/tests//// -/vl.c/1.164/Mon Feb 13 19:35:11 2006// -/qemu-doc.texi/1.80/Mon Feb 13 20:09:02 2006// +/vl.c/1.164/Mon Feb 13 19:10:42 2006// diff -BurN qemu/qemu-doc.texi qemu-smb/qemu-doc.texi --- qemu/qemu-doc.texi Mon Feb 13 12:09:02 2006 +++ qemu-smb/qemu-doc.texi Mon Feb 13 11:34:10 2006 @@ -348,7 +348,7 @@ the Unix TFTP client). The host IP address on the guest is as usual 10.0.2.2. -@item -smb dir +@item -smb dir[:share,dir2:share2,dir3:share3...] When using the user mode network stack, activate a built-in SMB server so that Windows OSes can access to the host files in @file{dir} transparently. @@ -361,6 +361,14 @@ or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000). Then @file{dir} can be accessed in @file{\\smbserver\qemu}. + +Additionally, you can share multiple folders by specifying the folder +name followed by a colon (:) and the desired share name, with each +folder / share name pair separated by commas (,). + +@example +qemu hd.img -smb /path/to/dir1:dir1,/path/to/dir2:dir2 +@end example Note that a SAMBA server must be installed on the host OS in @file{/usr/sbin/smbd}. QEMU was tested succesfully with smbd version diff -BurN qemu/vl.c qemu-smb/vl.c --- qemu/vl.c Mon Feb 13 11:35:11 2006 +++ qemu-smb/vl.c Mon Feb 13 11:34:10 2006 @@ -2045,6 +2045,9 @@ { char smb_conf[1024]; char smb_cmdline[1024]; + char smb_export[1024]; + char *smb_share; + char *smb_path; FILE *f; if (!slirp_inited) { @@ -2074,18 +2077,51 @@ "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, + "security = share\n", smb_dir, smb_dir, smb_dir, smb_dir, + smb_dir + ); + if ( strchr(exported_dir, ':') == NULL ) { + fprintf(f, + "[qemu]\n" + "path=%s\n" + "read only=no\n" + "guest ok=yes\n\n", exported_dir ); + } else { + + stpcpy( smb_export, exported_dir ); + /* Extract first path / share pair*/ + smb_share = strtok(smb_export, ":"); + smb_path = smb_share; + smb_share = strtok(NULL, ","); + fprintf(f, + "[%s]\n" + "path=%s\n" + "read only=no\n" + "guest ok=yes\n\n", + smb_share, + smb_path + ); + /* Extract remaining path / share pair*/ + while ( (smb_share=strtok(NULL, ":")) != NULL) + { + smb_path = smb_share; + smb_share=strtok(NULL, ","); + fprintf(f, + "[%s]\n" + "path=%s\n" + "read only=no\n" + "guest ok=yes\n\n", + smb_share, + smb_path + ); + } + } fclose(f); atexit(smb_exit); --Apple-Mail-1-493640628--