[Qemu-devel] [PATCH 1/2] qcow2: fix return error code in qcow2_truncate()

Pavel Butsykin posted 2 patches 8 years, 1 month ago
There is a newer version of this series
[Qemu-devel] [PATCH 1/2] qcow2: fix return error code in qcow2_truncate()
Posted by Pavel Butsykin 8 years, 1 month ago
Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 block/qcow2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/qcow2.c b/block/qcow2.c
index 2174a84d1f..8a4311d338 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3166,7 +3166,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
         if (old_file_size < 0) {
             error_setg_errno(errp, -old_file_size,
                              "Failed to inquire current file length");
-            return ret;
+            return old_file_size;
         }
 
         nb_new_data_clusters = DIV_ROUND_UP(offset - old_length,
@@ -3195,7 +3195,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
         if (allocation_start < 0) {
             error_setg_errno(errp, -allocation_start,
                              "Failed to resize refcount structures");
-            return -allocation_start;
+            return allocation_start;
         }
 
         clusters_allocated = qcow2_alloc_clusters_at(bs, allocation_start,
-- 
2.14.1


Re: [Qemu-devel] [PATCH 1/2] qcow2: fix return error code in qcow2_truncate()
Posted by Eric Blake 8 years, 1 month ago
On 09/20/2017 08:58 AM, Pavel Butsykin wrote:
> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
> ---
>  block/qcow2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Wow, bdrv_truncate() has had problems!  You found fixes unrelated to my
current struggles to fix the dirty-bitmap failure.

Reviewed-by: Eric Blake <eblake@redhat.com>
CC: qemu-stable@nongnu.org

> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 2174a84d1f..8a4311d338 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -3166,7 +3166,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
>          if (old_file_size < 0) {
>              error_setg_errno(errp, -old_file_size,
>                               "Failed to inquire current file length");
> -            return ret;
> +            return old_file_size;
>          }
>  
>          nb_new_data_clusters = DIV_ROUND_UP(offset - old_length,
> @@ -3195,7 +3195,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
>          if (allocation_start < 0) {
>              error_setg_errno(errp, -allocation_start,
>                               "Failed to resize refcount structures");
> -            return -allocation_start;
> +            return allocation_start;
>          }
>  
>          clusters_allocated = qcow2_alloc_clusters_at(bs, allocation_start,
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [Qemu-block] [PATCH 1/2] qcow2: fix return error code in qcow2_truncate()
Posted by John Snow 8 years, 1 month ago

On 09/20/2017 09:58 AM, Pavel Butsykin wrote:
> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
> ---
>  block/qcow2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 2174a84d1f..8a4311d338 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -3166,7 +3166,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
>          if (old_file_size < 0) {
>              error_setg_errno(errp, -old_file_size,
>                               "Failed to inquire current file length");
> -            return ret;
> +            return old_file_size;
>          }
>  
>          nb_new_data_clusters = DIV_ROUND_UP(offset - old_length,
> @@ -3195,7 +3195,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
>          if (allocation_start < 0) {
>              error_setg_errno(errp, -allocation_start,
>                               "Failed to resize refcount structures");
> -            return -allocation_start;
> +            return allocation_start;
>          }
>  
>          clusters_allocated = qcow2_alloc_clusters_at(bs, allocation_start,
> 

Yikes...

Reviewed-by: John Snow <jsnow@redhat.com>

Re: [Qemu-devel] [PATCH 1/2] qcow2: fix return error code in qcow2_truncate()
Posted by Max Reitz 8 years, 1 month ago
On 2017-09-20 15:58, Pavel Butsykin wrote:
> Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
> ---
>  block/qcow2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>