From: Jeff Cody <jcody@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Pavel Butsykin <pbutsykin@virtuozzo.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] qcow2: Emit errp when truncating the image tail
Date: Mon, 9 Oct 2017 14:14:03 -0400 [thread overview]
Message-ID: <20171009181403.GK4501@localhost.localdomain> (raw)
In-Reply-To: <20171009155431.14093-1-mreitz@redhat.com>
On Mon, Oct 09, 2017 at 05:54:31PM +0200, Max Reitz wrote:
> bdrv_truncate() has an errp parameter which is always set when an error
> occurs. Let's use that instead of a plain strerror().
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> block/qcow2.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/block/qcow2.c b/block/qcow2.c
> index dff903e05c..2f6a8e1ff8 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -3150,12 +3150,13 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
> return last_cluster;
> }
> if ((last_cluster + 1) * s->cluster_size < old_file_size) {
> - ret = bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
> - PREALLOC_MODE_OFF, NULL);
> - if (ret < 0) {
> - warn_report("Failed to truncate the tail of the image: %s",
> - strerror(-ret));
> - ret = 0;
> + Error *local_err = NULL;
> +
> + bdrv_truncate(bs->file, (last_cluster + 1) * s->cluster_size,
> + PREALLOC_MODE_OFF, &local_err);
> + if (local_err) {
> + warn_reportf_err(local_err,
> + "Failed to truncate the tail of the image: ");
> }
> }
> } else {
> --
> 2.13.6
>
>
Reviewed-by: Jeff Cody <jcody@redhat.com>
next prev parent reply other threads:[~2017-10-09 18:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-09 15:54 [Qemu-devel] [PATCH] qcow2: Emit errp when truncating the image tail Max Reitz
2017-10-09 16:16 ` Pavel Butsykin
2017-10-09 18:14 ` Jeff Cody [this message]
2017-10-09 19:56 ` Max Reitz
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=20171009181403.GK4501@localhost.localdomain \
--to=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbutsykin@virtuozzo.com \
--cc=qemu-block@nongnu.org \
--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).