From patchwork Fri Jul 6 06:43:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 169338 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 53D712C0201 for ; Fri, 6 Jul 2012 16:44:17 +1000 (EST) Received: from localhost ([::1]:51771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn2H1-00087d-9g for incoming@patchwork.ozlabs.org; Fri, 06 Jul 2012 02:44:15 -0400 Received: from eggs.gnu.org ([208.118.235.92]:35530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn2Gt-00087X-WC for qemu-devel@nongnu.org; Fri, 06 Jul 2012 02:44:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sn2Gp-0000Xe-1I for qemu-devel@nongnu.org; Fri, 06 Jul 2012 02:44:07 -0400 Received: from mout.web.de ([212.227.15.4]:55798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sn2Go-0000XT-NI for qemu-devel@nongnu.org; Fri, 06 Jul 2012 02:44:02 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.56.37]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M9os0-1SgSgR2fRA-00BSg2; Fri, 06 Jul 2012 08:44:00 +0200 Message-ID: <4FF6892A.8020703@web.de> Date: Fri, 06 Jul 2012 08:43:54 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Dunrong Huang References: <1341554683-20116-1-git-send-email-riegamaths@gmail.com> In-Reply-To: <1341554683-20116-1-git-send-email-riegamaths@gmail.com> X-Enigmail-Version: 1.4.2 X-Provags-ID: V02:K0:fE7aeHJg1mipePBq4EI50Jo0hsl/ymrre27ToSrbV9j Y3z/mrmp20o9lwY3bsjnXXIzy5XjnGfhRd81G6A6OEdmH1/pJ1 EzgsKGuLiywB29FPTLVYTCQd2T/LYQ+RYmq/xyBSpLiMF600fs ETPyMgfXTLjJS5hjlWwiNsFNS238U228WMvMNotSy0yfJjr/6h v4ruPOejgyzlDGcy+EA1g== X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 212.227.15.4 Cc: Mark McLoughlin , Anthony Liguori , qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH v2] slirp: Ensure smbd and shared directory exist when enable smb 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 On 2012-07-06 08:04, Dunrong Huang wrote: > Users may pass the following parameters to qemu: > $ qemu-kvm -net nic -net user,smb= ... > $ qemu-kvm -net nic -net user,smb ... > $ qemu-kvm -net nic -net user,smb=bad_directory ... > > In these cases, qemu started successfully while samba server > failed to start. Users will confuse since samba server > failed silently without any indication of what it did wrong. > > To avoid it, we check whether the shared directory exist and > if users have permission to access this directory when QEMU's > "built-in" SMB server is enabled. > > Signed-off-by: Dunrong Huang > --- > net/slirp.c | 12 ++++++++++++ > 1 files changed, 12 insertions(+), 0 deletions(-) > > diff --git a/net/slirp.c b/net/slirp.c > index 37b6ccf..ff36fa2 100644 > --- a/net/slirp.c > +++ b/net/slirp.c > @@ -489,6 +489,18 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, > char smb_cmdline[128]; > FILE *f; > > + if (access(CONFIG_SMBD_COMMAND, F_OK)) { > + error_report("could not find '%s', please install it", > + CONFIG_SMBD_COMMAND); > + return -1; > + } > + > + if (access(exported_dir, R_OK | X_OK)) { > + error_report("no such directory '%s', or you do not have permission " > + "to access it, please check it", exported_dir); > + return -1; > + } > + > snprintf(s->smb_dir, sizeof(s->smb_dir), "/tmp/qemu-smb.%ld-%d", > (long)getpid(), instance++); > if (mkdir(s->smb_dir, 0700) < 0) { > Thanks, applied to slirp queue. I added a tiny patch on top that reports the exact error returned by access(): Jan diff --git a/net/slirp.c b/net/slirp.c index eb80889..b82eab0 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -504,8 +504,8 @@ static int slirp_smb(SlirpState* s, const char *exported_dir, } if (access(exported_dir, R_OK | X_OK)) { - error_report("no such directory '%s', or you do not have permission " - "to access it, please check it", exported_dir); + error_report("error accessing shared directory '%s': %s", + exported_dir, strerror(errno)); return -1; }