From nobody Mon Sep 28 02:02:43 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1785317581; cv=none; d=zohomail.com; s=zohoarc; b=XNJJIZhUT9m/EzOcWCyWAjzo6puPDProgZ/4IakYcV4NI6iJnl1Hi3GZBSL/Xz0l8bEYVroQr7joH5vUpBxQJlHkUp5cjE9g+nA9IZZjiO83zUNi1trg3+zw1saHASYjoa/RsRQOeWwC5fInSlHSmy4f3HdmeVAghGE8ujYEP0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785317581; 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=A4ebB8HLDseDR8vfsLUWnp1Ldex+8n1ox5y/Vnz21xI=; b=lSJVdeSq1pov4ZM0qzguTh8lLljNPjysy6FOInsM3dRMLXMUiFWYH2qyU9B5G0TdhWaWgjHINxq8/dPvSZfXy6BwTIIRm2Ev5v5tpA5Un3HVBSojjDnSxR97KFTdbQQnM7knjfpoNbEMZ3WLYY0HFu9wdc4Zcb1TLjBsP/y3lOo= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178531758137377.74154619492572; Wed, 29 Jul 2026 02:33:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wp0dp-00058E-0v; Wed, 29 Jul 2026 05:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dn-00057G-N7 for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:55 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dj-0007ki-TP for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:55 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id 46540C0A30; Wed, 29 Jul 2026 12:31:49 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:484::1:24]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id kVacraKWFGk0-uDo1mEko; Wed, 29 Jul 2026 12:31:48 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785317508; bh=A4ebB8HLDseDR8vfsLUWnp1Ldex+8n1ox5y/Vnz21xI=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=Kmeal9Z52ZyP/6uO1oASs/MV+sBFfXZwftaKAITkfTPh7dpCX7jKw+PuDtNoS4ynu NvNEKtehMYpWOZK+hg7VWJbHJj09Bvx5/YXpCeaV54OhcH2+0gpjYiKPFfaOteOXd5 4gWse1QztV/wz9nT2jQ1XuIcXYG3YTXcw6SRTroY= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com, mst@redhat.com Cc: armbru@redhat.com, peterx@redhat.com, farosas@suse.de, raphael.s.norwitz@gmail.com, bchaney@akamai.com, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, yc-core@yandex-team.ru, mark.caveayland@nutanix.com, John Snow , Cleber Rosa Subject: [PATCH 1/5] python/qemu/machine: add possibility to postpone qmp connect Date: Wed, 29 Jul 2026 12:31:41 +0300 Message-ID: <20260729093146.1893719-2-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260729093146.1893719-1-vsementsov@yandex-team.ru> References: <20260729093146.1893719-1-vsementsov@yandex-team.ru> 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=lists1p.gnu.org; Received-SPF: pass client-ip=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net 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_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 @yandex-team.ru) X-ZM-MESSAGEID: 1785317582218158500 Content-Type: text/plain; charset="utf-8" This is need to test cpr-transfer migration, as on started target QMP is not available until we call "migrate" on source. Signed-off-by: Vladimir Sementsov-Ogievskiy --- python/qemu/machine/machine.py | 53 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index bfb59d4c0bf..00154b8591f 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -449,17 +449,17 @@ def _post_shutdown(self) -> None: self._user_killed =3D False self._launched =3D False =20 - def launch(self) -> None: + def launch(self, do_start_process=3DTrue, do_qmp_connect=3DTrue) -> No= ne: """ Launch the VM and make sure we cleanup and expose the command line/output in case of exception """ =20 - if self._launched: + if self._launched and do_start_process: raise QEMUMachineError('VM already launched') =20 try: - self._launch() + self._launch(do_start_process, do_qmp_connect) except BaseException as exc: # We may have launched the process but it may # have exited before we could connect via QMP. @@ -482,31 +482,34 @@ def launch(self) -> None: # that exception. However, we still want to clean up. raise =20 - def _launch(self) -> None: + def _launch(self, do_start_process=3DTrue, do_qmp_connect=3DTrue) -> N= one: """ Launch the VM and establish a QMP connection """ - self._pre_launch() - LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_args)) - # Log a simplified, developer-runnable command: - # Exclude harness-managed infrastructure args (harness_args) - # and wrapper. - debug_cmd =3D [self._binary] - debug_cmd.extend(self._console_args(interactive=3DTrue)) - debug_cmd.extend(self._base_args) - debug_cmd.extend(self._args) - LOG.debug('Developer-runnable command: %r', ' '.join(debug_cmd)) - - # Cleaning up of this subprocess is guaranteed by _do_shutdown. - # pylint: disable=3Dconsider-using-with - self._popen =3D subprocess.Popen(self._qemu_full_args, - stdin=3Dsubprocess.DEVNULL, - stdout=3Dself._qemu_log_file, - stderr=3Dsubprocess.STDOUT, - shell=3DFalse, - close_fds=3DFalse) - self._launched =3D True - self._post_launch() + if do_start_process: + self._pre_launch() + LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_ar= gs)) + # Log a simplified, developer-runnable command: + # Exclude harness-managed infrastructure args (harness_args) + # and wrapper. + debug_cmd =3D [self._binary] + debug_cmd.extend(self._console_args(interactive=3DTrue)) + debug_cmd.extend(self._base_args) + debug_cmd.extend(self._args) + LOG.debug('Developer-runnable command: %r', ' '.join(debug_cmd= )) + + # Cleaning up of this subprocess is guaranteed by _do_shutdown. + # pylint: disable=3Dconsider-using-with + self._popen =3D subprocess.Popen(self._qemu_full_args, + stdin=3Dsubprocess.DEVNULL, + stdout=3Dself._qemu_log_file, + stderr=3Dsubprocess.STDOUT, + shell=3DFalse, + close_fds=3DFalse) + self._launched =3D True + + if do_qmp_connect: + self._post_launch() =20 def _close_qmp_connection(self) -> None: """ --=20 2.43.0 From nobody Mon Sep 28 02:02:43 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1785317556; cv=none; d=zohomail.com; s=zohoarc; b=Y50U4T4nISvgz2l+40ufi83LkRm+vs8LSe4gLE+tW7Nzfy4nGc8/xRg9v4HPafDvNwNaOzT2FVSvBRSGRPuMFsu/QYGOglUGxr4+0pvqHV7HzybfB8sMWraFazQGCX9LwXnenlldwJE7BPzJbMgms+h73lqYtTEfXW2q3SavX3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785317556; 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=kpFI+Sq6hDSo9FArcBTmOvsw9J/vVjMk1ZhQtqh1Iv4=; b=mgc0NFWNbRtOzq6Op80MKkd9TDg9WQMYeyfv7o0JBC47OuD5SM6mWKSBe94lzlNoLfGryoydXQaBe0rkA4ym3PsoKCHWJ/zqMs4jePKzwdioroJDzLei4QsWEuipeMVKqfcGdl4wRenMNi/3Oa5jcyOlhO9Plq83l2ygJuEk/60= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785317555951557.0306168309337; Wed, 29 Jul 2026 02:32:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wp0do-00057c-73; Wed, 29 Jul 2026 05:31:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dm-00056x-7L for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:54 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dj-0007kl-UH for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:53 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id 27FE5C0161; Wed, 29 Jul 2026 12:31:50 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:484::1:24]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id kVacraKWFGk0-CaHBnQTP; Wed, 29 Jul 2026 12:31:49 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785317509; bh=kpFI+Sq6hDSo9FArcBTmOvsw9J/vVjMk1ZhQtqh1Iv4=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=uTOhE7A4ahz/h87Ooed9aZnRhzzdGBPum8JNRcfBGpgLiEZhTlhDRPPQQo+r4lLJB AamW4CHqTnK/Rjk19RSi16yYnn1wUasVr+9DBlQpAPC3lj0UZ+q3S/1csEkMwsdtQ6 Y8CnPnmaiKJ/Cdo6IPaP/gGlkNovOH1QRYoEUu6E= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com, mst@redhat.com Cc: armbru@redhat.com, peterx@redhat.com, farosas@suse.de, raphael.s.norwitz@gmail.com, bchaney@akamai.com, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, yc-core@yandex-team.ru, mark.caveayland@nutanix.com, Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 2/5] tests/functional/qemu_test: drop *args argument from .get_vm() Date: Wed, 29 Jul 2026 12:31:42 +0300 Message-ID: <20260729093146.1893719-3-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260729093146.1893719-1-vsementsov@yandex-team.ru> References: <20260729093146.1893719-1-vsementsov@yandex-team.ru> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 @yandex-team.ru) X-ZM-MESSAGEID: 1785317558908158500 Content-Type: text/plain; charset="utf-8" It's redundant. Only one caller use it, and it may be simply substituted by .add_args(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Thomas Huth --- tests/functional/migration.py | 3 ++- tests/functional/qemu_test/testcase.py | 9 +++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/functional/migration.py b/tests/functional/migration.py index 4344e03be41..8d2428efc24 100644 --- a/tests/functional/migration.py +++ b/tests/functional/migration.py @@ -63,7 +63,8 @@ def migrate_vms(self, dst_uri, src_uri, dst_vm, src_vm): self.assert_dest_vm(dst_vm) =20 def migrate(self, dst_uri, src_uri=3DNone): - dst_vm =3D self.get_vm('-incoming', 'defer', name=3D"dst-qemu") + dst_vm =3D self.get_vm("dst-qemu") + dst_vm.add_args('-incoming', 'defer') self.configure_machine(dst_vm) dst_vm.launch() =20 diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu= _test/testcase.py index e4179d165c0..12ef84281c4 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -381,7 +381,7 @@ def require_device(self, devicename): if helptxt.find(devicename) < 0: self.skipTest('no support for device ' + devicename) =20 - def _new_vm(self, name, *args): + def _new_vm(self, name): vm =3D QEMUMachine(self.qemu_bin, name=3Dname, base_temp_dir=3Dself.workdir, @@ -394,20 +394,17 @@ def _new_vm(self, name, *args): vm.add_args("-chardev", f"socket,id=3Dbackdoor,path=3D{sockpath},server=3D= on,wait=3Doff", "-mon", "chardev=3Dbackdoor,mode=3Dcontrol") - - if args: - vm.add_args(*args) return vm =20 @property def vm(self): return self.get_vm(name=3D'default') =20 - def get_vm(self, *args, name=3DNone): + def get_vm(self, name=3DNone): if not name: name =3D str(uuid.uuid4()) if self._vms.get(name) is None: - self._vms[name] =3D self._new_vm(name, *args) + self._vms[name] =3D self._new_vm(name) if self.cpu is not None: self._vms[name].add_args('-cpu', self.cpu) if self.machine is not None: --=20 2.43.0 From nobody Mon Sep 28 02:02:43 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1785317572; cv=none; d=zohomail.com; s=zohoarc; b=ZV65dmEAs8HhZQY5DSaND4sis4xvnVd0HhmeUIyvv0ZfMYXnKy71tU/Nu33OysSzGDHKikpiShZlKKLGrquwi0nJDA0OSidvV+myaXEvPb/s7qO7NePNc+MbZbkTIlRw4Gw3hQ14yOciz6+EKCaygaGqY/8ZiB2J1/QtI8Gabhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785317572; 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=YpjAEe6FHdcRJ7cUU4WELDQ/GHvOIgjYgh73uTALw1E=; b=acV1R+jns2xAfp3Aj7tYn/X0T8KoMSFdnEuvvvbBnoLft3iGrWw353ei7Ph/KBn0qCzFmxUsbSW0TBmXfzRJtvU6CP00h/pwh2cwo9wCY84Fz4TTwtVFEF2TCzONifyiYmOeGFoS57nMwzd5L2cmAm80Bh8vVdqY0sjrtjHz8Cs= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785317571831256.5043512888823; Wed, 29 Jul 2026 02:32:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wp0dp-000593-Q9; Wed, 29 Jul 2026 05:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dn-00057E-MV for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:55 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dk-0007kr-QN for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:55 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id DF5C7C0A60; Wed, 29 Jul 2026 12:31:50 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:484::1:24]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id kVacraKWFGk0-rsGCUJt7; Wed, 29 Jul 2026 12:31:50 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785317510; bh=YpjAEe6FHdcRJ7cUU4WELDQ/GHvOIgjYgh73uTALw1E=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=xKdfr1VaqRknF1TamZWK/AUR6gui51XsbV1YuUrs8oik8XANwTH8UBO4n6Xydm1pt Da50dMEpoChbkrVaDFyvSQDNxRSMA9+hEwP+Kehy9PYMTOOvQEQW1pRNz4xXx1sYOd loliv1xMZ2cNle/UcuMfP2QtUXi1j68vUABIri4o= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com, mst@redhat.com Cc: armbru@redhat.com, peterx@redhat.com, farosas@suse.de, raphael.s.norwitz@gmail.com, bchaney@akamai.com, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, yc-core@yandex-team.ru, mark.caveayland@nutanix.com, John Snow , Cleber Rosa Subject: [PATCH 3/5] python/machine.py: store qemu console fd before closing Date: Wed, 29 Jul 2026 12:31:43 +0300 Message-ID: <20260729093146.1893719-4-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260729093146.1893719-1-vsementsov@yandex-team.ru> References: <20260729093146.1893719-1-vsementsov@yandex-team.ru> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 @yandex-team.ru) X-ZM-MESSAGEID: 1785317574218158500 Content-Type: text/plain; charset="utf-8" We'll need it soon to implement test for cpr-exec mode of tap-fd-migration. Signed-off-by: Vladimir Sementsov-Ogievskiy --- python/qemu/machine/machine.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/qemu/machine/machine.py b/python/qemu/machine/machine.py index 00154b8591f..14ba8e80aac 100644 --- a/python/qemu/machine/machine.py +++ b/python/qemu/machine/machine.py @@ -159,6 +159,7 @@ def __init__(self, self._sock_pair: Optional[Tuple[socket.socket, socket.socket]] =3D= None self._cons_sock_pair: Optional[ Tuple[socket.socket, socket.socket]] =3D None + self._cons_sock_saved_fd: Optional[int] =3D None self._temp_dir: Optional[str] =3D None self._base_temp_dir =3D base_temp_dir self._log_dir =3D log_dir @@ -388,6 +389,7 @@ def _post_launch(self) -> None: if self._sock_pair: self._sock_pair[0].close() if self._cons_sock_pair: + self._cons_sock_saved_fd =3D self._cons_sock_pair[0].fileno() self._cons_sock_pair[0].close() =20 if self._qmp_connection: --=20 2.43.0 From nobody Mon Sep 28 02:02:43 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1785317580; cv=none; d=zohomail.com; s=zohoarc; b=FwbwEM/RQXNz/f2UDWWtnwxbZ6Fy5H+XYCTYPAwGchraHFKzF+vY9OTxZK/3giy9IBBUeQISr+/JbTZ3M8YdBOWEBqhfY+w6PPQ69p5Vkt09lP8Ko2lZvoYkndA53OAzQLcNtAR5Tqsr0F/konAXySnA+lZR5hrB7Hwlcu5oqxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785317580; 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=Heugvd44UzeLE9Y7zi6x0k/Glc660bM46rnMu4b77TM=; b=bbGMhiGy3ac8f4WxIJJTzhEdTCjuWecUZJcV3k9ANoQHN3y77dmI8KLEAmbRXkl1PDj3u19Cd60FLNmI+ODElV3o1S1mQaUhQKZEJNI7EFUsIx3kfMG8EerO2izVEEUmzmTECWfcMbnsB5NoURpDjydDBcZb3Y8WRZ9rlR/Ed0g= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785317580688845.9326211956255; Wed, 29 Jul 2026 02:33:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wp0dp-00058J-9O; Wed, 29 Jul 2026 05:31:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dn-00057D-Jb for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:55 -0400 Received: from forwardcorp1a.mail.yandex.net ([2a02:6b8:c0e:500:1:45:d181:df01]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dl-0007kx-06 for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:55 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id B5A26C0A4A; Wed, 29 Jul 2026 12:31:51 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:484::1:24]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id kVacraKWFGk0-Pn7GdoXq; Wed, 29 Jul 2026 12:31:51 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785317511; bh=Heugvd44UzeLE9Y7zi6x0k/Glc660bM46rnMu4b77TM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=SGXYJEvCNAnuMcKt3cjMntW90BbdPsDfN86r0r8LtvAdTtQqPOJ66VFNy1O+COnH+ JDVBwGkjxdOtVkVJtIWacqdgZC0xz7G0tFzlGDSbOmZ/pWp8CdZmKarHIoy6NeSOMw 2Shy2O1mahzLuz4zyBI49NOp7sSdWmV2cNwvyIQk= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com, mst@redhat.com Cc: armbru@redhat.com, peterx@redhat.com, farosas@suse.de, raphael.s.norwitz@gmail.com, bchaney@akamai.com, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, yc-core@yandex-team.ru, mark.caveayland@nutanix.com, Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 4/5] tests/testcase.py: passthrough monitor_address Date: Wed, 29 Jul 2026 12:31:44 +0300 Message-ID: <20260729093146.1893719-5-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260729093146.1893719-1-vsementsov@yandex-team.ru> References: <20260729093146.1893719-1-vsementsov@yandex-team.ru> 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a02:6b8:c0e:500:1:45:d181:df01; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net 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=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 @yandex-team.ru) X-ZM-MESSAGEID: 1785317583301158500 Content-Type: text/plain; charset="utf-8" We'll need it soon to implement test for cpr-exec mode of tap-fd-migration. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Thomas Huth --- tests/functional/qemu_test/testcase.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu= _test/testcase.py index 12ef84281c4..69d3d06cc0e 100644 --- a/tests/functional/qemu_test/testcase.py +++ b/tests/functional/qemu_test/testcase.py @@ -381,11 +381,12 @@ def require_device(self, devicename): if helptxt.find(devicename) < 0: self.skipTest('no support for device ' + devicename) =20 - def _new_vm(self, name): + def _new_vm(self, name, monitor_address): vm =3D QEMUMachine(self.qemu_bin, name=3Dname, base_temp_dir=3Dself.workdir, - log_dir=3Dself.log_file()) + log_dir=3Dself.log_file(), + monitor_address=3Dmonitor_address) self.log.debug('QEMUMachine "%s" created', name) self.log.debug('QEMUMachine "%s" temp_dir: %s', name, vm.temp_dir) =20 @@ -400,11 +401,11 @@ def _new_vm(self, name): def vm(self): return self.get_vm(name=3D'default') =20 - def get_vm(self, name=3DNone): + def get_vm(self, name=3DNone, monitor_address=3DNone): if not name: name =3D str(uuid.uuid4()) if self._vms.get(name) is None: - self._vms[name] =3D self._new_vm(name) + self._vms[name] =3D self._new_vm(name, monitor_address) if self.cpu is not None: self._vms[name].add_args('-cpu', self.cpu) if self.machine is not None: --=20 2.43.0 From nobody Mon Sep 28 02:02:43 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=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1785317575; cv=none; d=zohomail.com; s=zohoarc; b=AJJCRLwqhovjsV9dX3Z+K3GqnvTLlbPTP8+M233gSYRRUTvilGVPx9yL76sL0r3d13CEsgdox5G1766diVNuyy8XCDXfsZVgMupArZFuTgYYgC8HKHFpF1wVrJsedSODQJf6f2MZ85ja+FZacVIT74ycLYM3Qnes77hjcnv1SBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785317575; 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=HV1FoDOcQbL4SYo01gnQ0Qs8H49RoCdBT7iobhWM0SM=; b=gqJThqS0/o6IIIvzZC2HIP7FXGlnivpiOZLPTZMSQqSd1PKFOvB2F0+AYDpJRbaH+MGx7DpBcn+CnJWdZkYGmSa7WUkgVhAuw+JTS/P0aFfSnWPpn0zs5ZHWpx1NwTU1Yes/+IMk9eiTTSkepZZRWHxpmUVnZtnfOE4/lmjxSdw= 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=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785317575358952.74516845733; Wed, 29 Jul 2026 02:32:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wp0dq-000597-JK; Wed, 29 Jul 2026 05:31:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0do-000587-Ny for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:56 -0400 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wp0dm-0007lB-Da for qemu-devel@nongnu.org; Wed, 29 Jul 2026 05:31:56 -0400 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c2d:3530:0:640:eca4:0]) by forwardcorp1a.mail.yandex.net (postfix) with ESMTPS id 2F34AC0A64; Wed, 29 Jul 2026 12:31:53 +0300 (MSK) Received: from i115954770.yandex-team.ru (unknown [2a02:6bf:8080:484::1:24]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp) with ESMTPSA id kVacraKWFGk0-huxt7y0S; Wed, 29 Jul 2026 12:31:52 +0300 Precedence: bulk X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1785317512; bh=HV1FoDOcQbL4SYo01gnQ0Qs8H49RoCdBT7iobhWM0SM=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=qnqDX3uizmBn29bpmrKL9B+NOgQRV3iW6wQIberN/ELWtIajmyiR22r5HCOVFOsUF ATJUPqDaJ4UB5yuKKmyTSyoiWq/3oYNxmPVJPQZxGpPYrz97fGl7k1dgnR5zh2HPpN sYjXADdN83tf3rgBS9plmc61aSmcwAuNSGjrALq8= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru From: Vladimir Sementsov-Ogievskiy To: jasowang@redhat.com, mst@redhat.com Cc: armbru@redhat.com, peterx@redhat.com, farosas@suse.de, raphael.s.norwitz@gmail.com, bchaney@akamai.com, vsementsov@yandex-team.ru, qemu-devel@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, yc-core@yandex-team.ru, mark.caveayland@nutanix.com, Zhao Liu Subject: [PATCH 5/5] test_tap_migration: add cpr test cases Date: Wed, 29 Jul 2026 12:31:45 +0300 Message-ID: <20260729093146.1893719-6-vsementsov@yandex-team.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260729093146.1893719-1-vsementsov@yandex-team.ru> References: <20260729093146.1893719-1-vsementsov@yandex-team.ru> 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=lists1p.gnu.org; Received-SPF: pass client-ip=178.154.239.72; envelope-from=vsementsov@yandex-team.ru; helo=forwardcorp1a.mail.yandex.net 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_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 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 @yandex-team.ru) X-ZM-MESSAGEID: 1785317578518158501 Content-Type: text/plain; charset="utf-8" Signed-off-by: Vladimir Sementsov-Ogievskiy --- tests/functional/x86_64/test_tap_migration.py | 251 ++++++++++++++++-- 1 file changed, 230 insertions(+), 21 deletions(-) diff --git a/tests/functional/x86_64/test_tap_migration.py b/tests/function= al/x86_64/test_tap_migration.py index 0506b01926e..103421a029a 100755 --- a/tests/functional/x86_64/test_tap_migration.py +++ b/tests/functional/x86_64/test_tap_migration.py @@ -24,6 +24,7 @@ exec_command_and_wait_for_pattern, ) from qemu_test.decorators import skipWithoutSudo +from qemu.qmp.legacy import QEMUMonitorProtocol =20 =20 GUEST_IP =3D "192.168.100.2" @@ -289,7 +290,8 @@ def setup_shared_memory(self): self.fail(f"Failed to create shared memory file: {e}") =20 def prepare_vm( - self, shm_path, vhost, incoming=3DFalse, vm=3DNone, local=3DTrue + self, shm_path, vhost, incoming=3DFalse, vm=3DNone, local=3DTrue, + cpr=3DFalse, cpr_sock=3D"" ): if not vm: vm =3D self.vm @@ -304,7 +306,10 @@ def prepare_vm( "-object", f"memory-backend-file,id=3Dram0,size=3D1G,mem-path=3D{shm_path= },share=3Don", ) - vm.add_args("-machine", "memory-backend=3Dram0") + machine_opt =3D "memory-backend=3Dram0" + if cpr: + machine_opt +=3D ",aux-ram-share=3Don" + vm.add_args("-machine", machine_opt) =20 vm.add_args( "-drive", @@ -315,6 +320,13 @@ def prepare_vm( =20 if incoming: vm.add_args("-incoming", "defer") + if cpr: + vm.add_args( + "-incoming", + '{"channel-type": "cpr", ' + '"addr": {"transport": "socket", ' + f'"type": "unix", "path": "{cpr_sock}"}}}}', + ) =20 def add_virtio_net( self, vm, vhost: bool, tap_name: str, local: bool, incoming: bool @@ -348,7 +360,7 @@ def add_virtio_net( disable_legacy=3D"off", ) =20 - def set_migration_capabilities(self, vm, local): + def set_migration_capabilities(self, vm, local, mode): vm.cmd( "migrate-set-capabilities", { @@ -358,7 +370,10 @@ def set_migration_capabilities(self, vm, local): ] }, ) - vm.cmd("migrate-set-parameters", {"local": local}) + vm.cmd( + "migrate-set-parameters", + {"local": local, "mode": mode}, + ) =20 def setup_guest_network(self) -> None: exec_command_and_wait_for_pattern(self, "ip addr", "# ") @@ -370,20 +385,51 @@ def setup_guest_network(self) -> None: ) self.wait_for_console_pattern("# ") =20 - def migrate(self, vm, mig_sock): - vm.cmd("migrate", uri=3Df"unix:{mig_sock}") - def do_test_tap_fd_migration(self, vhost, local=3DTrue): + def migrate(self, vm, mig_sock, cpr=3DFalse, cpr_sock=3D""): + if cpr: + vm.cmd( + "migrate", + { + "channels": [ + { + "channel-type": "main", + "addr": { + "transport": "socket", + "type": "unix", + "path": mig_sock, + }, + }, + { + "channel-type": "cpr", + "addr": { + "transport": "socket", + "type": "unix", + "path": cpr_sock, + }, + }, + ] + }, + ) + else: + vm.cmd("migrate", uri=3Df"unix:{mig_sock}") + + def do_test_tap_fd_migration(self, vhost, local=3DTrue, + cpr=3DFalse): + mig_mode =3D "cpr-transfer" if cpr else "normal" + socket_dir =3D self.socket_dir() mig_sock =3D os.path.join(socket_dir.name, "mig.sock") + cpr_sock =3D os.path.join(socket_dir.name, "cpr.sock") =20 # Setup second TAP if needed if not local: del_tap(TAP_ID2) init_tap(TAP_ID2, with_ip=3DFalse) =20 - self.prepare_vm(self.shm_path, vhost, local=3Dlocal) + self.prepare_vm(self.shm_path, vhost, local=3Dlocal, cpr=3Dcpr, + cpr_sock=3Dcpr_sock) self.vm.launch() - self.set_migration_capabilities(self.vm, local=3Dlocal) + self.set_migration_capabilities(self.vm, local=3Dlocal, mode=3Dmig= _mode) self.add_virtio_net(self.vm, vhost, TAP_ID, local, incoming=3DFals= e) =20 self.vm.cmd("cont") @@ -406,21 +452,53 @@ def do_test_tap_fd_migration(self, vhost, local=3DTru= e): incoming=3DTrue, vm=3Dtarget_vm, local=3Dlocal, + cpr=3Dcpr, + cpr_sock=3Dcpr_sock, ) =20 - target_vm.launch() - if not local: - tap_name =3D TAP_ID2 + if cpr: + # Launch target QEMU process; it will block in cpr_state_load() + # waiting for the source to connect and send CPR state. QMP is + # not available until after CPR state is loaded. + target_vm.launch(do_qmp_connect=3DFalse) + time.sleep(1) + + # Tell source to start CPR migration; it connects to the CPR + # socket, sends CPR state, then target unblocks and QMP becomes + # available. + self.migrate(self.vm, mig_sock, True, cpr_sock=3Dcpr_sock) + + # Now block waiting for target QMP greeting; it will arrive on= ce + # the CPR state transfer completes. + target_vm.launch(do_start_process=3DFalse, do_qmp_connect=3DTr= ue) + + if not local: + tap_name =3D TAP_ID2 + else: + tap_name =3D TAP_ID + self.set_migration_capabilities(target_vm, local=3Dlocal, + mode=3D"cpr-transfer") + self.add_virtio_net(target_vm, vhost, tap_name, local, + incoming=3DTrue) + + freeze_start =3D time.time() + target_vm.cmd("migrate-incoming", {"uri": f"unix:{mig_sock}"}) else: - tap_name =3D TAP_ID - self.set_migration_capabilities(target_vm, local=3Dlocal) - self.add_virtio_net(target_vm, vhost, tap_name, local, incoming=3D= True) - - target_vm.cmd("migrate-incoming", {"uri": f"unix:{mig_sock}"}) - - self.log.info("Starting migration") - freeze_start =3D time.time() - self.migrate(self.vm, mig_sock) + target_vm.launch() + if not local: + tap_name =3D TAP_ID2 + else: + tap_name =3D TAP_ID + self.set_migration_capabilities(target_vm, local=3Dlocal, + mode=3D"normal") + self.add_virtio_net(target_vm, vhost, tap_name, local, + incoming=3DTrue) + + target_vm.cmd("migrate-incoming", {"uri": f"unix:{mig_sock}"}) + + self.log.info("Starting migration") + freeze_start =3D time.time() + self.migrate(self.vm, mig_sock) =20 self.log.info("Waiting for migration completion") wait_migration_finish(self.vm, target_vm) @@ -444,6 +522,119 @@ def do_test_tap_fd_migration(self, vhost, local=3DTru= e): =20 target_vm.shutdown() =20 + def do_test_tap_cpr_exec_migration(self, vhost): + socket_dir =3D self.socket_dir() + mig_file =3D self.scratch_file("migstate") + + # Source VM: use a UNIX socket path for QMP so that the exec'ed + # new QEMU process can reconnect to the same monitor socket. + qmp_sock =3D os.path.join(socket_dir.name, "qmp.sock") + self.get_vm(name=3D"default", monitor_address=3Dqmp_sock) + self.prepare_vm(self.shm_path, vhost, local=3DTrue, + cpr=3DTrue) + self.vm.launch() + self.set_migration_capabilities(self.vm, local=3DTrue, mode=3D"cpr= -exec") + self.add_virtio_net(self.vm, vhost, TAP_ID, local=3DTrue, incoming= =3DFalse) + + self.vm.cmd("cont") + self.wait_for_console_pattern("login:") + exec_command_and_wait_for_pattern(self, "root", "# ") + + self.setup_guest_network() + + self.one_ping_from_guest(self.vm) + self.one_ping_from_host() + self.start_outer_ping() + + # Get some successful pings before migration + time.sleep(0.5) + + # Capture the console socket fd so we can pass it to the exec'ed + # QEMU; it is inheritable and preserved across exec. + cons_fd =3D self.vm._cons_sock_saved_fd + + # Build the command line for the new QEMU process that will replace + # the source after exec. Reuse the same QMP path and console fd. + exec_cmd =3D [self.qemu_bin] + exec_cmd.extend(self.vm._harness_args) + exec_cmd.extend(["-chardev", f"socket,id=3Dconsole,fd=3D{cons_fd}", + "-serial", "chardev:console"]) + exec_cmd.extend(self.vm._base_args) + exec_cmd.extend(self.vm.args) + exec_cmd.extend(["-incoming", "defer"]) + + self.vm.cmd("migrate-set-parameters", + {"cpr-exec-command": exec_cmd}) + + self.log.info("Starting cpr-exec migration") + freeze_start =3D time.time() + self.vm.cmd("migrate", {"uri": f"file:{mig_file}"}) + + self.log.info("Waiting for source migration to complete (exec)") + source_e =3D self.vm.events_wait( + ( + ("MIGRATION", {"data": {"status": "completed"}}), + ("MIGRATION", {"data": {"status": "failed"}}), + ) + )["data"] + assert source_e["status"] =3D=3D "completed", \ + f"Source migration failed: {source_e}" + + # The source QEMU has now exec'ed the new QEMU. The old QMP + # connection is gone; create a fresh QMP server on the same path + # and accept the new QEMU's connection. + self.vm._qmp_connection.close() + self.vm._events.clear() + # Remove the stale UNIX socket file left by the old server. + try: + os.unlink(qmp_sock) + except FileNotFoundError: + pass + self.vm._qmp_connection =3D QEMUMonitorProtocol( + qmp_sock, server=3DTrue, nickname=3Dself.vm._name) + self.vm._qmp_connection.accept(timeout=3D120) + + # The new QEMU is now reachable through the same QEMUMachine objec= t. + self.set_migration_capabilities(self.vm, local=3DTrue, mode=3D"cpr= -exec") + self.add_virtio_net(self.vm, vhost, TAP_ID, local=3DTrue, incoming= =3DTrue) + self.vm.cmd( + "migrate-incoming", + channels=3D[ + { + "channel-type": "main", + "addr": { + "transport": "file", + "filename": mig_file, + "offset": 0, + }, + } + ], + conv_keys=3DFalse, + ) + + self.log.info("Waiting for target migration to complete") + target_e =3D self.vm.events_wait( + ( + ("MIGRATION", {"data": {"status": "completed"}}), + ("MIGRATION", {"data": {"status": "failed"}}), + ) + )["data"] + assert target_e["status"] =3D=3D "completed", \ + f"Target migration failed: {target_e}" + + self.vm.cmd("cont") + freeze_end =3D time.time() + + self.log.info("Verifying PING on target VM after migration") + self.one_ping_from_guest(self.vm) + self.one_ping_from_host() + + # And a bit more pings after migration + time.sleep(0.3) + self.stop_ping_and_check(freeze_start, freeze_end) + + self.vm.shutdown() + def test_tap_fd_migration(self): self.do_test_tap_fd_migration(False) =20 @@ -456,6 +647,24 @@ def test_tap_new_tap_migration(self): def test_tap_new_tap_migration_vhost(self): self.do_test_tap_fd_migration(True, local=3DFalse) =20 + def test_tap_fd_migration_cpr(self): + self.do_test_tap_fd_migration(False, cpr=3DTrue) + + def test_tap_fd_migration_vhost_cpr(self): + self.do_test_tap_fd_migration(True, cpr=3DTrue) + + def test_tap_new_tap_migration_cpr(self): + self.do_test_tap_fd_migration(False, local=3DFalse, cpr=3DTrue) + + def test_tap_new_tap_migration_vhost_cpr(self): + self.do_test_tap_fd_migration(True, local=3DFalse, cpr=3DTrue) + + def test_tap_cpr_exec_migration(self): + self.do_test_tap_cpr_exec_migration(False) + + def test_tap_cpr_exec_migration_vhost(self): + self.do_test_tap_cpr_exec_migration(True) + =20 if __name__ =3D=3D "__main__": LinuxKernelTest.main() --=20 2.43.0