* [Qemu-devel] [PATCH] slirp: Ensure smbd and shared directory exist when enable smb
@ 2012-07-03 13:13 Dunrong Huang
2012-07-05 23:18 ` Jan Kiszka
0 siblings, 1 reply; 3+ messages in thread
From: Dunrong Huang @ 2012-07-03 13:13 UTC (permalink / raw)
To: qemu-devel; +Cc: ark McLoughlin, Anthony Liguori
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] slirp: Ensure smbd and shared directory exist when enable smb
2012-07-03 13:13 [Qemu-devel] [PATCH] slirp: Ensure smbd and shared directory exist when enable smb Dunrong Huang
@ 2012-07-05 23:18 ` Jan Kiszka
2012-07-06 5:55 ` Dunrong Huang
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kiszka @ 2012-07-05 23:18 UTC (permalink / raw)
To: Dunrong Huang; +Cc: ark McLoughlin, Anthony Liguori, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1838 bytes --]
Sorry for the late review. Two comments below.
On 2012-07-03 15:13, 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 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);
Both slirp_smb_cleanup are redundant at this point, please remove them.
> + error_report("could not find '%s', please install it",
> + CONFIG_SMBD_COMMAND);
> + return -1;
> + }
> +
> + if (access(exported_dir, F_OK)) {
What about checking for R_OK | X_OK to avoid that we run into lacking
permissions later on?
> + 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) {
>
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 262 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] slirp: Ensure smbd and shared directory exist when enable smb
2012-07-05 23:18 ` Jan Kiszka
@ 2012-07-06 5:55 ` Dunrong Huang
0 siblings, 0 replies; 3+ messages in thread
From: Dunrong Huang @ 2012-07-06 5:55 UTC (permalink / raw)
To: Jan Kiszka; +Cc: ark McLoughlin, Anthony Liguori, qemu-devel
Thanks for your reply.
2012/7/6 Jan Kiszka <jan.kiszka@web.de>:
>> 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);
>
> Both slirp_smb_cleanup are redundant at this point, please remove them.
You are right, i will fix it
>
>> + error_report("could not find '%s', please install it",
>> + CONFIG_SMBD_COMMAND);
>> + return -1;
>> + }
>> +
>> + if (access(exported_dir, F_OK)) {
>
> What about checking for R_OK | X_OK to avoid that we run into lacking
> permissions later on?
>
I agree with you, I will send a v2 patch
--
Best Regards,
Dunrong Huang
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-07-06 5:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-03 13:13 [Qemu-devel] [PATCH] slirp: Ensure smbd and shared directory exist when enable smb Dunrong Huang
2012-07-05 23:18 ` Jan Kiszka
2012-07-06 5:55 ` Dunrong Huang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).