From nobody Sun Jul 26 12:29:02 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1781752895; cv=none; d=zohomail.com; s=zohoarc; b=iQbHAW/B622zjVH3sxq4eh6iFyjKLc4OBIIaKjVI3Su4gUBDNO+IcuEZ/PUerhN2Aokt4H5coxv1ri6b7iu9HRg9NUFf/T/nWRKrQ8xm56pFuMrBQejF0V/ULJdUPaqek20xZWxsV5AYYDHMHPIK6YRQGN9Mg1pegp128djFloc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781752895; 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=5UuQ1fcG6Nvpe6RYZ8HgiP4tWeblSoX4zuvVb8Lrw5U=; b=IOhy+EEgpwhb1tAaFE/WiN2k4e5wZveXlf81Y7ovtpbcEKtEQt6aBzccigCh7WGj4nigQOPqueW9zDxdcuFZtVVDY4G9bq9pqzB8xBWmPKzk+VBD6yAbUAFQAAkVTaJcVbARREWVy97+UUsKzyRo/gDz1hIQFR6F9IsqNmBuoFg= 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 1781752895769148.51422840304724; Wed, 17 Jun 2026 20:21:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wa3JS-00087i-6y; Wed, 17 Jun 2026 23:21:06 -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 1wa3JQ-00086R-0b for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:04 -0400 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wa3JN-0002FF-PZ for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:03 -0400 Received: by mail-pg1-x533.google.com with SMTP id 41be03b00d2f7-c858961a8efso199179a12.2 for ; Wed, 17 Jun 2026 20:21:01 -0700 (PDT) Received: from setun ([2405:201:502b:3014:cc0c:536:1b1e:6def]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c88c6c2b2easm1534623a12.27.2026.06.17.20.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 20:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781752860; x=1782357660; 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=5UuQ1fcG6Nvpe6RYZ8HgiP4tWeblSoX4zuvVb8Lrw5U=; b=OOafGZ4qezB72cfkn0O+V7CGmNXCqKxq2jsdD79eyKqx8S6Blq/3WuIdcnVW5CKUhz KAZCfujbdA7ETyadj3kLzlod9TRi7lZ6/ax2/BpB7DO/69FHLCz6KjiPDidmT3+K8682 ATRzuYVE8XUQrtOrGuvty6FynWliyqvuyK7gDWstTO1ZdBbZtWhP17LNc/43ElZ4oFRe 8uqioFew/ffJSHxl9/sAK5jQ+tOoe3KtwmescqNnxjREIX/7W9+tX2cjspGGiuHw0V+q YZw3KiyVdZjIb3NwfR8gjdy64zRxcbTro7XwUxD1n0cSGYqrg7XSdkmOlkfZV7NyQ/+x rVpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781752860; x=1782357660; 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=5UuQ1fcG6Nvpe6RYZ8HgiP4tWeblSoX4zuvVb8Lrw5U=; b=Q1TM/lVHcIFbAWOrtIIJy2AvJjaJA5GbHa6J4j00KVYx2XzfG0AdipOFnIKDHj0AvX shmLSXkZbjJqeq+BWytRfVOZULHJF+fO65dLgvA6x8meqPXFxgExJ+gl226khpnTdz++ umtwcnVVgWYULrs3pJPRqiupRalbq/+5UBv2LkNg2NqZd5Ijj1zN2XkI6Sryg5Bu8ey/ PXGYqQRMWIB96UDEKhNV1Lthsxmf10HQ+0VKmZzNsMziC5fqPg3SDQQDVOMxkSAqA/Y2 Rrosc79RE24HypjTvDLQiWZspN7bwssxyylXT5cnCZmpyykqO22dCCo939OOZU1iyQhS UPSQ== X-Gm-Message-State: AOJu0Yz49GwtVmHJHjjIUxmnK0OTO9XMSdncspB61dUVoau/dMfO9YDL 2JdtfOzWH7iCNxExXU0gOCfdHFfSexeIts3JRtEPE0hGJV7C+ecM8Rs6jZSkM5hW X-Gm-Gg: Acq92OHKxWdWxKSyvZGJXhHHlQuJulMFEGSB/t5Hs5ksrB6TmbdgMcwbSxngAweCuC7 +68qO0HUvq80pr8Xq+oeffu3Fup6HsQTUyxPlAjGzEMrcha4RFgmC2h6ypkVYaBEYvNC8PDbhVH Fh5Ig7hNbAQ3JlBOogxDEJzKfMHMFj0/EyxATPYKsIMnylIv11nE51zqM3RVsJmU+Y7nkIlc+iO 4sALGptcLExhZ9+mSQqDlTFutQUAvZKvnnTaOe7rfVXU0BJ45+YSDqW/so9Fh7hYRzPz4iLswIc DNrbYq5nci1p40nmljvuFz08iC+UfMybQv4dSedOAPOzSg8Tjp2Q8uYtx5JqO31bJWnJukVpA/p i+maLOO5euagkaIASEZms8rvnIE7S6BMUbfb6fCF55ETphTLEInI9Ha7MbWgcSIHUTKvzZOV5pG F6is2YcRsKkQQ7lLLbNlgAExZ4Y9cCSHxzLOqjpuKElA== X-Received: by 2002:a05:6a20:3ca7:b0:3b3:fc6:622d with SMTP id adf61e73a8af0-3b8b7eef8e2mr7251409637.38.1781752859965; Wed, 17 Jun 2026 20:20:59 -0700 (PDT) From: Aadeshveer Singh To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, philmd@mailo.com, lvivier@redhat.com, ayoub@saferwall.com, Aadeshveer Singh Subject: [RFC PATCH 1/5] migration: add RAM Block fields and helpers for fast snapshot load Date: Thu, 18 Jun 2026 08:50:06 +0530 Message-ID: <20260618032010.88755-2-aadeshveer07@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618032010.88755-1-aadeshveer07@gmail.com> References: <20260618032010.88755-1-aadeshveer07@gmail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::533; envelope-from=aadeshveer07@gmail.com; helo=mail-pg1-x533.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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 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 @gmail.com) X-ZM-MESSAGEID: 1781752899390158500 Content-Type: text/plain; charset="utf-8" Add two fields per RAMBlock: - nonzeropages: Mirrors the mapped-ram bitmap for storing which pages are present in file and which are zero. - pending_bmap: Bitmap to store internal state of which pages have been read by some thread to ensure coordination between threads. Both fields are allocated and initialized in ram_load_setup and freed in ram_load_cleanup. nonzeropages is populated in parse_ramblock_mapped_ram eliminating the use of a temporary bitmap. Change ram_load() to load using ram_load_precopy() in case of fast snapshot load. Also add migrate_fast_snapshot_load() returning true when both postcopy-ram and mapped-ram capabilities are set. Update qemu_get_buffer_at() to not set error to make it thread safe. All the callers of qemu_get_buffer_at(), take care of error handling. Signed-off-by: Aadeshveer Singh --- include/system/ramblock.h | 8 +++++ migration/options.c | 5 ++++ migration/options.h | 1 + migration/qemu-file.c | 10 +------ migration/ram.c | 61 ++++++++++++++++++++++++++++++++------- 5 files changed, 65 insertions(+), 20 deletions(-) diff --git a/include/system/ramblock.h b/include/system/ramblock.h index 4435f8d55f..73275d0459 100644 --- a/include/system/ramblock.h +++ b/include/system/ramblock.h @@ -60,6 +60,14 @@ struct RAMBlock { =20 /* Bitmap of already received pages. Only used on destination side. */ unsigned long *receivedmap; + /* Bitmap of zero pages. Used for fast snapshot load. */ + unsigned long *nonzeropages; + /* + * Bitmap for pages that are yet to be read from disk. It is required = for + * fault thread and eager thread to keep note of which pages are curre= ntly + * being read. Used by fast snapshot load. + */ + unsigned long *pending_bmap; =20 /* * bitmap to track already cleared dirty bitmap. When the bit is diff --git a/migration/options.c b/migration/options.c index 5cbfd29099..5f80dd5b42 100644 --- a/migration/options.c +++ b/migration/options.c @@ -467,6 +467,11 @@ bool migrate_rdma(void) return s->rdma_migration; } =20 +bool migrate_fast_snapshot_load(void) +{ + return migrate_mapped_ram() && migrate_postcopy_ram(); +} + typedef enum WriteTrackingSupport { WT_SUPPORT_UNKNOWN =3D 0, WT_SUPPORT_ABSENT, diff --git a/migration/options.h b/migration/options.h index b46221998a..a81ca40d23 100644 --- a/migration/options.h +++ b/migration/options.h @@ -54,6 +54,7 @@ bool migrate_multifd_flush_after_each_section(void); bool migrate_postcopy(void); bool migrate_rdma(void); bool migrate_tls(void); +bool migrate_fast_snapshot_load(void); =20 /* capabilities helpers */ =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index d5a48115bd..602ece1b74 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -553,17 +553,9 @@ void qemu_put_buffer_at(QEMUFile *f, const uint8_t *bu= f, size_t buflen, size_t qemu_get_buffer_at(QEMUFile *f, uint8_t *buf, size_t buflen, off_t pos) { - Error *err =3D NULL; - - if (f->last_error) { - return 0; - } - - if (qio_channel_pread_all(f->ioc, buf, buflen, pos, &err) < 0) { - qemu_file_set_error_obj(f, -EIO, err); + if (qio_channel_pread_all(f->ioc, buf, buflen, pos, NULL) < 0) { return 0; } - return buflen; } =20 diff --git a/migration/ram.c b/migration/ram.c index fc38ffbf8a..c2bacf3dfc 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -252,6 +252,31 @@ int foreach_not_ignored_block(RAMBlockIterFunc func, v= oid *opaque) return ret; } =20 +static void ramblock_non_zero_map_init(void) +{ + RAMBlock *rb; + + RAMBLOCK_FOREACH_NOT_IGNORED(rb) + { + assert(!rb->nonzeropages); + size_t size =3D rb->max_length >> qemu_target_page_bits(); + rb->nonzeropages =3D bitmap_new(size); + } +} + +static void ramblock_pending_bmap_init(void) +{ + RAMBlock *rb; + + RAMBLOCK_FOREACH_NOT_IGNORED(rb) + { + assert(!rb->pending_bmap); + size_t size =3D rb->max_length >> qemu_target_page_bits(); + rb->pending_bmap =3D bitmap_new(size); + bitmap_set(rb->pending_bmap, 0, size); + } +} + static void ramblock_recv_map_init(void) { RAMBlock *rb; @@ -3749,6 +3774,12 @@ static int ram_load_setup(QEMUFile *f, void *opaque,= Error **errp) { xbzrle_load_setup(); ramblock_recv_map_init(); + if (migrate_mapped_ram()) { + ramblock_non_zero_map_init(); + } + if (migrate_fast_snapshot_load()) { + ramblock_pending_bmap_init(); + } =20 return 0; } @@ -3768,6 +3799,10 @@ static int ram_load_cleanup(void *opaque) RAMBLOCK_FOREACH_NOT_IGNORED(rb) { g_free(rb->receivedmap); rb->receivedmap =3D NULL; + g_free(rb->pending_bmap); + rb->pending_bmap =3D NULL; + g_free(rb->nonzeropages); + rb->nonzeropages =3D NULL; } =20 return 0; @@ -4102,7 +4137,7 @@ static bool read_ramblock_mapped_ram(QEMUFile *f, RAM= Block *block, host =3D host_from_ram_block_offset(block, offset); if (!host) { error_setg(errp, "page outside of ramblock %s range", - block->idstr); + block->idstr); return false; } =20 @@ -4110,10 +4145,10 @@ static bool read_ramblock_mapped_ram(QEMUFile *f, R= AMBlock *block, =20 if (migrate_multifd()) { read =3D ram_load_multifd_pages(host, size, - block->pages_offset + offset= ); + block->pages_offset + offs= et); } else { read =3D qemu_get_buffer_at(f, host, size, - block->pages_offset + offset); + block->pages_offset + offset); } =20 if (!read) { @@ -4142,7 +4177,6 @@ err: static void parse_ramblock_mapped_ram(QEMUFile *f, RAMBlock *block, ram_addr_t length, Error **errp) { - g_autofree unsigned long *bitmap =3D NULL; MappedRamHeader header; size_t bitmap_size; long num_pages; @@ -4174,15 +4208,18 @@ static void parse_ramblock_mapped_ram(QEMUFile *f, = RAMBlock *block, num_pages =3D length / header.page_size; bitmap_size =3D BITS_TO_LONGS(num_pages) * sizeof(unsigned long); =20 - bitmap =3D g_malloc0(bitmap_size); - if (qemu_get_buffer_at(f, (uint8_t *)bitmap, bitmap_size, + if (qemu_get_buffer_at(f, (uint8_t *)block->nonzeropages, bitmap_size, header.bitmap_offset) !=3D bitmap_size) { error_setg(errp, "Error reading dirty bitmap"); return; } =20 - if (!read_ramblock_mapped_ram(f, block, num_pages, bitmap, errp)) { - return; + if (!migrate_fast_snapshot_load()) { + /* Do not load RAM during setup for fast snapshot load */ + if (!read_ramblock_mapped_ram(f, block, num_pages, block->nonzerop= ages, + errp)) { + return; + } } =20 /* Skip pages array */ @@ -4460,9 +4497,11 @@ static int ram_load(QEMUFile *f, void *opaque, int v= ersion_id) static uint64_t seq_iter; /* * If system is running in postcopy mode, page inserts to host memory = must - * be atomic + * be atomic. However, fast snapshot load uses the mapped ram precopy = like + * path to read block headers and populating bitmaps. */ - bool postcopy_running =3D postcopy_is_running(); + bool load_using_postcopy =3D + postcopy_is_running() && !migrate_fast_snapshot_load(); =20 seq_iter++; =20 @@ -4478,7 +4517,7 @@ static int ram_load(QEMUFile *f, void *opaque, int ve= rsion_id) */ trace_ram_load_start(); WITH_RCU_READ_LOCK_GUARD() { - if (postcopy_running) { + if (load_using_postcopy) { /* * Note! Here RAM_CHANNEL_PRECOPY is the precopy channel of * postcopy migration, we have another RAM_CHANNEL_POSTCOPY to --=20 2.54.0 From nobody Sun Jul 26 12:29:02 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1781752916; cv=none; d=zohomail.com; s=zohoarc; b=U5kr8mHVK7UNh0HUE7/qgWHoZF0kQoK3SfakcWO5eeEprUetURk0yAGc6U75KjJIpuSiqvzti2UvvVkCKvw3IHPFH/tSE6gH7XPqHA8o+0tJJ5Jm+n9l+WYj9wcgdXSobk5xk7XH//U3cZgzzS/0PXwWT0UScvpUvKzpRg+sYNw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781752916; 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=IIe6BJESqe4Ygko+qukm5nUWAzH4BOCtOFcveqmu/ag=; b=SIOx5Zp515CKsGqaDecZOyKlMKupfchV1cW7w1HKxE8jvTuUmRbHjGXl6WEvEX5lFMUP/3nTeBiJhM9SZZMMSHN53ZmGruF4p7erdF28mmpeFl4QxAvguGfNoH7mrgC6t2XHIg1Jag8FjY3BP6OzUfobk8iy7DAxJEvLO31ywn0= 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 1781752916364154.05821526592933; Wed, 17 Jun 2026 20:21:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wa3JY-000895-KY; Wed, 17 Jun 2026 23:21:12 -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 1wa3JW-00088H-TI for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:10 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wa3JV-0002GC-4T for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:10 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-c858961a8efso199206a12.2 for ; Wed, 17 Jun 2026 20:21:08 -0700 (PDT) Received: from setun ([2405:201:502b:3014:cc0c:536:1b1e:6def]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c88c6c2b2easm1534623a12.27.2026.06.17.20.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 20:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781752868; x=1782357668; 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=IIe6BJESqe4Ygko+qukm5nUWAzH4BOCtOFcveqmu/ag=; b=JUyDhlEGygep7mGcb57H+aABTxiro4lmDAHg3n1AJdgVK40lJUoLyzJhGrnGB+JEoO tamaXQyFqgtjO69qUoJHPWx4cxBW5XBiyYaxXEymUkTXJB2t1pcuFEQJAdAJUxze/Zg4 8C5kavUSS2r0ajyVtvfVqiIjy+m949JcbASceFNp4Hn0pTCWzr0uGxh5VKJMtiI2821F lEu/P4cebjwlQF+FRo0QRX+IL4lznVBi2zPa4co25/o/+ddJsn2mLMXvP4EFLYUPHVnA fDgCpXQDfjp71lmuN9aOnh/85+fi3NNiFAhUwuyE6egTC5zvk7iGZ18aM9dMvACrGS0e OGUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781752868; x=1782357668; 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=IIe6BJESqe4Ygko+qukm5nUWAzH4BOCtOFcveqmu/ag=; b=m6z9dQvCBAOEVlVcn2zA89raPg5NqTtQMKL119poNraV8Q7VQfMsnO06yoE3y2qyoK YQIJS7+SYP9kZn/lssp554YRXBdzM/ALiIPOm1FNw3FV3Cg22Kf0xQCZzFMl1koRwsxm hksYiczdXeuT9zYDDSZdPQLVwfnFolIoJrTjk1Y3ww+bseZFexXIhTuEOTkC+55xl3bW 4D645iQvpF2iblb8tx3YohQM9U5sjJ9D+xgNfFlYPUafdAZowzKqopjr/OqeMWmregCM 0tekep46+IC9n1oudhHdE/Ean+8iikRcDsgrUfWOjVWIlHAGDesyiaZ0vhMcvU1QGHgm Ew1w== X-Gm-Message-State: AOJu0Ywh2+P6vDup1k1qmE1JUaUrytxZJDXS6Xl5x4TVGVtq7Jn0Hhcv 2IjjPNenx1ICR6rHjo7/UIsTDt7VO2546FJmzWdhk6Q2VoZu0FnOZJIP0GEMZ6KN X-Gm-Gg: Acq92OGvAXfW4EmfiDVbmiUshQ+nLVzSQz2RMLBEIjuPm5ewul+v0Y3bDvXIZWB2UJw QAeQMk3sMjd9yYva7hZ2RXAGqjtTfhva7zqf/w6mtiIVBLYUFOgFQyN61j82Ve2Opf4mCquxeT7 B21kILoA4Oxkqz2hAjPoOPBLDr9j8TSVAySCsYusgdJWZrGHpM+l3Yhz6cuiZ2+9v+zzn85riNX MLPSbJKjiynmgwYH3tt/n6yaMPgtET/G5zsQQKZ9hjjdsgPcjc8fIMJCO6HhVMPsBcRbu3CCOod WwTtaaaaZVmLgqYGjRd1fkdizbwpdW2LdO1A6AKF7tv6sTb2yN02j8l5DECWhMMiSFRGRj9xvV7 s6n9vp9k45KE9xilbR2f5CZGYGGOV5JlB6FJlOrCG+B8thzizQWDBj+NdVBP/DxzkwhFa3eZ9iq aRcbNuyMVmqzQTEGA5tz4mYN0bRCg9Y5L+PdYZp1LMQw== X-Received: by 2002:a05:6a20:d508:b0:3b4:6265:3786 with SMTP id adf61e73a8af0-3b8b80f48d2mr7214494637.43.1781752867484; Wed, 17 Jun 2026 20:21:07 -0700 (PDT) From: Aadeshveer Singh To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, philmd@mailo.com, lvivier@redhat.com, ayoub@saferwall.com, Aadeshveer Singh Subject: [RFC PATCH 2/5] migration: add support for fault thread to load pages from disk Date: Thu, 18 Jun 2026 08:50:07 +0530 Message-ID: <20260618032010.88755-3-aadeshveer07@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618032010.88755-1-aadeshveer07@gmail.com> References: <20260618032010.88755-1-aadeshveer07@gmail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=aadeshveer07@gmail.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URG_BIZ=0.573 autolearn=no 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 @gmail.com) X-ZM-MESSAGEID: 1781752918902158500 Content-Type: text/plain; charset="utf-8" In fast snapshot load, we would like to serve faults as soon as possible hence loading pages directly instead of requesting a source Add postcopy_mapped_ram_load_page() function which serves single page fault by reading the snapshot file. It uses bitmap_test_and_clear_atomic on pending_bmap to coordinate between threads so each page is loaded exactly once. Non-zero pages are read using qemu_get_buffer_at into a temporary page (for loading page atomically), which is then placed using postcopy_place_page. Zero pages are placed directly using postcopy_place_page_zero. Update postcopy_ram_fault_thread to call postcopy_mapped_ram_load_page instead of requesting source in case of fast snapshot load. to_src_file check is bypassed in fast snapshot load case as there is no source Allocate another channel in postcopy_temp_pages_setup(like the preempt case), for both the fault thread and eager thread to load pages independently. In case of failure to read required page crash the system using assert as disk failure is critical and VM cannot be recovered. Signed-off-by: Aadeshveer Singh --- migration/postcopy-ram.c | 92 ++++++++++++++++++++++++++++++++-------- 1 file changed, 75 insertions(+), 17 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index f5ef93f193..1ec20a07dd 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -949,6 +949,53 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd, pagesize); } =20 +/* + * Load a page from RAMBlock at offset at given host address. + * Used by postcopy ram fault thread and eager thread in fast snapshot load + * case. rb_offset: Offset of page in RAMBlock haddr: Base of page where t= o load + * in page Channel: Used to identify between threads and use corresponding= temp + * pages Returns 0 on success + */ +static int postcopy_mapped_ram_load_page(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t rb_offse= t, + uint64_t haddr, int channel) +{ + int ret =3D 0; + unsigned long page; + void *host =3D (void *)haddr; + void *place_source =3D mis->postcopy_tmp_pages[channel].tmp_huge_page; + size_t read; + + page =3D rb_offset >> TARGET_PAGE_BITS; + + if (bitmap_test_and_clear_atomic(rb->pending_bmap, page, 1)) { + if (test_bit(page, rb->nonzeropages)) { + /* + * qemu_get_buffer_at uses preadv which is thread safe we do n= ot + * need different channels + */ + read =3D qemu_get_buffer_at(mis->from_src_file, place_source, + TARGET_PAGE_SIZE, + rb->pages_offset + rb_offset); + + g_assert(read =3D=3D TARGET_PAGE_SIZE); + + ret =3D postcopy_place_page(mis, host, place_source, rb); + if (ret) { + return ret; + } + + } else { + /* zero page */ + ret =3D postcopy_place_page_zero(mis, host, rb); + if (ret) { + return ret; + } + } + } + return ret; +} + /* * NOTE: @tid is only used when postcopy-blocktime feature is enabled, and * also optional: when zero is provided, the fault accounting will be igno= red. @@ -1320,11 +1367,11 @@ static void *postcopy_ram_fault_thread(void *opaque) break; } =20 - if (!mis->to_src_file) { + if (!migrate_fast_snapshot_load() && !mis->to_src_file) { /* - * Possibly someone tells us that the return path is - * broken already using the event. We should hold until - * the channel is rebuilt. + * Fast snapshot load has no to src file or in other case some= one + * possibly tells us that the return path is broken already us= ing + * the event. We should hold until the channel is rebuilt. */ postcopy_pause_fault_thread(mis); } @@ -1387,18 +1434,26 @@ static void *postcopy_ram_fault_thread(void *opaque) qemu_ram_get_idstr(rb), rb_offset, msg.arg.pagefault.feat.pti= d); + + if (migrate_fast_snapshot_load()) { + if (postcopy_mapped_ram_load_page( + mis, rb, rb_offset, msg.arg.pagefault.address, 1))= { + break; + } + } else { retry: - /* - * Send the request to the source - we want to request one - * of our host page sizes (which is >=3D TPS) - */ - ret =3D postcopy_request_page(mis, rb, rb_offset, - msg.arg.pagefault.address, - msg.arg.pagefault.feat.ptid); - if (ret) { - /* May be network failure, try to wait for recovery */ - postcopy_pause_fault_thread(mis); - goto retry; + /* + * Send the request to the source - we want to request one + * of our host page sizes (which is >=3D TPS) + */ + ret =3D postcopy_request_page(mis, rb, rb_offset, + msg.arg.pagefault.address, + msg.arg.pagefault.feat.ptid); + if (ret) { + /* May be network failure, try to wait for recovery */ + postcopy_pause_fault_thread(mis); + goto retry; + } } } =20 @@ -1471,8 +1526,11 @@ static int postcopy_temp_pages_setup(MigrationIncomi= ngState *mis) unsigned i, channels; void *temp_page; =20 - if (migrate_postcopy_preempt()) { - /* If preemption enabled, need extra channel for urgent requests */ + if (migrate_postcopy_preempt() || migrate_fast_snapshot_load()) { + /* + * If preemption enabled or it is fast snapshot load, need extra c= hannel + * for urgent requests/faults + */ mis->postcopy_channels =3D RAM_CHANNEL_MAX; } else { /* Both precopy/postcopy on the same channel */ --=20 2.54.0 From nobody Sun Jul 26 12:29:02 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1781752917; cv=none; d=zohomail.com; s=zohoarc; b=OuI40P4HnQzMgWS+6LCGRq5PyZavauzktBblu0LcfBlEsfmrzv6j+nDImnX5P6Sd6DXoqsXfQKN6h5fvCK3RJV2OecUkuVaPxzsvhnOr4+nFvo+aoPRlqTqipP1C0feQWclEA7Cv/jlmCclD5xOcJlrgtR1MfF1pAzMAsxMy5Zg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781752917; 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=BZAhkoUSVHRSAGY2Ipy3MCJxg2YtSmIGz0dtg14WcYo=; b=elaFFHJ63UQA8Mzt1mwKEm55lZMb18zRYm2kwcnctn5TMYo3toBozwV4iW1KUSkuCEgcFzi7waTRtQ7xrP6mDJzy7RpvouUel6gzcrkxIMiDS6MN109rfIclodJLG8Y8nzVozMxFFiTqSFLE2suQ9Y0Du9uSfGbUye68TCdqck4= 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 178175291766734.593296695323716; Wed, 17 Jun 2026 20:21:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wa3Jg-0008AN-0r; Wed, 17 Jun 2026 23:21:20 -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 1wa3Je-0008A1-PS for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:18 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wa3Jb-0002IV-Gn for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:18 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-c86307c4e6bso233405a12.0 for ; Wed, 17 Jun 2026 20:21:14 -0700 (PDT) Received: from setun ([2405:201:502b:3014:cc0c:536:1b1e:6def]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c88c6c2b2easm1534623a12.27.2026.06.17.20.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 20:21:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781752873; x=1782357673; 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=BZAhkoUSVHRSAGY2Ipy3MCJxg2YtSmIGz0dtg14WcYo=; b=AESvt/kCF6ham3aZl6hwi3Gn9meL2ynKYN+7c8s8+cfmJhKqRgN50/3wrxw8axxFX2 +y6at1rYIwyC5uMKkhi3cGWTCs5nI9LOxYv2ewh/Gx35OGIiWmz673MqX9oJrwLsZoSn Sw3gQ3Y4uOdJ1zEqWrHnLG9Seku535swsaiBkk6Eimruw2yPNptii0R420mp2u9eFw2H hunFJRBBza7rV02zBUbgivE4ufYZKaYrQpQlUs7JerRxfh4x061xV/srop491dohe3ve SgPFZd/0by3hkK/ugvD0VhNwGngNTTgByy5gEgGer4p0PCkXN0p3aywfndUOAxVzPAKv 8kdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781752873; x=1782357673; 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=BZAhkoUSVHRSAGY2Ipy3MCJxg2YtSmIGz0dtg14WcYo=; b=EKymVdG02ZYJbyaBk593rcj+vmKtLd0lhc08yfaa9ImeA7jFpyhmMENH1DeXtQfmRy +pNI3MukhjOxkjebud9LNlQDtDJbBaSbMgx2ohK48/p3BwYkrOGLjbcZ3WccOSvzKkuY 8ZKBElrEZUUZLHi8tSycwfhexU7G3ljwPg9yin0PrDBTcfleGBj6bKf/aFNwTLh1GuZA pVFC0hTIs+4a+mz3EB28UFWwMhBcjXifgHYYNgHRftCqTziRpjLzoKKr9aRAiGWeo7T+ ehHHNPRpRmeIKZcEfjE5QyNK7LmiP9thRu9ZvKRNhSNO//RpZrfzDIaO8cw4ObSLNVsC IZzA== X-Gm-Message-State: AOJu0YwCXJJq+KLwqTJGOtjpILfFhFiFs98euYamtGB9ZA7E3xWdqeAZ /yFJpZ49fEvx+OQdJYixSiO98uX3ozh8YISeDXvCWgEx3SUblSVs4qn8998pu6Yy X-Gm-Gg: Acq92OG2r9PfsXCLI6+b1qgo+hP/GP4ek2bio86KzB/nLoi7tJtwyYw6WJwxVhJoBS/ KkaH9jsG8/aRcgvVEv6qM/V69Rv2VvR2r8YFOMn2d6MuxwwchIu47NuOrnZT5qbrJpmNUbpOb6F 8JKOmaFjPgcdr7U7RFA3+jtlM8kbiQi4B7GHPIUq/mxtAqjKkRaBno/CkSz6h3Mw2M38SVi6qI4 K66trnIBDLIl+rcuHBuJszMlI8J604x0Rmh/1Mw7gs7ybAEBDRy3ABHiEh9ANMXmsQLDTihMuiQ ARmT01Z2EKfiQ+FpkM+f5rlVrRrLSthYr2rVM/UBRVxMpQIL1aFbWC+maxyj5+uXV28uhgrPr83 0VZKwzObB4Gkiwqf+gfYEWMz9eHbJiDMsET2kGMmKScbfmn5TJo4sjTOjL70HJKHxG29COmR8Hr dpgZXMyVGS9fZY54LTDlZFJv5fHypEnQKYWtvMkyMpbQ== X-Received: by 2002:a05:6a20:2d23:b0:3b2:8685:13e4 with SMTP id adf61e73a8af0-3ba4d7fe75fmr809874637.15.1781752873495; Wed, 17 Jun 2026 20:21:13 -0700 (PDT) From: Aadeshveer Singh To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, philmd@mailo.com, lvivier@redhat.com, ayoub@saferwall.com, Aadeshveer Singh Subject: [RFC PATCH 3/5] migration: add eager load thread for fast snapshot load Date: Thu, 18 Jun 2026 08:50:08 +0530 Message-ID: <20260618032010.88755-4-aadeshveer07@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618032010.88755-1-aadeshveer07@gmail.com> References: <20260618032010.88755-1-aadeshveer07@gmail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=aadeshveer07@gmail.com; helo=mail-pg1-x534.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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 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 @gmail.com) X-ZM-MESSAGEID: 1781752918911158500 Content-Type: text/plain; charset="utf-8" In fast snapshot load a thread is needed for actively loading in pages along with the fault path so that the guest is not dependent on fault thread indefinitely. Add postcopy_ram_eager_load_thread(), for the eager thread which iterates over all non ignored blocks calling ram_block_load_eager() each. ram_block_load_eager then iterates to load in all pages using postcopy_mapped_ram_load_page(), with a different channel, which takes care of not loading in pages already loaded by fault thread. On completion the thread schedules postcopy_ram_eager_load_bh() to destroy the incoming migration state and set states to completed/end. Add postcopy_ram_eager_load_setup() to create the thread. Added joining logic in postcopy_incoming_cleanup(). Add tracepoints for entry and exit to eager load thread. Signed-off-by: Aadeshveer Singh --- migration/migration.h | 5 +++ migration/postcopy-ram.c | 75 ++++++++++++++++++++++++++++++++++++++++ migration/postcopy-ram.h | 2 ++ migration/trace-events | 2 ++ 4 files changed, 84 insertions(+) diff --git a/migration/migration.h b/migration/migration.h index 841f49b215..7bb54a6584 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -42,6 +42,7 @@ #define MIGRATION_THREAD_DST_FAULT "mig/dst/fault" #define MIGRATION_THREAD_DST_LISTEN "mig/dst/listen" #define MIGRATION_THREAD_DST_PREEMPT "mig/dst/preempt" +#define MIGRATION_THREAD_DST_EAGER "mig/dst/eager" =20 struct PostcopyBlocktimeContext; typedef struct ThreadPool ThreadPool; @@ -120,6 +121,10 @@ struct MigrationIncomingState { bool have_listen_thread; QemuThread listen_thread; =20 + /* Thread to load pages eagerly in fast snapshot load case */ + bool have_eager_load_thread; + QemuThread eager_load_thread; + /* For the kernel to send us notifications */ int userfault_fd; /* To notify the fault_thread to wake, e.g., when need to quit */ diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 1ec20a07dd..0ee294a381 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -2289,9 +2289,84 @@ int postcopy_incoming_cleanup(MigrationIncomingState= *mis) mis->have_listen_thread =3D false; } =20 + if (mis->have_eager_load_thread) { + qemu_thread_join(&mis->eager_load_thread); + mis->have_eager_load_thread =3D false; + } + if (migrate_postcopy_ram()) { rc =3D postcopy_ram_incoming_cleanup(mis); } =20 return rc; } + +/* + * Called by postcopy_ram_eager_load_thread over all blocks to load in all= the + * pending pages of given ram block + */ +static int ram_block_load_eager(RAMBlock *rb, void *opaque) +{ + MigrationIncomingState *mis =3D opaque; + void *host =3D qemu_ram_get_host_addr(rb); + void *target; + int ret =3D 0; + + for (ram_addr_t page_loc =3D 0; page_loc < rb->used_length; + page_loc +=3D TARGET_PAGE_SIZE) { + target =3D (uint8_t *)host + page_loc; + ret =3D postcopy_mapped_ram_load_page(mis, rb, page_loc, (uint64_t= )target, + 0); + if (ret) { + break; + } + } + return ret; +} + +/* + * Bottom half for fast snapshot load, scheduled by eager load thread + */ +static void postcopy_ram_eager_load_bh(void *opaque) +{ + MigrationIncomingState *mis =3D opaque; + postcopy_state_set(POSTCOPY_INCOMING_END); + migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, + MIGRATION_STATUS_COMPLETED); + migration_incoming_state_destroy(); +} + +/* + * Used by fast snapshot load to eagerly load in all pages of RAM and sche= dule + * cleanup after entire RAM is loaded + */ +static void *postcopy_ram_eager_load_thread(void *opaque) +{ + MigrationIncomingState *mis =3D opaque; + + trace_postcopy_ram_eager_load_thread_entry(); + rcu_register_thread(); + qemu_event_set(&mis->thread_sync_event); + + if (foreach_not_ignored_block(ram_block_load_eager, mis)) { + error_report("ram_block_load_eager failed"); + } + + migration_bh_schedule(postcopy_ram_eager_load_bh, mis); + + rcu_unregister_thread(); + trace_postcopy_ram_eager_load_thread_exit(); + return NULL; +} + +/* + * Create thread for eager loading in fast snapshot load case + */ +int postcopy_ram_eager_load_setup(MigrationIncomingState *mis) +{ + postcopy_thread_create( + mis, &mis->eager_load_thread, MIGRATION_THREAD_DST_EAGER, + postcopy_ram_eager_load_thread, QEMU_THREAD_JOINABLE); + mis->have_eager_load_thread =3D true; + return 0; +} diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index a080dd65a7..b3ba42e447 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -202,4 +202,6 @@ void mark_postcopy_blocktime_begin(uintptr_t addr, uint= 32_t ptid, int postcopy_incoming_setup(MigrationIncomingState *mis, Error **errp); int postcopy_incoming_cleanup(MigrationIncomingState *mis); =20 +int postcopy_ram_eager_load_setup(MigrationIncomingState *mis); + #endif diff --git a/migration/trace-events b/migration/trace-events index de99d976ab..38f11e1e9f 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -314,6 +314,8 @@ postcopy_blocktime_tid_cpu_map(int cpu, uint32_t tid) "= cpu: %d, tid: %u" postcopy_blocktime_begin(uint64_t addr, uint64_t time, int cpu, bool exist= s) "addr: 0x%" PRIx64 ", time: %" PRIu64 ", cpu: %d, exist: %d" postcopy_blocktime_end(uint64_t addr, uint64_t time, int affected_cpu, int= affected_non_cpus) "addr: 0x%" PRIx64 ", time: %" PRIu64 ", affected_cpus:= %d, affected_non_cpus: %d" postcopy_blocktime_end_one(int cpu, uint8_t left_faults) "cpu: %d, left_fa= ults: %" PRIu8 +postcopy_ram_eager_load_thread_entry(void) "" +postcopy_ram_eager_load_thread_exit(void) "" =20 # exec.c migration_exec_outgoing(const char *cmd) "cmd=3D%s" --=20 2.54.0 From nobody Sun Jul 26 12:29:02 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1781752916; cv=none; d=zohomail.com; s=zohoarc; b=hlSIazGFsC58atLhxbD+w932fuk+wr6YjsvBVVYUn/W+4JthldbAmO6qU8mHXYEEam+pzH0nQa50igP4gAlmAMaBXQdS/XagiDxQgabf0YrROLhLj5ql6TF0LStOZvyT5dKzIplhE03xmzpv2pTmksy+rZ82YdL+P5zQsFH5ihU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781752916; 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=HktabLtwsgOICpypiuiSex0ShyKn6VFTpFu0belFXIM=; b=R2DtN0/7lhZiPUtHchwxOqkTYI5a+fsc4i6Pi0y57o/IuRd5P2LyjtLupAygLpbQ1isKFFhK+Br3qhxkKuGmEHVP2sZv2c1XHuaLgMaoqwZabYXrM8tV/8vtjpztS5CiW1180xJT4bnprqZSup7+CmHUjNf/FQsXP7lL2GvyQ5s= 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 178175291656387.66410029284134; Wed, 17 Jun 2026 20:21:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wa3Jk-0008B6-2X; Wed, 17 Jun 2026 23:21:24 -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 1wa3Ji-0008Aj-FJ for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:22 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wa3Jg-0002JN-ON for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:22 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-c88a4d79ba5so318725a12.2 for ; Wed, 17 Jun 2026 20:21:20 -0700 (PDT) Received: from setun ([2405:201:502b:3014:cc0c:536:1b1e:6def]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c88c6c2b2easm1534623a12.27.2026.06.17.20.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 20:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781752879; x=1782357679; 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=HktabLtwsgOICpypiuiSex0ShyKn6VFTpFu0belFXIM=; b=VPPbGQtVlksLWH/Q7e/KFuIQkckt7I+Rwfpq3aqFVZ27usOzIuEOLgMD4gpQ6uit7q XTTk3TQ22TJJlZnGM/wstXuwDu+Ao0tdw96kIyDXkd1jpF8fubpWjeUefOqocHkMchoX PHeU+cQp0iee8hAJ117eMsD8TmvTOfJcBYPkBSkIfjHf6d8/c+ZuA4R+DLz1UFx7OPPN lcFPxxqwTggA76SVsj9cGuWiwqe5b1I+it07fKo0UE0hraZ0123tqdDPn6wjVutdg736 49SMU1GEreVDxiUprRMt3taz19MfohXUGgQDI2qG7Lw1t395wb9fw8zvrZEnxjPYfDL+ N/eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781752879; x=1782357679; 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=HktabLtwsgOICpypiuiSex0ShyKn6VFTpFu0belFXIM=; b=iLc9OPUxjmbbisRhKuhfe1CiOvsHaYuWxI9NaqDgH3YSV1PPaiXvVcJ/F7AgUqRexK the2cadq2O+zrXSWjSqifbxLMYw/hbgMSHVuvCI4+i33/1mAzUsGNqjFHASZepwcormj ZrT6gxuYbNY7BQ98SRYMz5mdSIRCJwuWCHXGauoRdo536PBn8iF10rsm8Sk7oOs0rDY4 LYdJxE2sVQ+6OzezSx9lpRL3pOJ2H7TYY3+PlYAYW9l7NsNv38Ipzc7BJZdoB5meOpLh Ug3OOV1bhLBSPeYVlx7tQRBLHCd5/Ql34d7SOc6S1lqwocmJ08EetI2FNGiLO+QUdcQs MYAg== X-Gm-Message-State: AOJu0YyXW4YTJR1fLb1PSrWecqom4p3IhQ8fyeHp7rETcl/nLpixi5zc r93X2VBhwZ871XTTHvqlvZe4jMYh2Eb6pRKfv5Ty6v1Pb/ORN9eL63FWFzz2YJfP X-Gm-Gg: Acq92OFz1LWusCcqR/5QwHOxbuZ66N/1w3fUGnmML1j1JFZHUYRG7G08ErjsdvQSCyf huaKY5XKZPr+Km8Hx+b8UyN29mDTsgcIvMpsflf8xK1SBnw+2t8utZfrFp0lsyFyyDBIZvUiXce 3SR6JzdIC/N5j//Hc9wh0E16rgdGH463mWsBsejgagyF8Cs+QoLkjpQKVL/ent5sr859YQucikC kZQWOIghio0KPANPAxCMidVGDTsuvfEsU85V80i4v0qnm3jv8Kh9ZAZ27v+V+K/aswvdPef5qkV Bp3cM0P8FQlTjLCR182AQrEhdJ+XtnDoQIoj7vEZ2SvmGGUhN4BTI3xV3czbMPttSsLfaNzfv2x VA/9Kg+fRlNJ+9IDxJBu2hvpIb6o8s7GYJDrp93Ti+L+Ooz451rpBmPwvW1p48DRAOLLX7f4fIs 0uDHsBxhWUIr+Dcqd0OHkoMB9rzcS48dcHtvz3UFZrbfr/MKYf4CeM X-Received: by 2002:a05:6a20:3d10:b0:39f:a42:9247 with SMTP id adf61e73a8af0-3b8bf4e2a25mr7680476637.37.1781752879441; Wed, 17 Jun 2026 20:21:19 -0700 (PDT) From: Aadeshveer Singh To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, philmd@mailo.com, lvivier@redhat.com, ayoub@saferwall.com, Aadeshveer Singh Subject: [RFC PATCH 4/5] migration: write up code to run fast snapshot load in qemu_loadvm_state Date: Thu, 18 Jun 2026 08:50:09 +0530 Message-ID: <20260618032010.88755-5-aadeshveer07@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618032010.88755-1-aadeshveer07@gmail.com> References: <20260618032010.88755-1-aadeshveer07@gmail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=aadeshveer07@gmail.com; helo=mail-pg1-x52a.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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 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 @gmail.com) X-ZM-MESSAGEID: 1781752918913158500 Content-Type: text/plain; charset="utf-8" When both mapped-ram and postcopy-ram are set, divert from qemu_loadvm_state to run fast snapshot load Initialize postcopy RAM state and register RAM Blocks with userfaultfd via ram_postcopy_incoming_init() and postcopy_ram_incoming_setup(). Launch fault thread before VM to serve faults for some hardwares emulation that need to read RAM (like vapic devices). Populate bitmaps and offset tables while reading file in qemu_loadvm_state_main. Call to qemu_loadvm_state_postcopy() which starts the VM using loadvm_postcopy_handle_run_bh() and launches eager load thread. Skip scheduling process_incoming_migration_bh() in process_incoming_migration_co(), for fast snapshot load as the state cleanup is managed by eager load thread on completion. Skip setting migration status to ACTIVE in process_incoming_migration_co and set set it to POSTCOPY_DEVICE in qemu_loadvm_state() itself. Remove the capability check that rejected mapped-ram and postcopy-ram being set simultaneously, as this combination now corresponds to fast snapshot load. The corresponding test will be updated in following patch. Signed-off-by: Aadeshveer Singh --- migration/migration.c | 10 ++++++--- migration/options.c | 6 ----- migration/savevm.c | 52 +++++++++++++++++++++++++++++++++++++++++-- migration/savevm.h | 2 ++ 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 074d3f2c69..e1ac310e20 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -756,8 +756,10 @@ process_incoming_migration_co(void *opaque) =20 mis->largest_page_size =3D qemu_ram_pagesize_largest(); postcopy_state_set(POSTCOPY_INCOMING_NONE); - migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP, - MIGRATION_STATUS_ACTIVE); + if (!migrate_fast_snapshot_load()) { + migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_ACTIVE); + } =20 mis->loadvm_co =3D qemu_coroutine_self(); ret =3D qemu_loadvm_state(mis->from_src_file, &local_err); @@ -786,7 +788,9 @@ process_incoming_migration_co(void *opaque) colo_incoming_co(); } =20 - migration_bh_schedule(process_incoming_migration_bh, mis); + if (!migrate_fast_snapshot_load()) { + migration_bh_schedule(process_incoming_migration_bh, mis); + } goto out; =20 fail: diff --git a/migration/options.c b/migration/options.c index 5f80dd5b42..3f447cf7b2 100644 --- a/migration/options.c +++ b/migration/options.c @@ -732,12 +732,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps= , Error **errp) "Mapped-ram migration is incompatible with xbzrle"); return false; } - - if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { - error_setg(errp, - "Mapped-ram migration is incompatible with postcopy= "); - return false; - } } =20 /* diff --git a/migration/savevm.c b/migration/savevm.c index 23adaf9dd9..f10cc3c2fc 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2959,6 +2959,32 @@ static bool postcopy_pause_incoming(MigrationIncomin= gState *mis) return true; } =20 +/* + * Starts the VM and launches the eager thread for fast snapshot load + */ +int qemu_loadvm_state_postcopy(QEMUFile *f, MigrationIncomingState *mis, + Error **errp) +{ + ERRP_GUARD(); + int ret =3D 0; + + postcopy_state_set(POSTCOPY_INCOMING_RUNNING); + + migration_bh_schedule(loadvm_postcopy_handle_run_bh, mis); + + migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_DEVICE, + MIGRATION_STATUS_POSTCOPY_ACTIVE); + + ret =3D postcopy_ram_eager_load_setup(mis); + if (ret) { + error_prepend(errp, + "Failed to setup eager load for fast snapshot load: = "); + return ret; + } + + return ret; +} + int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, Error **errp) { @@ -3067,8 +3093,30 @@ int qemu_loadvm_state(QEMUFile *f, Error **errp) =20 cpu_synchronize_all_pre_loadvm(); =20 - ret =3D qemu_loadvm_state_main(f, mis, errp); - qemu_event_set(&mis->main_thread_load_event); + if (migrate_fast_snapshot_load()) { + migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_POSTCOPY_DEVICE); + + if (ram_postcopy_incoming_init(mis, errp)) { + return -EINVAL; + } + + postcopy_state_set(POSTCOPY_INCOMING_LISTENING); + if (postcopy_ram_incoming_setup(mis)) { + return -EINVAL; + } + + ret =3D qemu_loadvm_state_main(f, mis, errp); + + qemu_event_set(&mis->main_thread_load_event); + + if (ret =3D=3D 0) { + ret =3D qemu_loadvm_state_postcopy(f, mis, errp); + } + } else { + ret =3D qemu_loadvm_state_main(f, mis, errp); + qemu_event_set(&mis->main_thread_load_event); + } =20 trace_qemu_loadvm_state_post_main(ret); =20 diff --git a/migration/savevm.h b/migration/savevm.h index 96fdf96d4e..9656acd7fe 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -67,6 +67,8 @@ void qemu_savevm_send_postcopy_ram_discard(QEMUFile *f, c= onst char *name, int qemu_save_device_state(QEMUFile *f, Error **errp); int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(MigrationIncomingState *mis); +int qemu_loadvm_state_postcopy(QEMUFile *f, MigrationIncomingState *mis, + Error **errp); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, Error **errp); int qemu_load_device_state(QEMUFile *f, Error **errp); --=20 2.54.0 From nobody Sun Jul 26 12:29:02 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1781752905; cv=none; d=zohomail.com; s=zohoarc; b=BLn3xYsFJVIsdZwSvHP3SUTWwHAHeTOXmzklES6zIFFr5O1WxEIZzXZFIisZ2UlzbPenl6F/n3xOaBmunBIFFXzIOK5ZkX9R48dNYxTVwN0hSi8ml1dcqFBvrrI7qDgN2z0k9GJYJFl0SwqdMjZol18kzehCv7gPCA2Y4TSiOho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781752905; 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=goi3dasaBf+1cFBZYCdvkL7YmSmIDj5gtvrwJACDgTs=; b=Px4Hra+YBnAIUVLE5nXeXyjzXCwmYGjj8ZWWpuqvGaQ1RyfZzRwLnNytX06vUXyTxrGSdzid4OVut8E/gnl+cbcSJT+9iVWgaZHmiTsNOW6/0F/fAQ1UM1Bb70VMYMRtw0Y3IKQCg4VHazFuwP1Zke23dc2iIHqUyomzKw5gBCM= 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 1781752905112859.4334299900256; Wed, 17 Jun 2026 20:21:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wa3Jq-0008BZ-RC; Wed, 17 Jun 2026 23:21:30 -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 1wa3Jo-0008BR-CH for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:28 -0400 Received: from mail-pg1-x536.google.com ([2607:f8b0:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wa3Jm-0002Ji-QS for qemu-devel@nongnu.org; Wed, 17 Jun 2026 23:21:28 -0400 Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-c8897045525so281699a12.0 for ; Wed, 17 Jun 2026 20:21:26 -0700 (PDT) Received: from setun ([2405:201:502b:3014:cc0c:536:1b1e:6def]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c88c6c2b2easm1534623a12.27.2026.06.17.20.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 20:21:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781752885; x=1782357685; 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=goi3dasaBf+1cFBZYCdvkL7YmSmIDj5gtvrwJACDgTs=; b=Fpa9EmktUCZe7x2pDysjXixklxaN+Qzm/Dp3Wmr2eCT61rlqCaL0NwD8VwlJ4LMScg DjiT2mQhCr1G1BRjzYzNhlm8cDUm0X73uUX5wDK1o54+6PpM7g2m+UdFIUzZ/OvgXqJm 6lP4s+s3a5YiDZgz0S7KxBZd1b1nloU5EUeiFhKosU6LelpOUtrFfDBmf2/X716ygD8f 888tQ9cWpcn0l678pfX9ZbKbjYErnO4qdLw6neQGAdilSC0gwuf0wSTjVT+KO/qSw3qW zeIx0pzChG984LEr5evJJRmxu7s8lIu9jhSlBrH80LwG3g3srfE77uNPPmeSHQd7gtGZ 7Vnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781752885; x=1782357685; 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=goi3dasaBf+1cFBZYCdvkL7YmSmIDj5gtvrwJACDgTs=; b=dbAlAFsT8imPr08UHZdPX9oPKZmteyNHgIrsYCEm41IudmRSq71CpaUlgnykHoHTg7 PLIXhSyPCW0N1r06EDMHKcedenH3zJ3QIgKi78TCjTMd+ieUZxm8YGXgKJbEt0XjYQHz j/Ho7K9mrn86idkeLOqH1ZiSRjPguD32EPnVKrCSl1Nn4A64yBre+IKc/vMVPyJJoRXE H2ucY/H8MFjYQfK1Wygh6/inKqhtKCcadmCPjLRJGje8+m/ofsabgZBZafVLGqiNjNAX OWknt4RSCrhv8/lPaFsttbFkLdrRCxY0LRhCqyRLit72Nas3HqcOqQ0KsTKMexI/JC9I RhhA== X-Gm-Message-State: AOJu0YxWh3yQrZu8wg19tXBnNoXnrdKX54zGL507ZXo/oGcAhIWX4ouJ 9vEGMbVi1CLAqgPJawb36l/nn4LpDaP0uUNWXUEqF2S5BqUg928dR0LN8ogJqFze X-Gm-Gg: Acq92OF+ixEgj34wItevva1YSJ3hf3mhtyjsWgdu9Cx4IjLWFI2AinoD1UoT4ElB+Zm PifkM+Dz5dZBN5JWBmLna0EfodysPGKrBR6Ru56Neak4gL8nKE+Om4mVmi6QbqZL3hgFIdjXycD o46LAMkQAVjwdc5VXagNITPVEe34NQDsZZOsXtXbpQOikRXslZz7ekv8BHmfXwELYWLO1zoMNss V4SrdiXyDQn9VJ9PmhBW2ThPeJKKs5i/HgtjKOVw+ROApzz2IqsbOfsGBTYLZV1vVo9YLRzkImW jAAHf+Xl9kXJ1uzpPTuNw8MeDWWg04EZg/YP24OlyRW/OxbzAVkjInfFhwfHqw5BMawy7OYNVQy VbImXMGhGa/oajcWsc5lcgMWSyxmMfJPNO03tJl5HFL3I9DfdxkJeimVaHzKbeIPtUWqOOwgWYf 4S5UdOe8M1UnGEj6wEkEfJF8bfzvF41nAp/E4GlKNqWQ== X-Received: by 2002:a05:6a21:1645:b0:398:90e5:a9b9 with SMTP id adf61e73a8af0-3b8be9aead5mr7505071637.27.1781752885499; Wed, 17 Jun 2026 20:21:25 -0700 (PDT) From: Aadeshveer Singh To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, pbonzini@redhat.com, philmd@mailo.com, lvivier@redhat.com, ayoub@saferwall.com, Aadeshveer Singh Subject: [RFC PATCH 5/5] migration/tests: remove capability conflict test postcopy-ram+mapped-ram Date: Thu, 18 Jun 2026 08:50:10 +0530 Message-ID: <20260618032010.88755-6-aadeshveer07@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618032010.88755-1-aadeshveer07@gmail.com> References: <20260618032010.88755-1-aadeshveer07@gmail.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=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::536; envelope-from=aadeshveer07@gmail.com; helo=mail-pg1-x536.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, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, 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 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 @gmail.com) X-ZM-MESSAGEID: 1781752906631158500 Content-Type: text/plain; charset="utf-8" Remove the test test_validate_caps_pair, which asserted postcopy-ram and mapped-ram capabilities cannot be active together. The new fast snapshot load feature is exactly this pair of capabilities active together, with the previous patches in this series, this combination is now supported and functional. No replacement test for fast snapshot load is included in this RFC. A test exercising the full save/load flow will be added in a follow-up. Signed-off-by: Aadeshveer Singh --- tests/qtest/migration/misc-tests.c | 52 ------------------------------ 1 file changed, 52 deletions(-) diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/mis= c-tests.c index ec6d438cdc..4e0deb7f18 100644 --- a/tests/qtest/migration/misc-tests.c +++ b/tests/qtest/migration/misc-tests.c @@ -201,55 +201,6 @@ static void do_test_validate_uri_channel(MigrateCommon= *args) migrate_end(from, to, false); } =20 -static void validate_caps_pair(QTestState *from, - const char *first_capability, - const char *second_capability, - const char *expected_error) -{ - QDict *rsp; - const char *error_desc; - - migrate_set_capability(from, first_capability, true); - - rsp =3D qtest_qmp_assert_failure_ref( - from, - "{ 'execute': 'migrate-set-capabilities'," - " 'arguments': { 'capabilities': [ { " - " 'capability': %s, 'state': true } ] } }", - second_capability); - - error_desc =3D qdict_get_str(rsp, "desc"); - g_assert_cmpstr(error_desc, =3D=3D, expected_error); - qobject_unref(rsp); - - migrate_set_capability(from, first_capability, false); -} - -static void test_validate_caps_pair(char *test_path, MigrateCommon *args) -{ - g_autofree char *serial_path =3D g_strconcat(tmpfs, "/src_serial", NUL= L); - g_autofree char *cap_pair =3D g_path_get_basename(test_path); - QTestState *from, *to; - - args->start.hide_stderr =3D true; - args->start.only_source =3D true; - - if (migrate_start(&from, &to, &args->start)) { - return; - } - - if (g_str_equal(cap_pair, "mapped_ram_postcopy")) { - const char *error =3D - "Mapped-ram migration is incompatible with postcopy"; - - validate_caps_pair(from, "mapped-ram", "postcopy-ram", error); - validate_caps_pair(from, "postcopy-ram", "mapped-ram", error); - } - - qtest_quit(from); - unlink(serial_path); -} - static void test_validate_uri_channels_both_set(char *name, MigrateCommon = *args) { args->uri =3D "tcp:127.0.0.1:0", @@ -309,7 +260,4 @@ void migration_test_add_misc(MigrationTestEnv *env) test_validate_uri_channels_both_set); migration_test_add("/migration/validate_uri/channels/none_set", test_validate_uri_channels_none_set); - migration_test_add_suffix("/migration/validate_caps/", - "mapped_ram_postcopy", - test_validate_caps_pair); } --=20 2.54.0