From: Jan Kiszka <jan.kiszka@web.de>
To: Dunrong Huang <riegamaths@gmail.com>
Cc: Mark McLoughlin <markmc@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] slirp: Ensure smbd and shared directory exist when enable smb
Date: Fri, 06 Jul 2012 08:43:54 +0200 [thread overview]
Message-ID: <4FF6892A.8020703@web.de> (raw)
In-Reply-To: <1341554683-20116-1-git-send-email-riegamaths@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2315 bytes --]
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 <riegamaths@gmail.com>
> ---
> 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():
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;
}
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
prev parent reply other threads:[~2012-07-06 6:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-06 6:04 [Qemu-devel] [PATCH v2] slirp: Ensure smbd and shared directory exist when enable smb Dunrong Huang
2012-07-06 6:43 ` Jan Kiszka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FF6892A.8020703@web.de \
--to=jan.kiszka@web.de \
--cc=aliguori@us.ibm.com \
--cc=markmc@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=riegamaths@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.