|
|
bf143f |
From 648193b48d8aeaded90fd657e3610d8040f505fc Mon Sep 17 00:00:00 2001
|
|
|
bf143f |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
bf143f |
Date: Thu, 12 Jan 2023 20:14:53 +0100
|
|
|
bf143f |
Subject: [PATCH 3/4] qemu-img bitmap: Report errors while closing the image
|
|
|
bf143f |
MIME-Version: 1.0
|
|
|
bf143f |
Content-Type: text/plain; charset=UTF-8
|
|
|
bf143f |
Content-Transfer-Encoding: 8bit
|
|
|
bf143f |
|
|
|
bf143f |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
bf143f |
RH-MergeRequest: 251: qemu-img: Fix exit code for errors closing the image
|
|
|
bf143f |
RH-Bugzilla: 2147617
|
|
|
bf143f |
RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
|
|
|
bf143f |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
bf143f |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
bf143f |
RH-Commit: [3/4] 8e13e09564718a0badd03af84f036246a46a0eba
|
|
|
bf143f |
|
|
|
bf143f |
blk_unref() can't report any errors that happen while closing the image.
|
|
|
bf143f |
For example, if qcow2 hits an -ENOSPC error while writing out dirty
|
|
|
bf143f |
bitmaps when it's closed, it prints error messages to stderr, but
|
|
|
bf143f |
'qemu-img bitmap' won't see any error return value and will therefore
|
|
|
bf143f |
look successful with exit code 0.
|
|
|
bf143f |
|
|
|
bf143f |
In order to fix this, manually inactivate the image first before calling
|
|
|
bf143f |
blk_unref(). This already performs the operations that would be most
|
|
|
bf143f |
likely to fail while closing the image, but it can still return errors.
|
|
|
bf143f |
|
|
|
bf143f |
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1330
|
|
|
bf143f |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
bf143f |
Message-Id: <20230112191454.169353-4-kwolf@redhat.com>
|
|
|
bf143f |
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
|
|
|
bf143f |
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
|
|
|
bf143f |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
bf143f |
(cherry picked from commit c5e477110dcb8ef4642dce399777c3dee68fa96c)
|
|
|
bf143f |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
bf143f |
---
|
|
|
bf143f |
qemu-img.c | 11 +++++++++++
|
|
|
bf143f |
1 file changed, 11 insertions(+)
|
|
|
bf143f |
|
|
|
bf143f |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
bf143f |
index 18833f7d69..7d035c0c7f 100644
|
|
|
bf143f |
--- a/qemu-img.c
|
|
|
bf143f |
+++ b/qemu-img.c
|
|
|
bf143f |
@@ -4622,6 +4622,7 @@ static int img_bitmap(int argc, char **argv)
|
|
|
bf143f |
QSIMPLEQ_HEAD(, ImgBitmapAction) actions;
|
|
|
bf143f |
ImgBitmapAction *act, *act_next;
|
|
|
bf143f |
const char *op;
|
|
|
bf143f |
+ int inactivate_ret;
|
|
|
bf143f |
|
|
|
bf143f |
QSIMPLEQ_INIT(&actions);
|
|
|
bf143f |
|
|
|
bf143f |
@@ -4806,6 +4807,16 @@ static int img_bitmap(int argc, char **argv)
|
|
|
bf143f |
ret = 0;
|
|
|
bf143f |
|
|
|
bf143f |
out:
|
|
|
bf143f |
+ /*
|
|
|
bf143f |
+ * Manually inactivate the images first because this way we can know whether
|
|
|
bf143f |
+ * an error occurred. blk_unref() doesn't tell us about failures.
|
|
|
bf143f |
+ */
|
|
|
bf143f |
+ inactivate_ret = bdrv_inactivate_all();
|
|
|
bf143f |
+ if (inactivate_ret < 0) {
|
|
|
bf143f |
+ error_report("Error while closing the image: %s", strerror(-inactivate_ret));
|
|
|
bf143f |
+ ret = 1;
|
|
|
bf143f |
+ }
|
|
|
bf143f |
+
|
|
|
bf143f |
blk_unref(src);
|
|
|
bf143f |
blk_unref(blk);
|
|
|
bf143f |
qemu_opts_del(opts);
|
|
|
bf143f |
--
|
|
|
bf143f |
2.37.3
|
|
|
bf143f |
|