From patchwork Thu Nov 28 19:32:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 295015 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7CCA92C0040 for ; Fri, 29 Nov 2013 06:33:38 +1100 (EST) Received: from localhost ([::1]:43785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm7LD-0002jW-FJ for incoming@patchwork.ozlabs.org; Thu, 28 Nov 2013 14:33:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm7Kr-0002j8-QO for Qemu-devel@nongnu.org; Thu, 28 Nov 2013 14:33:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vm7Ki-0003M8-Ue for Qemu-devel@nongnu.org; Thu, 28 Nov 2013 14:33:13 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:53332) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vm7Ki-0003LS-NG for Qemu-devel@nongnu.org; Thu, 28 Nov 2013 14:33:04 -0500 Received: from [192.168.88.2] (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id B6ED943979; Thu, 28 Nov 2013 23:32:55 +0400 (MSK) Message-ID: <52979A67.80305@msgid.tls.msk.ru> Date: Thu, 28 Nov 2013 23:32:55 +0400 From: Michael Tokarev Organization: Telecom Service, JSC User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10 MIME-Version: 1.0 To: Jan Kiszka , Qemu Development List X-Enigmail-Version: 1.5.1 OpenPGP: id=804465C5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Subject: [Qemu-devel] slirp smb with modern win guests when samba is also running on host X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org After numerous reports that -smb (or -netdev user,smb=foo) not working with modern windows (win7 and vista are reported as non-working), I started digging myself. And found that indeed it doesn't work, and why. The thing is that modern win tries to connect to port 445 (microsoft-ds) first, and if that fails, it falls back to old port 139 (netbios-ssn). slirp code in qemu only redirects port 139, it does not touch port 445. So the prob is that if samba is also running on the host, guest will try to communicate using port 445, and that will succed, but ofcourse guest will not talk with our samba but with samba running on the host. If samba is not running on the host, guest will fall back to port 139, and will reach the redirecting rule and qemu will spawn smbd correctly. The solution is to redirect both ports (139 and 445), and the fix is a one-liner, adding second call to slirp_add_exec() at the end of net/slirp.c:slirp_smb() function (provided below). But it looks like that is not a proper fix really, since in theory we should redirect both ports to the SAME, single samba instance, but I'm not sure this is possible with slirp. Well, even if two smbd processes will be run on the same config dir, it should not be a problem. The one-liner (not exactly 1 since it touches previous line too) is like this: Signed-off-By: Michael Tokarev diff --git a/net/slirp.c b/net/slirp.c index 124e953..a22e976 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -549,7 +549,8 @@ static int slirp_smb(SlirpState* s, const char *exported_dir snprintf(smb_cmdline, sizeof(smb_cmdline), "%s -s %s", CONFIG_SMBD_COMMAND, smb_conf); - if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0) { + if (slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 139) < 0 || + slirp_add_exec(s->slirp, 0, smb_cmdline, &vserver_addr, 445) < 0) { slirp_smb_cleanup(s); error_report("conflicting/invalid smbserver address"); return -1;