[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 0/4] qemu-img: Fix exit code for errors closing the image
From: |
Kevin Wolf |
Subject: |
[PATCH 0/4] qemu-img: Fix exit code for errors closing the image |
Date: |
Thu, 12 Jan 2023 20:14:50 +0100 |
This series addresses the problem described in these bug reports:
https://gitlab.com/qemu-project/qemu/-/issues/1330
https://bugzilla.redhat.com/show_bug.cgi?id=2147617
qcow2 can fail when writing back dirty bitmaps in qcow2_inactivate().
However, when the function is called through blk_unref(), in the case of
such errors, while an error message is written to stderr, the callers
never see an error return. Specifically, 'qemu-img bitmap/commit' are
reported to exit with an exit code 0 despite the errors.
The solution taken here is inactivating the images first, which can
still return errors, but already performs all of the write operations.
Only then the images are actually blk_unref()-ed.
If we agree that this is the way to go (as a potential alternative,
allowing blk_unref() to fail would require changes in all kinds of
places, many of which probably wouldn't even know what to do with the
error), then I suppose doing the same for other qemu-img subcommands
would make sense, too.
As a bonus fix, I found an endianness confusion in an error path of
store_bitmap(). The reported error message "qcow2_free_clusters failed:
No space left on device" looked too suspicious to ignore this. Freeing
an actually existing cluster should never run into ENOSPC.
Kevin Wolf (4):
qcow2: Fix theoretical corruption in store_bitmap() error path
qemu-img commit: Report errors while closing the image
qemu-img bitmap: Report errors while closing the image
qemu-iotests: Test qemu-img bitmap/commit exit code on error
block/qcow2-bitmap.c | 5 +-
qemu-img.c | 24 +++++
.../qemu-iotests/tests/qemu-img-close-errors | 95 +++++++++++++++++++
.../tests/qemu-img-close-errors.out | 23 +++++
4 files changed, 145 insertions(+), 2 deletions(-)
create mode 100755 tests/qemu-iotests/tests/qemu-img-close-errors
create mode 100644 tests/qemu-iotests/tests/qemu-img-close-errors.out
--
2.38.1