aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Kiszka <jan.kiszka@siemens.com>2009-06-24 14:42:31 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2009-06-29 08:52:50 -0500
commit492efabd47d225998f8391e4d31b233915bf79a5 (patch)
treeedc1205bc4f55230580bb71dc2ddfaa7c1e6dab2
parent09c18925761f932a59f0838c889f31e2d3aa3fcb (diff)
slirp: Improve error handling in slirp_smb
Make sure for invocations from the monitor that slirp_smb properly reports errors and doesn't terminate qemu. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
-rw-r--r--net.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net.c b/net.c
index bfc63178bb..db7c37024f 100644
--- a/net.c
+++ b/net.c
@@ -697,7 +697,7 @@ static void slirp_guestfwd(SlirpState *s, Monitor *mon, const char *config_str,
#ifndef _WIN32
static const char *legacy_smb_export;
-static void slirp_smb(SlirpState *s, const char *exported_dir,
+static void slirp_smb(SlirpState *s, Monitor *mon, const char *exported_dir,
struct in_addr vserver_addr);
#endif
@@ -864,7 +864,7 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *model,
smb_export = legacy_smb_export;
}
if (smb_export) {
- slirp_smb(s, smb_export, smbsrv);
+ slirp_smb(s, mon, smb_export, smbsrv);
}
#endif
@@ -1023,7 +1023,7 @@ static void smb_exit(void)
system(cmd);
}
-static void slirp_smb(SlirpState* s, const char *exported_dir,
+static void slirp_smb(SlirpState* s, Monitor *mon, const char *exported_dir,
struct in_addr vserver_addr)
{
char smb_conf[1024];
@@ -1033,15 +1033,17 @@ static void slirp_smb(SlirpState* s, const char *exported_dir,
/* XXX: better tmp dir construction */
snprintf(smb_dir, sizeof(smb_dir), "/tmp/qemu-smb.%ld", (long)getpid());
if (mkdir(smb_dir, 0700) < 0) {
- fprintf(stderr, "qemu: could not create samba server dir '%s'\n", smb_dir);
- exit(1);
+ config_error(mon, "could not create samba server dir '%s'\n", smb_dir);
+ return;
}
snprintf(smb_conf, sizeof(smb_conf), "%s/%s", smb_dir, "smb.conf");
f = fopen(smb_conf, "w");
if (!f) {
- fprintf(stderr, "qemu: could not create samba server configuration file '%s'\n", smb_conf);
- exit(1);
+ smb_exit();
+ config_error(mon, "could not create samba server "
+ "configuration file '%s'\n", smb_conf);
+ return;
}
fprintf(f,
"[global]\n"
@@ -1071,8 +1073,7 @@ static void slirp_smb(SlirpState* s, const char *exported_dir,
SMBD_COMMAND, smb_conf);
if (slirp_add_exec(s->slirp, 0, smb_cmdline, vserver_addr, 139) < 0) {
- fprintf(stderr, "conflicting/invalid smbserver address\n");
- exit(1);
+ config_error(mon, "conflicting/invalid smbserver address\n");
}
}
@@ -1087,7 +1088,8 @@ void net_slirp_smb(const char *exported_dir)
}
legacy_smb_export = exported_dir;
if (!TAILQ_EMPTY(&slirp_stacks)) {
- slirp_smb(TAILQ_FIRST(&slirp_stacks), exported_dir, vserver_addr);
+ slirp_smb(TAILQ_FIRST(&slirp_stacks), NULL, exported_dir,
+ vserver_addr);
}
}