qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
To: "Yasmin Beatriz" <yasmins@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-trivial@nongnu.org, joserz@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH] dump: Show custom message for ENOSPC
Date: Fri, 9 Feb 2018 18:07:21 -0200	[thread overview]
Message-ID: <1f0c05ec-511a-374d-4be0-7a01a9630867@linux.vnet.ibm.com> (raw)
In-Reply-To: <20180209193138.97198-1-yasmins@linux.vnet.ibm.com>

Hi Yasmin,

On 02/09/2018 05:31 PM, Yasmin Beatriz wrote:
> This patch intends to make a more specific message for when
> the system has not enough space to save guest memory.
>
> Reported-by: yilzhang@redhat.com
> Cc: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
> Signed-off-by: Yasmin Beatriz <yasmins@linux.vnet.ibm.com>
> ---
>   dump.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/dump.c b/dump.c
> index e9dfed060a..eb56ff53f6 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -106,6 +106,9 @@ 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) {
> +        if (errno == ENOSPC) {
> +            return -ENOSPC;
> +        }
You can do like this:


      if (written_size != size) {
+        return -errno;
+     }


Everyone is checking for a negative "ret" to see if an error occurred in 
qemu_write_full.
There is no negative errno AFAIK, so you can spare one "if" clause there 
and still
check for -ENOSPC down there.

It might be worth checking if this code can't be baked into 
qemu_write_full too.



Thanks,


Daniel

>           return -1;
>       }
>
> @@ -364,7 +367,11 @@ static void write_data(DumpState *s, void *buf, int length, Error **errp)
>
>       ret = fd_write_vmcore(buf, length, s);
>       if (ret < 0) {
> -        error_setg(errp, "dump: failed to save memory");
> +        if (ret == -ENOSPC) {
> +            error_setg(errp, "dump: not enough space to save memory");
> +        } else {
> +            error_setg(errp, "dump: failed to save memory");
> +        }
>       } else {
>           s->written_size += length;
>       }

  reply	other threads:[~2018-02-09 20:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 19:31 [Qemu-devel] [PATCH] dump: Show custom message for ENOSPC Yasmin Beatriz
2018-02-09 20:07 ` Daniel Henrique Barboza [this message]
2018-02-09 20:27 ` Murilo Opsfelder Araujo
2018-02-09 20:52 ` Eric Blake

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=1f0c05ec-511a-374d-4be0-7a01a9630867@linux.vnet.ibm.com \
    --to=danielhb@linux.vnet.ibm.com \
    --cc=joserz@linux.vnet.ibm.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@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).