summaryrefslogtreecommitdiff
path: root/vl.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2009-10-06 12:16:57 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-10-06 14:36:10 -0500
commit8b572b454781200c36a9af61c666bc8c2d9d673b (patch)
treedbc0c0efe57ace7812b1889fde6d35ae6d2e0d11 /vl.c
parentf2b5db596a779c2eba8dde72f903178552ba3d8d (diff)
downloadqemu-8b572b454781200c36a9af61c666bc8c2d9d673b.tar.gz
qemu-8b572b454781200c36a9af61c666bc8c2d9d673b.tar.bz2
qemu-8b572b454781200c36a9af61c666bc8c2d9d673b.zip
Don't exit() in config_error()
Propagating errors up the call chain is tedious. In startup code, we can take a shortcut: terminate the program. This is wrong elsewhere, the monitor in particular. config_error() tries to cater for both customers: it terminates the program unless its mon parameter tells it it's working for the monitor. Its users need to return status anyway (unless passing a null mon argument, which none do), which their users need to check. So this automatic exit buys us exactly nothing useful. Only the dangerous delusion that we can get away without returning status. Some of its users fell for that. Their callers continue executing after failure when working for the monitor. This bites monitor command host_net_add in two places: * net_slirp_init() continues after slirp_hostfwd(), slirp_guestfwd(), or slirp_smb() failed, and may end up reporting success. This happens for "host_net_add user guestfwd=foo": it complains about the invalid guest forwarding rule, then happily creates the user network without guest forwarding. * net_client_init() can't detect slirp_guestfwd() failure, and gets fooled by net_slirp_init() lying about success. Suppresses its "Could not initialize device" message. Add the missing error reporting, make sure errors are checked, and drop the exit() from config_error(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'vl.c')
-rw-r--r--vl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/vl.c b/vl.c
index 776dd0e577..75b640a6be 100644
--- a/vl.c
+++ b/vl.c
@@ -5098,11 +5098,13 @@ int main(int argc, char **argv, char **envp)
break;
#ifndef _WIN32
case QEMU_OPTION_smb:
- net_slirp_smb(optarg);
+ if (net_slirp_smb(optarg) < 0)
+ exit(1);
break;
#endif
case QEMU_OPTION_redir:
- net_slirp_redir(optarg);
+ if (net_slirp_redir(optarg) < 0)
+ exit(1);
break;
#endif
case QEMU_OPTION_bt:
@@ -5849,7 +5851,8 @@ int main(int argc, char **argv, char **envp)
/* init USB devices */
if (usb_enabled) {
- foreach_device_config(DEV_USB, usb_parse);
+ if (foreach_device_config(DEV_USB, usb_parse) < 0)
+ exit(1);
}
/* init generic devices */