qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Mark McLoughlin <markmc@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] Don't exit() in config_error()
Date: Wed, 30 Sep 2009 11:27:42 +0100	[thread overview]
Message-ID: <1254306462.3105.20.camel@blaa> (raw)
In-Reply-To: <af73f6935dc41c4b88de71aebffdee797f82a6cb.1254164748.git.armbru@redhat.com>

On Mon, 2009-09-28 at 21:11 +0200, Markus Armbruster wrote:
> 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>
> ---
>  net.c |   83 ++++++++++++++++++++++++++++++++++++----------------------------
>  net.h |    4 +-
>  vl.c  |    9 ++++--
>  3 files changed, 55 insertions(+), 41 deletions(-)
> 
...
> diff --git a/vl.c b/vl.c
> index 7bfd415..96e4312 100644
> --- a/vl.c
> +++ b/vl.c
...
> @@ -5766,7 +5768,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 */

This hunk appears to be unrelated

Cheers,
Mark.

  reply	other threads:[~2009-09-30 10:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1254164748.git.armbru@redhat.com>
2009-09-28 19:11 ` [Qemu-devel] [PATCH 1/3] Make net_client_init() consume slirp_configs even on error Markus Armbruster
2009-09-28 19:11 ` [Qemu-devel] [PATCH 2/3] Don't exit() in config_error() Markus Armbruster
2009-09-30 10:27   ` Mark McLoughlin [this message]
2009-09-30 13:24     ` Markus Armbruster
2009-09-30 13:27       ` Mark McLoughlin
2009-09-28 19:11 ` [Qemu-devel] [PATCH 3/3] Drop config_error(), use qemu_error() instead Markus Armbruster

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=1254306462.3105.20.camel@blaa \
    --to=markmc@redhat.com \
    --cc=armbru@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 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).