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-8.0/8.1 2/2] iotests/migrate-cpr-exec: cover a guest reset with a new BIOS file #VSTOR-155779
Date: Wed, 18 Nov 2026 12:47:39 +0100	[thread overview]
Message-ID: <20261118114739.2973860-3-den@openvz.org> (raw)
In-Reply-To: <20261118114739.2973860-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 cpr-exec and system_reset the BIOS ROM must still hold the
image the guest started with.

Signed-off-by: Denis V. Lunev <den@openvz.org>
---
 tests/qemu-iotests/tests/migrate-cpr-exec     | 38 +++++++++++++++++++
 tests/qemu-iotests/tests/migrate-cpr-exec.out |  4 +-
 2 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/tests/qemu-iotests/tests/migrate-cpr-exec b/tests/qemu-iotests/tests/migrate-cpr-exec
index 2b30929561c..450c8f41783 100755
--- a/tests/qemu-iotests/tests/migrate-cpr-exec
+++ b/tests/qemu-iotests/tests/migrate-cpr-exec
@@ -20,6 +20,7 @@
 
 import logging
 import os
+import re
 from tempfile import NamedTemporaryFile
 
 import iotests
@@ -529,6 +530,43 @@ class TestCprExec(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 = self._log_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 cpr-exec keeps the guest's BIOS. See #VSTOR-155779"""
+        new_bios = self._log_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/migrate-cpr-exec.out b/tests/qemu-iotests/tests/migrate-cpr-exec.out
index cfa5c0d0e66..5c26d15c0d0 100644
--- a/tests/qemu-iotests/tests/migrate-cpr-exec.out
+++ b/tests/qemu-iotests/tests/migrate-cpr-exec.out
@@ -1,5 +1,5 @@
-...................................
+....................................
 ----------------------------------------------------------------------
-Ran 35 tests
+Ran 36 tests
 
 OK
-- 
2.55.0


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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18 11:47 [PATCH hci-8.0/8.1 0/2] hw/loader: keep the guest's BIOS on reset after qemu-update #VSTOR-155779 Denis V. Lunev
2026-11-18 11:47 ` [PATCH hci-8.0/8.1 1/2] hw/loader: stop rom_reset() overwriting the BIOS after cpr-exec #VSTOR-155779 Denis V. Lunev
2026-11-18 11:47 ` Denis V. Lunev [this message]
2026-11-18 14:11 ` [PATCH hci-8.0/8.1 0/2] hw/loader: keep the guest's BIOS on reset after qemu-update #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=20261118114739.2973860-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.