Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2217858/?format=api
{ "id": 2217858, "url": "http://patchwork.ozlabs.org/api/patches/2217858/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260330-fast-snapshot-refactor-v1-1-22143e70c467@gmail.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260330-fast-snapshot-refactor-v1-1-22143e70c467@gmail.com>", "list_archive_url": null, "date": "2026-03-30T19:04:41", "name": "[1/3] migration/postcopy: Extract page fault handler callback", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b2e7cfca277b396d9c7bd6724c095557e99f6995", "submitter": { "id": 87325, "url": "http://patchwork.ozlabs.org/api/people/87325/?format=api", "name": "Takeru Hayasaka", "email": "hayatake396@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260330-fast-snapshot-refactor-v1-1-22143e70c467@gmail.com/mbox/", "series": [ { "id": 498082, "url": "http://patchwork.ozlabs.org/api/series/498082/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=498082", "date": "2026-03-30T19:04:41", "name": "migration/postcopy: Preparatory refactoring for fast snapshot load", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498082/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2217858/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2217858/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=NxbyE7GD;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fl11M2rdbz1yG7\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 31 Mar 2026 06:05:59 +1100 (AEDT)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w7Hvi-0003pt-B2; Mon, 30 Mar 2026 15:05:42 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <hayatake396@gmail.com>)\n id 1w7HvV-0003ok-Gl\n for qemu-devel@nongnu.org; Mon, 30 Mar 2026 15:05:29 -0400", "from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <hayatake396@gmail.com>)\n id 1w7HvS-0005DJ-9W\n for qemu-devel@nongnu.org; Mon, 30 Mar 2026 15:05:27 -0400", "by mail-pf1-x42b.google.com with SMTP id\n d2e1a72fcca58-82ae378fff8so3067187b3a.2\n for <qemu-devel@nongnu.org>; Mon, 30 Mar 2026 12:05:25 -0700 (PDT)", "from [127.0.1.1] (191.68.231.218.rev.ocx2915.net. [218.231.68.191])\n by smtp.gmail.com with ESMTPSA id\n d2e1a72fcca58-82ca84644d9sm8496989b3a.13.2026.03.30.12.05.22\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 30 Mar 2026 12:05:23 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1774897524; x=1775502324; darn=nongnu.org;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:from:to:cc:subject:date:message-id\n :reply-to; bh=GWXg+mj1MOof8W2D421QpIVtIcM/Q39yej/+pKha1zc=;\n b=NxbyE7GDpfa0A3980XL0Faqc17PU6RzqiqYAagwzVXOhLjY2Eo4DxSPnBd4gYkW/xB\n Oq3dG/wcLOkuEckkkCTrV0CEWcH5e/xVUGKckmqHBPoR6UkVwttiFNITixRpHtidpcCU\n 0nNOeCbRPXRfGuEEi5YOVf2LaTU8T6kmN3G/WfAKh6WgKpP8uPQD1b8u2o/I8qd91Q9l\n +6tG9f5wPYp7pPccKZy1oj8MwnoFD1yU/Kh872J3yyd0m9gSnJEVrw9BSeMEG6cGBTsf\n RKDyBGYIbxvCi43ERjyXCrsQ92Dq/jGhIS7hf5RfQ5gXEmL/eTOv0UwfJj7pgVEBWiue\n nCGA==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774897524; x=1775502324;\n h=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to\n :cc:subject:date:message-id:reply-to;\n bh=GWXg+mj1MOof8W2D421QpIVtIcM/Q39yej/+pKha1zc=;\n b=dVLJZmb+02LJvDlo2rx4hIvVo5vzdEAzbHfq9VItHYRnyIO8L6bZEPILqoYo7+tFTW\n NJpLQUHO+Th3ZRfwVJmbjlkTkR4BfJCEORdeiPFkHlS+2YVXBExlQU5YCualL2HcpBw6\n 5yv7ILs4O3Grp7LNOZ6Y5y/nCtceLixu5NjxTB5UyV4FhPnsmP829qxOsI8hlKuRreo5\n XaDaNa5xGFWi4fY47Mw6+p+8gCQWXng20TOQosv1W0PomZnZwLibJu1DiPahwFiAWdR/\n S/jLrIlhoVDqX84Zn1B3BE+N5bWAzr6ceDoxTXP2YHD7M1wnUlqsXb7CRpodsHcAGr0A\n zwOA==", "X-Gm-Message-State": "AOJu0YwspvY3ANDzojqcRr/zkD9L0a1EHgdKBOIYJns4P3J2ssB85Ene\n E74Ssj6qs8B5ysLShHEr8suwkBHvMBeA1Ezdd1gSpsgmbEdFuXPrvyMCqDmpiQ==", "X-Gm-Gg": "ATEYQzx1/GQadZJgRtZYldTNYg4+E75Do8LyBFSLSrwp4+WPyIs5peIMDomQd7Sa4+l\n jWUteeT8Ixo9d/GkvoQAvi3iLlbuSFwMwfLNdW0uKB6R0QO0lDWWizxepCU34ZNkG32YZY388tC\n hVR7fgyHQo89cXmURGnPVd06vS5NAn/dpd00zTQ6ps3msHaMsV16bxPd5FOQMV3ocYH3Vp6zkrL\n DzU1hmnKb08Q/3igFDw83U0mBo+e61rbuQItwVFWUCQNP6tGUfTg4qvv/IcFm0K141TXDF+OiO/\n pdAUHBFUofqpUbcQijJNFc3K86XSLVTcSlU67/Z2jIInlRlX7Vqcjj1EaXIhvOpOp05VVX2fSvE\n AIWN0ulGlhvtN+seYzswKgW3w29vFx6vZPrNvvJlFv8iFCFcbgAFR/i7VdK61GiqCrYBHcKzkC7\n vsNDnaIRytskGETrhT76FhbDz/j1uTLGh2YBPTLzeH455bHOSV/LJEbgLOrWYCjgMIgtR1XkT/N\n zLy9bYWcwQxJCemo5sX8DnYA7n9", "X-Received": "by 2002:a05:6a00:1ca8:b0:82a:778:cd73 with SMTP id\n d2e1a72fcca58-82c96039a20mr11884762b3a.51.1774897524430;\n Mon, 30 Mar 2026 12:05:24 -0700 (PDT)", "From": "Takeru Hayasaka <hayatake396@gmail.com>", "Date": "Mon, 30 Mar 2026 19:04:41 +0000", "Subject": "[PATCH 1/3] migration/postcopy: Extract page fault handler\n callback", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260330-fast-snapshot-refactor-v1-1-22143e70c467@gmail.com>", "References": "<20260330-fast-snapshot-refactor-v1-0-22143e70c467@gmail.com>", "In-Reply-To": "<20260330-fast-snapshot-refactor-v1-0-22143e70c467@gmail.com>", "To": "qemu-devel@nongnu.org", "Cc": "Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>,\n Takeru Hayasaka <hayatake396@gmail.com>", "X-Mailer": "b4 0.15.1", "Received-SPF": "pass client-ip=2607:f8b0:4864:20::42b;\n envelope-from=hayatake396@gmail.com; helo=mail-pf1-x42b.google.com", "X-Spam_score_int": "-17", "X-Spam_score": "-1.8", "X-Spam_bar": "-", "X-Spam_report": "(-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n 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": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "Introduce a PostcopyPageHandler callback type and use it to decouple\nthe userfaultfd fault thread from the postcopy-specific page request\nlogic. This prepares for fast snapshot load, which will supply pages\nfrom a local file instead of requesting them over the network.\n\nThe fault thread now calls mis->page_fault_handler() instead of\npostcopy_request_page() directly. For postcopy, the handler is set to\npostcopy_page_fault_handler() which delegates to the existing\npostcopy_request_page().\n\nNo functional change for postcopy migration.\n\nSigned-off-by: Takeru Hayasaka <hayatake396@gmail.com>\n---\n migration/migration.h | 16 ++++++++++++++++\n migration/postcopy-ram.c | 22 +++++++++++++++++++---\n 2 files changed, 35 insertions(+), 3 deletions(-)", "diff": "diff --git a/migration/migration.h b/migration/migration.h\nindex b6888daceddf..33525402922d 100644\n--- a/migration/migration.h\n+++ b/migration/migration.h\n@@ -89,6 +89,17 @@ typedef enum {\n PREEMPT_THREAD_QUIT,\n } PreemptThreadStatus;\n \n+/*\n+ * Callback to handle a page fault from the userfaultfd fault thread.\n+ * Implementations resolve the fault by supplying the requested page,\n+ * e.g., by requesting it from the migration source (postcopy) or by\n+ * reading it from a snapshot file (fast snapshot load).\n+ */\n+typedef int (*PostcopyPageHandler)(MigrationIncomingState *mis,\n+ RAMBlock *rb,\n+ ram_addr_t offset,\n+ void *fault_address);\n+\n /* State for the incoming migration */\n struct MigrationIncomingState {\n QEMUFile *from_src_file;\n@@ -116,6 +127,11 @@ struct MigrationIncomingState {\n QemuThread fault_thread;\n /* Set this when we want the fault thread to quit */\n bool fault_thread_quit;\n+ /* Callback to resolve page faults; set before fault thread starts */\n+ PostcopyPageHandler page_fault_handler;\n+ void *page_fault_opaque;\n+ /* ptid from current uffd fault msg, for postcopy blocktime tracking */\n+ uint32_t fault_thread_ptid;\n \n bool have_listen_thread;\n QemuThread listen_thread;\ndiff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c\nindex f5ef93f1933c..8dcd8ff35e85 100644\n--- a/migration/postcopy-ram.c\n+++ b/migration/postcopy-ram.c\n@@ -976,6 +976,20 @@ static int postcopy_request_page(MigrationIncomingState *mis, RAMBlock *rb,\n return migrate_send_rp_req_pages(mis, rb, start, haddr, tid);\n }\n \n+/*\n+ * Default page fault handler for postcopy live migration.\n+ * Requests the faulted page from the source via the return path.\n+ */\n+static int postcopy_page_fault_handler(MigrationIncomingState *mis,\n+ RAMBlock *rb,\n+ ram_addr_t offset,\n+ void *fault_address)\n+{\n+ return postcopy_request_page(mis, rb, offset,\n+ (uint64_t)(uintptr_t)fault_address,\n+ mis->fault_thread_ptid);\n+}\n+\n /*\n * Callback from shared fault handlers to ask for a page,\n * the page must be specified by a RAMBlock and an offset in that rb\n@@ -1392,9 +1406,9 @@ retry:\n * Send the request to the source - we want to request one\n * of our host page sizes (which is >= TPS)\n */\n- ret = postcopy_request_page(mis, rb, rb_offset,\n- msg.arg.pagefault.address,\n- msg.arg.pagefault.feat.ptid);\n+ mis->fault_thread_ptid = msg.arg.pagefault.feat.ptid;\n+ ret = mis->page_fault_handler(mis, rb, rb_offset,\n+ (void *)(uintptr_t)msg.arg.pagefault.address);\n if (ret) {\n /* May be network failure, try to wait for recovery */\n postcopy_pause_fault_thread(mis);\n@@ -1552,6 +1566,8 @@ int postcopy_ram_incoming_setup(MigrationIncomingState *mis)\n return -1;\n }\n \n+ mis->page_fault_handler = postcopy_page_fault_handler;\n+\n postcopy_thread_create(mis, &mis->fault_thread,\n MIGRATION_THREAD_DST_FAULT,\n postcopy_ram_fault_thread, QEMU_THREAD_JOINABLE);\n", "prefixes": [ "1/3" ] }