From nobody Mon Apr 13 13:32:48 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=mihalicyn.com ARC-Seal: i=1; a=rsa-sha256; t=1772809654; cv=none; d=zohomail.com; s=zohoarc; b=Ljib0gSg6xZTwscU/9kHJY8Unm28ASEvJkF2Wlq7BoD+hKRoed6WoCv8zBZPnh/6TiVKPjXqtR+BB+HDT3UQVGuc4MoLlQLjcBGnyXAvmhvOV+D1DBhEmaOYB5E8swG67BLkdhgj2ie94JRdc7oQt8BuC1zpW/Ri6t15C3hmFXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772809654; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9BVjzpz+g8zyE8326nn6m7L9ExlEPRzKWbaO0sFI7v0=; b=BH13Q8JjXeuzEZRXayp8+UeKLy/vU9nc8ZIvgTufNEPPurFv1RHVcbjo47CPpkyQk6vGSfTBoUASeuHwYN4dN24ueaDOUWDqw3KMHTU5nMl5zHs2Ys6s+w69XH81RZbxTJw1+cMmye699jvp85d6exUfi8YSuoMfGcmAK2wUxVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772809654908133.72732492946454; Fri, 6 Mar 2026 07:07:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vyWip-00083z-8L; Fri, 06 Mar 2026 10:04:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vyWic-0007q7-Hq for qemu-devel@nongnu.org; Fri, 06 Mar 2026 10:04:00 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vyWia-0003LE-5g for qemu-devel@nongnu.org; Fri, 06 Mar 2026 10:03:58 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-439c5cce2c6so3208855f8f.3 for ; Fri, 06 Mar 2026 07:03:55 -0800 (PST) Received: from alex-laptop.lan (p200300cf57228c00583f1937c9b9cecc.dip0.t-ipconnect.de. [2003:cf:5722:8c00:583f:1937:c9b9:cecc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439dae36785sm4703623f8f.27.2026.03.06.07.03.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Mar 2026 07:03:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mihalicyn.com; s=mihalicyn; t=1772809434; x=1773414234; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9BVjzpz+g8zyE8326nn6m7L9ExlEPRzKWbaO0sFI7v0=; b=SnlUqC+oH2MgfSef53a8fVo0G8PfAAs12DJneZ9BzY3v34LLFqAYL8I3NLqASiW2+W f7UEh5h5zE5hWCuT1kmQB7+N2AbTqM8gU0IpJe9nCfBEsvj+wgDe+p9eOp8SUcXPfHca LeDyUtPE4ZXwW1cQKmDT4o2G57197ACdeMeE0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772809434; x=1773414234; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=9BVjzpz+g8zyE8326nn6m7L9ExlEPRzKWbaO0sFI7v0=; b=GQdK4qTtBoIWF3WYSdS/ccr5aZeN49/+GEd1SuJOm1ZRFd/Z0iMm1EkIrUcUp+he7j jFpvjF3EpgVsjDSnTBM4gUvzHgFvXcG5Pew4qkAI0RmUMWl7RnYf+6kmYtiB2wmNZRL1 YiyjciBGFu2tpu6PG2s2h66q5y74P8jIFAOoiSytxP+zWh9JDbTllhnbAcT8ijxl/vzC j49rVPuH0jfNnYJlcXSNtwpEC38D5T6OKL9n2h36nFMipFESZGT2yn7bPL6CRBDn2tZN xG/LEd6hqI4KhVaHUGmESBAxtI400dAUsfhFEa5m1En/JW503KO/0zqXPKBOYkEpZN04 jv2w== X-Gm-Message-State: AOJu0YyboEA2FrMW0g0fK4JzZe/PlYsUDiFbUNROjKs9pF7PlSuLg+zd Zfpfse4oKEbXjJgizIzCqMVZZcTiWfgMhebihEu5zdMng2V5WZ9OJ9WYQQpxzn+PI8FhCHj+rnr oXup8734= X-Gm-Gg: ATEYQzzm92H7IY3fSe3Lly2iXuoIrttjWQDWHO1PfXllvZfhF7O8I3IcpAZrh9VKGEv qtF0lJnzmHSpH/r1HyO888GdX9O+YqXE1f068ctmSmV0HBwhfupilB4elH7qaByf/0dzrLF2tJ7 Y3pRhaAT4ut7+GR+yTWEtKvBMB7PO2Xj048cxNRWcs55CIYbi4OKdH8I/d/SAHWuNunApFhhzPo u4KfwbEFLBkBePbxgxfij2ljUuaYI/R9MDDWIG9Bb2DabO7SVPd+biz6bxVkmwxQgVV6VFdDyfC BH73oQgxhD8vteXY8Z63XajHxdNdDuj/rfUooBwyVD1rHhBUFmqORb9ad9pcQmm7ry2lqoHhmK0 OMoQRAKrByYKmVg8+gZvs8JPURDXBLVDhB+/zP5MXPsBVPVdiTD45b1XtTBHvNnhLdmeliFI69J 4KtLVmZgVp8kgP2RxALU7HUabD/NtttoeY21cWalhp9mKfaNmBqZe0vgIqY8b6r04EL1pIBUGlF GEPMDnbbmPAyEYOzPt4cmI= X-Received: by 2002:a05:6000:604:b0:439:b715:6f4b with SMTP id ffacd0b85a97d-439da8a78d1mr4395120f8f.57.1772809430264; Fri, 06 Mar 2026 07:03:50 -0800 (PST) From: Alexander Mikhalitsyn To: qemu-devel@nongnu.org Cc: Zhao Liu , Jesper Devantier , Alexander Mikhalitsyn , Klaus Jensen , =?UTF-8?q?St=C3=A9phane=20Graber?= , Paolo Bonzini , qemu-block@nongnu.org, Keith Busch , Peter Xu , Fabiano Rosas , Alexander Mikhalitsyn Subject: [PATCH v3 6/6] tests/functional/x86_64: add migration test for NVMe device Date: Fri, 6 Mar 2026 16:03:42 +0100 Message-ID: <20260306150342.395923-7-alexander@mihalicyn.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260306150342.395923-1-alexander@mihalicyn.com> References: <20260306150342.395923-1-alexander@mihalicyn.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alexander@mihalicyn.com; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @mihalicyn.com) X-ZM-MESSAGEID: 1772809658829154100 Content-Type: text/plain; charset="utf-8" From: Alexander Mikhalitsyn Introduce a very simple test to ensure that NVMe device migration works fine. Test plan is simple: 1. prepare VM with NVMe device 2. run workload that produces relatively heavy IO on the device 3. migrate VM 4. ensure that workload is alive and finishes without errors Test can be run as simple as: $ meson test 'func-x86_64-nvme_migration' --setup thorough -C build In the future we can extend this approach, and introduce some fio-based tests. And probably, it makes sense to make this test to apply not only to NVMe device, but also virtio-{blk,scsi}, ide, sata and other migratable devices. Signed-off-by: Alexander Mikhalitsyn --- tests/functional/x86_64/meson.build | 1 + .../functional/x86_64/test_nvme_migration.py | 159 ++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100755 tests/functional/x86_64/test_nvme_migration.py diff --git a/tests/functional/x86_64/meson.build b/tests/functional/x86_64/= meson.build index 05e4914c772..a3b010d24c6 100644 --- a/tests/functional/x86_64/meson.build +++ b/tests/functional/x86_64/meson.build @@ -30,6 +30,7 @@ tests_x86_64_system_thorough =3D [ 'linux_initrd', 'multiprocess', 'netdev_ethtool', + 'nvme_migration', 'replay', 'reverse_debug', 'tuxrun', diff --git a/tests/functional/x86_64/test_nvme_migration.py b/tests/functio= nal/x86_64/test_nvme_migration.py new file mode 100755 index 00000000000..3788a8e3473 --- /dev/null +++ b/tests/functional/x86_64/test_nvme_migration.py @@ -0,0 +1,159 @@ +#!/usr/bin/env python3 +# +# SPDX-License-Identifier: GPL-2.0-or-later +# +# x86_64 NVMe migration test + +from migration import MigrationTest +from qemu_test import QemuSystemTest, Asset +from qemu_test import wait_for_console_pattern +from qemu_test import exec_command, exec_command_and_wait_for_pattern + + +class X8664NVMeMigrationTest(MigrationTest): + ASSET_KERNEL =3D Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora/linux/rele= ases' + '/31/Server/x86_64/os/images/pxeboot/vmlinuz'), + 'd4738d03dbbe083ca610d0821d0a8f1488bebbdccef54ce33e3adb35fda00129') + + ASSET_INITRD =3D Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora/linux/rele= ases' + '/31/Server/x86_64/os/images/pxeboot/initrd.img'), + '277cd6c7adf77c7e63d73bbb2cded8ef9e2d3a2f100000e92ff1f8396513cd8b') + + ASSET_DISKIMAGE =3D Asset( + ('https://archives.fedoraproject.org/pub/archive/fedora/linux/rele= ases' + '/31/Cloud/x86_64/images/Fedora-Cloud-Base-31-1.9.x86_64.qcow2'), + 'e3c1b309d9203604922d6e255c2c5d098a309c2d46215d8fc026954f3c5c27a0') + + DEFAULT_KERNEL_PARAMS =3D ('root=3D/dev/nvme0n1p1 console=3DttyS0 net.= ifnames=3D0 ' + 'rd.rescue quiet') + + def wait_for_console_pattern(self, success_message, vm): + wait_for_console_pattern( + self, + success_message, + failure_message=3D"Kernel panic - not syncing", + vm=3Dvm, + ) + + def exec_command_and_check(self, command, vm): + prompt =3D '# ' + exec_command_and_wait_for_pattern(self, + f"{command} && echo OK || echo FAI= L", + 'FAIL', vm=3Dvm) + # Note, that commands we send to the console are echo-ed back, so = if we have a word "FAIL" + # in the command itself, we should expect to see it once. + wait_for_console_pattern(self, 'OK', failure_message=3D"FAIL", vm= =3Dvm) + self.wait_for_console_pattern(prompt, vm) + + def configure_machine(self, vm): + kernel_path =3D self.ASSET_KERNEL.fetch() + initrd_path =3D self.ASSET_INITRD.fetch() + diskimage_path =3D self.ASSET_DISKIMAGE.fetch() + + vm.set_console() + vm.add_args("-cpu", "max") + vm.add_args("-m", "2G") + vm.add_args("-accel", "kvm") + + vm.add_args('-drive', + f'file=3D{diskimage_path},if=3Dnone,id=3Ddrv0,sna= pshot=3Don') + vm.add_args('-device', 'nvme,bus=3Dpcie.0,' + + 'drive=3Ddrv0,id=3Dnvme-disk0,serial=3Dnvmemigrat= etest,bootindex=3D1') + + vm.add_args( + "-kernel", + kernel_path, + "-initrd", + initrd_path, + "-append", + self.DEFAULT_KERNEL_PARAMS + ) + + def launch_source_vm(self, vm): + vm.launch() + + self.wait_for_console_pattern('Entering emergency mode.', vm) + prompt =3D '# ' + self.wait_for_console_pattern(prompt, vm) + + # Synchronize on NVMe driver creating the root device + exec_command_and_wait_for_pattern(self, + "while ! (dmesg -c | grep nvme0n1:) ; do sleep 1 ;= done", + "nvme0n1", vm=3Dvm) + self.wait_for_console_pattern(prompt, vm) + + # prepare system + exec_command_and_wait_for_pattern(self, 'mount /dev/nvme0n1p1 /sys= root', + prompt, vm=3Dvm) + exec_command_and_wait_for_pattern(self, 'chroot /sysroot', + prompt, vm=3Dvm) + exec_command_and_wait_for_pattern(self, 'mount -t proc proc /proc', + prompt, vm=3Dvm) + exec_command_and_wait_for_pattern(self, 'mount -t sysfs sysfs /sys= ', + prompt, vm=3Dvm) + + # Run workload before migration to check if it continues to run pr= operly after migration + # + # Workload is simple: it continuously calculates checksums of all = files in /usr/bin + # to generate some I/O load on the NVMe disk and at the same time = it drops caches to + # make sure that we have some read I/O on the disk as well. + # If there are any issues with the migration of the NVMe device, w= e should see errors + # in dmesg and consequently in the workload log. + exec_command_and_wait_for_pattern(self, + "(while [ ! -f /tmp/test_nvme_migr= ation_workload.stop ]; do \ + rm -f /tmp/test_nvme_migration= _workload.iteration_finished; \ + echo 3 > /proc/sys/vm/drop_cac= hes; \ + find /usr/bin -type f -exec ck= sum {} \\;; \ + touch /tmp/test_nvme_migration= _workload.iteration_finished; \ + done) > /dev/null 2> /tmp/test_nvm= e_migration_workload.errors &", + prompt, vm=3Dvm) + exec_command_and_wait_for_pattern(self, 'echo $! > /tmp/test_nvme_= migration_workload.pid', + prompt, vm=3Dvm) + + # check if process is alive and running + self.exec_command_and_check("kill -0 $(cat /tmp/test_nvme_migratio= n_workload.pid)", vm) + + def assert_dest_vm(self, vm): + prompt =3D '# ' + + # check if process is alive and running after migration, if not - = fail the test + self.exec_command_and_check("kill -0 $(cat /tmp/test_nvme_migratio= n_workload.pid)", vm) + + # signal workload to stop + exec_command_and_wait_for_pattern(self, 'touch /tmp/test_nvme_migr= ation_workload.stop', + prompt, vm=3Dvm) + + # wait workload to finish, because we want to examine log to see i= f there are any errors + exec_command_and_wait_for_pattern(self, + "while [ ! -f /tmp/test_nvme_migra= tion_workload.iteration_finished ]; do sleep 1; done;", + prompt, vm=3Dvm) + + exec_command_and_wait_for_pattern(self, 'cat /tmp/test_nvme_migrat= ion_workload.errors', + prompt, vm=3Dvm) + + # fail the test if non-empty + self.exec_command_and_check("[ ! -s /tmp/test_nvme_migration_workl= oad.errors ]", vm) + + def test_migration_with_tcp_localhost(self): + self.set_machine('q35') + self.require_accelerator("kvm") + + self.migration_with_tcp_localhost() + + def test_migration_with_unix(self): + self.set_machine('q35') + self.require_accelerator("kvm") + + self.migration_with_unix() + + def test_migration_with_exec(self): + self.set_machine('q35') + self.require_accelerator("kvm") + + self.migration_with_exec() + + +if __name__ =3D=3D '__main__': + MigrationTest.main() --=20 2.47.3