All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dunrong Huang <riegamaths@gmail.com>
To: qemu-devel@nongnu.org
Cc: ark McLoughlin <markmc@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH] slirp: Ensure smbd and shared directory exist when enable smb
Date: Tue,  3 Jul 2012 21:13:12 +0800	[thread overview]
Message-ID: <1341321192-30258-1-git-send-email-riegamaths@gmail.com> (raw)

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 exists or
not when QEMU's "built-in" SMB server is enabled.

Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
---
 net/slirp.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/net/slirp.c b/net/slirp.c
index 37b6ccf..a672cff 100644
--- a/net/slirp.c
+++ b/net/slirp.c
@@ -489,6 +489,20 @@ static int slirp_smb(SlirpState* s, const char *exported_dir,
     char smb_cmdline[128];
     FILE *f;
 
+    if (access(CONFIG_SMBD_COMMAND, F_OK)) {
+        slirp_smb_cleanup(s);
+        error_report("could not find '%s', please install it",
+                     CONFIG_SMBD_COMMAND);
+        return -1;
+    }
+
+    if (access(exported_dir, F_OK)) {
+        slirp_smb_cleanup(s);
+        error_report("no such shared directory '%s', 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) {
-- 
1.7.8.4

             reply	other threads:[~2012-07-03 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-03 13:13 Dunrong Huang [this message]
2012-07-05 23:18 ` [Qemu-devel] [PATCH] slirp: Ensure smbd and shared directory exist when enable smb Jan Kiszka
2012-07-06  5:55   ` Dunrong Huang

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=1341321192-30258-1-git-send-email-riegamaths@gmail.com \
    --to=riegamaths@gmail.com \
    --cc=aliguori@us.ibm.com \
    --cc=markmc@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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.