* [Qemu-devel] [PATCH] qcow2: Emit errp when truncating the image tail
@ 2017-10-09 15:54 Max Reitz
2017-10-09 16:16 ` Pavel Butsykin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Max Reitz @ 2017-10-09 15:54 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf, Pavel Butsykin
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: Emit errp when truncating the image tail
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 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-10-09 19:56 ` [Qemu-devel] " Max Reitz
2 siblings, 0 replies; 4+ messages in thread
From: Pavel Butsykin @ 2017-10-09 16:16 UTC (permalink / raw)
To: Max Reitz, qemu-block; +Cc: qemu-devel, Kevin Wolf
On 09.10.2017 18:54, 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 {
>
Reviewed-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] qcow2: Emit errp when truncating the image tail
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
2017-10-09 19:56 ` [Qemu-devel] " Max Reitz
2 siblings, 0 replies; 4+ messages in thread
From: Jeff Cody @ 2017-10-09 18:14 UTC (permalink / raw)
To: Max Reitz; +Cc: qemu-block, Kevin Wolf, Pavel Butsykin, qemu-devel
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: Emit errp when truncating the image tail
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 ` [Qemu-devel] [Qemu-block] " Jeff Cody
@ 2017-10-09 19:56 ` Max Reitz
2 siblings, 0 replies; 4+ messages in thread
From: Max Reitz @ 2017-10-09 19:56 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Kevin Wolf, Pavel Butsykin
[-- Attachment #1: Type: text/plain, Size: 433 bytes --]
On 2017-10-09 17:54, 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(-)
Thanks for the reviews, applied to my block branch:
https://github.com/XanClic/qemu/commits/block
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-09 19:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2017-10-09 19:56 ` [Qemu-devel] " Max Reitz
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).