From: Murilo Opsfelder Araujo <muriloo@linux.vnet.ibm.com>
To: Eric Blake <eblake@redhat.com>,
Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>,
qemu-devel@nongnu.org
Cc: marcandre.lureau@redhat.com,
Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>,
Yasmin Beatriz <yasmins@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH v3 1/1] dump.c: allow fd_write_vmcore to return errno on failure
Date: Mon, 12 Feb 2018 17:19:38 -0200 [thread overview]
Message-ID: <49dd3029-ceee-8ca7-5da2-b257ffabe74e@linux.vnet.ibm.com> (raw)
In-Reply-To: <b4cafa8f-efac-00e1-683a-304a91c695ca@redhat.com>
On 02/12/2018 03:31 PM, Eric Blake wrote:
> On 02/12/2018 08:46 AM, Murilo Opsfelder Araujo wrote:
>> On 02/12/2018 12:25 PM, Daniel Henrique Barboza wrote:
>>> From: Yasmin Beatriz <yasmins@linux.vnet.ibm.com>
>>>
>>> fd_write_vmcore can fail to execute for a lot of reasons that can be
>>> retrieved by errno, but it only returns -1. This makes difficult for
>>> the caller to know what happened and only a generic error message is
>>> propagated back to the user. This is an example using dump-guest-memory:
>>>
>
>>> +++ b/dump.c
>>> @@ -107,7 +107,7 @@ static int fd_write_vmcore(const void *buf,
>>> size_t size, void *opaque)
>>>
>>> written_size = qemu_write_full(s->fd, buf, size);
>>> if (written_size != size) {
>>> - return -1;
>>> + return -errno;
>>> }
>>>
>>> return 0;
>>> @@ -140,7 +140,7 @@ static void write_elf64_header(DumpState *s,
>>> Error **errp)
>>>
>>> ret = fd_write_vmcore(&elf_header, sizeof(elf_header), s);
>>> if (ret < 0) {
>>> - error_setg(errp, "dump: failed to write elf header");
>>> + error_setg_errno(errp, -ret, "dump: failed to write elf
>>> header");
>>
>> Do we need -ret passed to error_setg_errno()? fd_write_vmcore() returns
>> negative errno in case of error.
>
> Yes, this usage is correct. error_setg_errno() takes a positive errno
> value (using strerror, which only decodes positive values into useful
> strings); but we typically return negative errno values (as was
> correctly done in fd_write_vmcore), so the extra layer of negation here
> is needed.
>
For some reason I assumed "non-zero" in the error_setg_errno()
description as negative.
Thanks Daniel and Eric.
next prev parent reply other threads:[~2018-02-12 19:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-12 14:25 [Qemu-devel] [PATCH v3 0/1] dump.c: allow fd_write_vmcore to return errno on failure Daniel Henrique Barboza
2018-02-12 14:25 ` [Qemu-devel] [PATCH v3 1/1] " Daniel Henrique Barboza
2018-02-12 14:31 ` Marc-Andre Lureau
2018-02-12 14:46 ` Murilo Opsfelder Araujo
2018-02-12 15:49 ` Daniel Henrique Barboza
2018-02-12 17:31 ` Eric Blake
2018-02-12 19:19 ` Murilo Opsfelder Araujo [this message]
2018-02-12 17:47 ` Eric Blake
2018-03-21 13:29 ` [Qemu-devel] [PATCH v3 0/1] " Daniel Henrique Barboza
2018-03-21 13:56 ` [Qemu-devel] [PATCH v3 for-2.12? " Eric Blake
2018-03-21 14:20 ` Marc-André Lureau
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=49dd3029-ceee-8ca7-5da2-b257ffabe74e@linux.vnet.ibm.com \
--to=muriloo@linux.vnet.ibm.com \
--cc=danielhb@linux.vnet.ibm.com \
--cc=eblake@redhat.com \
--cc=joserz@linux.vnet.ibm.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yasmins@linux.vnet.ibm.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).