ae23c9
From f0b9cea2fd575e86a3d2d2c8ca7b7f6b65cd7b08 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Thu, 12 Jul 2018 14:42:53 +0200
ae23c9
Subject: [PATCH 208/268] qcow2: Fix qcow2_truncate() error return value
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20180712144258.17303-2-kwolf@redhat.com>
ae23c9
Patchwork-id: 81325
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/6] qcow2: Fix qcow2_truncate() error return value
ae23c9
Bugzilla: 1595173
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
RH-Acked-by: John Snow <jsnow@redhat.com>
ae23c9
ae23c9
If qcow2_alloc_clusters_at() returns an error, we do need to negate it
ae23c9
to get back the positive errno code for error_setg_errno(), but we still
ae23c9
need to return the negative error code.
ae23c9
ae23c9
Fixes: 772d1f973f87269f6a4a4ea4b880680f3779bbdf
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
(cherry picked from commit ae5475e82fd1ebb24f4f77cf28f59ca6548c6136)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 block/qcow2.c | 2 +-
ae23c9
 1 file changed, 1 insertion(+), 1 deletion(-)
ae23c9
ae23c9
diff --git a/block/qcow2.c b/block/qcow2.c
ae23c9
index da74e2a..dbd448c 100644
ae23c9
--- a/block/qcow2.c
ae23c9
+++ b/block/qcow2.c
ae23c9
@@ -3594,7 +3594,7 @@ static int qcow2_truncate(BlockDriverState *bs, int64_t offset,
ae23c9
         if (clusters_allocated < 0) {
ae23c9
             error_setg_errno(errp, -clusters_allocated,
ae23c9
                              "Failed to allocate data clusters");
ae23c9
-            return -clusters_allocated;
ae23c9
+            return clusters_allocated;
ae23c9
         }
ae23c9
 
ae23c9
         assert(clusters_allocated == nb_new_data_clusters);
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9