[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.9 1/8] block: Fix crash when loading snapshot on inactive no
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.9 1/8] block: Fix crash when loading snapshot on inactive node |
Date: |
Thu, 18 Jan 2024 21:00:20 +0300 |
From: Kevin Wolf <kwolf@redhat.com>
bdrv_is_read_only() only checks if the node is configured to be
read-only eventually, but even if it returns false, writing to the node
may not be permitted at the moment (because it's inactive).
bdrv_is_writable() checks that the node can be written to right now, and
this is what the snapshot operations really need.
Change bdrv_can_snapshot() to use bdrv_is_writable() to fix crashes like
the following:
$ ./qemu-system-x86_64 -hda /tmp/test.qcow2 -loadvm foo -incoming defer
qemu-system-x86_64: ../block/io.c:1990: int bdrv_co_write_req_prepare(BdrvChild
*, int64_t, int64_t, BdrvTrackedRequest *, int): Assertion `!(bs->open_flags &
BDRV_O_INACTIVE)' failed.
The resulting error message after this patch isn't perfect yet, but at
least it doesn't crash any more:
$ ./qemu-system-x86_64 -hda /tmp/test.qcow2 -loadvm foo -incoming defer
qemu-system-x86_64: Device 'ide0-hd0' is writable but does not support snapshots
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20231201142520.32255-2-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit d3007d348adaaf04ee8b099a475282034a662414)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/block/snapshot.c b/block/snapshot.c
index e22ac3eac6..86e29ca59f 100644
--- a/block/snapshot.c
+++ b/block/snapshot.c
@@ -190,8 +190,10 @@ static BlockDriverState
*bdrv_snapshot_fallback(BlockDriverState *bs)
int bdrv_can_snapshot(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
+
GLOBAL_STATE_CODE();
- if (!drv || !bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
+
+ if (!drv || !bdrv_is_inserted(bs) || !bdrv_is_writable(bs)) {
return 0;
}
--
2.39.2
- [Stable-7.2.9 0/8] Patch Round-up for stable 7.2.9, freeze on 2024-01-27, Michael Tokarev, 2024/01/18
- [Stable-7.2.9 1/8] block: Fix crash when loading snapshot on inactive node,
Michael Tokarev <=
- [Stable-7.2.9 2/8] vl: Improve error message for conflicting -incoming and -loadvm, Michael Tokarev, 2024/01/18
- [Stable-7.2.9 3/8] iotests: Basic tests for internal snapshots, Michael Tokarev, 2024/01/18
- [Stable-7.2.9 5/8] chardev/char.c: fix "abstract device type" error message, Michael Tokarev, 2024/01/18
- [Stable-7.2.9 7/8] target/s390x: Fix LAE setting a wrong access register, Michael Tokarev, 2024/01/18
- [Stable-7.2.9 6/8] hw/intc/arm_gicv3_cpuif: handle LPIs in in the list registers, Michael Tokarev, 2024/01/18
- [Stable-7.2.9 8/8] .gitlab-ci.d/buildtest.yml: Work around htags bug when environment is large, Michael Tokarev, 2024/01/18
- [Stable-7.2.9 4/8] target/riscv: Fix mcycle/minstret increment behavior, Michael Tokarev, 2024/01/18