* [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779
@ 2026-11-18 11:47 Denis V. Lunev
2026-11-18 11:47 ` [PATCH hci-7.4 1/2] hw/loader: stop rom_reset() overwriting the BIOS " Denis V. Lunev
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Denis V. Lunev @ 2026-11-18 11:47 UTC (permalink / raw)
To: svt-core; +Cc: andrey.drobyshev, den
hci-7.4 has the bug fixed on hci-8.0/8.1 in VSTOR-155779 as well. Since
8883d1305f1 rom_reset() returns early while a cpr restart is in
progress, so the restarted QEMU keeps the host's BIOS image and writes
it into pc.bios on the first guest reset after vz-cprload. A VM whose
node got a new seabios-bin after the VM started then pauses on reboot
with "KVM internal error. Suberror: 1".
https://virtuozzo.atlassian.net/browse/VSTOR-155779
The fix differs from hci-8.0/8.1 only in the check. The restarted QEMU
starts in RUN_STATE_CPR_POSTEXEC, not INMIGRATE, so the early return
cannot simply go: the startup reset would write the ROMs over the
preserved RAM again. Patch 1 makes rom_reset() treat a cpr restart like
an incoming migration instead. Patch 2 adds the same BIOS-swap case to
vz-cpr as on hci-8.0/8.1.
Tested on dev-cl04: vz-cpr passes, and with patch 1 reverted only the
new case fails, with the new image in the ROM.
Denis V. Lunev (2):
hw/loader: stop rom_reset() overwriting the BIOS after vz-cprload
#VSTOR-155779
iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779
hw/core/loader.c | 12 +++------
tests/qemu-iotests/tests/vz-cpr | 42 ++++++++++++++++++++++++++++-
tests/qemu-iotests/tests/vz-cpr.out | 4 +--
3 files changed, 47 insertions(+), 11 deletions(-)
base-commit: 31d8e05b43806b8a997660f1bc92eae6373602ea
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH hci-7.4 1/2] hw/loader: stop rom_reset() overwriting the BIOS after vz-cprload #VSTOR-155779
2026-11-18 11:47 [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779 Denis V. Lunev
@ 2026-11-18 11:47 ` Denis V. Lunev
2026-11-18 11:51 ` no-reply
2026-11-18 11:47 ` [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779 Denis V. Lunev
2026-11-18 14:11 ` [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779 Andrey Drobyshev
2 siblings, 1 reply; 6+ messages in thread
From: Denis V. Lunev @ 2026-11-18 11:47 UTC (permalink / raw)
To: svt-core; +Cc: andrey.drobyshev, den
From: Denis V. Lunev <den@openvz.org>
Since 8883d1305f1 rom_reset() returns early while a cpr restart is in
progress. The new QEMU starts in RUN_STATE_CPR_POSTEXEC, not INMIGRATE,
so the branch that drops the data of isrom ROMs never runs and the BIOS
image loaded from the host is kept. vz-cprload clears
CPR_RESTART_POSTEXEC, and the next guest reset copies that image into
pc.bios.
The guest does not re-enter through the ROM. PAM is not reset, so
SeaBIOS runs from shadow RAM, finds HaveRunPost set and copies its code
back from the high ROM alias in qemu_reboot(). When the host's
bios-256k.bin is a different build from the one the guest started with,
SeaBIOS overwrites the code it is running and the vCPU stops with "KVM
internal error. Suberror: 1". A VM whose node got a new seabios-bin
after the VM started pauses this way on its first reboot after the
update.
Treat a cpr restart like an incoming migration: drop the data of isrom
ROMs and write nothing. Dropping the early return alone is not enough
here: the startup reset would then write the ROMs over the preserved
RAM again.
Fixes: 8883d1305f1 ("cpr: avoid resetting ROMs on qemu-update #VSTOR-101576")
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
hw/core/loader.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index efd043d7a2d..d786dd7a012 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -1254,21 +1254,17 @@ static void rom_reset(void *unused)
{
Rom *rom;
- if (cpr_restart_in_progress()) {
- /* No need to reset any ROM on CPR */
- return;
- }
-
QTAILQ_FOREACH(rom, &roms, next) {
if (rom->fw_file) {
continue;
}
/*
* We don't need to fill in the RAM with ROM data because we'll fill
- * the data in during the next incoming migration in all cases. Note
- * that some of those RAMs can actually be modified by the guest.
+ * the data in during the next incoming migration in all cases, and
+ * CPR keeps the RAM in place. Note that some of those RAMs can
+ * actually be modified by the guest.
*/
- if (runstate_check(RUN_STATE_INMIGRATE)) {
+ if (runstate_check(RUN_STATE_INMIGRATE) || cpr_restart_in_progress()) {
if (rom->data && rom->isrom) {
/*
* Free it so that a rom_reset after migration doesn't
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779
2026-11-18 11:47 [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779 Denis V. Lunev
2026-11-18 11:47 ` [PATCH hci-7.4 1/2] hw/loader: stop rom_reset() overwriting the BIOS " Denis V. Lunev
@ 2026-11-18 11:47 ` Denis V. Lunev
2026-11-18 11:50 ` no-reply
2026-11-18 14:11 ` [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779 Andrey Drobyshev
2 siblings, 1 reply; 6+ messages in thread
From: Denis V. Lunev @ 2026-11-18 11:47 UTC (permalink / raw)
To: svt-core; +Cc: andrey.drobyshev, den
From: Denis V. Lunev <den@openvz.org>
Start the new QEMU with a BIOS file that differs from the guest's in one
byte. After vz-cprload and system_reset the BIOS ROM must still hold the
image the guest started with. _test_cpr() gets a post_cpr_hook for that.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
tests/qemu-iotests/tests/vz-cpr | 42 ++++++++++++++++++++++++++++-
tests/qemu-iotests/tests/vz-cpr.out | 4 +--
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/tests/qemu-iotests/tests/vz-cpr b/tests/qemu-iotests/tests/vz-cpr
index cee14b3f185..0ad0d7658ee 100755
--- a/tests/qemu-iotests/tests/vz-cpr
+++ b/tests/qemu-iotests/tests/vz-cpr
@@ -57,7 +57,7 @@ class TestVzCpr(iotests.QMPTestCase):
os.remove(self.cprfile)
self.cprfile = NamedTemporaryFile(dir=iotests.test_dir, delete=False).name
- def _test_cpr(self, pre_cpr_hook=None) -> None:
+ def _test_cpr(self, pre_cpr_hook=None, post_cpr_hook=None) -> None:
self.vm.launch()
self.vm.qmp_check_log('cont')
@@ -79,6 +79,9 @@ class TestVzCpr(iotests.QMPTestCase):
mode='restart', cmdline=cpr_cmdline)
self.vm.qmp_check_log('vz-cprload', file=self.cprfile)
+ if post_cpr_hook is not None:
+ post_cpr_hook()
+
self.vm.shutdown()
def test_virtio_blk_hd(self) -> None:
@@ -232,6 +235,43 @@ class TestVzCpr(iotests.QMPTestCase):
'-numa', 'node,nodeid=0,memdev=ram0')
self._test_cpr(pre_cpr_hook=hotplug_dimm)
+ def _bios_rom(self) -> tuple:
+ roms = self.vm.qmp('human-monitor-command',
+ command_line='info roms')['return']
+ m = re.search(r'addr=([0-9a-f]+) size=0x([0-9a-f]+) mem=rom '
+ r'name="([^"]*bios[^"]*)"', roms)
+ assert m, roms
+ return int(m[1], 16), int(m[2], 16)
+
+ def _dump_guest_mem(self, addr: int, size: int) -> bytes:
+ path = iotests.file_path('guest-mem.bin')
+ res = self.vm.qmp('pmemsave', val=addr, size=size, filename=path)
+ assert 'return' in res, res
+ with open(path, 'rb') as f:
+ return f.read()
+
+ def test_bios_rom_reset(self) -> None:
+ """Reset after vz-cprload keeps the guest's BIOS. See #VSTOR-155779"""
+ new_bios = iotests.file_path('bios-new.bin')
+ rom = {}
+
+ def swap_bios():
+ addr, size = self._bios_rom()
+ old = self._dump_guest_mem(addr, size)
+ with open(new_bios, 'wb') as f:
+ f.write(bytes([old[0] ^ 0xff]) + old[1:])
+ self.vm._qemu_full_args += ('-bios', new_bios)
+ rom.update(addr=addr, old=old)
+
+ def reset():
+ res = self.vm.qmp('system_reset')
+ assert 'return' in res, res
+ self.assertEqual(
+ self._dump_guest_mem(rom['addr'], len(rom['old'])),
+ rom['old'])
+
+ self._test_cpr(pre_cpr_hook=swap_bios, post_cpr_hook=reset)
+
if __name__ == '__main__':
iotests.activate_logging()
diff --git a/tests/qemu-iotests/tests/vz-cpr.out b/tests/qemu-iotests/tests/vz-cpr.out
index c6a10f870d0..84bfd63fba1 100644
--- a/tests/qemu-iotests/tests/vz-cpr.out
+++ b/tests/qemu-iotests/tests/vz-cpr.out
@@ -1,5 +1,5 @@
-.....................
+......................
----------------------------------------------------------------------
-Ran 21 tests
+Ran 22 tests
OK
--
2.55.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779
2026-11-18 11:47 ` [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779 Denis V. Lunev
@ 2026-11-18 11:50 ` no-reply
0 siblings, 0 replies; 6+ messages in thread
From: no-reply @ 2026-11-18 11:50 UTC (permalink / raw)
To: Denis V. Lunev, svt-core; +Cc: andrey.drobyshev
> From: Denis V. Lunev <den@openvz.org>
>
> Start the new QEMU with a BIOS file that differs from the guest's in one
> byte. After vz-cprload and system_reset the BIOS ROM must still hold the
> image the guest started with. _test_cpr() gets a post_cpr_hook for that.
>
> Signed-off-by: Denis V. Lunev <den@openvz.org>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118114729.2973585-1-den@openvz.org?part=2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH hci-7.4 1/2] hw/loader: stop rom_reset() overwriting the BIOS after vz-cprload #VSTOR-155779
2026-11-18 11:47 ` [PATCH hci-7.4 1/2] hw/loader: stop rom_reset() overwriting the BIOS " Denis V. Lunev
@ 2026-11-18 11:51 ` no-reply
0 siblings, 0 replies; 6+ messages in thread
From: no-reply @ 2026-11-18 11:51 UTC (permalink / raw)
To: Denis V. Lunev, svt-core; +Cc: andrey.drobyshev
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] commit message: Fixes trailer uses 11-char SHA instead of 12
--
commit 3e556a0c6ff6fde2016d52a18d0f182cfe188ae5
Author: Denis V. Lunev <den@openvz.org>
> hw/loader: stop rom_reset() overwriting the BIOS after vz-cprload #VSTOR-155779
>
> Since 8883d1305f1 rom_reset() returns early while a cpr restart is in
> progress. The new QEMU starts in RUN_STATE_CPR_POSTEXEC, not INMIGRATE,
> so the branch that drops the data of isrom ROMs never runs and the BIOS
> image loaded from the host is kept. vz-cprload clears
> CPR_RESTART_POSTEXEC, and the next guest reset copies that image into
> pc.bios.
>
> The guest does not re-enter through the ROM. PAM is not reset, so
> SeaBIOS runs from shadow RAM, finds HaveRunPost set and copies its code
> back from the high ROM alias in qemu_reboot(). When the host's
> bios-256k.bin is a different build from the one the guest started with,
> SeaBIOS overwrites the code it is running and the vCPU stops with "KVM
> internal error. Suberror: 1". A VM whose node got a new seabios-bin
> after the VM started pauses this way on its first reboot after the
> update.
>
> Treat a cpr restart like an incoming migration: drop the data of isrom
> ROMs and write nothing. Dropping the early return alone is not enough
> here: the startup reset would then write the ROMs over the preserved
> RAM again.
>
> Fixes: 8883d1305f1 ("cpr: avoid resetting ROMs on qemu-update #VSTOR-101576")
> Signed-off-by: Denis V. Lunev <den@openvz.org>
[Severity: Low]
This isn't a bug, but the Fixes: tag uses an 11-character abbreviated sha. It should be at least 12 characters:
Fixes: 8883d1305f1e ("cpr: avoid resetting ROMs on qemu-update #VSTOR-101576")
The first sentence of the message cites the same commit as a bare 8883d1305f1. It could use the 12-character sha with the subject as well.
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261118114729.2973585-1-den@openvz.org?part=1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779
2026-11-18 11:47 [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779 Denis V. Lunev
2026-11-18 11:47 ` [PATCH hci-7.4 1/2] hw/loader: stop rom_reset() overwriting the BIOS " Denis V. Lunev
2026-11-18 11:47 ` [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779 Denis V. Lunev
@ 2026-11-18 14:11 ` Andrey Drobyshev
2 siblings, 0 replies; 6+ messages in thread
From: Andrey Drobyshev @ 2026-11-18 14:11 UTC (permalink / raw)
To: Denis V. Lunev, svt-core
LGTM, Ack
Applied to hci-7.4
On 11/18/26 1:47 PM, Denis V. Lunev wrote:
> hci-7.4 has the bug fixed on hci-8.0/8.1 in VSTOR-155779 as well. Since
> 8883d1305f1 rom_reset() returns early while a cpr restart is in
> progress, so the restarted QEMU keeps the host's BIOS image and writes
> it into pc.bios on the first guest reset after vz-cprload. A VM whose
> node got a new seabios-bin after the VM started then pauses on reboot
> with "KVM internal error. Suberror: 1".
>
> https://virtuozzo.atlassian.net/browse/VSTOR-155779
>
> The fix differs from hci-8.0/8.1 only in the check. The restarted QEMU
> starts in RUN_STATE_CPR_POSTEXEC, not INMIGRATE, so the early return
> cannot simply go: the startup reset would write the ROMs over the
> preserved RAM again. Patch 1 makes rom_reset() treat a cpr restart like
> an incoming migration instead. Patch 2 adds the same BIOS-swap case to
> vz-cpr as on hci-8.0/8.1.
>
> Tested on dev-cl04: vz-cpr passes, and with patch 1 reverted only the
> new case fails, with the new image in the ROM.
>
> Denis V. Lunev (2):
> hw/loader: stop rom_reset() overwriting the BIOS after vz-cprload
> #VSTOR-155779
> iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779
>
> hw/core/loader.c | 12 +++------
> tests/qemu-iotests/tests/vz-cpr | 42 ++++++++++++++++++++++++++++-
> tests/qemu-iotests/tests/vz-cpr.out | 4 +--
> 3 files changed, 47 insertions(+), 11 deletions(-)
>
>
> base-commit: 31d8e05b43806b8a997660f1bc92eae6373602ea
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-11-18 14:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 11:47 [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779 Denis V. Lunev
2026-11-18 11:47 ` [PATCH hci-7.4 1/2] hw/loader: stop rom_reset() overwriting the BIOS " Denis V. Lunev
2026-11-18 11:51 ` no-reply
2026-11-18 11:47 ` [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779 Denis V. Lunev
2026-11-18 11:50 ` no-reply
2026-11-18 14:11 ` [PATCH hci-7.4 0/2] hw/loader: keep the guest's BIOS on reset after vz-cprload #VSTOR-155779 Andrey Drobyshev
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.