From nobody Wed Jan 7 09:14:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=me@linux.beauty; 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; arc=pass (i=1 dmarc=pass fromdomain=linux.beauty) ARC-Seal: i=2; a=rsa-sha256; t=1767010184; cv=pass; d=zohomail.com; s=zohoarc; b=B1tGkoSbwK9wwrWml4lByBftuLPR+g/4yXF2BiWzIEyX2NLSPU2KXxWo1E04SvDfu5CtMBYb77YuwtGPs2rMWlIZnV1cbNk5S5rP0F8eLfqO3/rl4pYUFfGgRXC7PdwMGNK9DJTugywXysL50sCRZ0jXT0YRPJw0WGL1r5PN5zw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767010184; 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=KmL3yQU8cI+4O6Tqt+R8xR9IxD5kn1z34uVz/ZpIegU=; b=TtmuwPpz72XMdiMJjGiy6r+JdYYiUaU9PAa+Ja7r5RerBlbLCKIvPBMzja0DmZ8KWtXDxtDEgfF9nCG75QZiqTKk6qseKGehXAnVuDegmp6UeY34i7ZNFNxVRIi4wYAHDE2Jd9l3GvZhPhsTtLdANDaLdPtQZmflCvjTdOGg++M= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=me@linux.beauty; 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; arc=pass (i=1 dmarc=pass fromdomain=linux.beauty) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767010184499637.5930718408185; Mon, 29 Dec 2025 04:09:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaC3r-0007vZ-SP; Mon, 29 Dec 2025 07:09:19 -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 1vaC3p-0007un-QN for qemu-devel@nongnu.org; Mon, 29 Dec 2025 07:09:18 -0500 Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaC3o-0005Au-7K for qemu-devel@nongnu.org; Mon, 29 Dec 2025 07:09:17 -0500 Received: by mx.zohomail.com with SMTPS id 1767010126666353.00298807412594; Mon, 29 Dec 2025 04:08:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1767010127; cv=none; d=zohomail.com; s=zohoarc; b=WwWbg7x4ZhKPv7Drz9LTjL0hqnBstpOGnLXVtK2mNQCPdlsvS7nN/sLwC/mgcRwy4MlmzbuSBLb8cOFtFT7r6qawy3vwRFxpSxrJumxbHXSEeVs5LBPnaIaO0PmBPqritN2zaJY6iTpdWJlIEezZdCicaxa189ppPs8+jPqY58k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767010127; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=KmL3yQU8cI+4O6Tqt+R8xR9IxD5kn1z34uVz/ZpIegU=; b=OPVKRmS7nvZViCKM63a9Ie6BiV8V7UURqcajCDB/IJh5fsC+i81dOhgZVZPgEyxYsryAv5P3jF0jpnREv7Y0RBVCQ3rT1SRxcAVyTPRUuGY1tdNRN5DQQNuJniQ3OOtaRwliK+UlTVDAvtHso7AORC8JBYcKfH/PeNPxD4RqbyY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1767010127; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=KmL3yQU8cI+4O6Tqt+R8xR9IxD5kn1z34uVz/ZpIegU=; b=TcgcwRmVW893pKZIet0XESxGjbCEAhqtlqjE8jPQjuBRhmBfPb4quTWsnK6ompVV 1h4x5RdhyE+uTVtXALpe7nuozkjQ1RClADexL60Wk1J5fXxw5cudu5/Bi+IwnwqrBHn 89slAsbJAxCs/Zsdpr3D46lwGgJUQ/aHBgByqWOI= From: Li Chen To: Peter Xu , Fabiano Rosas , Paolo Bonzini , Laurent Vivier Cc: David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Pasha Tatashin" , qemu-devel@nongnu.org, Li Chen Subject: [PATCH 1/3] system/physmem: allow /dev/fdset for file-backed RAM Date: Mon, 29 Dec 2025 20:08:35 +0800 Message-ID: <20251229120839.89817-2-me@linux.beauty> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251229120839.89817-1-me@linux.beauty> References: <20251229120839.89817-1-me@linux.beauty> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External 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 (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=136.143.188.112; envelope-from=me@linux.beauty; helo=sender4-pp-f112.zoho.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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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 Precedence: list List-Id: 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 me@linux.beauty) X-ZM-MESSAGEID: 1767010185419158500 Content-Type: text/plain; charset="utf-8" CPR with x-ignore-shared can skip migration of shared RAM pages, so only vmstate is transferred. This relies on guest RAM being externally managed and re-used in place. Allow users to pass a pre-opened RAM backing FD via -add-fd and attach it with memory-backend-file mem-path=3D/dev/fdset/. File-backed RAM used plain open()/creat(), so /dev/fdset/ could not be resolved through the fdset mechanism. Switch to qemu_open()/qemu_create(), return -EINVAL when creation is attempted, and add a hint for missing -add-fd. Add a qtest that creates a memory-backend-file object from /dev/fdset/. Signed-off-by: Li Chen --- system/physmem.c | 17 ++++++++++++-- tests/qtest/migration/cpr-tests.c | 38 ++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index c9869e4049..7717de5e7b 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1650,10 +1650,14 @@ static int file_ram_open(const char *path, char *sanitized_name; char *c; int fd =3D -1; + const char *tmp; + const bool is_fdset =3D strstart(path, "/dev/fdset/", &tmp); =20 *created =3D false; for (;;) { - fd =3D open(path, readonly ? O_RDONLY : O_RDWR); + g_autoptr(Error) local_err =3D NULL; + + fd =3D qemu_open(path, readonly ? O_RDONLY : O_RDWR, &local_err); if (fd >=3D 0) { /* * open(O_RDONLY) won't fail with EISDIR. Check manually if we @@ -1682,8 +1686,13 @@ static int file_ram_open(const char *path, /* Refuse to create new, readonly files. */ return -ENOENT; } + if (is_fdset) { + /* /dev/fdset/N is a QEMU fdset handle and cannot be creat= ed. */ + return -EINVAL; + } /* @path names a file that doesn't exist, create it */ - fd =3D open(path, O_RDWR | O_CREAT | O_EXCL, 0644); + local_err =3D NULL; + fd =3D qemu_create(path, O_RDWR | O_EXCL, 0644, &local_err); if (fd >=3D 0) { *created =3D true; break; @@ -2410,6 +2419,10 @@ RAMBlock *qemu_ram_alloc_from_file(ram_addr_t size, = MemoryRegion *mr, if (fd < 0) { error_setg_errno(errp, -fd, "can't open backing store %s for guest= RAM", mem_path); + if (g_str_has_prefix(mem_path, "/dev/fdset/")) { + error_append_hint(errp, "Did you forget to pass the backing FD= via" + " '-add-fd fd=3D,set=3D'?\n"); + } if (!(ram_flags & RAM_READONLY_FD) && !(ram_flags & RAM_SHARED) && fd =3D=3D -EACCES) { /* diff --git a/tests/qtest/migration/cpr-tests.c b/tests/qtest/migration/cpr-= tests.c index 2a186c6f35..5eafc4d678 100644 --- a/tests/qtest/migration/cpr-tests.c +++ b/tests/qtest/migration/cpr-tests.c @@ -19,6 +19,39 @@ =20 static char *tmpfs; =20 +#ifndef _WIN32 +static void test_mem_backend_file_fdset(void) +{ + const uint64_t size =3D 8 * 1024 * 1024; + g_autofree char *file =3D g_strdup_printf("%s/fdset-ram.bin", tmpfs); + QTestState *qts; + int fd; + + fd =3D open(file, O_RDWR | O_CREAT | O_TRUNC, 0600); + g_assert_cmpint(fd, >=3D, 0); + g_assert_cmpint(ftruncate(fd, size), =3D=3D, 0); + + qts =3D qtest_init("-machine none -nodefaults"); + qtest_qmp_fds_assert_success(qts, &fd, 1, + "{'execute': 'add-fd'," + " 'arguments': { 'fdset-id': 1 } }"); + close(fd); + + qtest_qmp_assert_success(qts, "{ 'execute': 'object-add'," + " 'arguments': {" + " 'qom-type': 'memory-backend-file'," + " 'id': 'ram0'," + " 'mem-path': '/dev/fdset/1'," + " 'size': %" PRIu64 " } }", + size); + qtest_qmp_assert_success(qts, "{ 'execute': 'object-del'," + " 'arguments': { 'id': 'ram0' } }"); + qtest_quit(qts); + + unlink(file); +} +#endif + static void *migrate_hook_start_mode_reboot(QTestState *from, QTestState *= to) { migrate_set_parameter_str(from, "mode", "cpr-reboot"); @@ -247,7 +280,10 @@ void migration_test_add_cpr(MigrationTestEnv *env) { tmpfs =3D env->tmpfs; =20 - /* no tests in the smoke set for now */ +#ifndef _WIN32 + migration_test_add("/migration/fdset/mem-backend-file", + test_mem_backend_file_fdset); +#endif =20 if (!env->full_set) { return; --=20 2.52.0 From nobody Wed Jan 7 09:14:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=me@linux.beauty; 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; arc=pass (i=1 dmarc=pass fromdomain=linux.beauty) ARC-Seal: i=2; a=rsa-sha256; t=1767010187; cv=pass; d=zohomail.com; s=zohoarc; b=jsHvy4C7UIo4g/0BVuUwzkCwal5naZbRcQoaHBgu9i0Is/5fViylmHtHR/Rc7Pec58sNtvL751f0CANI/4L//HhwlprMWLp3RacO3IXDzrK4tXUmqjBB2vofm7WSwvqVjEYODYI+diBPM3qwTzpmJAlGo38pL6nUH+uKygDwHWw= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767010187; 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=b6RbZnrLQU46HzS5xhrvB1zLEVHidENk4tAlk9JT9F4=; b=LFD4rKtibtd6JTIo88NdhYAhqlQW+nPE6ODyTyGlYIluWaqKpilsltsVfH8EWQ5YIS7jy88mn5neVgTTth0u9U14Cxrb3b4PS+4FMOft2Y+klygakYLibI3GKBhsAVsZLvx1hPyJu26DCzK5lNcRhwMcN+PgmX6cy375ilFLGoA= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=me@linux.beauty; 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; arc=pass (i=1 dmarc=pass fromdomain=linux.beauty) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767010187560868.1385523682133; Mon, 29 Dec 2025 04:09:47 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaC43-0007zz-GK; Mon, 29 Dec 2025 07:09:31 -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 1vaC3z-0007xv-Oh for qemu-devel@nongnu.org; Mon, 29 Dec 2025 07:09:28 -0500 Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaC3y-0005Bk-1v for qemu-devel@nongnu.org; Mon, 29 Dec 2025 07:09:27 -0500 Received: by mx.zohomail.com with SMTPS id 1767010128989281.3144807790054; Mon, 29 Dec 2025 04:08:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1767010129; cv=none; d=zohomail.com; s=zohoarc; b=c0GcFYFy9KIPyJeFoywGkDvGQ0aDyru6c99K0h7gX383ATbe9CVYQcQq0Q3SMzq1a1m1AuAQLnoi1W0KoVAXyuFK6rTbwVP57huINZICpcog2ojIiWTm5rKAztNOfxPl/uQF3SQEOZoQEfRnVc54ce4vUoapWKuFdFB6I1P/+Ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767010129; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=b6RbZnrLQU46HzS5xhrvB1zLEVHidENk4tAlk9JT9F4=; b=HOYdMmoOoFfS9IfucvmOoDc1mD8mWymQ/wRgBlAJ6nHt/v46RfG+hzq7/nQzKrdIlQS4hEHu5gOxKlQTGUX3ErpXq0XoJMnPdpnGtOEchWMFwrztej7o2mPqYHjKCoi6r+KOUsl7/bvz1UhKIMlRngXkRMon1VxSLvU+/AS/do4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1767010129; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=b6RbZnrLQU46HzS5xhrvB1zLEVHidENk4tAlk9JT9F4=; b=i0lLJwykfUPiXyewbbNTN9phMRoUtJAgIFGcicGErp2jsW5IjG+sAYi0DB3Bggic Tw5aHPXW7fB8bifHs8YGI6lbcyK19ecEcY6w6A0IkMH3XTVTOer+zOrwaXKT0bQYtbC aKHBKbS2OIDASoAnxaOZ8OJAE30MFlR/Sqdq7Zc0= From: Li Chen To: Peter Xu , Fabiano Rosas , Paolo Bonzini , Laurent Vivier Cc: David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Pasha Tatashin" , qemu-devel@nongnu.org, Li Chen Subject: [PATCH 2/3] docs: CPR: document shared RAM with x-ignore-shared Date: Mon, 29 Dec 2025 20:08:36 +0800 Message-ID: <20251229120839.89817-3-me@linux.beauty> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251229120839.89817-1-me@linux.beauty> References: <20251229120839.89817-1-me@linux.beauty> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External 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 (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=136.143.188.112; envelope-from=me@linux.beauty; helo=sender4-pp-f112.zoho.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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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 Precedence: list List-Id: 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 me@linux.beauty) X-ZM-MESSAGEID: 1767010189447158500 Content-Type: text/plain; charset="utf-8" Document a CPR setup where guest RAM is shared/external and preserved in place. With shared RAM and x-ignore-shared enabled, the migration stream skips guest RAM pages and transfers only non-RAM VM state (vmstate). Note that a memfd-backed RAM file is not persistent across a reboot by itself. For a host kexec reboot, use persistent shared memory (for example a DAX device), or use an external manager (for example Linux Live Update Orchestrator (LUO)) to preserve the RAM backing file and re-attach it to the new QEMU instance. Signed-off-by: Li Chen --- docs/devel/migration/CPR.rst | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/devel/migration/CPR.rst b/docs/devel/migration/CPR.rst index b6178568a8..e60ae31b45 100644 --- a/docs/devel/migration/CPR.rst +++ b/docs/devel/migration/CPR.rst @@ -46,9 +46,20 @@ Usage =20 It is recommended that guest RAM be backed with some type of shared memory, such as ``memory-backend-file,share=3Don``, and that the -``x-ignore-shared`` capability be set. This combination allows memory -to be saved in place. Otherwise, after QEMU stops the VM, all guest -RAM is copied to the migration URI. +``x-ignore-shared`` capability be set. With shared RAM and +``x-ignore-shared``, the migration stream skips guest RAM pages and +transfers only non-RAM VM state (vmstate), while guest RAM is preserved +in place. Otherwise, after QEMU stops the VM, all guest RAM is copied +to the migration URI. + +Note that a memfd-backed RAM file is not persistent across a reboot by +itself. If you want to reboot to a new host kernel while keeping RAM in +place, use persistent shared memory (for example a DAX device), or use +an external manager (for example Linux Live Update Orchestrator (LUO)) +that preserves the RAM backing file and re-attaches it to the new QEMU +instance (for example with ``-add-fd`` and a ``memory-backend-file`` +pointing at ``/dev/fdset/``). QEMU does not manage that +orchestration. =20 Outgoing: * Set the migration mode parameter to ``cpr-reboot``. --=20 2.52.0 From nobody Wed Jan 7 09:14:35 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=me@linux.beauty; 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; arc=pass (i=1 dmarc=pass fromdomain=linux.beauty) ARC-Seal: i=2; a=rsa-sha256; t=1767010206; cv=pass; d=zohomail.com; s=zohoarc; b=UJfB1jDOiWKejmMnvLPaEE76RUbjYDgyPHSMKxaltCHcrrkl8Yt4hxB/UJmSF+tV25RlUSNwsYqAvZI10SABFcZyKD9GPycdjh76bkiF5KILCC3Sr7NZc5SnzbnTpS2+JOxz/dNgi0MlQrrcxzcJlCbLzvQnaHOzTZ4Ml7VcKAo= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767010206; 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=HxLFsoVDmsqRvELTh+BEpbqJgwtq55Gc8sai31DAemU=; b=gE7uUVPfpzTfBcJ+eRfkEnIB81vXTyz2fDixAzKqSx9P95COrs3Kwck5QxxNSmtvdxk+wMmPOoyi1u4+Pq2dF/8q6C08Rv1/hHCHkxBtk/7FmIvEQtT03NpQFQvpSyhyn3uHSnQ097QGPxOb+GfHGltXXUw+0UOfAhq9n7eSu4o= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass header.i=me@linux.beauty; 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; arc=pass (i=1 dmarc=pass fromdomain=linux.beauty) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767010206240741.4705534064074; Mon, 29 Dec 2025 04:10:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vaC4N-000889-Pk; Mon, 29 Dec 2025 07:09:55 -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 1vaC4C-000828-9T for qemu-devel@nongnu.org; Mon, 29 Dec 2025 07:09:41 -0500 Received: from sender4-pp-f112.zoho.com ([136.143.188.112]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vaC4A-0005CP-PH for qemu-devel@nongnu.org; Mon, 29 Dec 2025 07:09:40 -0500 Received: by mx.zohomail.com with SMTPS id 1767010131227743.6672530480084; Mon, 29 Dec 2025 04:08:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1767010134; cv=none; d=zohomail.com; s=zohoarc; b=JMeTRdngsOjXP41ZeM0ftEVP9993mpQBwj1wB11zI9loknX29Nq6sTJEmTC5d9KEwFvnf54EOo2W5kaa4JvBPMydAmVg//QcVaEKAMvv3AHmYkttKWJtOiggOBQZ6XhuUySrmT6tkPocKVnGt/iMqanoOIyWdqaL2TptzaFLvzk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767010134; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=HxLFsoVDmsqRvELTh+BEpbqJgwtq55Gc8sai31DAemU=; b=TZrUz2bF06VGb4cQO/W/6gAyRx1Mj7KNQ1vfxjG2y6RcCLdP+PnpjDevjDBiVltgHKocsrQMVrvBjltBmJEJJwFFmDDDo7FJ7OmlcMOFyKI8VYYd7BHnVnwQ6tkVxk56K2dQfvJRQ0Rn0/9ovheRq6wH0FNX2EtwJbQHiezbpGo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=linux.beauty; spf=pass smtp.mailfrom=me@linux.beauty; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1767010134; s=zmail; d=linux.beauty; i=me@linux.beauty; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Message-Id:Reply-To; bh=HxLFsoVDmsqRvELTh+BEpbqJgwtq55Gc8sai31DAemU=; b=sj2R9RuFyC7Q4VK2ZzTgEAfVgeJ40T98/C6lHWkOz+EyMuZIO5Dyi1uHz15C45b2 IAflGzAFMJWLsHG1RheBleFWZXLGy1HOOMjQHiCFKI/iUlr29EWugJ9EeUC4fJvoePD Fv/leEA9g00fMLQqZMtlxqnkOSRMam3CkJDrEqbU= From: Li Chen To: Peter Xu , Fabiano Rosas , Paolo Bonzini , Laurent Vivier Cc: David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , "Pasha Tatashin" , qemu-devel@nongnu.org, Li Chen Subject: [PATCH 3/3] tests/qtest: cpr-reboot: check ignore-shared transfer Date: Mon, 29 Dec 2025 20:08:37 +0800 Message-ID: <20251229120839.89817-4-me@linux.beauty> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251229120839.89817-1-me@linux.beauty> References: <20251229120839.89817-1-me@linux.beauty> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMailClient: External 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 (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=136.143.188.112; envelope-from=me@linux.beauty; helo=sender4-pp-f112.zoho.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, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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 Precedence: list List-Id: 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 me@linux.beauty) X-ZM-MESSAGEID: 1767010207552158500 Content-Type: text/plain; charset="utf-8" Add a cpr-reboot qtest that enables x-ignore-shared and asserts the amount of RAM transferred stays far below the guest RAM size. This covers the shared RAM behavior: device state is saved while shared RAM is preserved in place. Signed-off-by: Li Chen --- tests/qtest/migration/cpr-tests.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/qtest/migration/cpr-tests.c b/tests/qtest/migration/cpr-= tests.c index 5eafc4d678..6fa09b54ee 100644 --- a/tests/qtest/migration/cpr-tests.c +++ b/tests/qtest/migration/cpr-tests.c @@ -52,6 +52,23 @@ static void test_mem_backend_file_fdset(void) } #endif =20 +static void test_ignore_shared_end(QTestState *from, QTestState *to, + void *opaque) +{ + int64_t transferred; + int64_t total; + int64_t limit; + + transferred =3D read_ram_property_int(from, "transferred"); + total =3D read_ram_property_int(from, "total"); + limit =3D total / 32; + limit =3D MIN(limit, 8 * 1024 * 1024); + limit =3D MAX(limit, 2 * 1024 * 1024); + g_test_message("ram.transferred=3D%" PRId64 " ram.total=3D%" PRId64 + " limit=3D%" PRId64, transferred, total, limit); + g_assert_cmpint(transferred, <, limit); +} + static void *migrate_hook_start_mode_reboot(QTestState *from, QTestState *= to) { migrate_set_parameter_str(from, "mode", "cpr-reboot"); @@ -69,6 +86,7 @@ static void test_mode_reboot(void) .connect_uri =3D uri, .listen_uri =3D "defer", .start_hook =3D migrate_hook_start_mode_reboot, + .end_hook =3D test_ignore_shared_end, .start =3D { .caps[MIGRATION_CAPABILITY_X_IGNORE_SHARED] =3D true, }, --=20 2.52.0