qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Capitulino <lcapitulino@redhat.com>
To: zhanghailiang <zhang.zhanghailiang@huawei.com>
Cc: qemu-trivial@nongnu.org, luonengjun@huawei.com,
	lersek@redhat.com, qemu-devel@nongnu.org,
	peter.huangpeng@huawei.com
Subject: Re: [Qemu-devel] [PATCH] dump: let dump_error printf the error reason
Date: Wed, 27 Aug 2014 09:18:27 -0400	[thread overview]
Message-ID: <20140827091827.4de1dc59@redhat.com> (raw)
In-Reply-To: <1409138333-12644-1-git-send-email-zhang.zhanghailiang@huawei.com>

On Wed, 27 Aug 2014 19:18:53 +0800
zhanghailiang <zhang.zhanghailiang@huawei.com> wrote:

> The second parameter of dump_error is unused, but one purpose of
> using this function is to report the error info.
> 
> Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
> ---
>  dump.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/dump.c b/dump.c
> index 71d3e94..0f44e9d 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -83,6 +83,9 @@ static int dump_cleanup(DumpState *s)
>  
>  static void dump_error(DumpState *s, const char *reason)
>  {
> +    if (reason) {
> +        error_report("%s", reason);
> +    }
>      dump_cleanup(s);
>  }
>  

Good catch, but error_report() will report the error only to the user. This
is QMP code, so we have to use the Error API.

I think that the best way to solve this is to make dump_error() fill an
Error object (eg. by calling error_setg()) and then returning it after
the call to dump_cleanup(). Of course that you will have to change _all_
code paths calling dump_error() to propagate the error up.

For more information on this, please read docs/writing-qmp-commands.txt.
You can also take a look at simple commands doing error propagation, like
qmp_cont() or qmp_block_passwd().

  reply	other threads:[~2014-08-27 13:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27 11:18 [Qemu-devel] [PATCH] dump: let dump_error printf the error reason zhanghailiang
2014-08-27 13:18 ` Luiz Capitulino [this message]
2014-08-29  8:06   ` zhanghailiang
2014-08-29 12:55     ` Luiz Capitulino
2014-09-01  7:40       ` zhanghailiang

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=20140827091827.4de1dc59@redhat.com \
    --to=lcapitulino@redhat.com \
    --cc=lersek@redhat.com \
    --cc=luonengjun@huawei.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=zhang.zhanghailiang@huawei.com \
    /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).