From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMd7w-0005Vx-IM for qemu-devel@nongnu.org; Wed, 27 Aug 2014 09:19:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMd7m-0001Ji-H8 for qemu-devel@nongnu.org; Wed, 27 Aug 2014 09:19:04 -0400 Date: Wed, 27 Aug 2014 09:18:27 -0400 From: Luiz Capitulino Message-ID: <20140827091827.4de1dc59@redhat.com> In-Reply-To: <1409138333-12644-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1409138333-12644-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] dump: let dump_error printf the error reason List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: qemu-trivial@nongnu.org, luonengjun@huawei.com, lersek@redhat.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com On Wed, 27 Aug 2014 19:18:53 +0800 zhanghailiang 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 > --- > 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().