From 7c6b684686daa73ac6f76d7e4249e553d326edff Mon Sep 17 00:00:00 2001 From: "taifu.gc" Date: Sat, 20 Jan 2024 15:14:34 +0800 Subject: [PATCH] Fix revert snapshot failed --- ...en-loading-snapshot-on-inactive-node.patch | 52 +++++++++++++++++++ qemu.spec | 6 ++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 0044-Fix-crash-when-loading-snapshot-on-inactive-node.patch diff --git a/0044-Fix-crash-when-loading-snapshot-on-inactive-node.patch b/0044-Fix-crash-when-loading-snapshot-on-inactive-node.patch new file mode 100644 index 0000000..68b84c6 --- /dev/null +++ b/0044-Fix-crash-when-loading-snapshot-on-inactive-node.patch @@ -0,0 +1,52 @@ +From a629fee99ba2189a7452a212f0a01696a65877ac Mon Sep 17 00:00:00 2001 +From: Kevin Wolf +Date: Fri, 1 Dec 2023 15:25:18 +0100 +Subject: [PATCH] block: Fix crash when loading snapshot on inactive node + +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 +Message-ID: <20231201142520.32255-2-kwolf@redhat.com> +Signed-off-by: Kevin Wolf +(cherry picked from commit d3007d348adaaf04ee8b099a475282034a662414) +Signed-off-by: Michael Tokarev +--- + block/snapshot.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/block/snapshot.c b/block/snapshot.c +index e22ac3eac63..86e29ca59f9 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; + } + +-- +GitLab + diff --git a/qemu.spec b/qemu.spec index accee61..3bb514c 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,4 +1,4 @@ -%define anolis_release 5 +%define anolis_release 6 %bcond_with check @@ -306,6 +306,7 @@ Patch0040: 0040-anolis-csv-i386-add-support-to-migrate-the-outgoing-.patch Patch0041: 0041-anolis-csv-i386-add-support-to-migrate-the-incoming-.patch Patch0042: 0042-anolis-csv-i386-add-support-to-migrate-the-outgoing-.patch Patch0043: 0043-anolis-csv-i386-add-support-to-migrate-the-incoming-.patch +Patch0044: 0044-Fix-crash-when-loading-snapshot-on-inactive-node.patch ExclusiveArch: x86_64 aarch64 @@ -1874,6 +1875,9 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \ %endif %changelog +* Fri Jan 19 2024 Chang Gao - 15:7.2.6-6 +- Fix crash when revert snapshot + * Thu Nov 30 2023 Xin Jiang - 15:7.2.6-5 - Patch0038: 0038-anolis-vfio-only-map-shared-region-for-CSV-virtual-m.patch - Patch0039: 0039-anolis-linux-headers-update-kernel-headers-to-includ.patch -- Gitee