All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: "Denis V. Lunev" <den@openvz.org>
To: svt-core@virtuozzo.com
Cc: andrey.drobyshev@virtuozzo.com, den@openvz.org
Subject: [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779
Date: Wed, 18 Nov 2026 12:47:29 +0100	[thread overview]
Message-ID: <20261118114729.2973585-3-den@openvz.org> (raw)
In-Reply-To: <20261118114729.2973585-1-den@openvz.org>

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


  parent reply	other threads:[~2026-11-18 11:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Denis V. Lunev [this message]
2026-11-18 11:50   ` [PATCH hci-7.4 2/2] iotests/vz-cpr: cover a guest reset with a new BIOS file #VSTOR-155779 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261118114729.2973585-3-den@openvz.org \
    --to=den@openvz.org \
    --cc=andrey.drobyshev@virtuozzo.com \
    --cc=svt-core@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.