]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
qcow2: fix return error code in qcow2_truncate()
authorPavel Butsykin <pbutsykin@virtuozzo.com>
Fri, 29 Sep 2017 12:16:12 +0000 (15:16 +0300)
committerMax Reitz <mreitz@redhat.com>
Fri, 6 Oct 2017 14:30:48 +0000 (16:30 +0200)
Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 20170929121613.25997-2-pbutsykin@virtuozzo.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/qcow2.c

index 33597394b5a1cf60f2fb5534d168991850943240..960b3ab977c36df2cb3c4189f4c7cc9564186950 100644 (file)
@@ -3167,7 +3167,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,
@@ -3196,7 +3196,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,