From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754742; cv=none; d=zohomail.com; s=zohoarc; b=XW1Vyr+N9sy44n2kEH1SXki7kNLFN1KZRX31EUkGMZlkK3pQCJPEvmA8ZOTlyjju8R8ex58nMvWsAxjE2/thwwqO0w08gY33JLtut4rWR9NXqE/l1R8ub/WkdvGxZnTh1DHBs0k/xC7+aGntJNlMsxYvVUpoaOHkJ2Jyic3F2ns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754742; 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=3RWZvgUuba1ly+5mbsdaLDsGlIp3+oJgpWbcXQM0UqA=; b=QzpiyXjzeS09MjcDRS9wqnnEJsExrVfJrEiHgPPDR4FAoVaLbemvXT04OVxByzofg/MKgIDD4ptHP1tKpxgdmNg9Xssp8H00eNW+MVYb8UcfYox5+Zp9a1SGz97DXaHp39JWlm9naO6nEswkcSnXFW5LP7FU/w1DYxeYEQlrfRk= 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 1787754742560970.9179954421886; Wed, 26 Aug 2026 07:32:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEd6-00015u-NW; Wed, 26 Aug 2026 10:29:28 -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 1wzEd3-00014c-5A for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:25 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd0-0001Qr-75 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:24 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9AD0921202; Wed, 26 Aug 2026 14:29:10 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7E6E41361C; Wed, 26 Aug 2026 14:29:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id EG/5EzX4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754554; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3RWZvgUuba1ly+5mbsdaLDsGlIp3+oJgpWbcXQM0UqA=; b=fHJ86Cj7aEXqCKMnjaDdN1Y1JbOVgpYtw4LLhLJaTrxlgRFcHOpSU9qFl18T0Y8FRkafS3 DxdU4NiYQHRYoCDcWHcsOxxeYvFQlvVUGSDbKoXAx6RKOUkGY7rdjH6sHPu0BBc0jBEOKb /LLUHcOGBf/Tpaf0iNpbiuNgysbw8DA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754554; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3RWZvgUuba1ly+5mbsdaLDsGlIp3+oJgpWbcXQM0UqA=; b=IxBmaaw7lcYwei83P5dVahzMKjk1mJOdx4mBF3zmGIP0aLoSOxE2IwT84POSrO5r4Kpd8D KGj7vl5EVOrYFvAg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=hq2pOURT; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=7+ffzkZ7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754550; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3RWZvgUuba1ly+5mbsdaLDsGlIp3+oJgpWbcXQM0UqA=; b=hq2pOURT+okRaqwlh4wjwTTraboSnFO1EMpmb5fJrh3IdL54tTTdaoTkUzr1kHfjS9XsU9 fhHXkbmcnYx+gdDp7e4Bsnt7/vV0SZGk4kV6lk6oQN2bAsLqq8mk2LeQ945Ulxz6gMAC8U NrmxS3/Qw3e9oEFdqbQmfo7vKJyB1kY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754550; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3RWZvgUuba1ly+5mbsdaLDsGlIp3+oJgpWbcXQM0UqA=; b=7+ffzkZ7KpvEXWOEFTxIQ5X9BvPTliomlkWthKscHXiWayJJ+8EvgCxPpL5R3Hl/4Ag31o Co2daDGp2Rxb36BA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh , Juraj Marcin Subject: [PULL 01/30] migration: Propagate error in postcopy setup functions Date: Wed, 26 Aug 2026 11:28:36 -0300 Message-ID: <20260826142905.2315503-2-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 9AD0921202 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[4]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754744257158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Modernize error handling in postcopy_ram_incoming_setup() and postcopy_temp_pages_setup() by replacing error_reports and local error handling with standard Error propagation. Replace use of strerror() on errno with error_setg_errno() for modular handling of errors and change return values to -1 on failure as no caller checks the actual return value. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/postcopy-ram.c | 43 +++++++++++++++++----------------------- migration/postcopy-ram.h | 2 +- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index a3314d3180d..120828a2ead 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1462,10 +1462,9 @@ retry: return NULL; } =20 -static int postcopy_temp_pages_setup(MigrationIncomingState *mis) +static int postcopy_temp_pages_setup(MigrationIncomingState *mis, Error **= errp) { PostcopyTmpPage *tmp_page; - int err; unsigned i, channels; void *temp_page; =20 @@ -1485,11 +1484,11 @@ static int postcopy_temp_pages_setup(MigrationIncom= ingState *mis) temp_page =3D mmap(NULL, mis->largest_page_size, PROT_READ | PROT_= WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (temp_page =3D=3D MAP_FAILED) { - err =3D errno; - error_report("%s: Failed to map postcopy_tmp_pages[%d]: %s", - __func__, i, strerror(err)); + error_setg_errno(errp, errno, + "%s: Failed to map postcopy_tmp_pages[%d]", + __func__, i); /* Clean up will be done later */ - return -err; + return -1; } tmp_page->tmp_huge_page =3D temp_page; /* Initialize default states for each tmp page */ @@ -1503,11 +1502,10 @@ static int postcopy_temp_pages_setup(MigrationIncom= ingState *mis) PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (mis->postcopy_tmp_zero_page =3D=3D MAP_FAILED) { - err =3D errno; mis->postcopy_tmp_zero_page =3D NULL; - error_report("%s: Failed to map large zero page %s", - __func__, strerror(err)); - return -err; + error_setg_errno(errp, errno, "%s: Failed to map large zero page", + __func__); + return -1; } =20 memset(mis->postcopy_tmp_zero_page, '\0', mis->largest_page_size); @@ -1515,15 +1513,13 @@ static int postcopy_temp_pages_setup(MigrationIncom= ingState *mis) return 0; } =20 -int postcopy_ram_incoming_setup(MigrationIncomingState *mis) +int postcopy_ram_incoming_setup(MigrationIncomingState *mis, Error **errp) { - Error *local_err =3D NULL; - /* Open the fd for the kernel to give us userfaults */ mis->userfault_fd =3D uffd_open(O_CLOEXEC | O_NONBLOCK); if (mis->userfault_fd =3D=3D -1) { - error_report("%s: Failed to open userfault fd: %s", __func__, - strerror(errno)); + error_setg_errno(errp, errno, "%s: Failed to open userfault fd", + __func__); return -1; } =20 @@ -1531,8 +1527,7 @@ int postcopy_ram_incoming_setup(MigrationIncomingStat= e *mis) * Although the host check already tested the API, we need to * do the check again as an ABI handshake on the new fd. */ - if (!ufd_check_and_apply(mis->userfault_fd, mis, &local_err)) { - error_report_err(local_err); + if (!ufd_check_and_apply(mis->userfault_fd, mis, errp)) { return -1; } =20 @@ -1544,8 +1539,8 @@ int postcopy_ram_incoming_setup(MigrationIncomingStat= e *mis) /* Now an eventfd we use to tell the fault-thread to quit */ mis->userfault_event_fd =3D eventfd(0, EFD_CLOEXEC); if (mis->userfault_event_fd =3D=3D -1) { - error_report("%s: Opening userfault_event_fd: %s", __func__, - strerror(errno)); + error_setg_errno(errp, errno, "%s: Opening userfault_event_fd", + __func__); close(mis->userfault_fd); return -1; } @@ -1557,12 +1552,11 @@ int postcopy_ram_incoming_setup(MigrationIncomingSt= ate *mis) =20 /* Mark so that we get notified of accesses to unwritten areas */ if (foreach_not_ignored_block(ram_block_enable_notify, mis)) { - error_report("ram_block_enable_notify failed"); + error_setg(errp, "ram_block_enable_notify failed"); return -1; } =20 - if (postcopy_temp_pages_setup(mis)) { - /* Error dumped in the sub-function */ + if (postcopy_temp_pages_setup(mis, errp)) { return -1; } =20 @@ -1727,7 +1721,7 @@ int postcopy_request_shared_page(struct PostCopyFD *p= cfd, RAMBlock *rb, g_assert_not_reached(); } =20 -int postcopy_ram_incoming_setup(MigrationIncomingState *mis) +int postcopy_ram_incoming_setup(MigrationIncomingState *mis, Error **errp) { g_assert_not_reached(); } @@ -2199,9 +2193,8 @@ int postcopy_incoming_setup(MigrationIncomingState *m= is, Error **errp) * shouldn't be doing anything yet so don't actually expect requests */ if (migrate_postcopy_ram()) { - if (postcopy_ram_incoming_setup(mis)) { + if (postcopy_ram_incoming_setup(mis, errp)) { postcopy_ram_incoming_cleanup(mis); - error_setg(errp, "Failed to setup incoming postcopy RAM blocks= "); return -1; } } diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index a080dd65a77..98d918713f5 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -23,7 +23,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingStat= e *mis, * Make all of RAM sensitive to accesses to areas that haven't yet been wr= itten * and wire up anything necessary to deal with it. */ -int postcopy_ram_incoming_setup(MigrationIncomingState *mis); +int postcopy_ram_incoming_setup(MigrationIncomingState *mis, Error **errp); =20 /* * Initialise postcopy-ram, setting the RAM to a state where we can go into --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754691; cv=none; d=zohomail.com; s=zohoarc; b=fIFxq7XWT8E+mHaD9BpqMqFbH+HeveA0KJUaZmF4STWfBjpyH+jTcqHRmlAeMmqaE4MH7IpvxLKfAeHB7Vi4RMXNegdokeUcalc0onpOP2PFaxLZ9AK8NcqfynyGCdMHh2I54Kqs4fAj82AiSbnLmUuOyI+I2sQjhi61KEKmTho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754691; 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=ewaRFj4nvWUr8moe8ioeqzVqPOi9UFniYimbaeaZ+qs=; b=fOMKeShUB6kYppNuH6wpeCgptgZv1aiLkWCEVLTPr4BhSjadXqkI18mMLg/6SLgE5EzZ7CmrUni6jpR3n1OuJwXc3tRFWmEIIIWkV9vCJnx2bDSAkP7DWZZ+YG2QMOqx+oH6wCDij/po4zpp6qTu67N1kTM4QWUO4/FVBeNjzFM= 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 1787754691611571.7772741036518; Wed, 26 Aug 2026 07:31:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEd4-00015M-VO; Wed, 26 Aug 2026 10:29:26 -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 1wzEd3-00014a-1d for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:25 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd0-0001S3-8T for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:24 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1CE1F2121A; Wed, 26 Aug 2026 14:29:12 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id F0A891364A; Wed, 26 Aug 2026 14:29:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OGfqLzb4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ewaRFj4nvWUr8moe8ioeqzVqPOi9UFniYimbaeaZ+qs=; b=tpq5X3xaJMmFO6BLV6muGjZHNHvOoDsdNQXagddoFcy14qjQVGZYZQTVZMBgq2uP+ADXIK iAvUrmSvzRWkIazb1B6gWVVFpg8xye1r8LMrM4jPts/Q3gsnBxXFFzzG5PRrwxQSyzbayv YPVuq7UcBCz1hLJPqAJW0VxNe0frg2k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754556; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ewaRFj4nvWUr8moe8ioeqzVqPOi9UFniYimbaeaZ+qs=; b=tWEsFAMx0lRbs5BHEsNCcd0U9L7IKgiD1uPM4gPXRIlYYQ+f2i8w8sKAX01bXTgJJV2hEy dyOQmX9ZiBuSJmDQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=NxP15OWF; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=YR1sLmzI DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754552; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ewaRFj4nvWUr8moe8ioeqzVqPOi9UFniYimbaeaZ+qs=; b=NxP15OWFb8l02CEAkBZfXdhvpVtptgyIJWbwfIxL/EIYzte74bWqD+4CT0yh8FUnvlQNHo dk0JsvosMPuK1+RuGWZIIAwcoT1FBfQyoKsC7E2PxFgvwOkzdPODey+7KXWtT1gmYR3IL6 7Dk6TZdsOaQL3+TxgFvic2emTzVx1wY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754552; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ewaRFj4nvWUr8moe8ioeqzVqPOi9UFniYimbaeaZ+qs=; b=YR1sLmzIpQ6dBleYP5+mZZ1X+rc2MuCmt9hN4gYh30D805ef8Eb8IHW5gJuWP6PClq1yQy gJr4sNT5fycYNcCQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh , Juraj Marcin Subject: [PULL 02/30] migration: Extract blocktime marking helper Date: Wed, 26 Aug 2026 11:28:37 -0300 Message-ID: <20260826142905.2315503-3-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 1CE1F2121A X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[4]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754694134158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Use new function try_mark_postcopy_blocktim_begin() to call mark_postcopy_blocktime_begin if page was not received and return if it actually marked it. This will help in having a cleaner API to call mark_postcopy_blocktime_begin as it requires the page to not be received by asserting on it's existance in RAMBlock->receivedmap. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/migration.c | 24 ++---------------------- migration/postcopy-ram.c | 39 +++++++++++++++++++++++++++++++++++++++ migration/postcopy-ram.h | 3 +++ 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 9df6da131ce..a30779f37c8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -577,32 +577,12 @@ int migrate_send_rp_req_pages(MigrationIncomingState = *mis, RAMBlock *rb, ram_addr_t start, uint64_t had= dr, uint32_t tid) { - void *aligned =3D (void *)(uintptr_t)ROUND_DOWN(haddr, qemu_ram_pagesi= ze(rb)); - bool received =3D false; - - WITH_QEMU_LOCK_GUARD(&mis->page_request_mutex) { - received =3D ramblock_recv_bitmap_test_byte_offset(rb, start); - if (!received) { - if (!g_tree_lookup(mis->page_requested, aligned)) { - /* - * The page has not been received, and it's not yet in the - * page request list. Queue it. Set the value of element - * to 1, so that things like g_tree_lookup() will return - * TRUE (1) when found. - */ - g_tree_insert(mis->page_requested, aligned, (gpointer)1); - qatomic_inc(&mis->page_requested_count); - trace_postcopy_page_req_add(aligned, mis->page_requested_c= ount); - } - mark_postcopy_blocktime_begin(haddr, tid, rb); - } - } - /* + * If not able to mark page for blocktime it must already be present. * If the page is there, skip sending the message. We don't even need= the * lock because as long as the page arrived, it'll be there forever. */ - if (received) { + if (!try_mark_postcopy_blocktime_begin(mis, rb, start, haddr, tid)) { return 0; } =20 diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 120828a2ead..7dead1c68fc 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1054,6 +1054,37 @@ static void blocktime_fault_inject(PostcopyBlocktime= Context *ctx, trace_postcopy_blocktime_begin(addr, time, cpu, !!head); } =20 +/* + * Take @page_request_mutex and try marking postcopy blocktime begin. + * Return true if marking is successful and false if page alredy exists. + */ +bool try_mark_postcopy_blocktime_begin(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t start, + uint64_t haddr, uint32_t tid) +{ + bool received =3D false; + void *aligned =3D (void *)(uintptr_t)ROUND_DOWN(haddr, qemu_ram_pagesi= ze(rb)); + + WITH_QEMU_LOCK_GUARD(&mis->page_request_mutex) { + received =3D ramblock_recv_bitmap_test_byte_offset(rb, start); + if (!received) { + if (!g_tree_lookup(mis->page_requested, aligned)) { + /* + * The page has not been received, and it's not yet in the + * page request list. Queue it. Set the value of element + * to 1, so that things like g_tree_lookup() will return + * TRUE (1) when found. + */ + g_tree_insert(mis->page_requested, aligned, (gpointer)1); + qatomic_inc(&mis->page_requested_count); + trace_postcopy_page_req_add(aligned, mis->page_requested_c= ount); + } + mark_postcopy_blocktime_begin((uint64_t)aligned, tid, rb); + } + } + return !received; +} + /* * This function is being called when pagefault occurs. It tracks down vCPU * blocking time. It's protected by @page_request_mutex. @@ -1749,6 +1780,14 @@ void mark_postcopy_blocktime_begin(uintptr_t addr, u= int32_t ptid, RAMBlock *rb) { } + +bool try_mark_postcopy_blocktime_begin(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t start, + uint64_t haddr, uint32_t tid) +{ + g_assert_not_reached(); + return false; +} #endif =20 /* -----------------------------------------------------------------------= -- */ diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 98d918713f5..ea879f0bc6f 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -196,6 +196,9 @@ void postcopy_preempt_new_channel(MigrationIncomingStat= e *mis, QEMUFile *file); void postcopy_preempt_setup(MigrationState *s); int postcopy_preempt_establish_channel(MigrationState *s); bool postcopy_is_paused(MigrationStatus status); +bool try_mark_postcopy_blocktime_begin(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t start, + uint64_t haddr, uint32_t tid); void mark_postcopy_blocktime_begin(uintptr_t addr, uint32_t ptid, RAMBlock *rb); =20 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754696; cv=none; d=zohomail.com; s=zohoarc; b=c/qFkKZGSJPp60FRbUhF8o2qVMlpzK7/yOAdpA+eWPEq6dskLZU2IrglmZGIowQ/mM9XTuKi7t6zOdtWBT3EDI911CxmIwstcjmJKtqAvfG1l5n9yBYu5UMjSdpA2yeq4oDLnkv4ZDlFacTRgSIUt8389ybcaVd3fe79cMqmjHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754696; 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=Rb8Z5SCDyJWp7TdpiITGRQvtQ0lXojHnbL+MAwG9tnw=; b=Qb5xETNQ76yu4u+K13N5V0MOOiEJnMkTAp96tJPn1t0hfolE0XqvidZx6WpmsMtoDB4LSqb4KSqfMe6p2OCPyO+Awmr/g9i90IqMj9OW+Wt7kRNN2o+DfsR4271M9KEM3ic1tycQY74OQCZgpGrsytPG40yiR/lShyiNj0Fhi9Q= 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 1787754696600592.9788537500402; Wed, 26 Aug 2026 07:31:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEd6-00015s-CE; Wed, 26 Aug 2026 10:29:28 -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 1wzEd4-00014s-7u for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:26 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd1-0001VW-9J for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:25 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8FD971F829; Wed, 26 Aug 2026 14:29:13 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6D6571364B; Wed, 26 Aug 2026 14:29:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sFHaDzj4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rb8Z5SCDyJWp7TdpiITGRQvtQ0lXojHnbL+MAwG9tnw=; b=iolav1lCL/ElD5rcznVx+wNSIY2aoCpcNLD52D7shj0mtiOhwMQbuXghA3rrgx04PrjQzx R1/M1EzevYsPM3P3YEHUJULRGVm90OK+gWS3iiV1isi8n0JQmDF5aKVXpHAKJ84XE6XGnh 3M7SdzFDSpTB2y0gh47UMTgYaU01jBY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rb8Z5SCDyJWp7TdpiITGRQvtQ0lXojHnbL+MAwG9tnw=; b=68uLPlpNiqI8XCYFwp+94akOeV81zaDAoDkOZO+sgIZy93OhPzcFrKMdlaQSO5PNb2gtXp puld06Bdyd1H1gDA== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754553; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rb8Z5SCDyJWp7TdpiITGRQvtQ0lXojHnbL+MAwG9tnw=; b=rhlCK4mmwX9Alfs2KRuFTrrhLP8aXGBzHdXMZijOZAzioaoxkTikXHiSD4EpQZ69N6DEVs GGCQT2lF4WO2+OwxDOuGPKlnl5eKyjAXyGeswCmVecDNc54YmKGEv7TI6jknNgOqxh5i9A MBnBcgL3IZsY9jRkMKPKXC+FVW7EhiI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754553; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Rb8Z5SCDyJWp7TdpiITGRQvtQ0lXojHnbL+MAwG9tnw=; b=Fe/j+h+NtWJ6LRt5t5CyihOmMl3NUMMdbF2vZeBaj0YBnG2V4oQOrJQUOGFFuVboCaBv1/ zEv0+t8hNFL5oFAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh , Juraj Marcin Subject: [PULL 03/30] migration: Rename postcopy_listen_thread_bh Date: Wed, 26 Aug 2026 11:28:38 -0300 Message-ID: <20260826142905.2315503-4-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.993]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -2.80 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754697750158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Rename postcopy_listen_thread_bh to postcopy_incoming_complete_bh for a more robust naming scheme. This will allow fast snapshot load to use this bh funciton directly to cleanup the incoming state. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/postcopy-ram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 7dead1c68fc..2286d25f8c6 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -2109,7 +2109,7 @@ bool postcopy_is_paused(MigrationStatus status) status =3D=3D MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP; } =20 -static void postcopy_listen_thread_bh(void *opaque) +static void postcopy_incoming_complete_bh(void *opaque) { MigrationState *s =3D migrate_get_current(); MigrationIncomingState *mis =3D migration_incoming_get_current(); @@ -2217,7 +2217,7 @@ out: rcu_unregister_thread(); postcopy_state_set(POSTCOPY_INCOMING_END); =20 - migration_bh_schedule(postcopy_listen_thread_bh, NULL); + migration_bh_schedule(postcopy_incoming_complete_bh, NULL); =20 object_unref(OBJECT(migr)); =20 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754769; cv=none; d=zohomail.com; s=zohoarc; b=kzRezsYIVZpDkGdl8uWsi77/fkfXMDZsmkqO1x1LnPw/Qm5iLFdE+qsSlt95XRCojbGtcc4LX7cClmwIiDw68BfUH+9i9iTLOAI2Vw4dNIPyyY+dgRNxfSN3bPF9ggJOufWI1iYlizAJdgF/etOivBMZIdtiiB4SEuWi7FqVPqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754769; 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=1OFQJUWDbKjObiV52ezMiOfXjlvswKMRphGWikfDBLk=; b=I5DUHTGl00wIwOkK05KpIggrTAn4QtP3O//JpFy6U51YG2w4YIiSsdkR8O1CPixgVLnZnG63Vrk+z0ayYccepsKeyscWaQy1CWl0qfl1dsXqAkKs6MsZEvkPMm1GfzSXyM+NFHxRg/SRTwQnOddv4KBKsY+zM1R6ZFeF39ckc44= 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 1787754769117962.7934362251607; Wed, 26 Aug 2026 07:32:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEd6-00015t-Cg; Wed, 26 Aug 2026 10:29:28 -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 1wzEd4-00015C-Eq for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:26 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd2-0001Xp-Fd for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:26 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0DA3E1F833; Wed, 26 Aug 2026 14:29:15 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DFEB01364F; Wed, 26 Aug 2026 14:29:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id iCHGKzn4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1OFQJUWDbKjObiV52ezMiOfXjlvswKMRphGWikfDBLk=; b=YZZCN/HpkCeiFb3uGRqJOwwoVDdhbZRMucuZcGdkeG62zqEnvayjrscGeeumW4zsZkuybT gJKrrcpS5uH3jByhfGyzJNkZ1fyhLRkiPWl18gSe1xrEJeE4LgnoyXqpipjlVnsqkTkelk JnMrssCtGJ9ij8Ehconzw46zTHtikag= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1OFQJUWDbKjObiV52ezMiOfXjlvswKMRphGWikfDBLk=; b=7FUfDniE50Po857ZAYY5+ajY6Yqqbt6Rb7PO1b+3J57d0P6hfKt1O62K0BfN/FcrIl3D9x fwnjm8bwfDDiKfBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ALP3wX+A; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WdL21pHI DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754555; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1OFQJUWDbKjObiV52ezMiOfXjlvswKMRphGWikfDBLk=; b=ALP3wX+AdM7rbYsirwjq+PMATwk4fjy90sHZhxj+D8LnuhC115c0hbSMF7XZ+qxg0/Z4L7 1BuMkRGwifRUJscZPCXDHDGfg3v8bwtDTQG0e8ZL7/xOT3EUvlKLMz3ZAUGSJ/wkUiXmZ6 Ruz0Iuy75h1pifZ31mz1TKbMDKd9jv4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754555; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1OFQJUWDbKjObiV52ezMiOfXjlvswKMRphGWikfDBLk=; b=WdL21pHI8GVRt0dIfkjfQbhbTzVFl4qTgwTVO80SSslHJbgcU5DiDg43wLtwxUtw1NysPW D++VOacJdUtun/Cg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh , Juraj Marcin Subject: [PULL 04/30] migration: Use file_bmap for RAMBlock during incoming file load Date: Wed, 26 Aug 2026 11:28:39 -0300 Message-ID: <20260826142905.2315503-5-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid,suse.de:dkim]; RCVD_VIA_SMTP_AUTH(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 0DA3E1F833 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754770386158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Replace the temporary bitmap with the existing file_bmap attribute of the RAMBlock. This acts as a preparatory change for the upcoming fast snapshot load feature. Reusing this bitmap allows the destination to track page types during a postcopy load, enabling faster, direct placement of zero pages. Since file_bmap is currently only utilized during the migration save phase, it can be safely repurposed during the load phase without introducing conflicts. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/ram.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index b6eb842746a..7fa4774246a 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -252,6 +252,17 @@ int foreach_not_ignored_block(RAMBlockIterFunc func, v= oid *opaque) return ret; } =20 +static void ramblock_file_bmap_init(void) +{ + RAMBlock *rb; + + RAMBLOCK_FOREACH_NOT_IGNORED(rb) { + assert(!rb->file_bmap); + size_t size =3D rb->max_length >> qemu_target_page_bits(); + rb->file_bmap =3D bitmap_new(size); + } +} + static void ramblock_recv_map_init(void) { RAMBlock *rb; @@ -3755,6 +3766,9 @@ static int ram_load_setup(QEMUFile *f, void *opaque, = Error **errp) { xbzrle_load_setup(); ramblock_recv_map_init(); + if (migrate_mapped_ram()) { + ramblock_file_bmap_init(); + } =20 return 0; } @@ -3772,8 +3786,8 @@ static int ram_load_cleanup(void *opaque) xbzrle_load_cleanup(); =20 RAMBLOCK_FOREACH_NOT_IGNORED(rb) { - g_free(rb->receivedmap); - rb->receivedmap =3D NULL; + g_clear_pointer(&rb->receivedmap, g_free); + g_clear_pointer(&rb->file_bmap, g_free); } =20 return 0; @@ -4148,11 +4162,18 @@ 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; =20 + if (length > block->max_length) { + error_setg(errp, + "mapped-ram header length %" PRIu64 " exceeds " + "RAMBlock(\"%s\") max_length %" PRIu64, + (uint64_t)length, block->idstr, (uint64_t)block->max_le= ngth); + return; + } + if (!mapped_ram_read_header(f, &header, errp)) { return; } @@ -4180,14 +4201,14 @@ 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->file_bmap, 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)) { + if (!read_ramblock_mapped_ram(f, block, num_pages, block->file_bmap, + errp)) { return; } =20 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754604; cv=none; d=zohomail.com; s=zohoarc; b=EVqeD/Ouyb41zO/fgbHSxDrXqZPu5MpwQ4AoomBtD7tvWV6Pm1RdVIZz3RUQQzI/jidbwF0qRzU5RLDgyBjfZEg7l9tPLVDjdClHmeVB/Mq0thv3ToyTkeFxL38A86SMaVqiOfa7TIsJpJ8ls1A9d0e6B/876/moZZUwXxrlAes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754604; 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=rrepw8xFVIYK0eTpXHlcG4uSiRXY3zAh8X76xJ5QxIo=; b=FrbrCplChb6nuzwfwS9EMp7jPinLhruetaeCyprhmIFkPmASbGbYiofj7zAJsM7PsX06y3tJQB8ZLjLN6OyPHd1B6sVMtkYx2axHCC4PEIX8KVt3cVG1312T5gkO5p9wXypiQzerWTZ54t4zMeGQ7WHQvOQexmHnV7BDWCLQrwM= 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 1787754604304434.9413342662298; Wed, 26 Aug 2026 07:30:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEd9-00016l-4A; Wed, 26 Aug 2026 10:29:31 -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 1wzEd7-00016V-Cw for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:29 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd5-0001cB-Lh for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:29 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7E09A211E3; Wed, 26 Aug 2026 14:29:17 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5DE4B13674; Wed, 26 Aug 2026 14:29:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 6DztCzv4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rrepw8xFVIYK0eTpXHlcG4uSiRXY3zAh8X76xJ5QxIo=; b=wJ4IAraLNDqe3HIuDt6ldSRdBhN9f0UPPHwfwVWdeXTlcEnHoZVCFH1uP+XpWJOMPGVsWR LNl0K3mONOc+f+ujCI+FWo9+9fIIeUan59nOTqccqR9zLuAY8Ok/bgYnNQpReVQvW5JNOd HhjL/VWm/exbsxEjhzUbsGcS1+LRets= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rrepw8xFVIYK0eTpXHlcG4uSiRXY3zAh8X76xJ5QxIo=; b=HLOKUoDhZNHeljJ5WiDrI31iswAwlFJFDpHNchJSKpAsin3emnETvjpvCPHDEh48IJW+1j ZRzkHbdvf2vFplCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rrepw8xFVIYK0eTpXHlcG4uSiRXY3zAh8X76xJ5QxIo=; b=nqD6B3CvZU8s4QYHmBJjeUvwLFLg6UBWfG1A2sfe7YY3ABaAWrVvgrTP6ud4WTZ958zDal U89SC36puAuVdZSAJsfoivbn9/NOWU04iXRixFQV+gOTBYdmIzJWpMztVaPg8IWZ41J6jZ KicgmbNsrdG6UYCnJx4wnuFwz3p1GbQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rrepw8xFVIYK0eTpXHlcG4uSiRXY3zAh8X76xJ5QxIo=; b=gdFrLShieCl0ukoAwOP8C7v6mo3qjqCz1uVLTwGMrvcR3NlPmTt8AHSVmy2gNmCVPvappb p50cTt7CyIzXrMAQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh , Juraj Marcin Subject: [PULL 05/30] migration: Make qemu_get_buffer_at() thread-safe Date: Wed, 26 Aug 2026 11:28:40 -0300 Message-ID: <20260826142905.2315503-6-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.992]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; RCPT_COUNT_THREE(0.00)[4]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754606979158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Remove the internal QEMUFile error state modification from qemu_get_buffer_at(). This function is called by two functions, both of which already check for unexpected return values and handle their own error reporting. Removing this shared state modification makes qemu_get_buffer_at() strictly thread-safe for concurrent disk reads, serving as a preparatory change for the upcoming fast snapshot load feature. Removed local error by passing errp to improve on error handling, consequently also change caller to use error_prevent and not error_setg. Set errp in case of f->last_error as function should set errp in case it fails, and caller can simply use error_prepend without checking errp in case of error. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/qemu-file.c | 11 +++++------ migration/qemu-file.h | 4 ++-- migration/ram.c | 6 +++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index f30e13c66d7..7735e618549 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -550,17 +550,16 @@ void qemu_put_buffer_at(QEMUFile *f, const uint8_t *b= uf, size_t buflen, } =20 =20 -size_t qemu_get_buffer_at(QEMUFile *f, uint8_t *buf, size_t buflen, - off_t pos) +size_t qemu_get_buffer_at(QEMUFile *f, uint8_t *buf, size_t buflen, off_t = pos, + Error **errp) { - Error *err =3D NULL; - if (f->last_error) { + error_setg(errp, "Cannot read from file: stream is in error state = %d", + f->last_error); return 0; } =20 - 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, errp) < 0) { return 0; } =20 diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 8f824c124d8..966766788dd 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -76,8 +76,8 @@ void qemu_set_offset(QEMUFile *f, off_t off, int whence); off_t qemu_get_offset(QEMUFile *f); void qemu_put_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, off_t pos); -size_t qemu_get_buffer_at(QEMUFile *f, uint8_t *buf, size_t buflen, - off_t pos); +size_t qemu_get_buffer_at(QEMUFile *f, uint8_t *buf, size_t buflen, off_t = pos, + Error **errp); =20 QIOChannel *qemu_file_get_ioc(QEMUFile *file); int qemu_file_put_fd(QEMUFile *f, int fd); diff --git a/migration/ram.c b/migration/ram.c index 7fa4774246a..60ad4352150 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4133,7 +4133,7 @@ static bool read_ramblock_mapped_ram(QEMUFile *f, RAM= Block *block, block->pages_offset + offset= ); } else { read =3D qemu_get_buffer_at(f, host, size, - block->pages_offset + offset); + block->pages_offset + offset, er= rp); } =20 if (!read) { @@ -4202,8 +4202,8 @@ static void parse_ramblock_mapped_ram(QEMUFile *f, RA= MBlock *block, bitmap_size =3D BITS_TO_LONGS(num_pages) * sizeof(unsigned long); =20 if (qemu_get_buffer_at(f, (uint8_t *)block->file_bmap, bitmap_size, - header.bitmap_offset) !=3D bitmap_size) { - error_setg(errp, "Error reading dirty bitmap"); + header.bitmap_offset, errp) !=3D bitmap_size) { + error_prepend(errp, "Error reading dirty bitmap"); return; } =20 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754779; cv=none; d=zohomail.com; s=zohoarc; b=O6RMmXeK0j1Kqv0UUIXmScDgWdi0tNp+HU0lor85rb3EOrdQcULiEqFcwxygGeP4mJBG8NFLHSikzn/sI89bcWOoZOIeFG3lbXcTAxlMNBzZq7ZZOne4uj/X5amDCT/XnFdyNWpZyyzDAKvJlg3l3xVRkJXYDYhasASOILGVCVA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754779; 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=NjkvZi9dCnM5PxlLXQzt4cvVIzMJFOAlxM7emsEzxpY=; b=FO/maCftLnKvxq0qCaywAes/0WI65wgTsfyANExdwSeB3tmWn5gQOb46r3CsgtnYWiLHXyaOJPbLe1o5f6TrfI6E7hmiWKFa5Ag6+VEJJMMm/awrVehcIKwt3eFAwukDRr0BQK5iBsqSBY56naie/sNDK0Fyz75f2Mbw/F6OACg= 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 1787754779754267.56363613220253; Wed, 26 Aug 2026 07:32:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEd8-00016k-Pl; Wed, 26 Aug 2026 10:29: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 1wzEd7-000162-3f for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:29 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd5-0001bY-A4 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:28 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id BEF681F837; Wed, 26 Aug 2026 14:29:17 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id CFA0C13675; Wed, 26 Aug 2026 14:29:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 6CTGJzz4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754562; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NjkvZi9dCnM5PxlLXQzt4cvVIzMJFOAlxM7emsEzxpY=; b=ngCzvpyHih9zC67dEhnx4m5fkjJwbQsc3pNm/zUANUGUJpdRigaFSC4TdlXdCXW3ZY/3Xe ujB6jZOEgDhM+MUy9vIuDF280xO9okuML18+Ay+zSnXMI3eoVDmZxhPVShaYfRAaWP0VZ2 mxe5f+OZKClqkE/ZpLNzf12B0ppkn+Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754562; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NjkvZi9dCnM5PxlLXQzt4cvVIzMJFOAlxM7emsEzxpY=; b=e2ZpQcitQNo7A/PEz5B/+DVKXoMa0tiDFYriU70n5eYqFW6L/PJ6yUQTNvF/3u98YKkVtV 4YFmMS3BIr/CScBw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Gz2PvYww; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=GSUQ5r62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NjkvZi9dCnM5PxlLXQzt4cvVIzMJFOAlxM7emsEzxpY=; b=Gz2PvYwwZGwSo58TsyMJhGc0bQM4Ep85Nj9xvH3ZOafE6H52eepN0oMPTUW36ADCW8NCfi KgTFYqZYdqGJSVG0yVgjSqjlIT+GjdlV7ydg8g1f6RHxeiYV5/F6wKhy8SlZypy1k2ndEj X4tEHdO5xcNjAgO+rFScQrnx66n1t3s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754557; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NjkvZi9dCnM5PxlLXQzt4cvVIzMJFOAlxM7emsEzxpY=; b=GSUQ5r62oKVL5T/0OCtERU3YjBaPlNrXsrhzpIgYiU79EGXTV1QYxa356HE0Nu1iqORVxP Cpy/DY9pJcBPxAAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh Subject: [PULL 06/30] migration: add RAMBlock field and helper for fast snapshot load Date: Wed, 26 Aug 2026 11:28:41 -0300 Message-ID: <20260826142905.2315503-7-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: BEF681F837 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754780491158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Add pending_bmap field per RAMBlock which is a Bitmap to store internal state of which pages have been read by some thread to ensure coordination between fault thread and eager load thread. Modify parse_ramblock_mapped_ram(), to not load the actual RAMBlocks data in postcopy case as that will be loaded by fault thread and eager thread after the VM starts running. Change ram_load() to use new function ram_should_load_postcopy_pages() to decide how to load/read RAM. Signed-off-by: Aadeshveer Singh Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/system/ramblock.h | 6 ++++ migration/ram.c | 66 +++++++++++++++++++++++++++++++++++---- 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/include/system/ramblock.h b/include/system/ramblock.h index f0639287bf0..84624aca2c9 100644 --- a/include/system/ramblock.h +++ b/include/system/ramblock.h @@ -60,6 +60,12 @@ struct RAMBlock { =20 /* Bitmap of already received pages. Only used on destination side. */ unsigned long *receivedmap; + /* + * 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/ram.c b/migration/ram.c index 60ad4352150..b7c406428e2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -263,6 +263,25 @@ static void ramblock_file_bmap_init(void) } } =20 +static void ramblock_pending_bmap_init(void) +{ + RAMBlock *rb; + + RAMBLOCK_FOREACH_NOT_IGNORED(rb) { + assert(!rb->pending_bmap); + /* + * The pending_bmap granularity must match the maximum of host and= guest + * page sizes. This ensures that every load operation checks for o= ne + * bit, allowing lockless thread coordination via a single-bit ato= mic + * test-and-clear. + */ + size_t size =3D rb->max_length / + MAX(qemu_ram_pagesize(rb), qemu_target_page_size()); + rb->pending_bmap =3D bitmap_new(size); + bitmap_set(rb->pending_bmap, 0, size); + } +} + static void ramblock_recv_map_init(void) { RAMBlock *rb; @@ -3768,6 +3787,10 @@ static int ram_load_setup(QEMUFile *f, void *opaque,= Error **errp) ramblock_recv_map_init(); if (migrate_mapped_ram()) { ramblock_file_bmap_init(); + if (migrate_postcopy_ram()) { + /* fast snapshot load */ + ramblock_pending_bmap_init(); + } } =20 return 0; @@ -3788,6 +3811,7 @@ static int ram_load_cleanup(void *opaque) RAMBLOCK_FOREACH_NOT_IGNORED(rb) { g_clear_pointer(&rb->receivedmap, g_free); g_clear_pointer(&rb->file_bmap, g_free); + g_clear_pointer(&rb->pending_bmap, g_free); } =20 return 0; @@ -4207,9 +4231,12 @@ static void parse_ramblock_mapped_ram(QEMUFile *f, R= AMBlock *block, return; } =20 - if (!read_ramblock_mapped_ram(f, block, num_pages, block->file_bmap, - errp)) { - return; + if (!migrate_postcopy_ram()) { + /* Do not load RAM during setup for fast snapshot load */ + if (!read_ramblock_mapped_ram(f, block, num_pages, block->file_bma= p, + errp)) { + return; + } } =20 /* Skip pages array */ @@ -4488,15 +4515,42 @@ static int ram_load_precopy(QEMUFile *f) return ret; } =20 +static bool ram_should_load_postcopy_pages(void) +{ + /* This is pure precopy, we don't need to load pages in postcopy way */ + if (!postcopy_is_running()) { + return false; + } + + /* + * This is postcopy, but when with mapped-ram, pages are not loaded in= the + * migration stream here, but done separately in a thread eagerly read= ing + * pages from the snapshot. Here, we only need to read the ram header= s, + * reusing the precopy code. + * TODO: when we have separate function to parse RAM headers we should + * switch to that. + */ + if (migrate_mapped_ram()) { + return false; + } + + /* + * Genuine network postcopy, we will load pages in this current stream= and + * they need to be done in postcopy way. + */ + return true; +} + static int ram_load(QEMUFile *f, void *opaque, int version_id) { int ret =3D 0; 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_postcopy_pages =3D ram_should_load_postcopy_pages(); =20 seq_iter++; =20 @@ -4512,7 +4566,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_postcopy_pages) { /* * Note! Here RAM_CHANNEL_PRECOPY is the precopy channel of * postcopy migration, we have another RAM_CHANNEL_POSTCOPY to --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754704; cv=none; d=zohomail.com; s=zohoarc; b=haR69MSP/2SVLshdESrD6Y4jvaHFAvpKHLKyRDCKkyy8elWYGmITzT0vvjkxI/OB3ZgCr9TvknZg5Z51nBVEs2HWfrWzwO7CCM3hqlw+Av0vpgUUEAwpNTU+tO4JZBBOMz0iy72g1pjxSrAOwfmWST6Lb3Gy6HoHS+YYi004++I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754704; 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=5SmeCai2W9mGUnaIlF+RloeydYydX2zCixfhNWH4ej8=; b=idOspefMu/8+idjxgSU8yQdC60ky6nUAtcgBO5UoekQkGxYfA6R9ZetHOB11HbwWQ9grADlbCpTFQsQomZjRzdRv5hEDTB+xygaQHQ+/XUtH7nYwRY8VuFs8uT16FCGTe1evVexj4x+b/4vikryoy2CPViwUQKO4YuMSf4hQVDA= 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 1787754704254135.47517191861857; Wed, 26 Aug 2026 07:31:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdA-00017U-TQ; Wed, 26 Aug 2026 10:29:32 -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 1wzEd9-00016m-5J for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:31 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd6-0001dE-S9 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:30 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 10BD71F821; Wed, 26 Aug 2026 14:29:19 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2123913354; Wed, 26 Aug 2026 14:29:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WJG6OD34jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754563; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5SmeCai2W9mGUnaIlF+RloeydYydX2zCixfhNWH4ej8=; b=AD1sJwOd3yAXf1tmwvxxmifYpLUie/nIwus5AZv+3a7kNQRvJYAmEQ6hRVk+xmfIONUIXL EoZiSpze+P+fvmLls1rnP+dt8psR/AD4YxMWmSYiTmyjkKImVY+tHuUk2/gD+nUYF8a6Y6 jWNYhbh7CgsWJLYuKY7wNbDjhCp13CY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754563; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5SmeCai2W9mGUnaIlF+RloeydYydX2zCixfhNWH4ej8=; b=DYBgqAGn00eQmZcRO3bJXF03pKQHmX0Me2YVAvYa2gGGqd1F56x8LptPCxVB7jAd1k5S5G bUwp8igNzmxER/Cg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5SmeCai2W9mGUnaIlF+RloeydYydX2zCixfhNWH4ej8=; b=l8QOdnpkd8KUJ4YeBU9LB47A5dNq6Zz9FWBTF43bHGwIlwRnxEytyJBydY5nhJXrWP/JDJ OuYz285CieWW44nBAF4prFjFXVwWfkobqDWW4ivpz/9Omw63dBTnyFbb/ANviqvtw9b85S 4angsjFJlRdHX/UXQpG8ZVCF1ty+CPw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754559; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5SmeCai2W9mGUnaIlF+RloeydYydX2zCixfhNWH4ej8=; b=jS7lweHoCguw04KS+XxB6ZjtnoTU0Ru1MBRXyCBEIrGzGblIc5MhNguTpw9hHTpWfIow8b KG9UxbDt11JOSMCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh Subject: [PULL 07/30] migration: add support for fault thread to load pages from disk Date: Wed, 26 Aug 2026 11:28:42 -0300 Message-ID: <20260826142905.2315503-8-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.80 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-0.992]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVRCPT(0.00)[gmail.com] 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.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, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URG_BIZ=0.573 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754706064158501 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh 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. It uses bitmap_test_and_clear_atomic() on pending_bmap to prevent multiple threads from loading same page. It loads a page or pages depending on size of guest pages and host pages, loading exactly the larger of two. If the entire page is zero postcopy_place_page_zero() is used for efficiency and in case some part is non zero it is part by part loaded on loop using new function postcopy_mapped_ram_load_guest_page() which loads a single guest page in a buffer which is then placed using postcopy_place_page(). This covers all possible cases for various page sizes of host and guest. Because postcopy_place_page and in general postcopy does not support larger guest pages this will not work in case of guest pages sizes larger than host. 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. Call try_mark_postcopy_blocktime_begin on every page fault to support postcopy-blocktime. Allocate another channel in postcopy_temp_pages_setup(like the preempt case), for both the fault thread and eager thread to load pages independently. Signed-off-by: Aadeshveer Singh Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/postcopy-ram.c | 183 +++++++++++++++++++++++++++++++++++---- 1 file changed, 166 insertions(+), 17 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 2286d25f8c6..430b5f24e1a 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -946,6 +946,130 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd, pagesize); } =20 +/* + * Load a single guest page from source file into the buffer. + * NOTE: This is not an atomic operation and should not be used to directl= y load + * pages on page faults in postcopy. It is meant to fill in buffer that ca= n then + * be copied into the faulting location using UFFDIO_COPY. + */ +static bool postcopy_mapped_ram_load_guest_page(MigrationIncomingState *mi= s, + RAMBlock *rb, + ram_addr_t rb_offset, void= *buf, + Error **errp) +{ + ERRP_GUARD(); + size_t page =3D rb_offset / qemu_target_page_size(); + size_t read; + + if (test_bit(page, rb->file_bmap)) { + /* + * This can happen concurrently, but it's thread-safe because + * qemu_get_buffer_at() is thread-safe, and the caller will be usi= ng + * different temporary buffers. + */ + read =3D + qemu_get_buffer_at(mis->from_src_file, buf, qemu_target_page_s= ize(), + rb->pages_offset + rb_offset, errp); + + if (read !=3D qemu_target_page_size()) { + error_prepend(errp, + "Could not read page %zu from RAM Block %s: ", p= age, + rb->idstr); + return false; + } + } else { + memset(buf, '\0', qemu_target_page_size()); + } + return true; +} + +/** + * postcopy_mapped_ram_load_page() - Load pages required to access host ad= dress. + * @mis: Migration Incoming State. + * @rb: RAMBlock from where page is loaded. + * @rb_offset: Offset of target page in RAMBlock. + * @haddr: Base of target page where to load in page. + * @channel: Used to identify between threads and use corresponding temp. + * @errp: Set error in case of failure + * + * Load page(s) from RAMBlock covering the faulting address. We might need= to + * load multiple pages in the case when host page size is greater than gue= st + * page size. As userfaultfd works on granularity of host pages, we might = need + * to load guest pages in single operation. + * + * Return: True on success. + */ +static bool postcopy_mapped_ram_load_page(MigrationIncomingState *mis, + RAMBlock *rb, ram_addr_t rb_offs= et, + uint64_t haddr, int channel, + Error **errp) +{ + void *place_source =3D mis->postcopy_tmp_pages[channel].tmp_huge_page; + char *buffer_ptr =3D (char *)place_source; + size_t guest_pages_to_load =3D + MAX(1, qemu_ram_pagesize(rb) / qemu_target_page_size()); + size_t guest_page; + size_t host_page; + + /* + * If guest page size is greater than host page size uffd needs to loa= d one + * guest page and multiple host pages, hence the offsets need to align= ed + * with guest pages (which is automatically aligned with host pages). = In the + * same case we need to check range of bits on pending_bmap(bit per ho= st + * page) to decide whether all the page have been loaded. + * + * NOTE: This is future proofing as currently target page size greater= than + * host page size is not supported. However if postcopy does support t= his in + * future, with updated place page functions this function should work + * readily. + */ + rb_offset =3D ROUND_DOWN(rb_offset, qemu_target_page_size()); + haddr =3D ROUND_DOWN(haddr, qemu_target_page_size()); + guest_page =3D rb_offset >> qemu_target_page_bits(); + host_page =3D rb_offset / qemu_ram_pagesize(rb); + + /* + * pending_bmap needs the index of host or guest page based on which is + * larger. As page index is inversely proportional to page size we use= the + * minimum of both. + */ + if (bitmap_test_and_clear_atomic(rb->pending_bmap, + MIN(host_page, guest_page), 1)) { + if (find_next_bit(rb->file_bmap, guest_page + guest_pages_to_load, + guest_page) =3D=3D guest_page + guest_pages_to_l= oad) { + /* It is efficient to use UFFDIO_ZERO if all pages are zero */ + if (postcopy_place_page_zero(mis, (void *)haddr, rb)) { + error_setg(errp, + "Failed to place zero page %zu from RAM Block %= s at " + "address %" PRIu64, + guest_page, rb->idstr, haddr); + return false; + } + } else { + size_t load_size =3D guest_pages_to_load * qemu_target_page_si= ze(); + size_t offset; + + for (offset =3D 0; offset < load_size; + offset +=3D qemu_target_page_size()) { + if (!postcopy_mapped_ram_load_guest_page( + mis, rb, rb_offset + offset, buffer_ptr + offset, + errp)) { + return false; + } + } + + if (postcopy_place_page(mis, (void *)haddr, place_source, rb))= { + error_setg(errp, + "Failed to place page %zu from RAM Block %s at " + "address %" PRIu64, + guest_page, rb->idstr, haddr); + return false; + } + } + } + return true; +} + /* * 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. @@ -1308,6 +1432,7 @@ static void *postcopy_ram_fault_thread(void *opaque) int ret; size_t index; RAMBlock *rb =3D NULL; + Error *local_err =3D NULL; =20 trace_postcopy_ram_fault_thread_entry(); rcu_register_thread(); @@ -1349,11 +1474,13 @@ static void *postcopy_ram_fault_thread(void *opaque) break; } =20 - if (!mis->to_src_file) { + if (!migrate_mapped_ram() && !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. + * Possibly someone tells us that the return path is broken al= ready + * using the event. We should hold until the channel is rebuil= t. + * Fast snapshot load doesn't support pause and recover, becau= se + * it's not necessary: we can fail right away when QEMU just b= ooted + * with nothing to lose. */ postcopy_pause_fault_thread(mis); } @@ -1416,18 +1543,37 @@ static void *postcopy_ram_fault_thread(void *opaque) qemu_ram_get_idstr(rb), rb_offset, msg.arg.pagefault.feat.pti= d); + + if (migrate_mapped_ram()) { + /* Load page directly in case of fast snapshot load */ + + uintptr_t aligned =3D (uintptr_t)ROUND_DOWN( + msg.arg.pagefault.address, qemu_ram_pagesize(rb)); + + if (try_mark_postcopy_blocktime_begin( + mis, rb, rb_offset, (uintptr_t)aligned, + msg.arg.pagefault.feat.ptid)) { + if (!postcopy_mapped_ram_load_page( + mis, rb, rb_offset, aligned, RAM_CHANNEL_POSTC= OPY, + &local_err)) { + error_report_err(local_err); + 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 @@ -1499,8 +1645,11 @@ static int postcopy_temp_pages_setup(MigrationIncomi= ngState *mis, Error **errp) 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_mapped_ram()) { + /* + * 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.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754632; cv=none; d=zohomail.com; s=zohoarc; b=VdeT7iaB3tdKS38U+ZOFMIi+TaeeissGBYksxO4L6lzJ3n5xyAy6zyrxUhIRWkCJKJ/4PJ/0wrbsE4zIfWJGI0E5UY2ug4WXEPEF1TzYPS9KCijwrRoc0NGY5ZSUSeKDblrH5dfcEyz67Jo8fGukan8r3vGDy4V6BbRzms71/lA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754632; 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=JBaiBj8RrIFlHoMR68yaE7kUmPAVZMY+pnjc1+jCVHI=; b=kPhSYmEA5W1Cs5tvyAmvMlvsUmOB5uUdHO2ggBdwN62kb8hK2Oa5hsNPmtN5cP0c9BTzbD7Zjv5OwUlnd/4g0yp3VMQLBUTjKmQrku/cYy3y7rO6gocTh78c6YkvjV6QbxzI+VxaFN3AmsaZhIBzXjFXnhc15uPEqVwdFqO3B7A= 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 1787754632985541.5023340258227; Wed, 26 Aug 2026 07:30:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdB-00017q-Kb; Wed, 26 Aug 2026 10:29:33 -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 1wzEdA-000179-H0 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:32 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd7-0001fc-U5 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:32 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 83DC11F82D; Wed, 26 Aug 2026 14:29:20 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 678551361C; Wed, 26 Aug 2026 14:29:19 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UAJeDj/4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JBaiBj8RrIFlHoMR68yaE7kUmPAVZMY+pnjc1+jCVHI=; b=Xtji2Hq+iMT5MHQyRV3BZaa1ErEGqZPcYaIvXzgPJUKorLbOKJlnUeM88xYxilgyhMkaPS RjX4bU4Qu+iNeDZMsIYVGRAiEfcx+2BhPMRbVPewLGesh/BTcb2ByHnOme+7UVpN+YhLin +YNKp6FpqyvuURkCcb1YsRNvMJfkyJg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JBaiBj8RrIFlHoMR68yaE7kUmPAVZMY+pnjc1+jCVHI=; b=lJNl5VTePWnYVrRFRWN6co8sw7VQ5Tkf1jDG5E+v16pxDJvqRj60tA4DQpfAVyNiJ5PhZu OSYRePn+LhEEdjDw== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=B6Bazs9V; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=U7UVZMoY DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754560; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JBaiBj8RrIFlHoMR68yaE7kUmPAVZMY+pnjc1+jCVHI=; b=B6Bazs9Vq3ACUwOJfYlGHeRLmI2hzvp+mRG1tzArgRLDkJeCjv3iSlpwaVjQlfJj+IhGwo 1l5ga1sJYZAUMt8z3oDl4ZCmUEb86+7Vyt9/1jNJ86AncH99A0TGF1lDVSHkuqJjMH/e+C Zt9780Rdha+aF7EnZ1PTXJwabvFPzSU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754560; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JBaiBj8RrIFlHoMR68yaE7kUmPAVZMY+pnjc1+jCVHI=; b=U7UVZMoYzaCeaxisZPbsOu7y5f5jZEWp7CWJzRlRIhQuW9QVw88Gq/+z2gW3yZV65QxHxN iSYQoeRnM8XhLfDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh , Juraj Marcin Subject: [PULL 08/30] migration: add eager load thread and setup for fast snapshot load Date: Wed, 26 Aug 2026 11:28:43 -0300 Message-ID: <20260826142905.2315503-9-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 83DC11F82D X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[4]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754633283158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh 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. Considering the difference from usual network postcopy where major chunk of RAM is already loaded here entire RAM needs to be loaded later. Existance of background pages which are not really accessed by the guest might never be loaded and system will be locked in migration for indefinite time. As there should be no assumption about how guest accesses memory, the load times can be indefinite. Add postcopy_ram_eager_load_thread(), for the eager thread which iterates over all non ignored blocks calling ram_block_load_eager() on 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_incoming_complete_bh() to destroy the incoming migration state. 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. 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() in process_incoming_migration_co(). Fault thread needs to be launched 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. Add function qemu_loadvm_run_fast_snapshot_load() 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. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/migration.c | 36 +++++++++++++++++-- migration/migration.h | 5 +++ migration/postcopy-ram.c | 76 ++++++++++++++++++++++++++++++++++++++++ migration/postcopy-ram.h | 2 ++ migration/savevm.c | 16 +++++++++ migration/savevm.h | 2 ++ migration/trace-events | 2 ++ 7 files changed, 137 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a30779f37c8..59cdc1a169f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -710,6 +710,11 @@ static void process_incoming_migration_bh(void *opaque) migration_incoming_state_destroy(); } =20 +static bool migration_incoming_has_postcopy_thread(MigrationIncomingState = *mis) +{ + return mis->have_listen_thread || mis->have_eager_load_thread; +} + static void coroutine_fn process_incoming_migration_co(void *opaque) { @@ -739,17 +744,44 @@ process_incoming_migration_co(void *opaque) migrate_set_state(&mis->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); =20 + /* + * When loading snapshot with postcopy enabled, setup the postcopy + * infrastructure before loading the major part of device states. + * It's required because qemu_loadvm_state() may access guest memory + * while loading device states, which can cause page faults already. + */ + if (migrate_postcopy_ram() && migrate_mapped_ram()) { + migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, + MIGRATION_STATUS_POSTCOPY_DEVICE); + + if (ram_postcopy_incoming_init(mis, &local_err)) { + goto fail; + } + + postcopy_state_set(POSTCOPY_INCOMING_LISTENING); + if (postcopy_ram_incoming_setup(mis, &local_err)) { + goto fail; + } + } + mis->loadvm_co =3D qemu_coroutine_self(); ret =3D qemu_loadvm_state(mis->from_src_file, &local_err); mis->loadvm_co =3D NULL; + if (ret < 0) { + goto fail; + } + + if (migrate_postcopy_ram() && migrate_mapped_ram()) { + qemu_loadvm_run_fast_snapshot_load(mis->from_src_file, mis); + } =20 trace_vmstate_downtime_checkpoint("dst-precopy-loadvm-completed"); =20 trace_process_incoming_migration_co_end(ret); - if (mis->have_listen_thread) { + if (migration_incoming_has_postcopy_thread(mis)) { /* * Postcopy was started, cleanup should happen at the end of the - * postcopy listen thread. + * postcopy listen thread or eager load thread. */ trace_process_incoming_migration_co_postcopy_end_main(); goto out; diff --git a/migration/migration.h b/migration/migration.h index 631421c784b..e47ff4e3d11 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_SNAPSHOT_LOAD "mig/dst/snapshot_load" =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 430b5f24e1a..3b66c1f6d42 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -39,6 +39,8 @@ #include "qemu/mmap-alloc.h" #include "options.h" =20 +static void postcopy_incoming_complete_bh(void *opaque); + /* Arbitrary limit on size of each discard command, * keeps them around ~200 bytes */ @@ -1867,6 +1869,70 @@ int postcopy_place_page_zero(MigrationIncomingState = *mis, void *host, } } =20 +/* + * 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 migration_incoming_get_current(); + MigrationState *s =3D migrate_get_current(); + Error *errp =3D NULL; + void *host =3D qemu_ram_get_host_addr(rb); + void *target; + + for (ram_addr_t page_loc =3D 0; page_loc < rb->used_length; + page_loc +=3D qemu_ram_pagesize(rb)) { + target =3D (uint8_t *)host + page_loc; + if (!postcopy_mapped_ram_load_page(mis, rb, page_loc, (uint64_t)ta= rget, + RAM_CHANNEL_PRECOPY, &errp)) { + migrate_error_propagate(s, errp); + return -1; + } + } + return 0; +} + +/* + * 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; + MigrationStatus next_state; + + 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, NULL)) { + next_state =3D MIGRATION_STATUS_FAILED; + } else { + next_state =3D MIGRATION_STATUS_COMPLETED; + } + migrate_set_state(&mis->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, + next_state); + + postcopy_state_set(POSTCOPY_INCOMING_END); + migration_bh_schedule(postcopy_incoming_complete_bh, mis); + + rcu_unregister_thread(); + trace_postcopy_ram_eager_load_thread_exit(); + return NULL; +} + +/* + * Create thread for eager loading in fast snapshot load case + */ +void postcopy_ram_eager_load_setup(MigrationIncomingState *mis) +{ + postcopy_thread_create( + mis, &mis->eager_load_thread, MIGRATION_THREAD_DST_SNAPSHOT_LOAD, + postcopy_ram_eager_load_thread, QEMU_THREAD_JOINABLE); + mis->have_eager_load_thread =3D true; +} + #else /* No target OS support, stubs just fail */ void fill_destination_postcopy_migration_info(MigrationInfo *info) @@ -1937,6 +2003,11 @@ bool try_mark_postcopy_blocktime_begin(MigrationInco= mingState *mis, g_assert_not_reached(); return false; } + +void postcopy_ram_eager_load_setup(MigrationIncomingState *mis) +{ + g_assert_not_reached(); +} #endif =20 /* -----------------------------------------------------------------------= -- */ @@ -2410,6 +2481,11 @@ 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); } diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index ea879f0bc6f..c58a60bc8ae 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -205,4 +205,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 +void postcopy_ram_eager_load_setup(MigrationIncomingState *mis); + #endif diff --git a/migration/savevm.c b/migration/savevm.c index 34dd06f9f73..161a9d090fa 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -3004,6 +3004,22 @@ static bool postcopy_pause_incoming(MigrationIncomin= gState *mis) return true; } =20 +/* + * Starts the VM and launches the eager thread for fast snapshot load + */ +void qemu_loadvm_run_fast_snapshot_load(QEMUFile *f, + MigrationIncomingState *mis) +{ + 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); + + postcopy_ram_eager_load_setup(mis); +} + int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, Error **errp) { diff --git a/migration/savevm.h b/migration/savevm.h index f7dcdd7d1b6..9988dd4b8a4 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -70,6 +70,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); +void qemu_loadvm_run_fast_snapshot_load(QEMUFile *f, + MigrationIncomingState *mis); int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, Error **errp); int qemu_load_device_state(QEMUFile *f, Error **errp); diff --git a/migration/trace-events b/migration/trace-events index af0e7845354..4ae1c226f90 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -315,6 +315,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.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754780; cv=none; d=zohomail.com; s=zohoarc; b=YyRgKyY8Ff9K1R0HE5W3WdycZFsOeVvaTX2q0mb+zd5eCbUjdDm790KPrxBTClG18GqTkIBxaZksbY/p7bz5uNtIQM9QwhuakjY1HxoaCqQQIA/WKQyK6ouUNA74RVvHz7o8p3VWbm398ioa7cNYbcbkZbPzloBtNP06p1UTasw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754780; 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=cspG0Dh2mxk8vVsB+09O0NDaNl4Dzf0rDzwGrop/RnM=; b=YLy23jeyYiL5UhLFQncuRmAooD2KHS0f1pbdj8p/9lfTNV0BKVjLcH3NyDUhkI+RNHsrQF6YuUTec6RAnuUWCmaBAyS/yaLXpYSqlVcw3fKhObtpJuRxAX3A8RULxUkCRgt82OWyTxlzrGozGQPE7p5rVLjUeUhm3NWWijnbFHQ= 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 17877547802361000.1720175045983; Wed, 26 Aug 2026 07:33:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdD-00018Q-0U; Wed, 26 Aug 2026 10:29:35 -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 1wzEdB-00017o-G2 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:33 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEd9-0001hR-B8 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:33 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D08D9211F7; Wed, 26 Aug 2026 14:29:21 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D9C9F1364A; Wed, 26 Aug 2026 14:29:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eBhKKkD4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754565; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cspG0Dh2mxk8vVsB+09O0NDaNl4Dzf0rDzwGrop/RnM=; b=OH+YPpQKQEg0kVPWB2vtmAHlSMmhtOjkNOUbLxmpTA47ivCwSb6TlXA8Trpo6imP3GAKQZ ISXUPfyQDSWlliU0aoEfvFBwnEa68CGUwEwXcbzu3/zHeWelZve8JZYY5o75G7OmUjm0zj hwBH9MMEgyEEg3nZhSX0Ql6n6UpUktM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754565; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cspG0Dh2mxk8vVsB+09O0NDaNl4Dzf0rDzwGrop/RnM=; b=kXgfFyOgz8FNF/80yO3fl8YhIq7hCFpU7EF7oa+UnYM/LTB0Rvs5vIDmEiP7PfkX8wfwJK 8CFZ1ECNTexAViBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=T+1VgmP1; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WCTjJTDi DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cspG0Dh2mxk8vVsB+09O0NDaNl4Dzf0rDzwGrop/RnM=; b=T+1VgmP1FxjlLIPKRpUbkpume0tSEqr8B1OqJIKJVe4rPtDPWPpfhROfpxNSY/1DcnCOoQ ly8l2yw6KcV1U1cJGzloraAxba3A+D4a2eQrWM3lnihFMzpWvIaZ4sfL/vEz0ndwLuJKdb +wp4RrvUEq1UfKGFS+Y2j1jy9fpZSSo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754561; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cspG0Dh2mxk8vVsB+09O0NDaNl4Dzf0rDzwGrop/RnM=; b=WCTjJTDiv8SVLH1wzShaIQw7abyxIeohePK9X59Zx/QXuQS62GgXm4bXd0QY+u5r959cNb o6EbesuNDK0pEcDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh Subject: [PULL 09/30] migration: update capability conflict test for postcopy-ram+mapped-ram Date: Wed, 26 Aug 2026 11:28:44 -0300 Message-ID: <20260826142905.2315503-10-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: D08D9211F7 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754782530158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh 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 following patches in this series, this combination will now supported and be functional. Remove the capability check that rejected mapped-ram and postcopy-ram being set simultaneously, as this combination now corresponds to fast snapshot load. Add a capability check against setting multifd when configured for fast snapshot load as it is not supported yet. Also add capability check against setting postcopy-preempt as it is incompatible. Add infrastructure to check postcopy_notifier_list being empty in capaility checking to block vhost-user with fast snapshot load as it is not supported. Add a check to bail in migrate_prepare to prevent unexpected usage when fast snapshot load is enabled. A smoke test exercising this feature has been added further in this series. Signed-off-by: Aadeshveer Singh Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/qemu/notify.h | 2 ++ migration/migration.c | 6 ++++ migration/options.c | 20 ++++++++++-- migration/postcopy-ram.c | 5 +++ migration/postcopy-ram.h | 1 + tests/qtest/migration/misc-tests.c | 52 ------------------------------ util/notify.c | 5 +++ 7 files changed, 37 insertions(+), 54 deletions(-) diff --git a/include/qemu/notify.h b/include/qemu/notify.h index abf18dbf595..666d13f727e 100644 --- a/include/qemu/notify.h +++ b/include/qemu/notify.h @@ -75,4 +75,6 @@ void notifier_with_return_remove(NotifierWithReturn *noti= fier); int notifier_with_return_list_notify(NotifierWithReturnList *list, void *data, Error **errp); =20 +bool notifier_with_return_list_empty(NotifierWithReturnList *list); + #endif diff --git a/migration/migration.c b/migration/migration.c index 59cdc1a169f..b413d28622a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2048,6 +2048,12 @@ static bool migrate_prepare(MigrationState *s, bool = resume, Error **errp) error_setg(errp, "Cannot use compression with mapped-ram"); return false; } + + if (migrate_postcopy_ram()) { + error_setg(errp, "Cannot migrate with fast snapshot load " + "enabled(mapped-ram + postcopy-ram)"); + return false; + } } =20 if (migrate_mode_is_cpr()) { diff --git a/migration/options.c b/migration/options.c index dfce19405d4..d2575edb6cb 100644 --- a/migration/options.c +++ b/migration/options.c @@ -736,10 +736,26 @@ bool migrate_caps_check(bool *old_caps, bool *new_cap= s, Error **errp) "Mapped-ram migration is incompatible with xbzrle"); return false; } + } =20 - if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { + if (new_caps[MIGRATION_CAPABILITY_MAPPED_RAM] && + new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { + if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) { error_setg(errp, - "Mapped-ram migration is incompatible with postcopy= "); + "Multifd is not supported with fast snapshot load"); + return false; + } + + if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_PREEMPT]) { + error_setg( + errp, + "Postcopy Preempt is incompatible with fast snapshot load"= ); + return false; + } + + if (!postcopy_notifier_list_empty()) { + error_setg(errp, + "vhost-user is not supported with fast snapshot loa= d"); return false; } } diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 3b66c1f6d42..885ab58fca5 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -84,6 +84,11 @@ int postcopy_notify(enum PostcopyNotifyReason reason, Er= ror **errp) &pnd, errp); } =20 +bool postcopy_notifier_list_empty(void) +{ + return notifier_with_return_list_empty(&postcopy_notifier_list); +} + /* * NOTE: this routine is not thread safe, we can't call it concurrently. B= ut it * should be good enough for migration's purposes. diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index c58a60bc8ae..edba7b02404 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -136,6 +136,7 @@ void postcopy_add_notifier(NotifierWithReturn *nn); void postcopy_remove_notifier(NotifierWithReturn *n); /* Call the notifier list set by postcopy_add_start_notifier */ int postcopy_notify(enum PostcopyNotifyReason reason, Error **errp); +bool postcopy_notifier_list_empty(void); =20 void postcopy_thread_create(MigrationIncomingState *mis, QemuThread *thread, const char *name, diff --git a/tests/qtest/migration/misc-tests.c b/tests/qtest/migration/mis= c-tests.c index ec6d438cdcb..4e0deb7f188 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); } diff --git a/util/notify.c b/util/notify.c index 24420a7288e..512ba6aa916 100644 --- a/util/notify.c +++ b/util/notify.c @@ -75,3 +75,8 @@ int notifier_with_return_list_notify(NotifierWithReturnLi= st *list, void *data, } return ret; } + +bool notifier_with_return_list_empty(NotifierWithReturnList *list) +{ + return QLIST_EMPTY(&list->notifiers); +} --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754604; cv=none; d=zohomail.com; s=zohoarc; b=b+08un+j/E3jnQubilpuMhV/1eeqI78J56mKz4F02CUZxCoskPtVo9+lbv6ft61qNXcSuK+NfiIwQscHIhhAx9kDzH8cZbGt9oKb7UvepHe82TraKkHknP+Lkr6Sg2VrxHlbk+TLIhqQrEHBIKFS6xvs1aMdSzudfiXOMZ+PEKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754604; 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=n4S1P9FhVcrug0Pv7l10DJXkcqiruL0W7qNcFKbXuXY=; b=m+kEV+ndNaxkEmWlTuJGzFdMT20DPyjee91Nab15ZlA7pSROXShh3ESMczw+eF+VG6hOkkUFf9mEA/r1r0YlYiI+4yjH5yq8lV/dj27HqV6wm8zBMOo7UlFIH7Li1mFeZyGvL4mDvDes1a6MqA6Yr7EEEsUq5QNNyjXxCW8H+9c= 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 1787754604461780.9387402065245; Wed, 26 Aug 2026 07:30:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdE-00018p-MP; Wed, 26 Aug 2026 10:29:36 -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 1wzEdC-00018C-Bj for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:34 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdA-0001k9-JV for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:34 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 46C471F822; Wed, 26 Aug 2026 14:29:23 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2B0131364B; Wed, 26 Aug 2026 14:29:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +Mk5O0H4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754567; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n4S1P9FhVcrug0Pv7l10DJXkcqiruL0W7qNcFKbXuXY=; b=KHLtgNXvdcfkB21c0ybJnwACXAN91v45NRzdluXtrTH+X+F4npFoxfilffZo0tJYkipmBV dxjnsTMIkHWtQssi32Pf32a2Bd2aiVk/vtqeOtn5+fGh+Td06PZm2C7nBhrmMk8K3hpdyt rQdP5T8yHALSnmcVfVA/yfPL5toj9x4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754567; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n4S1P9FhVcrug0Pv7l10DJXkcqiruL0W7qNcFKbXuXY=; b=06X7TzJ7GyPJWHFxBFdNMvtFP6SMcEKF7jDXGbrFRRrjID/+oYpWf5j1k00ZWlP9kGRU76 F7CUR1/3ezg5ZkDA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=qXYzy0HY; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Y7kPXzdd DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754563; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n4S1P9FhVcrug0Pv7l10DJXkcqiruL0W7qNcFKbXuXY=; b=qXYzy0HYkV5lArkUEMLJRSNJu4IcTmg40dQB75AyE3nnQOOD598EZpMftDRExTAJpAAOcb ACA8oxijmZbeG3PXG24YO8n607JzAk8uW3kbBJFhonDmWfDoHGGSOlF07Lf1SKxKHlDOgY fUC3AfjsARA9iwh0d+dkusx3dEvYLNM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754563; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n4S1P9FhVcrug0Pv7l10DJXkcqiruL0W7qNcFKbXuXY=; b=Y7kPXzddGtcfgam1MUKOAhdeqGzcutirgYyLNtizj5pBVUuxBFoxCQ+6gHWUEE2kH2YXrU iZAqf96WqHaw8bDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh , Juraj Marcin Subject: [PULL 10/30] migration/tests: Add test for fast snapshot load Date: Wed, 26 Aug 2026 11:28:45 -0300 Message-ID: <20260826142905.2315503-11-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 46C471F822 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[4]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754605111158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Add test_postcopy_file_mapped_ram() to test for saving a snapshot in mapped ram format and loading it using postcopy/fast snapshot load. Test is similar to test_precopy_file_mapped_ram() with additional start_hook to set postcopy capabilities on the receiving end. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Reviewed-by: Juraj Marcin Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- tests/qtest/migration/file-tests.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/qtest/migration/file-tests.c b/tests/qtest/migration/fil= e-tests.c index 5118d9dec97..c7e4b05c61c 100644 --- a/tests/qtest/migration/file-tests.c +++ b/tests/qtest/migration/file-tests.c @@ -190,6 +190,25 @@ static void test_multifd_file_mapped_ram_dio(char *nam= e, MigrateCommon *args) test_file_common(args, true); } =20 +static void *migrate_hook_start_postcopy_mapped_ram(QTestState *from, + QTestState *to) +{ + migrate_set_capability( + to, MigrationCapability_lookup.array[MIGRATION_CAPABILITY_POSTCOPY= _RAM], + true); + + return NULL; +} + +static void test_postcopy_file_mapped_ram(char *name, MigrateCommon *args) +{ + args->start.caps[MIGRATION_CAPABILITY_MAPPED_RAM] =3D true; + + args->start_hook =3D migrate_hook_start_postcopy_mapped_ram; + + test_file_common(args, false); +} + #ifndef _WIN32 static void migrate_hook_end_multifd_mapped_ram_fdset(QTestState *from, QTestState *to, @@ -330,6 +349,11 @@ void migration_test_add_file(MigrationTestEnv *env) migration_test_add("/migration/multifd/file/mapped-ram/live", test_multifd_file_mapped_ram_live); =20 + if (env->has_uffd) { + migration_test_add("/migration/postcopy/file/mapped-ram", + test_postcopy_file_mapped_ram); + } + #ifndef _WIN32 migration_test_add("/migration/multifd/file/mapped-ram/fdset", test_multifd_file_mapped_ram_fdset); --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754645; cv=none; d=zohomail.com; s=zohoarc; b=EBP8fjifgpRun52milKkO47rf7GC71b7Yek7VVsPBAbx06KcHB1/C0ISx24VkIRD8gLGtVVe3cU1XdvgsFP45WRQGCH7+dxh5t4Ovas1tbnc/hXfBFicka0CBoA+QrpzEfFXmalYloeV5m0hOPn1oZDU2MwMdf6b/PWvoNv49qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754645; 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=OH8PIWdsNXOXaCv296Cw5fvd6R8sSm1H9li+6Zmc81A=; b=geggg+TeFEl/1Qd+uEwaJNOJuzbo/7Y+dYGjYHRylTQK/k6dl10WQf3RkXTSnY1f0+wegX/Kj8ySyEWqjAubpt1q1Pcy4WFQpCMNU22tE4UAb5WftrbwU53mLzhgaU8epcoXoQNmmklGwRlo1OlJiAw1akImMFkJk22fi5a8WaQ= 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 1787754645255315.0789626297267; Wed, 26 Aug 2026 07:30:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdF-000191-7T; Wed, 26 Aug 2026 10:29:37 -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 1wzEdD-00018h-Tw for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:35 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdC-0001m1-2Z for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:35 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8DD121F811; Wed, 26 Aug 2026 14:29:24 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9C5631364F; Wed, 26 Aug 2026 14:29:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sAFMG0P4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754568; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OH8PIWdsNXOXaCv296Cw5fvd6R8sSm1H9li+6Zmc81A=; b=sRDUzboQSqVZXdecJ/woiz74cIWGZ1wRofMAgHABwgJope/PM9BTAxtTrZ6hWwmoAtCZ52 ucL4MnB7YsfcDpZJIpUt0uE0Sn5u70D/Pc+vXVocy5NWjpCcStXVLe7weaZX0Hmse/+vw5 l3+sx9GMmqmhDVgwiEYoKqrVUHuR6IQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754568; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OH8PIWdsNXOXaCv296Cw5fvd6R8sSm1H9li+6Zmc81A=; b=5iRuVbEkteLt+GSXvbvUSSaWMjsVFkBLIPvySVnAmVe7t1yoC1+Z5vw1wkDfzcMF6FF6ya RSbDgu5tdUNR5VAg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="j/ryIHZI"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="UNsEXp/n" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OH8PIWdsNXOXaCv296Cw5fvd6R8sSm1H9li+6Zmc81A=; b=j/ryIHZIbJ/NE0K3pk7pslg2T4o1mysOmHXEwo6xhZWZevyzcS0VSehpMpIf6v1UBfKeQH Qrp32nQbk+6YeDtlKt/isYSJz75/zby6/0cgeSLwch/LaIx9VfYFBN1rchaVG0JlR6Mq2W e5X9rep6MoEpKjfgeWC4tKMIxBhXVVc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754564; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OH8PIWdsNXOXaCv296Cw5fvd6R8sSm1H9li+6Zmc81A=; b=UNsEXp/nhqXekIfEt2T3dKCXjex3LTvjM9gSSxXeFacy3JEJ29ObvCpF5S6eAQ/TQ8RL1k 1E9zyOQ0dEpcRcBA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Aadeshveer Singh Subject: [PULL 11/30] docs/migration: Add documentation for fast snapshot load feature Date: Wed, 26 Aug 2026 11:28:46 -0300 Message-ID: <20260826142905.2315503-12-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.999]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_VIA_SMTP_AUTH(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_TRACE(0.00)[suse.de:+]; RCPT_COUNT_THREE(0.00)[3]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 8DD121F811 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754647377158500 Content-Type: text/plain; charset="utf-8" From: Aadeshveer Singh Add documenatation for fast snapshot load covering an overview, the architecture, usage and limitations. Signed-off-by: Aadeshveer Singh Reviewed-by: Peter Xu Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- docs/devel/migration/fast-snapshot-load.rst | 82 +++++++++++++++++++++ docs/devel/migration/features.rst | 1 + 2 files changed, 83 insertions(+) create mode 100644 docs/devel/migration/fast-snapshot-load.rst diff --git a/docs/devel/migration/fast-snapshot-load.rst b/docs/devel/migra= tion/fast-snapshot-load.rst new file mode 100644 index 00000000000..fe2361d6fe1 --- /dev/null +++ b/docs/devel/migration/fast-snapshot-load.rst @@ -0,0 +1,82 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Fast Snapshot Load +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Overview +=3D=3D=3D=3D=3D=3D=3D=3D +Fast snapshot load is an extension of the postcopy migration feature +to disk loads. + +Unlike a usual snapshot load, which requires all VM data (RAM as well +as device states) to be loaded into host RAM from the snapshot file +for the guest to run, fast snapshot load uses postcopy infrastructure +to load in only the required device states and allows RAM pages to +be loaded after the guest starts execution. The idea is to start the +guest and serve its page faults on the go, reducing the perceived +resume time for large snapshots. + +Architecture +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +This feature combines postcopy migration and mapped-ram capabilities +to load RAM pages on demand. It is done by catching guest faults using +Linux ``userfaultfd`` and loading the page by calculating the offset +of its location in the snapshot file using mapped-ram capabilities. + +Fault Thread +------------ +The fault thread uses Linux ``userfaultfd`` to catch page faults caused +by guest and directly load the page from the snapshot file. It is +very similar to network postcopy fault thread, with primary difference +being it loads pages directly by reading from the snapshot file. + +Eager Thread +------------ +Eager thread iterates over all pages in RAM and loads each page not +yet loaded by fault thread. It is required as unlike network postcopy +where majority of RAM has already been loaded via precopy, here entire +RAM is waiting to be loaded. If there is no eager loading thread each +page will only be loaded when it is required by guest. In case there +are some background pages that are never/rarely accessed by guest, +the system will be locked in migration state indefinitely. + +Synchronization +--------------- +In order to make sure both of these threads do not load the same page +twice potentially overwriting and corrupting user RAM, a bitmap is +used (``RAMBlock->pending_bmap``) which tracks the pages claimed to +be loaded by threads. This prevents race condition when one thread +is loading the page and other one tries to do the same. + +Usage +=3D=3D=3D=3D=3D + +Simply enable ``mapped-ram`` and ``postcopy-ram`` capabilities on +the destination: + +.. code-block:: text + + migrate_set_capability mapped-ram on + migrate_set_capability postcopy-ram on + +Use a ``file:`` URI for migration: + +.. code-block:: text + + migrate_incoming file:/path/to/snapshot/file + +Limitations +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + + - Multifd + Fast snapshot load is currently incompatible with ``multifd`` + capability. While ``mapped-ram`` allows for parallel disk I/O, + coupling it with ``postcopy`` capability requires additional + infrastructure. + + - Host OS support + Because this feautre essentially depends on ``userfaultfd`` + to trap page faults, it is supported only on Linux hosts. + + - vhost-user + Fast snapshot load does not currently support ``vhost-user`` + backends. diff --git a/docs/devel/migration/features.rst b/docs/devel/migration/featu= res.rst index 9aef79e7fa4..23c2a93173c 100644 --- a/docs/devel/migration/features.rst +++ b/docs/devel/migration/features.rst @@ -11,6 +11,7 @@ Migration has plenty of features to support different use= cases. vfio virtio mapped-ram + fast-snapshot-load CPR qpl-compression uadk-compression --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754602; cv=none; d=zohomail.com; s=zohoarc; b=iQpNdZwfSwYO3yejzyCmJfq1U0v48ASXZB01qz10WzBtGLFRXx2dMmyAuPrhqlId4XiXf/8bMEXBiYJggxy1xl24P3sVwokD0yHUncEnzYx2dmQP8V40zn7jK7VW0RPE4nOgVQM954Pp463HYum5rFrOBTPwZL4uEvxhbqT+YGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754602; 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=EG3tEJg1Q8Qn100kIO02Wh6YC7gR63FtT/AddHPZaVc=; b=PxPy0Ooh3rX25wZ58Grvuk+pnnK2XcOiB4Yy3nvPrQAkKyDrEXTsZrBco+TH1rkPHSKwMirRhObAZUf5ppT1acavL/hvYWcpVIsPHyy1N9Oor7IM+ZBji8NplRQjz1wORB25boaZMqxZrlCxQufrEaalf+e165PFmHpnxSt5Kf0= 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 1787754602197804.2419364817258; Wed, 26 Aug 2026 07:30:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdF-00019F-QG; Wed, 26 Aug 2026 10:29:37 -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 1wzEdE-00018q-U2 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:36 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdD-0001oP-E4 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:36 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D6927211E0; Wed, 26 Aug 2026 14:29:25 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E166513676; Wed, 26 Aug 2026 14:29:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0EwlLET4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754570; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EG3tEJg1Q8Qn100kIO02Wh6YC7gR63FtT/AddHPZaVc=; b=M4Un2QVTru1unj7V4+J8koeFx4qE+NIKxYxsQ1ev5NLGS2moqOp0pgEiIZs1RLKaq9b/Rr rDNhUM1gglsEncGfhIEe99OH9sKVp6M0I7u3vMkZ9hB0+4C6VszLnPh7vBx2ZZHz4DODW3 FlJJ5BbKABbnegzdaqjdIzO4YQuVngg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754570; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EG3tEJg1Q8Qn100kIO02Wh6YC7gR63FtT/AddHPZaVc=; b=UWpwWdynSfl5oGw+7QlpVs1K/3EiNGVppYLgATvhZyb1/CRn9YmNDvOCXoKr4IJaKpxKem jqbS+GcCRWQFABDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=rosQGM+L; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0JpGTwD1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754565; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EG3tEJg1Q8Qn100kIO02Wh6YC7gR63FtT/AddHPZaVc=; b=rosQGM+L5DF85LZM3pc6lS9nw5QnHejzUPLcJGjldjN6AbmtjmCzkq0/3WGhUtG1Z4fyKF B7WI2TPBynZGpU+WF+S0tGD6GvJOhpBhGm71tke+1Q0BBg9QRGl/u2evAvl4etIYXu1ki3 cPzsg8PgaU2AqakUjNQ9WBwDOaLyA5A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754565; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EG3tEJg1Q8Qn100kIO02Wh6YC7gR63FtT/AddHPZaVc=; b=0JpGTwD1XmutYLWMS2SWEFCeONLIpawC1NZR75zgrMD4+wr9vN93fxI7JR4NsyrT3F6LGr rnIyWpiTjflfLHAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 12/30] migration/rdma: Introduce RDMA_CONTROL_NUM Date: Wed, 26 Aug 2026 11:28:47 -0300 Message-ID: <20260826142905.2315503-13-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.990]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid,suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,ionos.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: D6927211E0 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754603597158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Introduce this to say how many control messages we have. We did it because we're going to remove the last one (RDMA_CONTROL_UNREGISTER_FINISHED) soon. Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Jack Wang Signed-off-by: Fabiano Rosas --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 438419d1894..62a509b2362 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -144,6 +144,7 @@ enum { RDMA_CONTROL_REGISTER_FINISHED, /* current iteration finished */ RDMA_CONTROL_UNREGISTER_REQUEST, /* dynamic UN-registration */ RDMA_CONTROL_UNREGISTER_FINISHED, /* unpinning finished */ + RDMA_CONTROL_NUM, }; =20 =20 @@ -235,7 +236,7 @@ static const char *control_desc(unsigned int rdma_contr= ol) [RDMA_CONTROL_UNREGISTER_FINISHED] =3D "UNREGISTER FINISHED", }; =20 - if (rdma_control > RDMA_CONTROL_UNREGISTER_FINISHED) { + if (rdma_control >=3D RDMA_CONTROL_NUM) { return "??BAD CONTROL VALUE??"; } =20 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754771; cv=none; d=zohomail.com; s=zohoarc; b=euOGfG4nWuF7efZ4371JCya0vlRFPaKENRIZx9uycWxFBHEMr9xgHOiqvRpu2qo/xW8k89XnSWfZEF8d5uDwqfoMlqSzma2cSPeTwzeUPh4Lg5rUrjboWdK4GiXgiIHqUSISEd5aTHuQrKRi5xpeTbYpwepmtWfNLHaaHjS9Zwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754771; 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=i5oqjmmi8+oxWLJMCwx89ZO5MoyymFjRNHN3YwHmaE8=; b=QeD3XOkx13aRi23CujEE3+3zIYTjTLDfnsXw0H2FsY+G09TyPl52kv4dJrGV+A2UnXRdMj40snkgGORUto4zt27w9LEMwB0of4nCrU3nEhRsA75bTjpN1csD+0TzRw+YLit1leHcmjvggGMyFiBPOE3d5rTy6tddMX4qcXpv2DM= 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 1787754771667228.11923737860616; Wed, 26 Aug 2026 07:32:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdI-00019m-5Y; Wed, 26 Aug 2026 10:29:40 -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 1wzEdH-00019X-1G for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:39 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdE-0001px-PK for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:38 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 22BFB211C4; Wed, 26 Aug 2026 14:29:27 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 32FD913675; Wed, 26 Aug 2026 14:29:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eA+GAUb4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754571; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i5oqjmmi8+oxWLJMCwx89ZO5MoyymFjRNHN3YwHmaE8=; b=xFz/S35vhM3d8UFHgm2DPMOjLAUlCwy6xpW3YqJL4MUceMFzcQCADngi//L/9/r9Mp/mFg /YcM3UWb9ZcQ3ifa6BRVXm4bNIBjN2mLQjbvEVVJ/Shhvl42LBrhEOE63+M6Ckuwit9Nuo 1ZzZe+71Z0uTM2PJ3i5cUPe60u/8fLU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754571; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i5oqjmmi8+oxWLJMCwx89ZO5MoyymFjRNHN3YwHmaE8=; b=hdtkxuIjbL9+RtspcTo+pTovRzEsVObbLmz2QEi/VupyRfjnvDPbhHW3n5JXcCjjBtXeik GnH26zZCIjMw39Dw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=MIMXgmaA; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=LfMiuARa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754567; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i5oqjmmi8+oxWLJMCwx89ZO5MoyymFjRNHN3YwHmaE8=; b=MIMXgmaAtjE4i1ZF5l6V6xVbMCWX0g/Jr4flLCSG2/yrCaxwHFrQInNxr7IPp8MPZ/Rq6L fkEv7Deu8NjNO4rZvKEu8mWp5mAAA9vyvPwOQeQ5O61yEG4hdbjy48TdYs5kN+v8b3qLRE 7LgHIyztp1mGSR/qTbDQuQMm0BuLvm8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754567; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i5oqjmmi8+oxWLJMCwx89ZO5MoyymFjRNHN3YwHmaE8=; b=LfMiuARaBbyH1b7EYsbeYnNGTAvJ/PNkMsAymbU51bOyrk08o9E0zBxJ+Sbiu9hz952yro 5SFaxR1bZmqzZZBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 13/30] migration/rdma: Remove unregister code Date: Wed, 26 Aug 2026 11:28:48 -0300 Message-ID: <20260826142905.2315503-14-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 22BFB211C4 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.979]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim,gitlab.com:url]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754772490158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu The unregister code was there since the first commit RDMA migration was merged, but it was never functioning. Remove the dead code. Since the two control messages are the last ones, we don't even need to worry about compatibility of legacy RDMA control commands, we can directly remove the messages too. As a side effect, this patch closes a report by removing the code completely. Reported-by: Tristan (@TristanInSec) Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4003 Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/rdma.c | 133 ----------------------------------------- migration/trace-events | 9 --- 2 files changed, 142 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 62a509b2362..eae4afd6df0 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -142,8 +142,6 @@ enum { RDMA_CONTROL_REGISTER_REQUEST, /* dynamic page registration */ RDMA_CONTROL_REGISTER_RESULT, /* key to use after registration */ RDMA_CONTROL_REGISTER_FINISHED, /* current iteration finished */ - RDMA_CONTROL_UNREGISTER_REQUEST, /* dynamic UN-registration */ - RDMA_CONTROL_UNREGISTER_FINISHED, /* unpinning finished */ RDMA_CONTROL_NUM, }; =20 @@ -232,8 +230,6 @@ static const char *control_desc(unsigned int rdma_contr= ol) [RDMA_CONTROL_REGISTER_REQUEST] =3D "REGISTER REQUEST", [RDMA_CONTROL_REGISTER_RESULT] =3D "REGISTER RESULT", [RDMA_CONTROL_REGISTER_FINISHED] =3D "REGISTER FINISHED", - [RDMA_CONTROL_UNREGISTER_REQUEST] =3D "UNREGISTER REQUEST", - [RDMA_CONTROL_UNREGISTER_FINISHED] =3D "UNREGISTER FINISHED", }; =20 if (rdma_control >=3D RDMA_CONTROL_NUM) { @@ -370,9 +366,6 @@ typedef struct RDMAContext { int total_registrations; int total_writes; =20 - int unregister_current, unregister_next; - uint64_t unregistrations[RDMA_SIGNALED_SEND_MAX]; - GHashTable *blockmap; =20 /* the RDMAContext for return path */ @@ -1186,91 +1179,6 @@ static int qemu_rdma_reg_control(RDMAContext *rdma, = int idx) return -1; } =20 -/* - * Perform a non-optimized memory unregistration after every transfer - * for demonstration purposes, only if pin-all is not requested. - * - * Potential optimizations: - * 1. Start a new thread to run this function continuously - - for bit clearing - - and for receipt of unregister messages - * 2. Use an LRU. - * 3. Use workload hints. - */ -static int qemu_rdma_unregister_waiting(RDMAContext *rdma) -{ - Error *err =3D NULL; - - while (rdma->unregistrations[rdma->unregister_current]) { - int ret; - uint64_t wr_id =3D rdma->unregistrations[rdma->unregister_current]; - uint64_t chunk =3D - (wr_id & RDMA_WRID_CHUNK_MASK) >> RDMA_WRID_CHUNK_SHIFT; - uint64_t index =3D - (wr_id & RDMA_WRID_BLOCK_MASK) >> RDMA_WRID_BLOCK_SHIFT; - RDMALocalBlock *block =3D - &(rdma->local_ram_blocks.block[index]); - RDMARegister reg =3D { .current_index =3D index }; - RDMAControlHeader resp =3D { .type =3D RDMA_CONTROL_UNREGISTER_FIN= ISHED, - }; - RDMAControlHeader head =3D { .len =3D sizeof(RDMARegister), - .type =3D RDMA_CONTROL_UNREGISTER_REQUE= ST, - .repeat =3D 1, - }; - - trace_qemu_rdma_unregister_waiting_proc(chunk, - rdma->unregister_current); - - rdma->unregistrations[rdma->unregister_current] =3D 0; - rdma->unregister_current++; - - if (rdma->unregister_current =3D=3D RDMA_SIGNALED_SEND_MAX) { - rdma->unregister_current =3D 0; - } - - - /* - * Unregistration is speculative (because migration is single-thre= aded - * and we cannot break the protocol's inifinband message ordering). - * Thus, if the memory is currently being used for transmission, - * then abort the attempt to unregister and try again - * later the next time a completion is received for this memory. - */ - clear_bit(chunk, block->unregister_bitmap); - - if (test_bit(chunk, block->transit_bitmap)) { - trace_qemu_rdma_unregister_waiting_inflight(chunk); - continue; - } - - trace_qemu_rdma_unregister_waiting_send(chunk); - - ret =3D ibv_dereg_mr(block->pmr[chunk]); - block->pmr[chunk] =3D NULL; - block->remote_keys[chunk] =3D 0; - - if (ret !=3D 0) { - error_report("unregistration chunk failed: %s", - strerror(ret)); - return -1; - } - rdma->total_registrations--; - - reg.key.chunk =3D chunk; - register_to_network(rdma, ®); - ret =3D qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®, - &resp, NULL, NULL, &err); - if (ret < 0) { - error_report_err(err); - return -1; - } - - trace_qemu_rdma_unregister_waiting_complete(chunk); - } - - return 0; -} - static uint64_t qemu_rdma_make_wrid(uint64_t wr_id, uint64_t index, uint64_t chunk) { @@ -2757,8 +2665,6 @@ static int qemu_rdma_drain_cq(RDMAContext *rdma) } } =20 - qemu_rdma_unregister_waiting(rdma); - return 0; } =20 @@ -3336,10 +3242,6 @@ int rdma_registration_handle(QEMUFile *f) .type =3D RDMA_CONTROL_REGISTER_RESULT, .repeat =3D 0, }; - RDMAControlHeader unreg_resp =3D { .len =3D 0, - .type =3D RDMA_CONTROL_UNREGISTER_FINISHED, - .repeat =3D 0, - }; RDMAControlHeader blocks =3D { .type =3D RDMA_CONTROL_RAM_BLOCKS_RESUL= T, .repeat =3D 1 }; QIOChannelRDMA *rioc; @@ -3552,41 +3454,6 @@ int rdma_registration_handle(QEMUFile *f) ret =3D qemu_rdma_post_send_control(rdma, (uint8_t *) results, ®_resp, &err); =20 - if (ret < 0) { - error_report_err(err); - goto err; - } - break; - case RDMA_CONTROL_UNREGISTER_REQUEST: - trace_rdma_registration_handle_unregister(head.repeat); - unreg_resp.repeat =3D head.repeat; - registers =3D (RDMARegister *) rdma->wr_data[idx].control_curr; - - for (int count =3D 0; count < head.repeat; count++) { - reg =3D ®isters[count]; - network_to_register(reg); - - trace_rdma_registration_handle_unregister_loop(count, - reg->current_index, reg->key.chunk); - - block =3D &(rdma->local_ram_blocks.block[reg->current_inde= x]); - - ret =3D ibv_dereg_mr(block->pmr[reg->key.chunk]); - block->pmr[reg->key.chunk] =3D NULL; - - if (ret !=3D 0) { - error_report("rdma unregistration chunk failed: %s", - strerror(errno)); - goto err; - } - - rdma->total_registrations--; - - trace_rdma_registration_handle_unregister_success(reg->key= .chunk); - } - - ret =3D qemu_rdma_post_send_control(rdma, NULL, &unreg_resp, &= err); - if (ret < 0) { error_report_err(err); goto err; diff --git a/migration/trace-events b/migration/trace-events index 4ae1c226f90..6d70f8e8cad 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -242,12 +242,6 @@ qemu_rdma_register_and_get_keys(uint64_t len, void *st= art) "Registering %" PRIu6 qemu_rdma_register_odp_mr(const char *name) "Try to register On-Demand Pag= ing memory region: %s" qemu_rdma_advise_mr(const char *name, uint32_t len, uint64_t addr, const c= har *res) "Try to advise block %s prefetch at %" PRIu32 "@0x%" PRIx64 ": %s" qemu_rdma_resolve_host_trying(const char *host, const char *ip) "Trying %s= =3D> %s" -qemu_rdma_signal_unregister_append(uint64_t chunk, int pos) "Appending unr= egister chunk %" PRIu64 " at position %d" -qemu_rdma_signal_unregister_already(uint64_t chunk) "Unregister chunk %" P= RIu64 " already in queue" -qemu_rdma_unregister_waiting_inflight(uint64_t chunk) "Cannot unregister i= nflight chunk: %" PRIu64 -qemu_rdma_unregister_waiting_proc(uint64_t chunk, int pos) "Processing unr= egister for chunk: %" PRIu64 " at position %d" -qemu_rdma_unregister_waiting_send(uint64_t chunk) "Sending unregister for = chunk: %" PRIu64 -qemu_rdma_unregister_waiting_complete(uint64_t chunk) "Unregister for chun= k: %" PRIu64 " complete." qemu_rdma_write_flush(int sent) "sent total: %d" qemu_rdma_write_one_block(int count, int block, uint64_t chunk, uint64_t c= urrent, uint64_t len, int nb_sent, int nb_chunks) "(%d) Not clobbering: blo= ck: %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d %d" qemu_rdma_write_one_post(uint64_t chunk, long addr, long remote, uint32_t = len) "Posting chunk: %" PRIu64 ", addr: 0x%lx remote: 0x%lx, bytes %" PRIu32 @@ -266,9 +260,6 @@ rdma_registration_handle_ram_blocks_loop(const char *na= me, uint64_t offset, uint rdma_registration_handle_register(int requests) "%d requests" rdma_registration_handle_register_loop(int req, int index, uint64_t addr, = uint64_t chunks) "Registration request (%d): index %d, current_addr %" PRIu= 64 " chunks: %" PRIu64 rdma_registration_handle_register_rkey(int rkey) "0x%x" -rdma_registration_handle_unregister(int requests) "%d requests" -rdma_registration_handle_unregister_loop(int count, int index, uint64_t ch= unk) "Unregistration request (%d): index %d, chunk %" PRIu64 -rdma_registration_handle_unregister_success(uint64_t chunk) "%" PRIu64 rdma_registration_handle_wait(void) "" rdma_registration_start(uint64_t flags) "%" PRIu64 rdma_registration_stop(uint64_t flags) "%" PRIu64 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754696; cv=none; d=zohomail.com; s=zohoarc; b=GjsFhg9MunGcPyiyLFqQm9fUPqM0RSk0yVHamk18yfGvA/zMIaQorOYMtExvSYb0Lajb2YDqPfy9ue352EPZfqGKtqSyAsgRGYc+y8pws0Hu35EhUGiEYMcpEcgNwz1kJXljTkS4u56NpayrVFAebxn2J6ktd5VvuAtS5LkqizI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754696; 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=yvMJE5mi8zsj6pryNWUVC7tIkIWE1cvTrnxmR6wVgmc=; b=Y72qTOlf375Uw1/MqG2H/O8JzbSpqVASPL2PO1LXUQ2D9u145GdOl+YbKb3Lnb6g0Ls+3+jvNmEthnftuK8fQGCsufGmOZ7c8yFTSjUe9TClFPubNsK5gvGzXJ0Kr8VHPZc77rcaSds9HihP/QxdX3ov6olWvAMFr8fp/JGLA9s= 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 178775469635627.72888622053904; Wed, 26 Aug 2026 07:31:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdK-0001B8-NC; Wed, 26 Aug 2026 10:29:42 -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 1wzEdI-0001AG-Ne for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:40 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdF-0001s8-Og for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:40 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 69642211C6; Wed, 26 Aug 2026 14:29:28 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 79B7613354; Wed, 26 Aug 2026 14:29:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IKrSEkf4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754572; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yvMJE5mi8zsj6pryNWUVC7tIkIWE1cvTrnxmR6wVgmc=; b=YI6vfdHBccTefsDSfpH89OYqgc9whNAuAlWRDdVuzQryw5vr+hKgsj58LVOqNgwou55Dm6 B8tJTIfDUt7ty38vWA0oarp3IL33CCHEjmKmibzVGcTr2ioqjJMF5b76DQX/WVoRlTKA8O 5Up3u7psDentpPxWKfawoMa/vOrs1hY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754572; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yvMJE5mi8zsj6pryNWUVC7tIkIWE1cvTrnxmR6wVgmc=; b=DK7i2yVLwa2strxVFgEyrZdAr7h3Kw9balRbLnB4qDzh+WU85W3gt+gLRMRYJ2gUMDnnv4 cn0NIJmQuCQsprBw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Z3FGYKYG; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=jKpJqdtr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754568; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yvMJE5mi8zsj6pryNWUVC7tIkIWE1cvTrnxmR6wVgmc=; b=Z3FGYKYGA1d7AIwIAh2EtIAuVh88gcf5xXrDf7WD58IoekP9aLAFoHJgrs48GfoNQkku5U gW4GH06h0wx+Nl5WX7jrboz8HciAsK48SEIHtIfrH99Ol9pW+EMkwu9FUCfq6RD6RYSH+J hwawphCuiJBZrfUCd60++0jqlg5V/r0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754568; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yvMJE5mi8zsj6pryNWUVC7tIkIWE1cvTrnxmR6wVgmc=; b=jKpJqdtrWdV4xlia9/2ZMW6oxjL6KCrVtteOzCYwM3r7Ni9nK4MTlzdZv3kmFxG/Hljx0T 3ziJPmCFmS82+WCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 14/30] migration/rdma: Stick with rdma_ prefix for all tracepoints Date: Wed, 26 Aug 2026 11:28:49 -0300 Message-ID: <20260826142905.2315503-15-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 69642211C6 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.990]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754697913158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu There're a bunch of RDMA tracepoints that are prefixed with "rdma_*", most of the rest with "qemu_rdma_*". Align them up. The "qemu_" prefix isn't helping. Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/rdma.c | 76 +++++++++++++++++++++--------------------- migration/trace-events | 72 +++++++++++++++++++-------------------- 2 files changed, 74 insertions(+), 74 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index eae4afd6df0..ffae0a887f6 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -631,7 +631,7 @@ static void qemu_rdma_init_ram_blocks(RDMAContext *rdma) memset(local, 0, sizeof *local); ret =3D foreach_not_ignored_block(qemu_rdma_init_one_block, rdma); assert(!ret); - trace_qemu_rdma_init_ram_blocks(local->nb_blocks); + trace_rdma_init_ram_blocks(local->nb_blocks); rdma->dest_blocks =3D g_new0(RDMADestBlock, rdma->local_ram_blocks.nb_blocks); local->init =3D true; @@ -734,11 +734,11 @@ static void qemu_rdma_dump_id(const char *who, struct= ibv_context *verbs) struct ibv_port_attr port; =20 if (ibv_query_port(verbs, 1, &port)) { - trace_qemu_rdma_dump_id_failed(who); + trace_rdma_dump_id_failed(who); return; } =20 - trace_qemu_rdma_dump_id(who, + trace_rdma_dump_id(who, verbs->device->name, verbs->device->dev_name, verbs->device->dev_path, @@ -759,7 +759,7 @@ static void qemu_rdma_dump_gid(const char *who, struct = rdma_cm_id *id) char dgid[33]; inet_ntop(AF_INET6, &id->route.addr.addr.ibaddr.sgid, sgid, sizeof sgi= d); inet_ntop(AF_INET6, &id->route.addr.addr.ibaddr.dgid, dgid, sizeof dgi= d); - trace_qemu_rdma_dump_gid(who, sgid, dgid); + trace_rdma_dump_gid(who, sgid, dgid); } =20 /* @@ -809,7 +809,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Er= ror **errp) =20 inet_ntop(e->ai_family, &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof= ip); - trace_qemu_rdma_resolve_host_trying(rdma->host, ip); + trace_rdma_resolve_host_trying(rdma->host, ip); =20 ret =3D rdma_resolve_addr(rdma->cm_id, NULL, e->ai_dst_addr, RDMA_RESOLVE_TIMEOUT_MS); @@ -998,7 +998,7 @@ static void qemu_rdma_advise_prefetch_mr(struct ibv_pd = *pd, uint64_t addr, ret =3D ibv_advise_mr(pd, advice, IBV_ADVISE_MR_FLAG_FLUSH, &sg_list, 1); /* ignore the error */ - trace_qemu_rdma_advise_mr(name, len, addr, strerror(ret)); + trace_rdma_advise_mr(name, len, addr, strerror(ret)); #endif } =20 @@ -1029,7 +1029,7 @@ static int qemu_rdma_reg_whole_ram_blocks(RDMAContext= *rdma, Error **errp) ibv_reg_mr(rdma->pd, local->block[i].local_host_addr, local->block[i].length, access); - trace_qemu_rdma_register_odp_mr(local->block[i].block_name= ); + trace_rdma_register_odp_mr(local->block[i].block_name); =20 if (local->block[i].mr) { qemu_rdma_advise_prefetch_mr(rdma->pd, @@ -1125,7 +1125,7 @@ static int qemu_rdma_register_and_get_keys(RDMAContex= t *rdma, int access =3D rkey ? IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_W= RITE : 0; =20 - trace_qemu_rdma_register_and_get_keys(len, chunk_start); + trace_rdma_register_and_get_keys(len, chunk_start); =20 block->pmr[chunk] =3D ibv_reg_mr(rdma->pd, chunk_start, len, acces= s); /* @@ -1139,7 +1139,7 @@ static int qemu_rdma_register_and_get_keys(RDMAContex= t *rdma, access |=3D IBV_ACCESS_ON_DEMAND; /* register ODP mr */ block->pmr[chunk] =3D ibv_reg_mr(rdma->pd, chunk_start, len, a= ccess); - trace_qemu_rdma_register_odp_mr(block->block_name); + trace_rdma_register_odp_mr(block->block_name); =20 if (block->pmr[chunk]) { qemu_rdma_advise_prefetch_mr(rdma->pd, (uintptr_t)chunk_st= art, @@ -1221,7 +1221,7 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, =20 if (rdma->control_ready_expected && (wr_id >=3D RDMA_WRID_RECV_CONTROL)) { - trace_qemu_rdma_poll_recv(wr_id - RDMA_WRID_RECV_CONTROL, wr_id, + trace_rdma_poll_recv(wr_id - RDMA_WRID_RECV_CONTROL, wr_id, rdma->nb_sent); rdma->control_ready_expected =3D 0; } @@ -1233,7 +1233,7 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, (wc.wr_id & RDMA_WRID_BLOCK_MASK) >> RDMA_WRID_BLOCK_SHIFT; RDMALocalBlock *block =3D &(rdma->local_ram_blocks.block[index]); =20 - trace_qemu_rdma_poll_write(wr_id, rdma->nb_sent, + trace_rdma_poll_write(wr_id, rdma->nb_sent, index, chunk, block->local_host_addr, (void *)(uintptr_t)block->remote_host_a= ddr); =20 @@ -1243,7 +1243,7 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, rdma->nb_sent--; } } else { - trace_qemu_rdma_poll_other(wr_id, rdma->nb_sent); + trace_rdma_poll_other(wr_id, rdma->nb_sent); } =20 *wr_id_out =3D wc.wr_id; @@ -1378,7 +1378,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, break; } if (wr_id !=3D wrid_requested) { - trace_qemu_rdma_block_for_wrid_miss(wrid_requested, wr_id); + trace_rdma_block_for_wrid_miss(wrid_requested, wr_id); } } =20 @@ -1415,7 +1415,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, break; } if (wr_id !=3D wrid_requested) { - trace_qemu_rdma_block_for_wrid_miss(wrid_requested, wr_id); + trace_rdma_block_for_wrid_miss(wrid_requested, wr_id); } } =20 @@ -1463,7 +1463,7 @@ static int qemu_rdma_post_send_control(RDMAContext *r= dma, uint8_t *buf, .num_sge =3D 1, }; =20 - trace_qemu_rdma_post_send_control(control_desc(head->type)); + trace_rdma_post_send_control(control_desc(head->type)); =20 /* * We don't actually need to do a memcpy() in here if we used @@ -1546,10 +1546,10 @@ static int qemu_rdma_exchange_get_response(RDMACont= ext *rdma, network_to_control((void *) rdma->wr_data[idx].control); memcpy(head, rdma->wr_data[idx].control, sizeof(RDMAControlHeader)); =20 - trace_qemu_rdma_exchange_get_response_start(control_desc(expecting)); + trace_rdma_exchange_get_response_start(control_desc(expecting)); =20 if (expecting =3D=3D RDMA_CONTROL_NONE) { - trace_qemu_rdma_exchange_get_response_none(control_desc(head->type= ), + trace_rdma_exchange_get_response_none(control_desc(head->type), head->type); } else if (head->type !=3D expecting || head->type =3D=3D RDMA_CONTROL= _ERROR) { error_setg(errp, "Was expecting a %s (%d) control message" @@ -1659,14 +1659,14 @@ static int qemu_rdma_exchange_send(RDMAContext *rdm= a, RDMAControlHeader *head, */ if (resp) { if (callback) { - trace_qemu_rdma_exchange_send_issue_callback(); + trace_rdma_exchange_send_issue_callback(); ret =3D callback(rdma, errp); if (ret < 0) { return -1; } } =20 - trace_qemu_rdma_exchange_send_waiting(control_desc(resp->type)); + trace_rdma_exchange_send_waiting(control_desc(resp->type)); ret =3D qemu_rdma_exchange_get_response(rdma, resp, resp->type, RDMA_WRID_DATA, errp); @@ -1679,7 +1679,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, if (resp_idx) { *resp_idx =3D RDMA_WRID_DATA; } - trace_qemu_rdma_exchange_send_received(control_desc(resp->type)); + trace_rdma_exchange_send_received(control_desc(resp->type)); } =20 rdma->control_ready_expected =3D 1; @@ -1782,7 +1782,7 @@ retry: } } =20 - trace_qemu_rdma_write_one_top(chunks + 1, + trace_rdma_write_one_top(chunks + 1, (chunks + 1) * chunk_size / 1024 / 1024); =20 chunk_end =3D ram_chunk_end(block, chunk + chunks); @@ -1790,7 +1790,7 @@ retry: =20 while (test_bit(chunk, block->transit_bitmap)) { (void)count; - trace_qemu_rdma_write_one_block(count++, current_index, chunk, + trace_rdma_write_one_block(count++, current_index, chunk, sge.addr, length, rdma->nb_sent, block->nb_chunks); =20 ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); @@ -1823,7 +1823,7 @@ retry: head.len =3D sizeof(comp); head.type =3D RDMA_CONTROL_COMPRESS; =20 - trace_qemu_rdma_write_one_zero(chunk, sge.length, + trace_rdma_write_one_zero(chunk, sge.length, current_index, current_addr= ); =20 compress_to_network(rdma, &comp); @@ -1860,7 +1860,7 @@ retry: } reg.chunks =3D chunks; =20 - trace_qemu_rdma_write_one_sendreg(chunk, sge.length, current_i= ndex, + trace_rdma_write_one_sendreg(chunk, sge.length, current_index, current_addr); =20 register_to_network(rdma, ®); @@ -1883,7 +1883,7 @@ retry: =20 network_to_result(reg_result); =20 - trace_qemu_rdma_write_one_recvregres(block->remote_keys[chunk], + trace_rdma_write_one_recvregres(block->remote_keys[chunk], reg_result->rkey, chunk); =20 block->remote_keys[chunk] =3D reg_result->rkey; @@ -1926,7 +1926,7 @@ retry: send_wr.wr.rdma.remote_addr =3D block->remote_host_addr + (current_addr - block->offset); =20 - trace_qemu_rdma_write_one_post(chunk, sge.addr, send_wr.wr.rdma.remote= _addr, + trace_rdma_write_one_post(chunk, sge.addr, send_wr.wr.rdma.remote_addr, sge.length); =20 /* @@ -1936,7 +1936,7 @@ retry: ret =3D ibv_post_send(rdma->qp, &send_wr, &bad_wr); =20 if (ret =3D=3D ENOMEM) { - trace_qemu_rdma_write_one_queue_full(); + trace_rdma_write_one_queue_full(); ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { error_setg(errp, "rdma migration: failed to make " @@ -1993,7 +1993,7 @@ static int qemu_rdma_write_flush(RDMAContext *rdma, E= rror **errp) =20 if (ret =3D=3D 0) { rdma->nb_sent++; - trace_qemu_rdma_write_flush(rdma->nb_sent); + trace_rdma_write_flush(rdma->nb_sent); } =20 rdma->current_length =3D 0; @@ -2109,7 +2109,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) } =20 rdma_disconnect(rdma->cm_id); - trace_qemu_rdma_cleanup_disconnect(); + trace_rdma_cleanup_disconnect(); rdma->connected =3D false; } =20 @@ -2292,7 +2292,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, * on the source first requested the capability. */ if (rdma->pin_all) { - trace_qemu_rdma_connect_pin_all_requested(); + trace_rdma_connect_pin_all_requested(); cap.flags |=3D RDMA_CAPABILITY_PIN_ALL; } =20 @@ -2343,7 +2343,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, rdma->pin_all =3D false; } =20 - trace_qemu_rdma_connect_pin_all_outcome(rdma->pin_all); + trace_rdma_connect_pin_all_outcome(rdma->pin_all); =20 rdma_ack_cm_event(cm_event); =20 @@ -2412,7 +2412,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) =20 inet_ntop(e->ai_family, &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof= ip); - trace_qemu_rdma_dest_init_trying(rdma->host, ip); + trace_rdma_dest_init_trying(rdma->host, ip); ret =3D rdma_bind_addr(listen_id, e->ai_dst_addr); if (ret < 0) { continue; @@ -2547,7 +2547,7 @@ static size_t qemu_rdma_fill(RDMAContext *rdma, uint8= _t *buf, size_t len =3D 0; =20 if (rdma->wr_data[idx].control_len) { - trace_qemu_rdma_fill(rdma->wr_data[idx].control_len, size); + trace_rdma_fill(rdma->wr_data[idx].control_len, size); =20 len =3D MIN(size, rdma->wr_data[idx].control_len); memcpy(buf, rdma->wr_data[idx].control_curr, len); @@ -2859,7 +2859,7 @@ static int qio_channel_rdma_close(QIOChannel *ioc, RDMAContext *rdmain, *rdmaout; struct rdma_close_rcu *rcu =3D g_new(struct rdma_close_rcu, 1); =20 - trace_qemu_rdma_close(); + trace_rdma_close(); =20 rdmain =3D rioc->rdmain; if (rdmain) { @@ -3132,11 +3132,11 @@ static int qemu_rdma_accept(RDMAContext *rdma) =20 rdma_ack_cm_event(cm_event); =20 - trace_qemu_rdma_accept_pin_state(rdma->pin_all); + trace_rdma_accept_pin_state(rdma->pin_all); =20 caps_to_network(&cap); =20 - trace_qemu_rdma_accept_pin_verbsc(verbs); + trace_rdma_accept_pin_verbsc(verbs); =20 if (!rdma->verbs) { rdma->verbs =3D verbs; @@ -3727,13 +3727,13 @@ static void rdma_accept_incoming_migration(void *op= aque) RDMAContext *rdma =3D opaque; QIOChannel *ioc; =20 - trace_qemu_rdma_accept_incoming_migration(); + trace_rdma_accept_incoming_migration(); if (qemu_rdma_accept(rdma) < 0) { error_report("RDMA ERROR: Migration initialization failed"); return; } =20 - trace_qemu_rdma_accept_incoming_migration_accepted(); + trace_rdma_accept_incoming_migration_accepted(); =20 if (rdma->is_return_path) { return; diff --git a/migration/trace-events b/migration/trace-events index 6d70f8e8cad..e87d4abd911 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -214,42 +214,42 @@ migrate_global_state_post_load(const char *state) "lo= aded state: %s" migrate_global_state_pre_save(const char *state) "saved state: %s" =20 # rdma.c -qemu_rdma_accept_incoming_migration(void) "" -qemu_rdma_accept_incoming_migration_accepted(void) "" -qemu_rdma_accept_pin_state(bool pin) "%d" -qemu_rdma_accept_pin_verbsc(void *verbs) "Verbs context after listen: %p" -qemu_rdma_block_for_wrid_miss(uint64_t wcomp, uint64_t req) "A Wanted wrid= %" PRIu64 " but got %" PRIu64 -qemu_rdma_cleanup_disconnect(void) "" -qemu_rdma_close(void) "" -qemu_rdma_connect_pin_all_requested(void) "" -qemu_rdma_connect_pin_all_outcome(bool pin) "%d" -qemu_rdma_dest_init_trying(const char *host, const char *ip) "%s =3D> %s" -qemu_rdma_dump_id_failed(const char *who) "%s RDMA Device opened, but can'= t query port information" -qemu_rdma_dump_id(const char *who, const char *name, const char *dev_name,= const char *dev_path, const char *ibdev_path, int transport, const char *t= ransport_name) "%s RDMA Device opened: kernel name %s uverbs device name %s= , infiniband_verbs class device path %s, infiniband class device path %s, t= ransport: (%d) %s" -qemu_rdma_dump_gid(const char *who, const char *src, const char *dst) "%s = Source GID: %s, Dest GID: %s" -qemu_rdma_exchange_get_response_start(const char *desc) "CONTROL: %s recei= ving..." -qemu_rdma_exchange_get_response_none(const char *desc, int type) "Surprise= : got %s (%d)" -qemu_rdma_exchange_send_issue_callback(void) "" -qemu_rdma_exchange_send_waiting(const char *desc) "Waiting for response %s" -qemu_rdma_exchange_send_received(const char *desc) "Response %s received." -qemu_rdma_fill(size_t control_len, size_t size) "RDMA %zd of %zd bytes alr= eady in buffer" -qemu_rdma_init_ram_blocks(int blocks) "Allocated %d local ram block struct= ures" -qemu_rdma_poll_recv(uint64_t comp, int64_t id, int sent) "completion %" PR= Iu64 " received (%" PRId64 ") left %d" -qemu_rdma_poll_write(uint64_t comp, int left, uint64_t block, uint64_t chu= nk, void *local, void *remote) "completions %" PRIu64 " left %d, block %" P= RIu64 ", chunk: %" PRIu64 " %p %p" -qemu_rdma_poll_other(uint64_t comp, int left) "other completion %" PRIu64 = " received left %d" -qemu_rdma_post_send_control(const char *desc) "CONTROL: sending %s.." -qemu_rdma_register_and_get_keys(uint64_t len, void *start) "Registering %"= PRIu64 " bytes @ %p" -qemu_rdma_register_odp_mr(const char *name) "Try to register On-Demand Pag= ing memory region: %s" -qemu_rdma_advise_mr(const char *name, uint32_t len, uint64_t addr, const c= har *res) "Try to advise block %s prefetch at %" PRIu32 "@0x%" PRIx64 ": %s" -qemu_rdma_resolve_host_trying(const char *host, const char *ip) "Trying %s= =3D> %s" -qemu_rdma_write_flush(int sent) "sent total: %d" -qemu_rdma_write_one_block(int count, int block, uint64_t chunk, uint64_t c= urrent, uint64_t len, int nb_sent, int nb_chunks) "(%d) Not clobbering: blo= ck: %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d %d" -qemu_rdma_write_one_post(uint64_t chunk, long addr, long remote, uint32_t = len) "Posting chunk: %" PRIu64 ", addr: 0x%lx remote: 0x%lx, bytes %" PRIu32 -qemu_rdma_write_one_queue_full(void) "" -qemu_rdma_write_one_recvregres(int mykey, int theirkey, uint64_t chunk) "R= eceived registration result: my key: 0x%x their key 0x%x, chunk %" PRIu64 -qemu_rdma_write_one_sendreg(uint64_t chunk, int len, int index, int64_t of= fset) "Sending registration request chunk %" PRIu64 " for %d bytes, index: = %d, offset: %" PRId64 -qemu_rdma_write_one_top(uint64_t chunks, uint64_t size) "Writing %" PRIu64= " chunks, (%" PRIu64 " MB)" -qemu_rdma_write_one_zero(uint64_t chunk, int len, int index, int64_t offse= t) "Entire chunk is zero, sending compress: %" PRIu64 " for %d bytes, index= : %d, offset: %" PRId64 +rdma_accept_incoming_migration(void) "" +rdma_accept_incoming_migration_accepted(void) "" +rdma_accept_pin_state(bool pin) "%d" +rdma_accept_pin_verbsc(void *verbs) "Verbs context after listen: %p" +rdma_block_for_wrid_miss(uint64_t wcomp, uint64_t req) "A Wanted wrid %" P= RIu64 " but got %" PRIu64 +rdma_cleanup_disconnect(void) "" +rdma_close(void) "" +rdma_connect_pin_all_requested(void) "" +rdma_connect_pin_all_outcome(bool pin) "%d" +rdma_dest_init_trying(const char *host, const char *ip) "%s =3D> %s" +rdma_dump_id_failed(const char *who) "%s RDMA Device opened, but can't que= ry port information" +rdma_dump_id(const char *who, const char *name, const char *dev_name, cons= t char *dev_path, const char *ibdev_path, int transport, const char *transp= ort_name) "%s RDMA Device opened: kernel name %s uverbs device name %s, inf= iniband_verbs class device path %s, infiniband class device path %s, transp= ort: (%d) %s" +rdma_dump_gid(const char *who, const char *src, const char *dst) "%s Sourc= e GID: %s, Dest GID: %s" +rdma_exchange_get_response_start(const char *desc) "CONTROL: %s receiving.= .." +rdma_exchange_get_response_none(const char *desc, int type) "Surprise: got= %s (%d)" +rdma_exchange_send_issue_callback(void) "" +rdma_exchange_send_waiting(const char *desc) "Waiting for response %s" +rdma_exchange_send_received(const char *desc) "Response %s received." +rdma_fill(size_t control_len, size_t size) "RDMA %zd of %zd bytes already = in buffer" +rdma_init_ram_blocks(int blocks) "Allocated %d local ram block structures" +rdma_poll_recv(uint64_t comp, int64_t id, int sent) "completion %" PRIu64 = " received (%" PRId64 ") left %d" +rdma_poll_write(uint64_t comp, int left, uint64_t block, uint64_t chunk, v= oid *local, void *remote) "completions %" PRIu64 " left %d, block %" PRIu64= ", chunk: %" PRIu64 " %p %p" +rdma_poll_other(uint64_t comp, int left) "other completion %" PRIu64 " rec= eived left %d" +rdma_post_send_control(const char *desc) "CONTROL: sending %s.." +rdma_register_and_get_keys(uint64_t len, void *start) "Registering %" PRIu= 64 " bytes @ %p" +rdma_register_odp_mr(const char *name) "Try to register On-Demand Paging m= emory region: %s" +rdma_advise_mr(const char *name, uint32_t len, uint64_t addr, const char *= res) "Try to advise block %s prefetch at %" PRIu32 "@0x%" PRIx64 ": %s" +rdma_resolve_host_trying(const char *host, const char *ip) "Trying %s =3D>= %s" +rdma_write_flush(int sent) "sent total: %d" +rdma_write_one_block(int count, int block, uint64_t chunk, uint64_t curren= t, uint64_t len, int nb_sent, int nb_chunks) "(%d) Not clobbering: block: %= d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d %d" +rdma_write_one_post(uint64_t chunk, long addr, long remote, uint32_t len) = "Posting chunk: %" PRIu64 ", addr: 0x%lx remote: 0x%lx, bytes %" PRIu32 +rdma_write_one_queue_full(void) "" +rdma_write_one_recvregres(int mykey, int theirkey, uint64_t chunk) "Receiv= ed registration result: my key: 0x%x their key 0x%x, chunk %" PRIu64 +rdma_write_one_sendreg(uint64_t chunk, int len, int index, int64_t offset)= "Sending registration request chunk %" PRIu64 " for %d bytes, index: %d, o= ffset: %" PRId64 +rdma_write_one_top(uint64_t chunks, uint64_t size) "Writing %" PRIu64 " ch= unks, (%" PRIu64 " MB)" +rdma_write_one_zero(uint64_t chunk, int len, int index, int64_t offset) "E= ntire chunk is zero, sending compress: %" PRIu64 " for %d bytes, index: %d,= offset: %" PRId64 rdma_add_block(const char *block_name, int block, uint64_t addr, uint64_t = offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Added Block= : '%s':%d, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: = %" PRIu64 " bits %" PRIu64 " chunks %d" rdma_block_notification_handle(const char *name, int index) "%s at %d" rdma_delete_block(void *block, uint64_t addr, uint64_t offset, uint64_t le= n, uint64_t end, uint64_t bits, int chunks) "Deleted Block: %p, addr: %" PR= Iu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PR= Iu64 " chunks %d" --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754707; cv=none; d=zohomail.com; s=zohoarc; b=cNNCop4yPjyEDd96eVU1ypQzW4LpP+Tj6U4C94D/9aNQadLHFBwW0JFHWD14YjjbyHSweSH1MAB6Y6s84bIQmfXZ9Kh5/WruP5PFGgPdQ57M5hLHL4ln/rhw92gV0+JwMF24CQA65pZyvtUk569y3SrXzD74ZQgR5OALKH7d6lY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754707; 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=8srkfRBJ8tr/sXtX0mTfj4YigIbqYI314IE+GV72yvo=; b=PrisVMalg5mhN3q8uhGNRor6iUYE5pxnYrYaeSdmj5qrXvoAP+wTzaMV5CoPKr13pQqxEslN6oWI50pgc/UgQW9sdVgBDxTK7MdYy8YEu+zg6C6ul6ZF8DBa7tBxHCMjV+xdFZLb0lE53Aoi7ZTqqpwQcQ6TFiav+zj7DfKVees= 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 1787754707378553.8474667533973; Wed, 26 Aug 2026 07:31:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdK-0001Al-7E; Wed, 26 Aug 2026 10:29:42 -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 1wzEdJ-0001AP-6L for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:41 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdH-0001tP-3T for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:40 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AE7531F839; Wed, 26 Aug 2026 14:29:29 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BEFC513674; Wed, 26 Aug 2026 14:29:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WFXFI0j4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8srkfRBJ8tr/sXtX0mTfj4YigIbqYI314IE+GV72yvo=; b=nFQjgW2rd6++O67gBpU0b/PiAPaV+iz44ioHhy4sfLQNzCdYIJNU6PUpd5D6pzewQ67eqX wqvhkxxTnnysPEmACY6O7bxS7x1ZXnpyra5Jx6CmpB7SWDYX4toy4Vv08WKOm5TxzNFTF/ I64Zryr+pMCz7UU5c1BlBj5R2uNf/B0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8srkfRBJ8tr/sXtX0mTfj4YigIbqYI314IE+GV72yvo=; b=1aLJqBRz+HFW2/e+wshRBt53Yog8FjtDrB7ZuCL/qlVjxITmYAf2j3tv7k94/1Wz3oVWkn Y2QHkr5CWimntpDg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=K18IGgEn; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=VmztXbOZ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754569; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8srkfRBJ8tr/sXtX0mTfj4YigIbqYI314IE+GV72yvo=; b=K18IGgEnfww+PYf20L0nP9ikPvGQxkq6/A/JLmmbfAZ4k2vuF1bO37gW8gUjCAfa4pm12/ O/VlwTMTTIES4VDgUVpjYrNmI6y5SLBWD3ExyMNo/Y5KxbdsUZGfxQGb9QyTCGrDdsrQjh 1HWEHDy4oiosSMeaTBHE9C0XT4TY7VQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754569; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8srkfRBJ8tr/sXtX0mTfj4YigIbqYI314IE+GV72yvo=; b=VmztXbOZj/vdbOWEMpxDtOSh1IP71ot3HExdCwDNVx+PBnKAtYWm9jJI0vxZ7abEWgsrNT hfujZYK/t8XhWdBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 15/30] migration/rdma: Drop RDMALocalBlock.is_ram_block Date: Wed, 26 Aug 2026 11:28:50 -0300 Message-ID: <20260826142905.2315503-16-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.977]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[gitlab.com:url,suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; URIBL_BLOCKED(0.00)[gitlab.com:url,ionos.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid,suse.de:dkim]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: AE7531F839 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754707942158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu This is guaranteed to be true. There seems to have support for some dynamically allocated buffers but it was never really supported. Remove dead code. As a side effect, this patch closes a report by removing the buggy code completely. Reported-by: Tristan (@TristanInSec) Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4006 Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Signed-off-by: Fabiano Rosas --- migration/rdma.c | 75 ++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 54 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index ffae0a887f6..63a8370be22 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -196,7 +196,6 @@ typedef struct RDMALocalBlock { uint32_t remote_rkey; /* rkeys for non-chunk-level registrat= ion */ int index; /* which block are we */ unsigned int src_index; /* (Only used on dest) */ - bool is_ram_block; int nb_chunks; unsigned long *transit_bitmap; unsigned long *unregister_bitmap; @@ -279,7 +278,6 @@ static void network_to_dest_block(RDMADestBlock *db) */ typedef struct RDMALocalBlocks { int nb_blocks; - bool init; /* main memory init complete */ RDMALocalBlock *block; } RDMALocalBlocks; =20 @@ -441,14 +439,12 @@ static void register_to_network(RDMAContext *rdma, RD= MARegister *reg) RDMALocalBlock *local_block; local_block =3D &rdma->local_ram_blocks.block[reg->current_index]; =20 - if (local_block->is_ram_block) { - /* - * current_addr as passed in is an address in the local ram_addr_t - * space, we need to translate this for the destination - */ - reg->key.current_addr -=3D local_block->offset; - reg->key.current_addr +=3D rdma->dest_blocks[reg->current_index].o= ffset; - } + /* + * current_addr as passed in is an address in the local ram_addr_t + * space, we need to translate this for the destination + */ + reg->key.current_addr -=3D local_block->offset; + reg->key.current_addr +=3D rdma->dest_blocks[reg->current_index].offse= t; reg->key.current_addr =3D htonll(reg->key.current_addr); reg->current_index =3D htonl(reg->current_index); reg->chunks =3D htonll(reg->chunks); @@ -585,8 +581,6 @@ static void rdma_add_block(RDMAContext *rdma, const cha= r *block_name, bitmap_clear(block->unregister_bitmap, 0, block->nb_chunks); block->remote_keys =3D g_new0(uint32_t, block->nb_chunks); =20 - block->is_ram_block =3D local->init ? false : true; - if (rdma->blockmap) { g_hash_table_insert(rdma->blockmap, (void *)(uintptr_t)block_offse= t, block); } @@ -634,7 +628,6 @@ static void qemu_rdma_init_ram_blocks(RDMAContext *rdma) trace_rdma_init_ram_blocks(local->nb_blocks); rdma->dest_blocks =3D g_new0(RDMADestBlock, rdma->local_ram_blocks.nb_blocks); - local->init =3D true; } =20 /* @@ -1767,19 +1760,10 @@ retry: chunk =3D ram_chunk_index(block->local_host_addr, (uint8_t *)(uintptr_t)sge.addr); chunk_start =3D ram_chunk_start(block, chunk); + chunks =3D length / chunk_size; =20 - if (block->is_ram_block) { - chunks =3D length / chunk_size; - - if (chunks && ((length % chunk_size) =3D=3D 0)) { - chunks--; - } - } else { - chunks =3D block->length / chunk_size; - - if (chunks && ((block->length % chunk_size) =3D=3D 0)) { - chunks--; - } + if (chunks && ((length % chunk_size) =3D=3D 0)) { + chunks--; } =20 trace_rdma_write_one_top(chunks + 1, @@ -1804,7 +1788,7 @@ retry: } } =20 - if (!rdma->pin_all || !block->is_ram_block) { + if (!rdma->pin_all) { if (!block->remote_keys[chunk]) { /* * This chunk has not yet been registered, so first check to s= ee @@ -1853,11 +1837,7 @@ retry: * Otherwise, tell other side to register. */ reg.current_index =3D current_index; - if (block->is_ram_block) { - reg.key.current_addr =3D current_addr; - } else { - reg.key.chunk =3D chunk; - } + reg.key.current_addr =3D current_addr; reg.chunks =3D chunks; =20 trace_rdma_write_one_sendreg(chunk, sge.length, current_index, @@ -3408,30 +3388,17 @@ int rdma_registration_handle(QEMUFile *f) goto err; } block =3D &(rdma->local_ram_blocks.block[reg->current_inde= x]); - if (block->is_ram_block) { - if (block->offset > reg->key.current_addr) { - error_report("rdma: bad register address for block= %s" - " offset: %" PRIx64 " current_addr: %" PRIx64, - block->block_name, block->offset, - reg->key.current_addr); - goto err; - } - host_addr =3D (block->local_host_addr + - (reg->key.current_addr - block->offset)); - chunk =3D ram_chunk_index(block->local_host_addr, - (uint8_t *) host_addr); - } else { - chunk =3D reg->key.chunk; - host_addr =3D block->local_host_addr + - (reg->key.chunk * migrate_rdma_chunk_size()); - /* Check for particularly bad chunk value */ - if (host_addr < (void *)block->local_host_addr) { - error_report("rdma: bad chunk for block %s" - " chunk: %" PRIx64, - block->block_name, reg->key.chunk); - goto err; - } + if (block->offset > reg->key.current_addr) { + error_report("rdma: bad register address for block %s" + " offset: %" PRIx64 " current_addr: %" PRIx64, + block->block_name, block->offset, + reg->key.current_addr); + goto err; } + host_addr =3D (block->local_host_addr + + (reg->key.current_addr - block->offset)); + chunk =3D ram_chunk_index(block->local_host_addr, + (uint8_t *) host_addr); chunk_start =3D ram_chunk_start(block, chunk); chunk_end =3D ram_chunk_end(block, chunk + reg->chunks); /* avoid "-Waddress-of-packed-member" warning */ --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754760; cv=none; d=zohomail.com; s=zohoarc; b=nSNWJv3SnY02LftX4hPDzkzvw6oCl7JpfOQm0raPSEP14uFfniSNjerKYCvjXHchk1R3D2YCrKho5p/IiPaKokGnNVy71rXBQ7Tuyc+9ilsBNbBne6FAbEF+CZ+W8fnhnEzGI6ycPm0Mv4d3gNrtJ5J2gYc6mwms7SB4uqJPbqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754760; 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=aFc6hA/abHmRVaNgSz5gbCQGFsz9FdGFyIKHi0KIXlQ=; b=i097qRwIy5Ggiw0QN98qilGckiNs+3M0aoL1wqpdnAWH1+tUzd7Ml6d8/qGYFgUk2wOYnxdgj3zBtk6hYVE21nZC3LI3j16ReqjhcFy+v+/IL+eZKQ/cpXPXwN+de+91Fb5nqG9G7LURMOIsOJw9h8kkB3EnMYgKgg6VmJvh5gA= 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 17877547604737.098245480506421; Wed, 26 Aug 2026 07:32:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdL-0001BG-Lv; Wed, 26 Aug 2026 10:29:43 -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 1wzEdK-0001An-BM for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:42 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdI-0001v6-Hm for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:41 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 0007B1F7F8; Wed, 26 Aug 2026 14:29:30 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 103FD1361C; Wed, 26 Aug 2026 14:29:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MHanNEn4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754575; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aFc6hA/abHmRVaNgSz5gbCQGFsz9FdGFyIKHi0KIXlQ=; b=W7iPl918/iK3Vxlrg2tFPtzbLj9NcEM7tlwPmS0E+FsH8eobu1e6ojSalpCE/D5IrlYqmz Af2asn/1soV+9AUoQ7DAlz1IHj1f5A6ZtNB1mJTt6VekR4m/+7Wd0hxq6mOSjqA4LRRqsH VLkfiH0lHqEKg355n8Vk3uDVTRB1PUA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754575; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aFc6hA/abHmRVaNgSz5gbCQGFsz9FdGFyIKHi0KIXlQ=; b=i8usxq50KAzDAMYt4KhNbqsS2hI8T8zJbFrl/S9FPXII7jeS2dZqrkwwLQgWZsI+UqEhVi CrjBublyKwhqAOAQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=CNqepotz; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0E8y9jB5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754571; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aFc6hA/abHmRVaNgSz5gbCQGFsz9FdGFyIKHi0KIXlQ=; b=CNqepotzv7wQGxQN9Dkc0gFIc4X4F9Eef4neDhtNVrWCJueeVZqCYL39hNDyl/fKtNUnh+ 1HZwmHG6BqcqG92/ZI7EoHjMBlJCOq00GbEa5lbqr8VaFQwHltwlaYxdkkKb37HkVya6LE z1tV6na2vKoxo53fyG9tmrQvcu6Bk2s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754571; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aFc6hA/abHmRVaNgSz5gbCQGFsz9FdGFyIKHi0KIXlQ=; b=0E8y9jB5wiLLWDAGg5ylkIXk6FnUetMFV38+JqmM+qHfQop9O5oDil1VgCjrt+HjmMy/u1 6/+P8r0zo8SzlsBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 16/30] migration/rdma: Drop RDMALocalBlock.unregister_bitmap Date: Wed, 26 Aug 2026 11:28:51 -0300 Message-ID: <20260826142905.2315503-17-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.990]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,ionos.com:email]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; URIBL_BLOCKED(0.00)[ionos.com:email,suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCPT_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 0007B1F7F8 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754762323158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Not used anymore. Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Jack Wang Signed-off-by: Fabiano Rosas --- migration/rdma.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 63a8370be22..f9f39402568 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -198,7 +198,6 @@ typedef struct RDMALocalBlock { unsigned int src_index; /* (Only used on dest) */ int nb_chunks; unsigned long *transit_bitmap; - unsigned long *unregister_bitmap; } RDMALocalBlock; =20 /* @@ -577,8 +576,6 @@ static void rdma_add_block(RDMAContext *rdma, const cha= r *block_name, block->nb_chunks =3D ram_chunk_index(host_addr, host_addr + length) + = 1UL; block->transit_bitmap =3D bitmap_new(block->nb_chunks); bitmap_clear(block->transit_bitmap, 0, block->nb_chunks); - block->unregister_bitmap =3D bitmap_new(block->nb_chunks); - bitmap_clear(block->unregister_bitmap, 0, block->nb_chunks); block->remote_keys =3D g_new0(uint32_t, block->nb_chunks); =20 if (rdma->blockmap) { @@ -663,9 +660,6 @@ static void rdma_delete_block(RDMAContext *rdma, RDMALo= calBlock *block) g_free(block->transit_bitmap); block->transit_bitmap =3D NULL; =20 - g_free(block->unregister_bitmap); - block->unregister_bitmap =3D NULL; - g_free(block->remote_keys); block->remote_keys =3D NULL; =20 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754804; cv=none; d=zohomail.com; s=zohoarc; b=dWmy2J7KwesExMu6hpNRnraPY9CXCHdpqDFZrCKmampsqRneQRZIFszUWsJT9diyVJLJUdB3ZbapDKupdR7vjDoPMPwBDB5U56SLT2zSPWDgpc9nX3NqUXGPk1yfdSCHAGhKDK+PNZYtKX0rwHdF1Z2APRSQ54UHLuBK81j7aVw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754804; 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=SU6M+9tQ87hTQgwr6I/3+gapxDIcAIUfg8QtxVIi6v4=; b=OotEd3lt9iA1ormAdV4DsDaOdfx8a5HBqaEuTgkYtYqOH76+x03f4ktaMos4eXu/nfx26+nNcYam3Qkz3qMI1YF7kjvmhWgJjInSnrftJq0HftWxvGIOHLPWwUSUbPoZV124Iq3BfDIQRnGWrxSOXL5ppFgrSqmJnB7HJFKrCDM= 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 1787754804060393.7546501721937; Wed, 26 Aug 2026 07:33:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdN-0001Bn-3b; Wed, 26 Aug 2026 10:29:45 -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 1wzEdL-0001BB-GA for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:43 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdJ-0001wy-NQ for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:43 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 453F421259; Wed, 26 Aug 2026 14:29:32 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 556CD1364A; Wed, 26 Aug 2026 14:29:31 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OPr6CUv4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754576; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SU6M+9tQ87hTQgwr6I/3+gapxDIcAIUfg8QtxVIi6v4=; b=Ge4uBZM05h0GEFhiW6eD2eb9/K4sSirNqkPGv4oRhsKkgALno+zSD+X6L3X5umqt06ks61 dxuYXKrhg0i1qhRTkA1pefkdC8uJ9foCsDSF++rNIHK9mzQ6Mqd6GCzPK0wg3K1geGJ//r dZlyokPHBC0bUDDrlX/9+UXV52U6sRc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754576; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SU6M+9tQ87hTQgwr6I/3+gapxDIcAIUfg8QtxVIi6v4=; b=F7FXOd0m6tSEOHpGnpcHWrPNoEUipj9VpzTgWgR4ykuZQ/hCowSZYdQGN8lTBQrq/hQrqq bpbytD3wZGlCSEAQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=tH0me2Ay; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Vm3KKz+q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754572; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SU6M+9tQ87hTQgwr6I/3+gapxDIcAIUfg8QtxVIi6v4=; b=tH0me2AyattKO9P1CaDP4UtnjbAWJBK5g+KuRUYjGNRAuJVesL2fBWTlJsE8sn5fvQKc6L q04ES01GrXUDHSyqw8EoaHzV9cP4saa0MIznjCxN3dHGKYwwT9cx4L12O8he1cP2OEwMJa SgrZeOaGlLDGo3sCmZsY5UgtsmnAep4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754572; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SU6M+9tQ87hTQgwr6I/3+gapxDIcAIUfg8QtxVIi6v4=; b=Vm3KKz+qXwRy2he5WPw/sZJzrPonmeLJYoGZErc6WmKKWimP4Jdf3KGcHLRvCxnb+/qAbI ROKDjjIGexsAzIAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 17/30] migration/rdma: Drop RDMARegister.key.chunk Date: Wed, 26 Aug 2026 11:28:52 -0300 Message-ID: <20260826142905.2315503-18-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.988]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,ionos.com:email,suse.de:email,suse.de:mid,suse.de:dkim]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid,suse.de:dkim,ionos.com:email]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 453F421259 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754804660158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Not used anymore. Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Jack Wang Signed-off-by: Fabiano Rosas --- migration/rdma.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index f9f39402568..683c24ba4dd 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -414,10 +414,7 @@ static void network_to_control(RDMAControlHeader *cont= rol) * the actual RDMA operation. */ typedef struct QEMU_PACKED { - union QEMU_PACKED { - uint64_t current_addr; /* offset into the ram_addr_t space */ - uint64_t chunk; /* chunk to lookup if unregistering */ - } key; + uint64_t current_addr; /* offset into the ram_addr_t space */ uint32_t current_index; /* which ramblock the chunk belongs to */ uint32_t padding; uint64_t chunks; /* how many sequential chunks to register = */ @@ -442,16 +439,16 @@ static void register_to_network(RDMAContext *rdma, RD= MARegister *reg) * current_addr as passed in is an address in the local ram_addr_t * space, we need to translate this for the destination */ - reg->key.current_addr -=3D local_block->offset; - reg->key.current_addr +=3D rdma->dest_blocks[reg->current_index].offse= t; - reg->key.current_addr =3D htonll(reg->key.current_addr); + reg->current_addr -=3D local_block->offset; + reg->current_addr +=3D rdma->dest_blocks[reg->current_index].offset; + reg->current_addr =3D htonll(reg->current_addr); reg->current_index =3D htonl(reg->current_index); reg->chunks =3D htonll(reg->chunks); } =20 static void network_to_register(RDMARegister *reg) { - reg->key.current_addr =3D ntohll(reg->key.current_addr); + reg->current_addr =3D ntohll(reg->current_addr); reg->current_index =3D ntohl(reg->current_index); reg->chunks =3D ntohll(reg->chunks); } @@ -1831,7 +1828,7 @@ retry: * Otherwise, tell other side to register. */ reg.current_index =3D current_index; - reg.key.current_addr =3D current_addr; + reg.current_addr =3D current_addr; reg.chunks =3D chunks; =20 trace_rdma_write_one_sendreg(chunk, sge.length, current_index, @@ -3373,7 +3370,7 @@ int rdma_registration_handle(QEMUFile *f) reg_result =3D &results[count]; =20 trace_rdma_registration_handle_register_loop(count, - reg->current_index, reg->key.current_addr, reg->c= hunks); + reg->current_index, reg->current_addr, reg->chunk= s); =20 if (reg->current_index >=3D rdma->local_ram_blocks.nb_bloc= ks) { error_report("rdma: 'register' bad block index %u (vs = %d)", @@ -3382,15 +3379,15 @@ int rdma_registration_handle(QEMUFile *f) goto err; } block =3D &(rdma->local_ram_blocks.block[reg->current_inde= x]); - if (block->offset > reg->key.current_addr) { + if (block->offset > reg->current_addr) { error_report("rdma: bad register address for block %s" " offset: %" PRIx64 " current_addr: %" PRIx64, block->block_name, block->offset, - reg->key.current_addr); + reg->current_addr); goto err; } host_addr =3D (block->local_host_addr + - (reg->key.current_addr - block->offset)); + (reg->current_addr - block->offset)); chunk =3D ram_chunk_index(block->local_host_addr, (uint8_t *) host_addr); chunk_start =3D ram_chunk_start(block, chunk); --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754728; cv=none; d=zohomail.com; s=zohoarc; b=EBdfEpfOVO4UNVX/+FjnXdEc1wcDsWdOqTsvTI5phXgcnsdGFlyw1dLzsLoVWSevX2c1TqcRGrr9exrnIqgDEFqqP/bzb75EaI2DeTC59JpX2p0JjNDwmaggMB6WDFZjJOoqb6ZJmR+Ncas5Ng1bqe7cSTczpXylyW18gag05ac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754728; 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=F9yJ3RLbH84d6XW+2lCMAgvOPxksUFhx40vXtd8SCNM=; b=E/bSc5La1oiUF0JYEW5SkfkH0mY+UYhZLkxoSNOovHVtVQU5kPieA1PZuz5mk5PQ/QuKMTgvcSRpD4/7rkaGUGu54+9VdDBVtwePlwX0lqhwrUr0ix/tDZEfku7jNtaa6OsuLGbFXHrLJ1NpjFCkGnVuqT6Z5powC7vBhqnuGzk= 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 1787754728276752.6527467908732; Wed, 26 Aug 2026 07:32:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdO-0001CT-Ht; Wed, 26 Aug 2026 10:29:46 -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 1wzEdM-0001Be-Md for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:44 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdL-0001z4-2s for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:44 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 89E911F810; Wed, 26 Aug 2026 14:29:33 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9AA1E1364B; Wed, 26 Aug 2026 14:29:32 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uO3fGkz4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754577; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F9yJ3RLbH84d6XW+2lCMAgvOPxksUFhx40vXtd8SCNM=; b=iGUmXjz9kgXgQj1Bh/glWoOCvjNBCvPRyPr9/h6qCQSqvpOnKT6u4XZJqwG5wb72BKlPSe G4Q3EueCXo9s89UjnGJcs/LVdB29zrvPr8ulKGVXd6otyteMBDHKFaQURYgwEyt0B6BLBH bqkSPuJP6knRCS1McpZ0UxPJzgOhGzw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754577; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F9yJ3RLbH84d6XW+2lCMAgvOPxksUFhx40vXtd8SCNM=; b=Yslpfypctyon7kIlVufEv7xMiQYaObP4d9fBRNsbnkDO8ZHu+ePPWtRGNe1QcdsSrhAwCI /UjhSgydt693+pDg== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F9yJ3RLbH84d6XW+2lCMAgvOPxksUFhx40vXtd8SCNM=; b=HuKKE9bCDnhzIJSsXBcGgVZSg2mIX40Ad+uqP6MJrNX+eaTp2qjpVWhtuMI8s48+/IEZ1D AbDsBlAuLzX4c3mgqwVw6AxoTQngBXz3evpTD++osz9O8up01SdeL7Cvl+1ltDqYN1gIXS n1oVD7BYowi3qfYYgmTl8BaYZLdKN58= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754573; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F9yJ3RLbH84d6XW+2lCMAgvOPxksUFhx40vXtd8SCNM=; b=umQI/Iix50mLc0deMA7Rsi6BY9PPpV7aEfeozh9DDBlhgVKekOQ4mU0pofqlS2jFrxIevC X0I3Aa47dYiQ49AA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 18/30] migration/rdma: Sanity check RDMA_CONTROL_REGISTER_REQUEST on buflen Date: Wed, 26 Aug 2026 11:28:53 -0300 Message-ID: <20260826142905.2315503-19-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.77 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.17)[-0.846]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo,ionos.com:email,gitlab.com:url]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[gitlab.com:url,suse.de:mid,suse.de:email,ionos.com:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.77 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754730108158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu RDMA header supports head.repeat on RDMA_CONTROL_REGISTER_REQUEST, which can include >1 memory registrations. The current code did check over head.repeat to guard against RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE, however it didn't further check the buffer size (head.len) to make sure the received data is large enough to include the repeated entries. Check it. This is almost only to harden this piece of code, in reality on source side QEMU never uses repeat>1.. However since it's a protocol, still keep it. Check the buffer size instead. In case it's not obvious to new RDMA readers: head.len should be the size RDMA has last received, as qemu_rdma_exchange_get_response() checked on it against byte_len (which was further fetched from ibv_wc.byte_len in qemu_rdma_poll()). Reported-by: Tristan (@TristanInSec) Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4028 Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Jack Wang Signed-off-by: Fabiano Rosas --- migration/rdma.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index 683c24ba4dd..f7356e759fc 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3360,6 +3360,14 @@ int rdma_registration_handle(QEMUFile *f) reg_resp.repeat =3D head.repeat; registers =3D (RDMARegister *) rdma->wr_data[idx].control_curr; =20 + /* Making sure the register buffers to read are valid */ + if (head.len !=3D head.repeat * sizeof(RDMARegister)) { + error_report("%s: Invalid RDMA_CONTROL_REGISTER_REQUEST " + "(head.repeat=3D%"PRIu32", head.len=3D%"PRIu3= 2")", + __func__, head.repeat, head.len); + goto err; + } + for (int count =3D 0; count < head.repeat; count++) { uint64_t chunk; uint8_t *chunk_start, *chunk_end; --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754641; cv=none; d=zohomail.com; s=zohoarc; b=BntBZWXlt72skc014hiCfcSoWHnQ+qNMKnj0VBbK1qieGGOSMK9McUTs4f6wQJlEacw4r6KEkx7jhusChds9YeL3TBxigXU//STOGnvdMj98Uof7ZxKDI4EzzfOZLdrYX0eTYLRwBloYT35nHApDoqm3uStVI5zCo9WattjzXLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754641; 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=wMa2/41ubuJQG7osaYAeN+fD11e+ewIuN36eXzoto9M=; b=V20BWHeaCYtEousTG3jzntlYnHYI839o+n+PEl1Kghj0H4WM2sCksgINnbXPUZOqdvgAflWV2y3hVxWRGAIVXcdxO5Zp6n9ONyXfPHoPjvy/rpBx+e2wGjuNNRJyRkUmKTzn/7IQXccR29BQzkpbfkKzV5h1KClPP82+mhADE+w= 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 1787754641345617.1344398814263; Wed, 26 Aug 2026 07:30:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdP-0001CW-4W; Wed, 26 Aug 2026 10:29:47 -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 1wzEdN-0001C2-UF for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:45 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdM-00020P-8E for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:45 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CFEEF1F840; Wed, 26 Aug 2026 14:29:34 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id DFEF31364F; Wed, 26 Aug 2026 14:29:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id yMPFK034jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754579; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wMa2/41ubuJQG7osaYAeN+fD11e+ewIuN36eXzoto9M=; b=sfViFL4G8DYPF990Ik1J2C874rQ6/8do1vUFgMVagCaHL+ZHuSBZtLuUWfVOyJhd25qBDV q1SNK5zIFNK78eNr0tjdLWWxjf2WF88oM837J7KzBsV+pI07OHB8XuuT0k64va//LCBy6n rJ0nL04XWKth2qwtY7xIljoeJVJq0Yg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754579; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wMa2/41ubuJQG7osaYAeN+fD11e+ewIuN36eXzoto9M=; b=XbY2c5aQDDYOBxbc8/sXv8dvSV8Qp1ClRa6/UcgJz8ckMU/U0G2HSZIFzPEobnlJzfPd1I Tscur5F47SMGj2AQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=C5wJ6pkK; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=8UFTKFH6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754574; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wMa2/41ubuJQG7osaYAeN+fD11e+ewIuN36eXzoto9M=; b=C5wJ6pkKTv5ThDiNxY425jrr5whkwEp4QwF3V9KnGPZX/Z4428MtDHa2fzbncdk+4b2Elr cFh3N79E2HYGoeUIcVqvDozRMFclvBtDOTq/vEVxR5HRUSgguunU2zEXM0TpGKrnH+cIik skqc2ZSmrky4ioZes6HyNbKHfAgjSjY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754574; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wMa2/41ubuJQG7osaYAeN+fD11e+ewIuN36eXzoto9M=; b=8UFTKFH6huwORz3qdKTeEwb8P6Iapas4/ebzybUdJ5Of0Y/0zUf5rTErV9MrZ1EFkbEzXb KptBNA779jfmryAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 19/30] migration/rdma: Sanity check RDMA_CONTROL_REGISTER_REQUEST chunks Date: Wed, 26 Aug 2026 11:28:54 -0300 Message-ID: <20260826142905.2315503-20-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.978]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,ionos.com:email,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,gitlab.com:url]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; URIBL_BLOCKED(0.00)[ionos.com:email,suse.de:email,suse.de:mid,suse.de:dkim,gitlab.com:url,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: CFEEF1F840 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754645281158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu The value received on wire for head.chunks when registering new RDMA regions is not correctly checked. Logically the value can still make ram_chunk_start() (of ram_chunk_end()) to overflow, having a result pointer very small, smaller than RDMALocalBlock.local_host_addr. Add the sanity check. Reported-by: Tristan (@TristanInSec) Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4011 Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Signed-off-by: Fabiano Rosas --- migration/rdma.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index f7356e759fc..cf6688a4bc3 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3369,7 +3369,7 @@ int rdma_registration_handle(QEMUFile *f) } =20 for (int count =3D 0; count < head.repeat; count++) { - uint64_t chunk; + uint64_t chunk, chunk_sum; uint8_t *chunk_start, *chunk_end; =20 reg =3D ®isters[count]; @@ -3399,6 +3399,14 @@ int rdma_registration_handle(QEMUFile *f) chunk =3D ram_chunk_index(block->local_host_addr, (uint8_t *) host_addr); chunk_start =3D ram_chunk_start(block, chunk); + if (uadd64_overflow(chunk, reg->chunks, &chunk_sum) || + chunk_sum >=3D block->nb_chunks) { + error_report("%s: head.chunks contains illegal value" + " (chunk=3D%"PRIu64", chunks=3D%"PRIu64",= " + "nb_chunks=3D%d)", __func__, chunk, + reg->chunks, block->nb_chunks); + goto err; + } chunk_end =3D ram_chunk_end(block, chunk + reg->chunks); /* avoid "-Waddress-of-packed-member" warning */ uint32_t tmp_rkey =3D 0; --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754745; cv=none; d=zohomail.com; s=zohoarc; b=kuHFMoRPS12UV6myNBK5HEhHmI2bUAcgr9aMpquxzL27LfbJRpyE9wVa/HgK64Qb/j3GSMTsnH7qGCIg7QB1wkbkE6ssxk+YyuudPbhdQJOOs3TWv+obG50IX4tamsQeDyy5Pd/SGQfGJgw4ICY7QJsW2AjVKrkYJHu+gfuTQX4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754745; 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=0ym9+t3Jz9G6MC9UG3qZwkpQPoOZRMWdsC8IFvFLrhg=; b=kh8Atb2JeWOD4H2ogJuOfzmHNz3afVjHaqlqfsowamkbcvrb9zvIMW/1hiMd94RpN1PjHdCmeBSxsGhdNwyIaVlUD1hsUWNOsbpTZWEtdXvwPs6cV3cvqUeP+fP+MJFwpouj6tTAPTdRAbFs7jOekHgKhgZVjRElEOnsCcnz1Pw= 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 1787754745253710.9321228095916; Wed, 26 Aug 2026 07:32:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdR-0001D4-1S; Wed, 26 Aug 2026 10:29:49 -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 1wzEdP-0001CY-71 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:47 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdN-00022W-Fi for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:46 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 215D4211E4; Wed, 26 Aug 2026 14:29:36 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 30E1013676; Wed, 26 Aug 2026 14:29:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UA8YAU/4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754580; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ym9+t3Jz9G6MC9UG3qZwkpQPoOZRMWdsC8IFvFLrhg=; b=pRywmZv3GgQkLW1vB1IpP9bL3iwVUgRrOwuPleaRaYTnS0rcNTtrbF2yUd23YSS3e7IZZQ kNBpyAzYHAmzJ5/06XzaKy/C5Ia4FNCLsfV4c91lcEq2q5+m985ZnHZqZYpmHROT84YLBA SSjsXOPnyc3VfFzxsA/36IzDRJIYo00= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754580; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ym9+t3Jz9G6MC9UG3qZwkpQPoOZRMWdsC8IFvFLrhg=; b=mi/3ZvCA9w3oalhOTYw4Ky5vwFuFwS+uMi0QF0mpX4Hm/f63dJYmHKvWFuW066ChnOHqZm eGRLeiOmjvSktBBQ== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LyeOHpDx; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=hdlszmDu DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754576; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ym9+t3Jz9G6MC9UG3qZwkpQPoOZRMWdsC8IFvFLrhg=; b=LyeOHpDxUkSsOlTpzX4YQIUUB6NXdRuujiO7a8hBj6r3LBA92p3mbOcdSsN0VMN5xLHzH+ cZd8I3CfrVZydQKyvxFxTOO/BpEbG6Qlsu3x8rudlIx9jQevcw6kBXvRWXQnw/zHEQ9tpI PzkRfG4j7a1nfFTMT1nov2lqHDm2qxQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754576; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ym9+t3Jz9G6MC9UG3qZwkpQPoOZRMWdsC8IFvFLrhg=; b=hdlszmDuCJ9a09lOOwYtEjxr8+Rh7Hj57Yd2og1l/QSLaG1Aygg2Eut5u0aFAgBWuo/ctq bmf6znJDFvv1dtCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 20/30] migration/rdma: Sanity check upper bound of register MR address Date: Wed, 26 Aug 2026 11:28:55 -0300 Message-ID: <20260826142905.2315503-21-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.978]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,gitlab.com:url,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,ionos.com:email]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; URIBL_BLOCKED(0.00)[suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,ionos.com:email,gitlab.com:url]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: 215D4211E4 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754746212158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu Before registration of RDMA ranges, QEMU destination checks for validity of current_addr no less than the target ramblock's start address. But it didn't check for the upper bound to make sure the address is within the size of the ramblock. Add it. Reported-by: Tristan (@TristanInSec) Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4007 Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Jack Wang Signed-off-by: Fabiano Rosas --- migration/rdma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index cf6688a4bc3..d8953363fe5 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3387,7 +3387,8 @@ int rdma_registration_handle(QEMUFile *f) goto err; } block =3D &(rdma->local_ram_blocks.block[reg->current_inde= x]); - if (block->offset > reg->current_addr) { + if (block->offset > reg->current_addr || + block->offset + block->length <=3D reg->current_addr) { error_report("rdma: bad register address for block %s" " offset: %" PRIx64 " current_addr: %" PRIx64, block->block_name, block->offset, --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754752; cv=none; d=zohomail.com; s=zohoarc; b=jLeS1xI9jZOuYt6wM5WJSCu5Jo7W2v/NVnqE2o9MS3iehAz8acEujhCffBHadpFgmraUYOgpxEfuNSYYQm/hN+AKfhQXSPm8k06BHeIvHgki6L4M/0jcGY2VOIrzeLwfBdETwmGgTsNMVJHrdGAFM9FGpwQhMHuRDUHfZC/7Nzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754752; 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=fRRHQXAWBSoz8D3kIzWAjQPHhGiF4yCSa3k6HkPIOAA=; b=IrBWGAdSSIkbdTBu6YFPeftHuMLSg0/VR/qTM7ziPL/sewL5YW68PySAjjckzESeTyE/iUtxtPm+UGEbBpaq8lD0Tg2kFg17DDUVw+Fo86ZlAOW75GOzLBOAOxsZPKN9XV7w285PM0bgD/7LVgnint/wCNMTRkN5M1fAlS2Ai7I= 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 1787754752901131.15595696955734; Wed, 26 Aug 2026 07:32:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdS-0001Do-HM; Wed, 26 Aug 2026 10:29:50 -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 1wzEdQ-0001Cx-L9 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:48 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdO-00024A-Ti for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:48 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 665C3211E0; Wed, 26 Aug 2026 14:29:37 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 76C3B13675; Wed, 26 Aug 2026 14:29:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id uAsRElD4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754581; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRRHQXAWBSoz8D3kIzWAjQPHhGiF4yCSa3k6HkPIOAA=; b=fCI3m7V7RBMMIp22LG04laoRd1F4plJw+B24gaYxgZdHS6qSAjC4/+bO00YRvRkMvJk90g Kks0mzQKuxZ9wtCKEQduON/CFjsjPUDLiyuYm7dOl3njZWpGT7UM5VK+UJzv7171XNAhNs RjsuzekIABon9LFCdgedxICkY4gMykE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754581; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRRHQXAWBSoz8D3kIzWAjQPHhGiF4yCSa3k6HkPIOAA=; b=8H5ZNE3pztNo51Ydf2o0YMADrwelxNU1aKMWvJwvnOfeGi3A+jx8WcGk66ch+9McvlzmBS 8RvJ95EDLguvOtCw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754577; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRRHQXAWBSoz8D3kIzWAjQPHhGiF4yCSa3k6HkPIOAA=; b=CVT3Mx2qyo3U1Wx4CH+SWoEsBsJq/ZFWtNG1TrtydJAYknNFB8TNLBPN+3+C+nbX9Kl23L DFXNpKz/JgVR1IiuArKWVcZ9yHecER3PwHNFQ+WSi8vUDOJwkeYuZ2ONg0AmboO070T97/ qp+BiRftlK5eKyJ6y+UFRUYYQUxQ4eQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754577; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fRRHQXAWBSoz8D3kIzWAjQPHhGiF4yCSa3k6HkPIOAA=; b=nf/YA87hL5ebLvN8IW72PNXo/NWSwZJXGfljyC+FEoBmcn4UIh3dlqA1VMVphTQK2Jxfg9 vjK5cs1j3QNV0gDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Jinpu Wang Subject: [PULL 21/30] migration/rdma: Sanity check compress request ranges Date: Wed, 26 Aug 2026 11:28:56 -0300 Message-ID: <20260826142905.2315503-22-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.77 X-Spamd-Result: default: False [-2.77 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.17)[-0.843]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[ionos.com:email,suse.de:email,suse.de:mid,gitlab.com:url,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754754244158500 Content-Type: text/plain; charset="utf-8" From: Peter Xu The offset/length ranges are not sanity checked in RDMA requests, add the checks. Reported-by: Tristan (@TristanInSec) Closes: https://gitlab.com/qemu-project/qemu/-/work_items/4005 Reviewed-by: Jinpu Wang Signed-off-by: Peter Xu Reviewed-by: Fabiano Rosas Reviewed-by: Jack Wang Signed-off-by: Fabiano Rosas --- migration/rdma.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index d8953363fe5..e976739fad3 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3198,6 +3198,28 @@ static int dest_ram_sort_func(const void *a, const v= oid *b) return (a_index < b_index) ? -1 : (a_index !=3D b_index); } =20 +static bool rdma_compress_range_check(RDMALocalBlock *block, + RDMACompress *comp) +{ + uint64_t block_end =3D block->offset + block->length; + uint64_t comp_end; + + if (uadd64_overflow(comp->offset, comp->length, &comp_end)) { + goto fail; + } + + if (comp->offset < block->offset || comp_end > block_end) { + goto fail; + } + + return true; +fail: + error_report("%s: compress request range outside range" + " (block=3D%s, offset=3D%"PRIu64", length=3D%"PRIu64")", + __func__, block->block_name, comp->offset, comp->length); + return false; +} + /* * During each iteration of the migration, we listen for instructions * by the source VM to perform dynamic page registrations before they @@ -3277,7 +3299,9 @@ int rdma_registration_handle(QEMUFile *f) goto err; } block =3D &(rdma->local_ram_blocks.block[comp->block_idx]); - + if (!rdma_compress_range_check(block, comp)) { + goto err; + } host_addr =3D block->local_host_addr + (comp->offset - block->offset); if (comp->value) { --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754759; cv=none; d=zohomail.com; s=zohoarc; b=PosYPthSkcOnKz3UZ6V26E31nOE4x8TZShsdLyoukw4C1Z3F+IGNKae3kythCk4Nxm9bfFRIDONLBG/wF/+1+EfnMvhMpXkY3qDQ8Er/3eweqaOkGU5ReOIyOaBkz/RhMfK4M3r8JLLKE6Sg+GO3hJsxIeP+2TvHPNlE04EP1P8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754759; 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=JK5hagYU1EUz0RO8LHP2IW2Zhm75w1JTYi6QloT7uOI=; b=FjBVG12/Ydst82BdVvh2IUFQlTo2kpiKcHepUePPoONXhVr9l8Rr7sqLe6OhhtKkLUl0QciNwJRFPz5O7OTe5MUk73/K6+JuU28CBIeehrk2lQ4apWvmkATlbwEN6FaD9mQV/ZnhvuTpMLrWeiTOf5GQejnKfOc6FJbFHTkbYdA= 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 178775475879367.50541798840447; Wed, 26 Aug 2026 07:32:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdT-0001Dx-Lu; Wed, 26 Aug 2026 10:29:51 -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 1wzEdR-0001DS-MG for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:49 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdP-00025u-VN for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:49 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7FD402121A; Wed, 26 Aug 2026 14:29:38 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BD3BA13354; Wed, 26 Aug 2026 14:29:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OG8NI1H4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754582; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JK5hagYU1EUz0RO8LHP2IW2Zhm75w1JTYi6QloT7uOI=; b=gHBQZGoDbtDQ/V4P5kexzErRRKNR9asSkNwDpPV64CiQ7KllnbBkqL8sxcpuEQty6KUmQj dtf0mHxWua5TWKMoCOQTAe9UCdS0wnBoeszRNGnyeIs6Q+B2sp3Tie6sRx9pqY3qjZ0hb9 9DKdig4Yxl8OScBdvHfvA1DVVc7EBoI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754582; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JK5hagYU1EUz0RO8LHP2IW2Zhm75w1JTYi6QloT7uOI=; b=vkIq7O3fFDNkdvfABvw6YDdXsmeIOeJQ00xx5PhemRuzWhXDLU62Ccm74Pt9PW9Lc+2ZYJ Aa7C+km/QGqpaBCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754578; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JK5hagYU1EUz0RO8LHP2IW2Zhm75w1JTYi6QloT7uOI=; b=AItfu4c+3oRVeZm+YkPw2LS5lLP72Fja6zGsKplvb1xR8YrWKO5IJEx6LG+k5jwZrxlogw I3m6rWMTtmqiR+ORjyY1YHnR57l/5B3odLwKG1rZXYgps37Hkfj/lyH6hEiVMpc3FQxHSA aYiMg6Z9hRjWZYJwPGAs6yzGOxhmpXY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754578; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JK5hagYU1EUz0RO8LHP2IW2Zhm75w1JTYi6QloT7uOI=; b=0qn7WqB8FDlPZ05pYQxGr0kgyE2JLIvVVyRj2lxCCq39k6BGo2VHnl5aMzvtpNahVL7l5e ofemaR6erL9qjdCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu Subject: [PULL 22/30] migration: Remove unused vmstate macros Date: Wed, 26 Aug 2026 11:28:57 -0300 Message-ID: <20260826142905.2315503-23-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.78 / 50.00]; BAYES_HAM(-3.00)[99.99%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.18)[-0.911]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.78 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=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754760324158500 Content-Type: text/plain; charset="utf-8" Remove the several vmstate macros that don't have any users. Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 45 ------------------------------------- 1 file changed, 45 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 1b7f295417e..214a2131350 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -451,15 +451,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_sub_array(_state, _field, _type, _start= ), \ } =20 -#define VMSTATE_ARRAY_INT32_UNSAFE(_field, _state, _field_num, _info, _typ= e) {\ - .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_INT32, \ - .offset =3D vmstate_offset_varray(_state, _field, _type), \ -} - #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, = _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ @@ -710,16 +701,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 -#define VMSTATE_STRUCT_VARRAY_INT32(_field, _state, _field_num, _version, = _vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ - .version_id =3D (_version), \ - .vmsd =3D &(_vmsd), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_INT32, \ - .offset =3D vmstate_offset_varray(_state, _field, _type), \ -} - #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version,= _vmsd, _type) { \ .name =3D (stringify(_field)), \ .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), \ @@ -1069,8 +1050,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; =20 #ifdef CONFIG_LINUX =20 -#define VMSTATE_U8(_f, _s) \ - VMSTATE_U8_V(_f, _s, 0) #define VMSTATE_U16(_f, _s) \ VMSTATE_U16_V(_f, _s, 0) #define VMSTATE_U32(_f, _s) \ @@ -1116,15 +1095,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_BOOL_TEST(_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_bool, bool) =20 -#define VMSTATE_INT8_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int8, int8_t) - -#define VMSTATE_INT16_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int16, int16_t) - -#define VMSTATE_INT32_TEST(_f, _s, _t) \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int32, int32_t) - #define VMSTATE_INT64_TEST(_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int64, int64_t) =20 @@ -1140,12 +1110,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_UINT64_TEST(_f, _s, _t) \ VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_uint64, uint64_t) =20 -#define VMSTATE_FD_TEST(_f, _s, _t) = \ - VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_fd, int32_t) - -#define VMSTATE_TIMER_PTR_TEST(_f, _s, _test) \ - VMSTATE_POINTER_TEST(_f, _s, _test, vmstate_info_timer, QEMUTimer *) - #define VMSTATE_TIMER_PTR_V(_f, _s, _v) \ VMSTATE_POINTER(_f, _s, _v, vmstate_info_timer, QEMUTimer *) =20 @@ -1155,9 +1119,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_TIMER_PTR_ARRAY(_f, _s, _n) \ VMSTATE_ARRAY_OF_POINTER(_f, _s, _n, 0, vmstate_info_timer, QEMUTimer) =20 -#define VMSTATE_TIMER_TEST(_f, _s, _test) \ - VMSTATE_SINGLE_TEST(_f, _s, _test, 0, vmstate_info_timer, QEMUTimer) - #define VMSTATE_TIMER_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_timer, QEMUTimer) =20 @@ -1275,12 +1236,6 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_BUFFER_START_MIDDLE(_f, _s, _start) \ VMSTATE_BUFFER_START_MIDDLE_V(_f, _s, _start, 0) =20 -#define VMSTATE_PARTIAL_VBUFFER(_f, _s, _size) \ - VMSTATE_VBUFFER(_f, _s, 0, NULL, _size) - -#define VMSTATE_PARTIAL_VBUFFER_UINT32(_f, _s, _size) = \ - VMSTATE_VBUFFER_UINT32(_f, _s, 0, NULL, _size) - #define VMSTATE_BUFFER_TEST(_f, _s, _test) \ VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f)= )) =20 --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754617; cv=none; d=zohomail.com; s=zohoarc; b=bXpgRGf/dZjXe3ix7+uOfQBfPzIJyr3SU3yo5pTC6W293rnLgCZbY1fcroJnq5FnkLSRdfr/PnrCwNzG1vKbvrx4RRKSqbJNfLPtWEF1qtn8yF/cSN4mkY01sAh/vBx9upXa0LxrtzOfq5u7fk8V5VsKeu1Ycpa1lYLyvfESowI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754617; 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=vr2C7oscjfX3B6sMUfuCbEokEqGfeU940jEvsFBifRQ=; b=fsxOO/4el2IGJxXM9p6Qyvv3XDqlo9s8uyR0vvFYjltDNqPvO+YDH0kPK7xN+O2XadebCpEyC2mDcjoXahoYPnmIF8OJUo7c2c3Ll3JPoqE3GoQ1tIf7Lre5tZDXtfv+YUpeiIhsLRHTh9st+xgPdc3gNWV7+Q+pHaouWIubsWc= 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 1787754617734200.59507797427875; Wed, 26 Aug 2026 07:30:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdW-0001ER-8D; Wed, 26 Aug 2026 10:29:54 -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 1wzEdV-0001E9-Ds for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:53 -0400 Received: from smtp-out1.suse.de ([2a07:de40:b251:101:10:150:64:1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdR-00029N-CR for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:53 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F30FA21225; Wed, 26 Aug 2026 14:29:39 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D693B13674; Wed, 26 Aug 2026 14:29:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id GPaBKVL4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754584; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vr2C7oscjfX3B6sMUfuCbEokEqGfeU940jEvsFBifRQ=; b=ZOijkN9L5TjgbpSyf3uL7b8d1PL3eKv76bVA1g5lvO4Qe4qBPdppQ5ThOBzmckE7uO8Wy4 xWN11DsrnvjIKWX/c2K1eBCl05YRYqVxOrctU90/9/syzIYEuez+LmHDeHn7Q8L/4BHzeZ KRvnJKY87XEOBa2CqTyJgX7ee7dXWKA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754584; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vr2C7oscjfX3B6sMUfuCbEokEqGfeU940jEvsFBifRQ=; b=fcLvA977jbb/HlcID/lTZaefKjcvrHKRlJxjN5EVhajFwVdhdP6VXNXDfJBJKFWNMO1gsA S/Rh/OwSQrZmfRAw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DMmYjkFV; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=EohcaE6r DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754580; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vr2C7oscjfX3B6sMUfuCbEokEqGfeU940jEvsFBifRQ=; b=DMmYjkFVEnxhgaLSF53PLaUxX56cJOU02Aln/zqHeucd+c8O6ZeyJ3N6Syi8vp3wHzpvpy ksSEHIgKpzSKEzrdT5FEl3UzLOWjRyCK85AZY5eARUeLiSD94YpX8InM9g/vZUbVrL7Nir /CNHHBFKokJsMWJ3dC9TLow5OUgMHik= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754580; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vr2C7oscjfX3B6sMUfuCbEokEqGfeU940jEvsFBifRQ=; b=EohcaE6rjE//oRvrG8NIxsaPG0mqJIyZuQfRE2zJ7KDA1hB/RUa/5Rwfj1u0WeDHludeyh fe5x4BXO3RjEpjCg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , Seungjung Kim Subject: [PULL 23/30] migration: Introduce VMStateStructMember Date: Wed, 26 Aug 2026 11:28:58 -0300 Message-ID: <20260826142905.2315503-24-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: F30FA21225 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; MIME_TRACE(0.00)[0:+]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FREEMAIL_CC(0.00)[redhat.com,gmail.com]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,gitlab.com:url,suse.de:mid,suse.de:email,suse.de:dkim]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754619191158500 Content-Type: text/plain; charset="utf-8" When migrating a buffer or array, the vmstate code needs to know the size of the buffer and the number of elements of the array. Today a vmstate writer can choose from a number of macros that take as last input the name of a struct member from where the size/num will be read. At load time, the code will access those values via an opaque pointer to the migrated data and therefore it needs to also know the size of the struct member at that offset. Currently that information is communicated by means of the VMS_VARRAY_* and VMS_VBUFFER_* flags, where each possible type is represented by a flag. So far, that's all fine, but since the vmstate code makes heavy use of macros, handling several types individually (i.e. by name: int, int32_t, etc) requires several versions of a same macro, one for each type. E.g: VMSTATE_VBUFFER_ALLOC_UINT32 ^ This creates a pattern where the vmstate writer has to match the macro name to the data type and has resulted in the code having a tendency of having one macro version for each type, for each type of vmstate. There is also some cognitive load to deal with, e.g. VMSTATE_VARRAY_INT32 doesn't hold an array of int32, it holds an array of something else and the number of elements for the array is stored in a variable of type int32. We're now dealing with the scenario where the code has been expecting int32_t at some places, but a uint64_t macro variant has been added without the code being updated. To address all these situations, introduce a new struct that will hold the offset of the struct members, but also their size, so the various extra macros can all be removed and the person writing the vmstate doesn't need to care about type-checking. Still, keep a minimum check that those fields are at least integers and fit into 64 bits. What changes: 1) type checking changes from individual types to a single check for all integers; 2) there are new ways to access the offsets; num_offset -> num_indirect.offset size_offset -> size_indirect.offset [new] num_indirect.size [new] size_indirect.size 2) reading the offsets goes from checking the VMS_VARRAY_* flags in an if/elseif block to comparing offset.size against the hardcoded sizes in bytes; 3) the VMS_VARRAY_* and VMS_VBUFFER_* flags become obsolete. Removed in the next patch; 4) memory usage increases +1 byte per vmstate; Reported-by: Seungjung Kim Fixes: CVE-2026-6426 Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3675 Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 163 +++++++++++++++++++++-------- migration/savevm.c | 4 +- migration/vmstate.c | 50 +++++---- rust/bindings/migration-sys/lib.rs | 10 ++ rust/migration/src/vmstate.rs | 24 ++++- rust/tests/tests/vmstate_tests.rs | 26 ++--- 6 files changed, 197 insertions(+), 80 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 214a2131350..12bfa64fb92 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -31,6 +31,7 @@ =20 typedef struct VMStateInfo VMStateInfo; typedef struct VMStateField VMStateField; +typedef struct VMStateStructMember VMStateStructMember; =20 /* * VMStateInfo allows customized migration of objects that don't fit in @@ -67,15 +68,15 @@ enum VMStateFlags { * to the actual field (e.g. struct a { uint8_t *b; * }). Dereference the pointer before using it as basis for * further pointer arithmetic (see e.g. VMS_ARRAY). Does not - * affect the meaning of VMStateField.num_offset or - * VMStateField.size_offset; see VMS_VARRAY* and VMS_VBUFFER for + * affect the meaning of VMStateField.num_indirect or + * VMStateField.size_indirect; see VMS_VARRAY* and VMS_VBUFFER for * those. */ VMS_POINTER =3D 0x002, =20 /* The field is an array of fixed size. VMStateField.num contains * the number of entries in the array. The size of each entry is * given by VMStateField.size and / or opaque + - * VMStateField.size_offset; see VMS_VBUFFER and + * VMStateField.size_indirect; see VMS_VBUFFER and * VMS_MULTIPLY. Each array entry will be processed individually * (VMStateField.info.get()/put() if VMS_STRUCT is not set, * recursion into VMStateField.vmsd if VMS_STRUCT is set). May not @@ -88,8 +89,9 @@ enum VMStateFlags { * array entry. */ VMS_STRUCT =3D 0x008, =20 - /* The field is an array of variable size. The int32_t at opaque + - * VMStateField.num_offset contains the number of entries in the + /* + * The field is an array of variable size. The integer at opaque + + * VMStateField.num_indirect contains the number of entries in the * array. See the VMS_ARRAY description regarding array handling * in general. May not be combined with VMS_ARRAY or any other * VMS_VARRAY*. */ @@ -105,7 +107,7 @@ enum VMStateFlags { VMS_ARRAY_OF_POINTER =3D 0x040, =20 /* The field is an array of variable size. The uint16_t at opaque - * + VMStateField.num_offset + * + VMStateField.num_indirect * contains the number of entries in the array. See the VMS_ARRAY * description regarding array handling in general. May not be * combined with VMS_ARRAY or any other VMS_VARRAY*. */ @@ -114,26 +116,27 @@ enum VMStateFlags { /* The size of the individual entries (a single array entry if * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if * neither is set) is variable (i.e. not known at compile-time), - * but the same for all entries. Use the int32_t at opaque + - * VMStateField.size_offset (subject to VMS_MULTIPLY) to determine + * but the same for all entries. Use the integer at opaque + + * VMStateField.size_indirect (subject to VMS_MULTIPLY) to determine * the size of each (and every) entry. */ VMS_VBUFFER =3D 0x100, =20 - /* Multiply the entry size given by the int32_t at opaque + - * VMStateField.size_offset (see VMS_VBUFFER description) with + /* + * Multiply the entry size given by the integer at opaque + + * VMStateField.size_indirect (see VMS_VBUFFER description) with * VMStateField.size to determine the number of bytes to be * allocated. Only valid in combination with VMS_VBUFFER. */ VMS_MULTIPLY =3D 0x200, =20 /* The field is an array of variable size. The uint8_t at opaque + - * VMStateField.num_offset + * VMStateField.num_indirect * contains the number of entries in the array. See the VMS_ARRAY * description regarding array handling in general. May not be * combined with VMS_ARRAY or any other VMS_VARRAY*. */ VMS_VARRAY_UINT8 =3D 0x400, =20 /* The field is an array of variable size. The uint32_t at opaque - * + VMStateField.num_offset + * + VMStateField.num_indirect * contains the number of entries in the array. See the VMS_ARRAY * description regarding array handling in general. May not be * combined with VMS_ARRAY or any other VMS_VARRAY*. */ @@ -187,29 +190,88 @@ typedef enum { MIG_PRI_MAX, } MigrationPriority; =20 + +/* + * VMStateStructMember: Metadata about a single member of the struct + * being migrated by the vmstate. This is kept separate from + * VMStateField because a single VMStateField can reference other + * members of the struct aside from the main struct member that's + * being migrated. + * + * One situation where extra fields are referenced is the common case + * of a struct containing an array or buffer, the size of which is + * stored in another member of the same struct. + * + * Example 1: + * struct IDEState { + * ... + * uint8_t *io_buffer; + * int32_t io_buffer_total_len; + * ... + * } + * VMSTATE_VARRAY_INT32(io_buffer, IDEState, io_buffer_total_len, 1, + * vmstate_info_uint8, uint8_t) + * + * In the above, io_buffer is the main field being migrated by the + * VMSTATE_VARRAY while io_buffer_total_len is the meta field that + * provides the size of the io_buffer. In this particular case, + * io_buffer_total_len is never migrated. + * + * Example 2: + * struct SpaprMachineState { + * ... + * uint32_t fdt_size; + * void *fdt_blob; + * ... + * } + * VMSTATE_UINT32(fdt_size, SpaprMachineState), + * VMSTATE_VBUFFER_ALLOC_UINT32(fdt_blob, SpaprMachineState, 0, NULL, fdt_= size), + * + * Here, fdt_blob is the field being migrated by VMSTATE_VBUFFER_ALLOC + * and fdt_size is the meta field providing the size. In this case, + * the extra field is also independently migrated by the + * VMSTATE_UINT32 above. + */ +struct VMStateStructMember { + /* offsetof the field inside the migrated struct */ + uint32_t offset; + /* size of field itself */ + uint8_t size; +}; + struct VMStateField { const char *name; size_t offset; =20 /* - * @size or @size_offset specifies the size of the element embeded in - * the field. Only one of them should be present never both. When - * @size_offset is used together with VMS_VBUFFER, it means the size is - * dynamic calculated instead of a constant. + * @size directly specifies the size of the element being + * migrated. * - * When the field is an array of any type, this stores the size of one - * element of the array. + * @size_indirect specifies the offset inside a struct where the + * size of the element is stored. * - * NOTE: even if VMS_POINTER or VMS_ARRAY_OF_POINTER may be specified, - * this parameter always reflects the real size of the objects that a - * pointer point to. + * Only one of the above should be present (except for + * VMSTATE_MULTIPLY which uses .size as a multiplier). When + * @size_indirect is used together with VMS_VBUFFER, it means + * the size is dynamic calculated instead of a constant. + * + * When the field is an array of any type, these refer to the size + * of one element of the array. + * + * NOTE: even if VMS_POINTER or VMS_ARRAY_OF_POINTER may be + * specified, these parameters always reflect the real size of the + * objects that a pointer point to. + * + * @num_indirect specifies the offset inside a struct where the + * number of elements of an array is stored. */ size_t size; - size_t size_offset; + VMStateStructMember size_indirect; + VMStateStructMember num_indirect; =20 size_t start; int num; - size_t num_offset; + const VMStateInfo *info; enum VMStateFlags flags; const VMStateDescription *vmsd; @@ -328,6 +390,17 @@ extern const VMStateInfo vmstate_info_g_byte_array; (type_check(t1, typeof_elt_of_field(t2, f)) \ + QEMU_BUILD_BUG_ON_ZERO(!QEMU_IS_ARRAY(((t2 *)0)->f))) =20 +#define type_check_int64(t) \ + (~((t)0) * sizeof(struct { \ + QEMU_BUILD_BUG_ON(sizeof(t) > sizeof(uint64_t)); \ + })) + +#define vmstate_field_offset(_state, _field) { \ + .offset =3D (offsetof(_state, _field) + \ + type_check_int64(typeof_field(_state, _field))), \ + .size =3D sizeof(typeof_field(_state, _field)), \ +} + #define vmstate_offset_value(_state, _field, _type) \ (offsetof(_state, _field) + \ type_check(_type, typeof_field(_state, _field))) @@ -454,7 +527,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, = _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_INT32|VMS_POINTER, \ @@ -464,7 +537,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info,= _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT32|VMS_POINTER, \ @@ -474,7 +547,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_INT32_ALLOC(_field, _state, _field_num, _version, _= info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_INT32 | VMS_POINTER | VMS_ALLOC, \ @@ -484,7 +557,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \ @@ -494,7 +567,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT16_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint16_t),\ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT16 | VMS_POINTER | VMS_ALLOC, \ @@ -504,7 +577,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version,= _info, _type) {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint16_t),\ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ .flags =3D VMS_VARRAY_UINT16, \ @@ -583,7 +656,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; _field, _state, _field_num, _version, _vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint8_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ .flags =3D VMS_POINTER | VMS_VARRAY_UINT8 | \ @@ -596,7 +669,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; _field, _state, _field_num, _version, _vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ .flags =3D VMS_POINTER | VMS_VARRAY_UINT32 | \ @@ -608,7 +681,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VARRAY_OF_POINTER_UINT32(_field, _state, _field_num, _vers= ion, _info, _type) { \ .name =3D (stringify(_field)), = \ .version_id =3D (_version), = \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), = \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), = \ .info =3D &(_info), = \ .flags =3D VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER= , \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ @@ -650,7 +723,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; =20 #define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, = _vmsd, _type) { \ .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint8_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ @@ -674,7 +747,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _v= msd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ @@ -684,7 +757,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _= vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ @@ -694,7 +767,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _= vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint16_t),\ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ .flags =3D VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ @@ -703,7 +776,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; =20 #define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version,= _vmsd, _type) { \ .name =3D (stringify(_field)), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ @@ -715,7 +788,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, int32_t), \ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .flags =3D VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ @@ -736,7 +809,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint32_t),\ + .size_indirect =3D vmstate_field_offset(_state, _field_size), \ .size =3D (_multiply), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER|VMS_MULTIPLY, \ @@ -747,7 +820,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, int32_t),\ + .size_indirect =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ @@ -757,7 +830,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint32_t),\ + .size_indirect =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ @@ -767,7 +840,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint64_t),\ + .size_indirect =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER | VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ @@ -778,7 +851,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, uint32_t),\ + .size_indirect =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_buffer, \ .flags =3D VMS_VBUFFER|VMS_POINTER|VMS_ALLOC, \ .offset =3D offsetof(_state, _field), \ @@ -838,7 +911,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_UNUSED_VARRAY_UINT32(_state, _test, _version, _field_num, = _size) {\ .name =3D "unused", \ .field_exists =3D (_test), \ - .num_offset =3D vmstate_offset_value(_state, _field_num, uint32_t),\ + .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ .size =3D (_size), \ .info =3D &vmstate_info_unused_buffer, \ @@ -852,7 +925,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .name =3D (stringify(_field)), \ .field_exists =3D (_test), \ .version_id =3D (_version), \ - .size_offset =3D vmstate_offset_value(_state, _field_size, int32_t),\ + .size_indirect =3D vmstate_field_offset(_state, _field_size), \ .info =3D &vmstate_info_bitmap, \ .flags =3D VMS_VBUFFER|VMS_POINTER, \ .offset =3D offsetof(_state, _field), \ diff --git a/migration/savevm.c b/migration/savevm.c index 161a9d090fa..16b049c4539 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -873,14 +873,14 @@ static void vmstate_check(const VMStateDescription *v= msd) * Size must be provided because dest QEMU needs that * info to know what to allocate */ - assert(field->size || field->size_offset); + assert(field->size !=3D 0 || field->size_indirect.size= !=3D 0); } else { /* * Otherwise size info isn't useful (because it's * always the size of host pointer), detect accidental * setup of sizes in this case. */ - assert(field->size =3D=3D 0 && field->size_offset =3D= =3D 0); + assert(field->size =3D=3D 0 && field->size_indirect.si= ze =3D=3D 0); } /* * VMS_ARRAY_OF_POINTER must be used only together with one diff --git a/migration/vmstate.c b/migration/vmstate.c index 50ebe378452..372aed258f1 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -78,32 +78,44 @@ vmsd_init_ptr_marker_field(VMStateField *fake, const VM= StateField *field) }; } =20 -static int vmstate_n_elems(void *opaque, const VMStateField *field) +static uint64_t vmstate_read_from_offset(const VMStateStructMember *member, + void *opaque) { - int n_elems =3D 1; + uint8_t *ptr =3D (uint8_t *)opaque + member->offset; + uint64_t v =3D 0; + + switch (member->size) { + case 1: + case 2: + case 4: + case 8: + memcpy(&v, ptr, member->size); + return v; + } + g_assert_not_reached(); +} + +static uint64_t vmstate_n_elems(void *opaque, const VMStateField *field) +{ + uint64_t n_elems =3D 1; =20 if (field->flags & VMS_ARRAY) { n_elems =3D field->num; - } else if (field->flags & VMS_VARRAY_INT32) { - n_elems =3D *(int32_t *)(opaque + field->num_offset); - } else if (field->flags & VMS_VARRAY_UINT32) { - n_elems =3D *(uint32_t *)(opaque + field->num_offset); - } else if (field->flags & VMS_VARRAY_UINT16) { - n_elems =3D *(uint16_t *)(opaque + field->num_offset); - } else if (field->flags & VMS_VARRAY_UINT8) { - n_elems =3D *(uint8_t *)(opaque + field->num_offset); + } else if (field->flags & (VMS_VARRAY_INT32 | VMS_VARRAY_UINT32 + | VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8)) { + n_elems =3D vmstate_read_from_offset(&field->num_indirect, opaque); } =20 trace_vmstate_n_elems(field->name, n_elems); return n_elems; } =20 -static int vmstate_size(void *opaque, const VMStateField *field) +static uint64_t vmstate_size(void *opaque, const VMStateField *field) { - int size; + uint64_t size; =20 if (field->flags & VMS_VBUFFER) { - size =3D *(int32_t *)(opaque + field->size_offset); + size =3D vmstate_read_from_offset(&field->size_indirect, opaque); if (field->flags & VMS_MULTIPLY) { size *=3D field->size; } @@ -124,7 +136,7 @@ static void vmstate_handle_alloc(void *ptr, const VMSta= teField *field, void *opaque) { if (field->flags & VMS_POINTER && field->flags & VMS_ALLOC) { - gsize size =3D vmstate_size(opaque, field); + uint64_t size =3D vmstate_size(opaque, field); size *=3D vmstate_n_elems(opaque, field); if (size) { *(void **)ptr =3D g_malloc(size); @@ -335,8 +347,9 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescri= ption *vmsd, =20 if (exists) { void *first_elem =3D opaque + field->offset; - int i, n_elems =3D vmstate_n_elems(opaque, field); - int size =3D vmstate_size(opaque, field); + int i; + uint64_t n_elems =3D vmstate_n_elems(opaque, field); + uint64_t size =3D vmstate_size(opaque, field); =20 vmstate_handle_alloc(first_elem, field, opaque); if (field->flags & VMS_POINTER) { @@ -650,8 +663,9 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMSt= ateDescription *vmsd, while (field->name) { if (vmstate_field_exists(vmsd, field, opaque, version_id)) { void *first_elem =3D opaque + field->offset; - int i, n_elems =3D vmstate_n_elems(opaque, field); - int size =3D vmstate_size(opaque, field); + int i; + uint64_t n_elems =3D vmstate_n_elems(opaque, field); + uint64_t size =3D vmstate_size(opaque, field); JSONWriter *vmdesc_loop =3D vmdesc; bool is_prev_null =3D false; /* diff --git a/rust/bindings/migration-sys/lib.rs b/rust/bindings/migration-s= ys/lib.rs index 9581481e421..baa2730ca9d 100644 --- a/rust/bindings/migration-sys/lib.rs +++ b/rust/bindings/migration-sys/lib.rs @@ -47,6 +47,7 @@ fn default() -> Self { unsafe impl Zeroable for VMStateFlags {} unsafe impl Zeroable for VMStateField {} unsafe impl Zeroable for VMStateDescription {} +unsafe impl Zeroable for VMStateStructMember {} =20 // The following higher-level helpers could be in "migration" // crate when Rust has const trait impl. @@ -115,3 +116,12 @@ pub const fn with_varray_flag(mut self, flag: VMStateF= lags) -> Self { self.with_varray_flag_unchecked(flag) } } + +impl VMStateStructMember { + pub const fn new(off: usize, size: usize) -> Self { + Self { + offset: off as u32, + size: size as u8, + } + } +} diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 7409b592a2c..48d0065139a 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -41,7 +41,7 @@ }; =20 use crate::bindings::{self, VMStateFlags}; -pub use crate::bindings::{MigrationPriority, VMStateField}; +pub use crate::bindings::{MigrationPriority, VMStateField, VMStateStructMe= mber}; =20 /// This macro is used to call a function with a generic argument bound /// to the type of a field. The function must take a @@ -119,6 +119,23 @@ pub const fn vmstate_varray_flag(_: Phanto= mData) -> VMStateFlags T::VARRAY_FLAG } =20 +pub const OPAQUE: &[u8; 1048576] =3D &[0; 1048576]; + +pub const fn size_of_ptr_type(_: *const T) -> usize { + ::core::mem::size_of::() +} + +#[macro_export] +macro_rules! size_of_field_type { + ($struct_name:ty, $($field_name:ident).+) =3D> { + $crate::vmstate::size_of_ptr_type(unsafe { + ::core::ptr::addr_of!( + (*$crate::vmstate::OPAQUE.as_ptr().cast::<$struct_name>())= .$($field_name).+ + ) + }) + }; +} + /// Return the `VMStateField` for a field of a struct. The field must be /// visible in the current scope. /// @@ -146,7 +163,10 @@ macro_rules! vmstate_of { .as_bytes() .as_ptr().cast::<::std::os::raw::c_char>(), offset: ::std::mem::offset_of!($struct_name, $($field_name).+), - $(num_offset: ::std::mem::offset_of!($struct_name, $($num).+),= )? + $(num_indirect: $crate::vmstate::VMStateStructMember { + offset: ::std::mem::offset_of!($struct_name, $($num).+) as= u32, + size: $crate::size_of_field_type!($struct_name, $($num).+) as u8, + },)? $(field_exists: $crate::vmstate_exist_fn!($struct_name, $test_= fn),)? // The calls to `call_func_with_field!` are the magic that // computes most of the VMStateField from the type of the fiel= d. diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_t= ests.rs index c2c12cfab52..c002ffb2bc4 100644 --- a/rust/tests/tests/vmstate_tests.rs +++ b/rust/tests/tests/vmstate_tests.rs @@ -65,7 +65,7 @@ fn test_vmstate_uint16() { b"elem\0" ); assert_eq!(foo_fields[0].offset, 16); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_indirect.size, 0); assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_int8 }); assert_eq!(foo_fields[0].version_id, 0); assert_eq!(foo_fields[0].size, 1); @@ -86,7 +86,7 @@ fn test_vmstate_unused() { b"unused\0" ); assert_eq!(foo_fields[1].offset, 0); - assert_eq!(foo_fields[1].num_offset, 0); + assert_eq!(foo_fields[1].num_indirect.size, 0); assert_eq!(foo_fields[1].info, unsafe { &vmstate_info_unused_buffer }); assert_eq!(foo_fields[1].version_id, 0); assert_eq!(foo_fields[1].size, 8); @@ -108,7 +108,7 @@ fn test_vmstate_varray_uint16_unsafe() { b"arr\0" ); assert_eq!(foo_fields[2].offset, 0); - assert_eq!(foo_fields[2].num_offset, 4); + assert_eq!(foo_fields[2].num_indirect.offset, 4); assert_eq!(foo_fields[2].info, unsafe { &vmstate_info_uint8 }); assert_eq!(foo_fields[2].version_id, 0); assert_eq!(foo_fields[2].size, 1); @@ -172,7 +172,7 @@ fn test_vmstate_bool_v() { b"val\0" ); assert_eq!(foo_fields[0].offset, 136); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_indirect.size, 0); assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_bool }); assert_eq!(foo_fields[0].version_id, 2); assert_eq!(foo_fields[0].size, 1); @@ -193,7 +193,7 @@ fn test_vmstate_uint64() { b"wrap\0" ); assert_eq!(foo_fields[1].offset, 128); - assert_eq!(foo_fields[1].num_offset, 0); + assert_eq!(foo_fields[1].num_indirect.size, 0); assert_eq!(foo_fields[1].info, unsafe { &vmstate_info_uint64 }); assert_eq!(foo_fields[1].version_id, 0); assert_eq!(foo_fields[1].size, 8); @@ -215,7 +215,7 @@ fn test_vmstate_struct_varray_uint8() { b"arr_a\0" ); assert_eq!(foo_fields[2].offset, 0); - assert_eq!(foo_fields[2].num_offset, 60); + assert_eq!(foo_fields[2].num_indirect.offset, 60); assert!(foo_fields[2].info.is_null()); // VMSTATE_STRUCT_VARRAY_UINT8 = doesn't set info field. assert_eq!(foo_fields[2].version_id, 1); assert_eq!(foo_fields[2].size, 20); @@ -240,7 +240,7 @@ fn test_vmstate_macro_array() { b"arr_i64\0" ); assert_eq!(foo_fields[4].offset, 144); - assert_eq!(foo_fields[4].num_offset, 0); + assert_eq!(foo_fields[4].num_indirect.size, 0); assert_eq!(foo_fields[4].info, unsafe { &vmstate_info_int64 }); assert_eq!(foo_fields[4].version_id, 0); assert_eq!(foo_fields[4].size, 8); @@ -264,7 +264,7 @@ fn test_vmstate_struct_varray_uint8_wrapper() { unsafe { CStr::from_ptr(foo_fields[5].name) }.to_bytes_with_nul(), b"arr_a_wrap\0" ); - assert_eq!(foo_fields[5].num_offset, 228); + assert_eq!(foo_fields[5].num_indirect.offset, 228); assert!(unsafe { foo_fields[5].field_exists.unwrap()(foo_b_p, 0) }); =20 // The last VMStateField in VMSTATE_FOOB. @@ -316,7 +316,7 @@ fn test_vmstate_pointer() { b"ptr\0" ); assert_eq!(foo_fields[0].offset, 0); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_indirect.size, 0); assert_eq!(foo_fields[0].info, unsafe { &vmstate_info_int32 }); assert_eq!(foo_fields[0].version_id, 2); assert_eq!(foo_fields[0].size, 4); @@ -341,7 +341,7 @@ fn test_vmstate_struct_pointer() { b"ptr_a\0" ); assert_eq!(foo_fields[1].offset, PTR_SIZE); - assert_eq!(foo_fields[1].num_offset, 0); + assert_eq!(foo_fields[1].num_indirect.size, 0); assert_eq!(foo_fields[1].vmsd, VMSTATE_FOOA.as_ref()); assert_eq!(foo_fields[1].version_id, 0); assert_eq!(foo_fields[1].size, size_of::()); @@ -366,7 +366,7 @@ fn test_vmstate_macro_array_of_pointer() { b"arr_ptr\0" ); assert_eq!(foo_fields[2].offset, 2 * PTR_SIZE); - assert_eq!(foo_fields[2].num_offset, 0); + assert_eq!(foo_fields[2].num_indirect.size, 0); assert_eq!(foo_fields[2].info, unsafe { &vmstate_info_uint8 }); assert_eq!(foo_fields[2].version_id, 0); assert_eq!(foo_fields[2].size, PTR_SIZE); @@ -391,7 +391,7 @@ fn test_vmstate_macro_array_of_pointer_wrapped() { b"arr_ptr_wrap\0" ); assert_eq!(foo_fields[3].offset, (FOO_ARRAY_MAX + 2) * PTR_SIZE); - assert_eq!(foo_fields[3].num_offset, 0); + assert_eq!(foo_fields[3].num_indirect.size, 0); assert_eq!(foo_fields[3].info, unsafe { &vmstate_info_uint8 }); assert_eq!(foo_fields[3].version_id, 0); assert_eq!(foo_fields[3].size, PTR_SIZE); @@ -454,7 +454,7 @@ fn test_vmstate_validate() { b"foo_d_0\0" ); assert_eq!(foo_fields[0].offset, 0); - assert_eq!(foo_fields[0].num_offset, 0); + assert_eq!(foo_fields[0].num_indirect.size, 0); assert!(foo_fields[0].info.is_null()); assert_eq!(foo_fields[0].version_id, 0); assert_eq!(foo_fields[0].size, 0); --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754826; cv=none; d=zohomail.com; s=zohoarc; b=ZmPFRu01tYwPKLov1x889lAg8hAVX7tkrdTKoxqkoLUJCaekCnGqnTjDkCKrorCvyU1JUL6HjF6J/mveMRUHpGeGL3GH8Cydu8I+SX+2YBcJ0oaqWLfWQd+ESa4UUF1XE1hsC8PPr+X3oeiRxdwv6KtxVR3RtAESa0UmnrPJxVE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754826; 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=wtkKWtu9DpZCeDi6PKkmcHjF6vdv1rPnAxh7VtMH5DQ=; b=dmDuQunzhV/hLM2CrdprtjV/WMv8Nr5PKdiveTSaka3g9AO7yMdZlIB8DrZ0sLbbQr6tt6FPuQ6ufof4PwL24nXf3u2wRqEJ48Mn0mkVlGBv7GdukzpowkIpLV4ROvpy/PgsOtRHYZkIqXWXzr9sDgKqvRnxrBVabbMiUYFEZv4= 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 1787754826725363.7401519875011; Wed, 26 Aug 2026 07:33:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdX-0001F8-Md; Wed, 26 Aug 2026 10:29:55 -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 1wzEdV-0001E8-Ay for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:53 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdS-0002Aw-Ho for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:53 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 196E221262; Wed, 26 Aug 2026 14:29:41 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 54F0D1361C; Wed, 26 Aug 2026 14:29:40 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +IjeCVT4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtkKWtu9DpZCeDi6PKkmcHjF6vdv1rPnAxh7VtMH5DQ=; b=w3BKJWqefnV1zPZWLmOQ/kqIKze9+zP38x6M1c3ICX/QBc0RzRoqQd4/YMjtb/rlYIDGvx PZmPhO/vA8XK//IX6GbsecCaFDDYzrkFN0MbdPty3QhkgtUw0TLbNnqwmqr2hzuRdrcptD SUilFxLXkjpWtpUUa8Eb2vR6m0l8It8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtkKWtu9DpZCeDi6PKkmcHjF6vdv1rPnAxh7VtMH5DQ=; b=KenLYyB7XSSqrOMSOBZNOdIOn/n2afq7wB3wFQtLdxXi4Vre4+FkjLGOiKuGHI/IfHX+6E HkzRCNS7GPOTrPCw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754581; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtkKWtu9DpZCeDi6PKkmcHjF6vdv1rPnAxh7VtMH5DQ=; b=u+TnL5qzNjEd1sJT2KVso+k6Juf9t5TiZ3G1q1MiiXtTHN91JcLonF6lcdZ1E3W98FXVg6 nRmNxBXEMppQsOVWZXNKGBOj5sNUdT8Q+IN7xSs/6frT5vj0P+6q8svHRmTLQyQqf7vh4h b287Bee3eIYBDVobQKvdeIJcTy4tTk4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754581; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtkKWtu9DpZCeDi6PKkmcHjF6vdv1rPnAxh7VtMH5DQ=; b=4zPU1H080jWmgbvNk9tc97jo7EIyRkxXLA39eP+xgNQjpZwMCL0zqHUOBsI/OLpGfwKKLN Qbtyt6t5Ixa8TWAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu Subject: [PULL 24/30] migration: Remove redundant flags Date: Wed, 26 Aug 2026 11:28:59 -0300 Message-ID: <20260826142905.2315503-25-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-2.78 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.18)[-0.912]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; URIBL_BLOCKED(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:mid,suse.de:email]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -2.78 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754828894158500 Content-Type: text/plain; charset="utf-8" Remove the VMS_VARRAY and VMS_VBUFFER flags that became redundant due to the previous commit which stores the size of the vmstate offset variables along with the offset itself. Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 74 +++++++++++------------------- migration/savevm.c | 6 +-- migration/vmstate.c | 3 +- rust/bindings/migration-sys/lib.rs | 7 +-- rust/migration/src/vmstate.rs | 6 +-- rust/tests/tests/vmstate_tests.rs | 4 +- 6 files changed, 37 insertions(+), 63 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 12bfa64fb92..a168651a062 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -69,8 +69,9 @@ enum VMStateFlags { * }). Dereference the pointer before using it as basis for * further pointer arithmetic (see e.g. VMS_ARRAY). Does not * affect the meaning of VMStateField.num_indirect or - * VMStateField.size_indirect; see VMS_VARRAY* and VMS_VBUFFER for - * those. */ + * VMStateField.size_indirect; see VMS_VARRAY and VMS_VBUFFER for + * those. + */ VMS_POINTER =3D 0x002, =20 /* The field is an array of fixed size. VMStateField.num contains @@ -80,12 +81,13 @@ enum VMStateFlags { * VMS_MULTIPLY. Each array entry will be processed individually * (VMStateField.info.get()/put() if VMS_STRUCT is not set, * recursion into VMStateField.vmsd if VMS_STRUCT is set). May not - * be combined with VMS_VARRAY*. */ + * be combined with VMS_VARRAY. + */ VMS_ARRAY =3D 0x004, =20 /* The field is itself a struct, containing one or more * fields. Recurse into VMStateField.vmsd. Most useful in - * combination with VMS_ARRAY / VMS_VARRAY*, recursing into each + * combination with VMS_ARRAY / VMS_VARRAY, recursing into each * array entry. */ VMS_STRUCT =3D 0x008, =20 @@ -93,9 +95,9 @@ enum VMStateFlags { * The field is an array of variable size. The integer at opaque + * VMStateField.num_indirect contains the number of entries in the * array. See the VMS_ARRAY description regarding array handling - * in general. May not be combined with VMS_ARRAY or any other - * VMS_VARRAY*. */ - VMS_VARRAY_INT32 =3D 0x010, + * in general. May not be combined with VMS_ARRAY. + */ + VMS_VARRAY =3D 0x010, =20 /* Ignored */ VMS_BUFFER =3D 0x020, @@ -103,18 +105,12 @@ enum VMStateFlags { /* The field is a (fixed-size or variable-size) array of pointers * (e.g. struct a { uint8_t *b[]; }). Dereference each array entry * before using it. Note: Does not imply any one of VMS_ARRAY / - * VMS_VARRAY*; these need to be set explicitly. */ + * VMS_VARRAY; these need to be set explicitly. + */ VMS_ARRAY_OF_POINTER =3D 0x040, =20 - /* The field is an array of variable size. The uint16_t at opaque - * + VMStateField.num_indirect - * contains the number of entries in the array. See the VMS_ARRAY - * description regarding array handling in general. May not be - * combined with VMS_ARRAY or any other VMS_VARRAY*. */ - VMS_VARRAY_UINT16 =3D 0x080, - /* The size of the individual entries (a single array entry if - * VMS_ARRAY or any of VMS_VARRAY* are set, or the field itself if + * VMS_ARRAY or VMS_VARRAY are set, or the field itself if * neither is set) is variable (i.e. not known at compile-time), * but the same for all entries. Use the integer at opaque + * VMStateField.size_indirect (subject to VMS_MULTIPLY) to determine @@ -128,20 +124,6 @@ enum VMStateFlags { * allocated. Only valid in combination with VMS_VBUFFER. */ VMS_MULTIPLY =3D 0x200, =20 - /* The field is an array of variable size. The uint8_t at opaque + - * VMStateField.num_indirect - * contains the number of entries in the array. See the VMS_ARRAY - * description regarding array handling in general. May not be - * combined with VMS_ARRAY or any other VMS_VARRAY*. */ - VMS_VARRAY_UINT8 =3D 0x400, - - /* The field is an array of variable size. The uint32_t at opaque - * + VMStateField.num_indirect - * contains the number of entries in the array. See the VMS_ARRAY - * description regarding array handling in general. May not be - * combined with VMS_ARRAY or any other VMS_VARRAY*. */ - VMS_VARRAY_UINT32 =3D 0x800, - /* Fail loading the serialised VM state if this field is missing * from the input. */ VMS_MUST_EXIST =3D 0x1000, @@ -530,7 +512,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_INT32|VMS_POINTER, \ + .flags =3D VMS_VARRAY | VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -540,7 +522,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT32|VMS_POINTER, \ + .flags =3D VMS_VARRAY | VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -550,7 +532,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_INT32 | VMS_POINTER | VMS_ALLOC, \ + .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -560,7 +542,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT32|VMS_POINTER|VMS_ALLOC, \ + .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -570,7 +552,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT16 | VMS_POINTER | VMS_ALLOC, \ + .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -580,7 +562,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .info =3D &(_info), \ .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY_UINT16, \ + .flags =3D VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 @@ -659,7 +641,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_POINTER | VMS_VARRAY_UINT8 | \ + .flags =3D VMS_POINTER | VMS_VARRAY | \ VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ @@ -672,7 +654,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_POINTER | VMS_VARRAY_UINT32 | \ + .flags =3D VMS_POINTER | VMS_VARRAY | \ VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ @@ -683,7 +665,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), = \ .num_indirect =3D vmstate_field_offset(_state, _field_num), = \ .info =3D &(_info), = \ - .flags =3D VMS_VARRAY_UINT32 | VMS_ARRAY_OF_POINTER | VMS_POINTER= , \ + .flags =3D VMS_VARRAY | VMS_ARRAY_OF_POINTER | VMS_POINTER, = \ .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ } =20 @@ -727,7 +709,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_UINT8, \ + .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 @@ -750,7 +732,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ + .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -760,7 +742,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY_INT32 | VMS_STRUCT, \ + .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -770,7 +752,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY_UINT16 | VMS_STRUCT, \ + .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -780,7 +762,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_UINT32, \ + .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 @@ -790,7 +772,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .vmsd =3D &(_vmsd), \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .size =3D sizeof(_type), \ - .flags =3D VMS_STRUCT|VMS_VARRAY_INT32|VMS_ALLOC|VMS_POINTER, \ + .flags =3D VMS_STRUCT | VMS_VARRAY | VMS_ALLOC | VMS_POINTER, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 @@ -915,7 +897,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .version_id =3D (_version), \ .size =3D (_size), \ .info =3D &vmstate_info_unused_buffer, \ - .flags =3D VMS_VARRAY_UINT32 | VMS_BUFFER, \ + .flags =3D VMS_VARRAY | VMS_BUFFER, \ } =20 /* _field_size should be a int32_t field in the _state struct giving the diff --git a/migration/savevm.c b/migration/savevm.c index 16b049c4539..ba705c941aa 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -884,11 +884,9 @@ static void vmstate_check(const VMStateDescription *vm= sd) } /* * VMS_ARRAY_OF_POINTER must be used only together with one - * of VMS_(V)ARRAY* flags. + * of VMS_(V)ARRAY flags. */ - assert(field->flags & (VMS_ARRAY | VMS_VARRAY_INT32 | - VMS_VARRAY_UINT16 | VMS_VARRAY_UINT= 8 | - VMS_VARRAY_UINT32)); + assert(field->flags & (VMS_ARRAY | VMS_VARRAY)); } =20 if (field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC) { diff --git a/migration/vmstate.c b/migration/vmstate.c index 372aed258f1..bc5285bcea2 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -101,8 +101,7 @@ static uint64_t vmstate_n_elems(void *opaque, const VMS= tateField *field) =20 if (field->flags & VMS_ARRAY) { n_elems =3D field->num; - } else if (field->flags & (VMS_VARRAY_INT32 | VMS_VARRAY_UINT32 - | VMS_VARRAY_UINT16 | VMS_VARRAY_UINT8)) { + } else if (field->flags & VMS_VARRAY) { n_elems =3D vmstate_read_from_offset(&field->num_indirect, opaque); } =20 diff --git a/rust/bindings/migration-sys/lib.rs b/rust/bindings/migration-s= ys/lib.rs index baa2730ca9d..c8397dc8974 100644 --- a/rust/bindings/migration-sys/lib.rs +++ b/rust/bindings/migration-sys/lib.rs @@ -57,12 +57,7 @@ pub trait VMStateFlagsExt { } =20 impl VMStateFlagsExt for VMStateFlags { - const VMS_VARRAY_FLAGS: VMStateFlags =3D VMStateFlags( - VMStateFlags::VMS_VARRAY_INT32.0 - | VMStateFlags::VMS_VARRAY_UINT8.0 - | VMStateFlags::VMS_VARRAY_UINT16.0 - | VMStateFlags::VMS_VARRAY_UINT32.0, - ); + const VMS_VARRAY_FLAGS: VMStateFlags =3D VMStateFlags(VMStateFlags::VM= S_VARRAY.0); } =20 // Add a couple builder-style methods to VMStateField, allowing diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 48d0065139a..45c0b52738b 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -250,9 +250,9 @@ unsafe impl $crate::vmstate::VMState for $type { impl_vmstate_scalar!(vmstate_info_int16, i16); impl_vmstate_scalar!(vmstate_info_int32, i32); impl_vmstate_scalar!(vmstate_info_int64, i64); -impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY_UINT8); -impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY_UINT16); -impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY_UINT32); +impl_vmstate_scalar!(vmstate_info_uint8, u8, VMS_VARRAY); +impl_vmstate_scalar!(vmstate_info_uint16, u16, VMS_VARRAY); +impl_vmstate_scalar!(vmstate_info_uint32, u32, VMS_VARRAY); impl_vmstate_scalar!(vmstate_info_uint64, u64); impl_vmstate_scalar!(vmstate_info_timer, util::timer::Timer); =20 diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_t= ests.rs index c002ffb2bc4..5f6dd8ae7f1 100644 --- a/rust/tests/tests/vmstate_tests.rs +++ b/rust/tests/tests/vmstate_tests.rs @@ -113,7 +113,7 @@ fn test_vmstate_varray_uint16_unsafe() { assert_eq!(foo_fields[2].version_id, 0); assert_eq!(foo_fields[2].size, 1); assert_eq!(foo_fields[2].num, 0); - assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY_UINT16); + assert_eq!(foo_fields[2].flags, VMStateFlags::VMS_VARRAY); assert!(foo_fields[2].vmsd.is_null()); assert!(foo_fields[2].field_exists.is_none()); } @@ -222,7 +222,7 @@ fn test_vmstate_struct_varray_uint8() { assert_eq!(foo_fields[2].num, 0); assert_eq!( foo_fields[2].flags.0, - VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY_UINT8.0 + VMStateFlags::VMS_STRUCT.0 | VMStateFlags::VMS_VARRAY.0 ); assert_eq!(foo_fields[2].vmsd, VMSTATE_FOOA.as_ref()); assert!(foo_fields[2].field_exists.is_none()); --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754818; cv=none; d=zohomail.com; s=zohoarc; b=EUsKD9y6ZUApFSDETRNoRoATT6OCarmj80VcSc4rTV6INJmUrTXRoknpSlHtlJmnHM15YF6uPKGHzGfVsWFoBtVQT55AISQ0xuyL0ucfg99bsH9MwvHHgRn/zee8M1PJzzScUwTjfiAeU9ZYjLP54rparsBlwD4SeREMVbnL3go= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754818; 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=P+k6wT9dlIGPFseuREKh7ReD8czK6BKywdzvBqkErBQ=; b=JOdVHRnvBnJM8+kXYtm9zRzwUE1Bg7BGx4hlpgM+oGYa+iCR/NQQO06dLHCfkyaQm+zw34m4iF/yHRnYuAfpniBeClJbv6WKej97LxJCBzdW5aG2YUQO3c5TF+8PXauxzDOUW8A4ViHjX3UR9i82AGcj43X+eUe//cpT4lXr4v8= 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 1787754818583282.2981858465347; Wed, 26 Aug 2026 07:33:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEda-0001G9-79; Wed, 26 Aug 2026 10:29:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wzEdW-0001EQ-5I for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:54 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdT-0002CR-LQ for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:53 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3125821263; Wed, 26 Aug 2026 14:29:42 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 6DFBD1364A; Wed, 26 Aug 2026 14:29:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cN38D1X4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754586; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+k6wT9dlIGPFseuREKh7ReD8czK6BKywdzvBqkErBQ=; b=MhYklx7Kv389Q4HS5DN3uhbdDSxd0yzj2MzHKtkqDyWW3AuHGiIorbEoHWmEsgpq+Ptqw4 gWnYRoTUAsZBxsxCde0GRDBLaDOXQUtT/29OnfbX+ZhkQe/Q/ifx1PDgK9dcLZJ0+zn5ZI Io9syLM+G98z4bZgGNWZjybnUfimYhU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754586; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+k6wT9dlIGPFseuREKh7ReD8czK6BKywdzvBqkErBQ=; b=e46KIFpOGvoh6SMt8fTaUb1bY49ZuIsX/LLyyhZ7Ssf/t+MhCN6Rr2SxQ7usef9KT2U2ot jaMCV8mwp3cqscCA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754582; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+k6wT9dlIGPFseuREKh7ReD8czK6BKywdzvBqkErBQ=; b=w8j5cEzOsRvonh17Q/fUFxtXZ2mHADgLdzic0Gv9Yxq2BPmMxsnyW1WpEX0zNB5g5DuBww YqoQA6XFu0qpS/qHl2EyvpKGoUDIwRWcpciHrmdRrifbWEX3QJWYmXoVnb2xMinRdPp411 bvwTA/KHiPuveFxoZlUVBZOiC5NWT9A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754582; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P+k6wT9dlIGPFseuREKh7ReD8czK6BKywdzvBqkErBQ=; b=n2WKZijvD1EQ4ad/Fqk0X6pDXwXuwX7Zf09xnZDDWWN8TXM//vKHJgl1u74Ng0R7BiXap9 8VFWI1f1EgXDuwCA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu Subject: [PULL 25/30] migration: Remove duplicate vmstate macros Date: Wed, 26 Aug 2026 11:29:00 -0300 Message-ID: <20260826142905.2315503-26-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.78 X-Spamd-Result: default: False [-2.78 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.18)[-0.907]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754818781158500 Content-Type: text/plain; charset="utf-8" Now that type-checking is not being done per integer size anymore, various macros have duplicated bodies. Remove them. The original names are left the same so the device code can be altered per-subsystem in the next patches. Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/migration/vmstate.h | 135 ++++++++++++------------------------ 1 file changed, 44 insertions(+), 91 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index a168651a062..4b6d52955ff 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -506,7 +506,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_sub_array(_state, _field, _type, _start= ), \ } =20 -#define VMSTATE_VARRAY_INT32(_field, _state, _field_num, _version, _info, = _type) {\ +#define VMSTATE_VARRAY(_field, _state, _field_num, _version, _info, _type)= {\ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ @@ -516,17 +516,11 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 -#define VMSTATE_VARRAY_UINT32(_field, _state, _field_num, _version, _info,= _type) {\ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_indirect =3D vmstate_field_offset(_state, _field_num), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY | VMS_POINTER, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} +#define VMSTATE_VARRAY_INT32 VMSTATE_VARRAY +#define VMSTATE_VARRAY_UINT32 VMSTATE_VARRAY =20 -#define VMSTATE_VARRAY_INT32_ALLOC(_field, _state, _field_num, _version, _= info, _type) {\ +#define VMSTATE_VARRAY_ALLOC(_field, _state, _field_num, _version, _info, \ + _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ @@ -536,27 +530,12 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } =20 -#define VMSTATE_VARRAY_UINT32_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_indirect =3D vmstate_field_offset(_state, _field_num), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_VARRAY_UINT16_ALLOC(_field, _state, _field_num, _version, = _info, _type) {\ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_indirect =3D vmstate_field_offset(_state, _field_num), \ - .info =3D &(_info), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_VARRAY | VMS_POINTER | VMS_ALLOC, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} +#define VMSTATE_VARRAY_INT32_ALLOC VMSTATE_VARRAY_ALLOC +#define VMSTATE_VARRAY_UINT32_ALLOC VMSTATE_VARRAY_ALLOC +#define VMSTATE_VARRAY_UINT16_ALLOC VMSTATE_VARRAY_ALLOC =20 -#define VMSTATE_VARRAY_UINT16_UNSAFE(_field, _state, _field_num, _version,= _info, _type) {\ +#define VMSTATE_VARRAY_UNSAFE(_field, _state, _field_num, _version, _info,= \ + _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ @@ -566,6 +545,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_varray(_state, _field, _type), \ } =20 +#define VMSTATE_VARRAY_UINT16_UNSAFE VMSTATE_VARRAY_UNSAFE + #define VMSTATE_VSTRUCT_TEST(_field, _state, _test, _version, _vmsd, _type= , _struct_version) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ @@ -634,7 +615,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; * _info: VMStateInfo for _type (when VMS_STRUCT is not set) * start: size of (_type) pointed to (for auto memory allocation) */ -#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT8_ALLOC(\ +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_ALLOC( \ _field, _state, _field_num, _version, _vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ @@ -647,20 +628,13 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ } =20 -#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC(\ - _field, _state, _field_num, _version, _vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .num_indirect =3D vmstate_field_offset(_state, _field_num), \ - .vmsd =3D &(_vmsd), \ - .size =3D sizeof(_type), \ - .flags =3D VMS_POINTER | VMS_VARRAY | \ - VMS_ARRAY_OF_POINTER | VMS_STRUCT | \ - VMS_ARRAY_OF_POINTER_AUTO_ALLOC, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type *), \ -} +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT8_ALLOC \ + VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_ALLOC +#define VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_UINT32_ALLOC \ + VMSTATE_VARRAY_OF_POINTER_TO_STRUCT_ALLOC =20 -#define VMSTATE_VARRAY_OF_POINTER_UINT32(_field, _state, _field_num, _vers= ion, _info, _type) { \ +#define VMSTATE_VARRAY_OF_POINTER(_field, _state, _field_num, _version, _i= nfo, \ + _type) { \ .name =3D (stringify(_field)), = \ .version_id =3D (_version), = \ .num_indirect =3D vmstate_field_offset(_state, _field_num), = \ @@ -669,6 +643,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D vmstate_offset_pointer(_state, _field, _type *), = \ } =20 +#define VMSTATE_VARRAY_OF_POINTER_UINT32 VMSTATE_VARRAY_OF_POINTER + #define VMSTATE_STRUCT_SUB_ARRAY(_field, _state, _start, _num, _version, _= vmsd, _type) { \ .name =3D (stringify(_field)), = \ .version_id =3D (_version), = \ @@ -703,7 +679,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; _n1, _n2), \ } =20 -#define VMSTATE_STRUCT_VARRAY_UINT8(_field, _state, _field_num, _version, = _vmsd, _type) { \ +#define VMSTATE_STRUCT_VARRAY(_field, _state, _field_num, _version, _vmsd,= \ + _type) { \ .name =3D (stringify(_field)), \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ @@ -712,6 +689,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } +#define VMSTATE_STRUCT_VARRAY_UINT8 VMSTATE_STRUCT_VARRAY =20 /* a variable length array (i.e. _type *_field) but we know the * length @@ -726,7 +704,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D offsetof(_state, _field), \ } =20 -#define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _v= msd, _type) { \ +#define VMSTATE_STRUCT_VARRAY_POINTER(_field, _state, _field_num, _vmsd, \ + _type) { \ .name =3D (stringify(_field)), \ .version_id =3D 0, \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ @@ -735,28 +714,12 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ .offset =3D vmstate_offset_pointer(_state, _field, _type), \ } +#define VMSTATE_STRUCT_VARRAY_POINTER_INT32 VMSTATE_STRUCT_VARRAY_POINTER +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32 VMSTATE_STRUCT_VARRAY_POINTER +#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16 VMSTATE_STRUCT_VARRAY_POINTER =20 -#define VMSTATE_STRUCT_VARRAY_POINTER_UINT32(_field, _state, _field_num, _= vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .version_id =3D 0, \ - .num_indirect =3D vmstate_field_offset(_state, _field_num), \ - .size =3D sizeof(_type), \ - .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_POINTER_UINT16(_field, _state, _field_num, _= vmsd, _type) { \ - .name =3D (stringify(_field)), \ - .version_id =3D 0, \ - .num_indirect =3D vmstate_field_offset(_state, _field_num), \ - .size =3D sizeof(_type), \ - .vmsd =3D &(_vmsd), \ - .flags =3D VMS_POINTER | VMS_VARRAY | VMS_STRUCT, \ - .offset =3D vmstate_offset_pointer(_state, _field, _type), \ -} - -#define VMSTATE_STRUCT_VARRAY_UINT32(_field, _state, _field_num, _version,= _vmsd, _type) { \ +#define VMSTATE_STRUCT_VARRAY(_field, _state, _field_num, _version, _vmsd,= \ + _type) { \ .name =3D (stringify(_field)), \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ .version_id =3D (_version), \ @@ -765,8 +728,11 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_STRUCT | VMS_VARRAY, \ .offset =3D vmstate_offset_varray(_state, _field, _type), \ } +#define VMSTATE_STRUCT_VARRAY_INT32 VMSTATE_STRUCT_VARRAY +#define VMSTATE_STRUCT_VARRAY_UINT32 VMSTATE_STRUCT_VARRAY =20 -#define VMSTATE_STRUCT_VARRAY_ALLOC(_field, _state, _field_num, _version, = _vmsd, _type) {\ +#define VMSTATE_STRUCT_VARRAY_ALLOC(_field, _state, _field_num, _version, \ + _vmsd, _type) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .vmsd =3D &(_vmsd), \ @@ -808,28 +774,11 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D offsetof(_state, _field), \ } =20 -#define VMSTATE_VBUFFER_UINT32(_field, _state, _version, _test, _field_siz= e) { \ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .field_exists =3D (_test), \ - .size_indirect =3D vmstate_field_offset(_state, _field_size), \ - .info =3D &vmstate_info_buffer, \ - .flags =3D VMS_VBUFFER|VMS_POINTER, \ - .offset =3D offsetof(_state, _field), \ -} +#define VMSTATE_VBUFFER_UINT32 VMSTATE_VBUFFER +#define VMSTATE_VBUFFER_UINT64 VMSTATE_VBUFFER =20 -#define VMSTATE_VBUFFER_UINT64(_field, _state, _version, _test, _field_siz= e) { \ - .name =3D (stringify(_field)), \ - .version_id =3D (_version), \ - .field_exists =3D (_test), \ - .size_indirect =3D vmstate_field_offset(_state, _field_size), \ - .info =3D &vmstate_info_buffer, \ - .flags =3D VMS_VBUFFER | VMS_POINTER, \ - .offset =3D offsetof(_state, _field), \ -} - -#define VMSTATE_VBUFFER_ALLOC_UINT32(_field, _state, _version, \ - _test, _field_size) { \ +#define VMSTATE_VBUFFER_ALLOC(_field, _state, _version, \ + _test, _field_size) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ .field_exists =3D (_test), \ @@ -839,6 +788,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .offset =3D offsetof(_state, _field), \ } =20 +#define VMSTATE_VBUFFER_ALLOC_UINT32 VMSTATE_VBUFFER_ALLOC + #define VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, _test, _version, _= info, _size) { \ .name =3D (stringify(_field)), \ .version_id =3D (_version), \ @@ -890,7 +841,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; } =20 /* Discard size * field_num bytes, where field_num is a uint32 member */ -#define VMSTATE_UNUSED_VARRAY_UINT32(_state, _test, _version, _field_num, = _size) {\ +#define VMSTATE_UNUSED_VARRAY(_state, _test, _version, _field_num, _size) = {\ .name =3D "unused", \ .field_exists =3D (_test), \ .num_indirect =3D vmstate_field_offset(_state, _field_num), \ @@ -900,6 +851,8 @@ extern const VMStateInfo vmstate_info_g_byte_array; .flags =3D VMS_VARRAY | VMS_BUFFER, \ } =20 +#define VMSTATE_UNUSED_VARRAY_UINT32 VMSTATE_UNUSED_VARRAY + /* _field_size should be a int32_t field in the _state struct giving the * size of the bitmap _field in bits. */ --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754816; cv=none; d=zohomail.com; s=zohoarc; b=BCflH2io/kKQhCkfrZKfTeYd9yYsTwMsbmRFuMqqKLk5xn0ddOhNGBCCN8GQewpKZwKX0yle7i7J+JIkiSiwWLkGqXEu772oRY1YXG/8eDXaGBGi3DmwXjEJh5WgjpJ4nnedD/0tGvAdk7tBiqMdGbb8dgE87bEh6wpeZ4J0oaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754816; 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=TTRVROe/NKWFyg2mijWNlcUE3qr2t7BSGXBfx4KDLXA=; b=noKTfSxBu5wJcUAE0NvNFcABNwWRVwHB8BzK4A6AW5DKLmG6Q7SVx+zAxcXVEn5xyRgX4PwV0jW4Xs8a55sH0KH72ftftd6vtOXwMrZ+pQBxgEYgQyYdVI/c/Des4VVWzu3RVJmAs7TPl8WWgyERQtjm4CGlgjTnmuvYH2332NE= 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 1787754816708666.4036859280711; Wed, 26 Aug 2026 07:33:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEda-0001Gb-L0; Wed, 26 Aug 2026 10:29:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wzEdX-0001Ey-Bk for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:55 -0400 Received: from smtp-out2.suse.de ([2a07:de40:b251:101:10:150:64:2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdU-0002Em-OM for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:55 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 495BC1F82D; Wed, 26 Aug 2026 14:29:43 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 86BAE1364B; Wed, 26 Aug 2026 14:29:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UAQEFlb4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754587; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TTRVROe/NKWFyg2mijWNlcUE3qr2t7BSGXBfx4KDLXA=; b=cilQKV5vsD4K4pp5h2b4b0SnCb20yRqGzirfPr3Wh2zOQDFf1fIhkG7IRYYwaMwRejLjWF P0oVI8wLA01fnGJLDnzqXvFEvwdi1k3rgLGWSOiFDPBNjr+DrvT0MFNTlOlLQP1BYWV3tL 0gfJ909tG3kUqii2bTMrf/M9ZFk3wCU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754587; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TTRVROe/NKWFyg2mijWNlcUE3qr2t7BSGXBfx4KDLXA=; b=Ih6lMbbsoGrGMlhG85AW4yPCBzl0Jrpl8S4QBug9LxD47myZ0gDYjPAQcQ3DXqNcoaDia7 LiuUS+MIRTKtYpAg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=oObAs4F7; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=eSNt2u62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754583; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TTRVROe/NKWFyg2mijWNlcUE3qr2t7BSGXBfx4KDLXA=; b=oObAs4F70gBdFYUHzg3BUDTUB0ZSXolHp7HM8B14sznd/BmgS8XO3N57NWhlbfsyvWV3wl WVw+Hun+obJEGBxPa2LBVVdGcYBSWC9R7CYqZ8CrYUQjvs1yY4PyB8293LnUkn8dEsazv/ xxO7mQdJwdHkvuptcQrZiuT7wPsQT/4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754583; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TTRVROe/NKWFyg2mijWNlcUE3qr2t7BSGXBfx4KDLXA=; b=eSNt2u62pw4oW12npMsomGVaonDiGeWra6Y+++aH0IXsJ0iRSMEpUvdcMrHUHbQhPJ2uH6 j7B8sao/zdKJo7Cw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu Subject: [PULL 26/30] migration: Add VMS_NO_STATE flag Date: Wed, 26 Aug 2026 11:29:01 -0300 Message-ID: <20260826142905.2315503-27-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 495BC1F82D X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.988]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de 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, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754818859158500 Content-Type: text/plain; charset="utf-8" There are a few special cases of vmstate usage: The vmstate_msix and vmstate_scsi_device have fields that contain no data, only a vmstate_info structure. The VMSTATE_VALIDATE macro serves only to invoke the .field_exists routine for validation. Regardless whether these scenarios are valid, add a separate flag to identify them so we can enforce common constraints for the normal vmstates such as having a size greater than zero. Note that n_elems is hardcoded to 1 for all vmstates, except VMS_[V]ARRAY, so VMSTATE_VALIDATE needed to set VMS_ARRAY to be able to force n_elems to 0. This patch now checks the flag at vmstate_n_elems(). Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- hw/pci/msix.c | 6 +----- hw/scsi/scsi-bus.c | 6 +----- include/migration/vmstate.h | 9 +++++++-- migration/vmstate.c | 6 +++++- rust/migration/src/vmstate.rs | 2 +- rust/tests/tests/vmstate_tests.rs | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/hw/pci/msix.c b/hw/pci/msix.c index 1b23eaf1007..adf76b5bccc 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -711,12 +711,8 @@ const VMStateDescription vmstate_msix =3D { .fields =3D (const VMStateField[]) { { .name =3D "msix", - .version_id =3D 0, - .field_exists =3D NULL, - .size =3D 0, /* ouch */ .info =3D &vmstate_info_msix, - .flags =3D VMS_SINGLE, - .offset =3D 0, + .flags =3D VMS_SINGLE | VMS_NO_STATE, }, VMSTATE_END_OF_LIST() } diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index deb43d5560e..aa02ff631b7 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -1980,12 +1980,8 @@ const VMStateDescription vmstate_scsi_device =3D { VMSTATE_UINT32(sense_len, SCSIDevice), { .name =3D "requests", - .version_id =3D 0, - .field_exists =3D NULL, - .size =3D 0, /* ouch */ .info =3D &vmstate_info_scsi_requests, - .flags =3D VMS_SINGLE, - .offset =3D 0, + .flags =3D VMS_SINGLE | VMS_NO_STATE, }, VMSTATE_END_OF_LIST() }, diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 4b6d52955ff..e72c3fae9a6 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -109,6 +109,12 @@ enum VMStateFlags { */ VMS_ARRAY_OF_POINTER =3D 0x040, =20 + /* + * The field contains no data. Used for special cases such as + * invoking a custom VMStateInfo. + */ + VMS_NO_STATE =3D 0x080, + /* The size of the individual entries (a single array entry if * VMS_ARRAY or VMS_VARRAY are set, or the field itself if * neither is set) is variable (i.e. not known at compile-time), @@ -454,8 +460,7 @@ extern const VMStateInfo vmstate_info_g_byte_array; #define VMSTATE_VALIDATE(_name, _test) { \ .name =3D (_name), \ .field_exists =3D (_test), \ - .flags =3D VMS_ARRAY | VMS_MUST_EXIST, \ - .num =3D 0, /* 0 elements: no data, only run _test */ \ + .flags =3D VMS_MUST_EXIST | VMS_NO_STATE, \ } =20 #define VMSTATE_POINTER(_field, _state, _version, _info, _type) { \ diff --git a/migration/vmstate.c b/migration/vmstate.c index bc5285bcea2..51d02b87e7e 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -97,12 +97,16 @@ static uint64_t vmstate_read_from_offset(const VMStateS= tructMember *member, =20 static uint64_t vmstate_n_elems(void *opaque, const VMStateField *field) { - uint64_t n_elems =3D 1; + uint64_t n_elems; =20 if (field->flags & VMS_ARRAY) { n_elems =3D field->num; } else if (field->flags & VMS_VARRAY) { n_elems =3D vmstate_read_from_offset(&field->num_indirect, opaque); + } else if (field->flags & VMS_MUST_EXIST && field->flags & VMS_NO_STAT= E) { + n_elems =3D 0; + } else { + n_elems =3D 1; } =20 trace_vmstate_n_elems(field->name, n_elems); diff --git a/rust/migration/src/vmstate.rs b/rust/migration/src/vmstate.rs index 45c0b52738b..5ed061f2abb 100644 --- a/rust/migration/src/vmstate.rs +++ b/rust/migration/src/vmstate.rs @@ -381,7 +381,7 @@ macro_rules! vmstate_validate { field_exists: $crate::vmstate_exist_fn!($struct_name, $test_fn= ), flags: $crate::bindings::VMStateFlags( $crate::bindings::VMStateFlags::VMS_MUST_EXIST.0 - | $crate::bindings::VMStateFlags::VMS_ARRAY.0, + | $crate::bindings::VMStateFlags::VMS_NO_STATE.0, ), num: 0, // 0 elements: no data, only run test_fn callback ..::common::zeroable::Zeroable::ZERO diff --git a/rust/tests/tests/vmstate_tests.rs b/rust/tests/tests/vmstate_t= ests.rs index 5f6dd8ae7f1..6578d54b37d 100644 --- a/rust/tests/tests/vmstate_tests.rs +++ b/rust/tests/tests/vmstate_tests.rs @@ -461,7 +461,7 @@ fn test_vmstate_validate() { assert_eq!(foo_fields[0].num, 0); assert_eq!( foo_fields[0].flags.0, - VMStateFlags::VMS_ARRAY.0 | VMStateFlags::VMS_MUST_EXIST.0 + VMStateFlags::VMS_NO_STATE.0 | VMStateFlags::VMS_MUST_EXIST.0 ); assert!(foo_fields[0].vmsd.is_null()); assert!(unsafe { foo_fields[0].field_exists.unwrap()(foo_d_p, 0) }); --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754678; cv=none; d=zohomail.com; s=zohoarc; b=kQ55Q7Odnue4L7glrTgwJ5h+y0ba9oB6q5gN84pxDaiy1k5rc950UakeRGu6cunJAXB1ka4/6hTgi9KHveHguwlWB8E1YJDNrnmalTEOMI1pyw5lEU4DBRwEdUlUAFhDl/rb4oTXWlwzKy2j/QNoklQvpcsKlubJt8TYCVdAhac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754678; 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=8tuHdlGGPQPD+UD6SrlaKWBfSOvo8qV7InxoVIfCWkY=; b=YKnyKBgrJRJDJtct72FGWNOfMfX2DmtqWT2cbmt7JcEM90mD8cNl7YcqhsssYWEOAdvUZYXB34uAQOqs6T91DAdYoSjaaWUa979/zqX6xFN44bIIV72UMFAYaYIOJaDsxdHwKxxyIR4MhpicwgViZo5tfnpawB/IRMgOmb3qKGU= 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 1787754678457205.66837612974325; Wed, 26 Aug 2026 07:31:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdZ-0001Ff-Av; Wed, 26 Aug 2026 10:29:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wzEdX-0001FD-On for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:55 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdV-0002HA-QR for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:55 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6272321272; Wed, 26 Aug 2026 14:29:44 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 9F5F11364F; Wed, 26 Aug 2026 14:29:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id kNQBHFf4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754588; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8tuHdlGGPQPD+UD6SrlaKWBfSOvo8qV7InxoVIfCWkY=; b=AvRRWNPZu+PhjDmqbaCYabBDkUztYoiBORk8LEGThyFdep3sjBRZSI4MqqUuWqOrDF7ISn dHZRzLMM1IHhLbdS2xt/89qH/x5iz3n1VZ9rvEIKVAA+H5Dfwt9hu4Rl79VkCLZuOFe8uR 1zb681QrGMHDi8jBSMRJfNhCzqxNTho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754588; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8tuHdlGGPQPD+UD6SrlaKWBfSOvo8qV7InxoVIfCWkY=; b=psgtP/M6Wl+nkcfH2NOKrT7AlGpzFz8aVq8m1EhajI9TsMX9kn5vqflMJ5o4jEtTjsOFq3 mZDHDzBhPza+/hDg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=tTVdwqxW; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=ulSdSxpG DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754584; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8tuHdlGGPQPD+UD6SrlaKWBfSOvo8qV7InxoVIfCWkY=; b=tTVdwqxWMhKOt0IfsKOF2XGasdaIte+J+m5rU0i98qQJgs/RpMcd3NhFfZnR3imgehy42X /ITJ00qC2T7GLj50S4fiQfVhvdada1RxS4Ne+QLyT6FMywbb/V+LzroRpSdtGfbpkR13Jd vxkPZuqh11jM6CJtgBL2e+G8rqUUCuQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754584; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8tuHdlGGPQPD+UD6SrlaKWBfSOvo8qV7InxoVIfCWkY=; b=ulSdSxpGWn9KOHOag9BdrPyNlkA+HY1vLg8i6he2j0kAGDKociGqMF+CZitjv8G8Vzg7L7 5AfJp0Jm26BTKwAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu Subject: [PULL 27/30] migration: Check more vmstate flags Date: Wed, 26 Aug 2026 11:29:02 -0300 Message-ID: <20260826142905.2315503-28-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 6272321272 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.987]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email,suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754679954158500 Content-Type: text/plain; charset="utf-8" Add more checks for vmstate flags constraints. Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/savevm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index ba705c941aa..5b0e89ca7c8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -893,6 +893,25 @@ static void vmstate_check(const VMStateDescription *vm= sd) assert(field->flags & VMS_ARRAY_OF_POINTER); } =20 + /* + * The VMS*ARRAY flags and VMS_VBUFFER affect allocation, + * they must have the proper fields set and no other + * vmstate types can set those fields, otherwise it won't + * be picked-up due to the missing flag. + */ + + if (field->flags & (VMS_ARRAY | VMS_VARRAY)) { + assert(field->num > 0 || field->num_indirect.size !=3D 0); + } else { + assert(field->num =3D=3D 0 && field->num_indirect.size =3D= =3D 0); + } + + if (field->flags & VMS_VBUFFER) { + assert(field->size_indirect.size !=3D 0); + } else { + assert(field->size_indirect.size =3D=3D 0); + } + if (field->flags & (VMS_STRUCT | VMS_VSTRUCT)) { /* Recurse to sub structures */ vmstate_check(field->vmsd); --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754769; cv=none; d=zohomail.com; s=zohoarc; b=ki3HpthbRkruosz4YM+mUZg0tKuDLt9rsDoW1ouqrBMLkE1l45xSI1zm2VrPNDFDdQowjnTdRdZEjf1odFDdtjGoZszNe583dTcjHk+S3NuIJmQ3JGa4YqQQG4u7phVpIkvlTeiK/q1ZeGhtfYLi9wcxlbmqI3SXwHuDBoRc9F8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754769; 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=KSGXmsk3W71ZigGaQDEGitHkLy0FifnfuzNRWcQJsFc=; b=HS29ljuF9dJLdK5NgrPHjNOAYDJS+D3YsBpwWucaMDdIs9MrpsjKSvyELbm4Xdt8dOyEgIjDO7NcnFnHZNX/q20GQDC8ymf0I7/u+f5Zr6ocemG0KH+k+boe8AfkQRB/AAUyvexL3AUpbQu0mwuYhcbs6FdIzWiZXAgpv70rIRE= 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 1787754769888863.7193908918624; Wed, 26 Aug 2026 07:32:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdb-0001IJ-PO; Wed, 26 Aug 2026 10:30:01 -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 1wzEdY-0001FZ-VB for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:56 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdX-0002JR-0Y for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:56 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7B74E21274; Wed, 26 Aug 2026 14:29:45 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B7CE413676; Wed, 26 Aug 2026 14:29:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id aOv9IVj4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754589; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KSGXmsk3W71ZigGaQDEGitHkLy0FifnfuzNRWcQJsFc=; b=Oiac/dWhpWucfkvvHzOXkXZ+R9dNsvk0WMt+ZNbLsCtRuy/CBM3DmcU1xFrN3NPd+TnI87 gBio+8slOAj7mAGy1KiBPB1a0ad4Q+69qDe4SLVQ7jZKprQ7M2jcBCOcnA97kcq8LLXSUA Q9hxzUEe2Qk2H3Rz70o8ILSzEQsZ9qc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754589; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KSGXmsk3W71ZigGaQDEGitHkLy0FifnfuzNRWcQJsFc=; b=vu/9QH2Tw04+tLRB/X+UNOjiEzdVENVkCskydeUD4QICasBMlfcNn55O9pgzKUjcWEpyil jGFYiccerfkC/VCw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DWbffqD8; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="6auGHsc/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KSGXmsk3W71ZigGaQDEGitHkLy0FifnfuzNRWcQJsFc=; b=DWbffqD81eK8SwO0EoQfsHwV9cbHx+xTbfFhDksnf4kbwfvIw8Dd1Z56gSMiVxs42GDkYt eze2U/kVNlyyameEEufxAPIy8Vtw1gbxJUKtQQnITI1lJVNVxhn3+3b7riaTNoEvI05TTq ZaMJtfbI/fyQcV73nUg6anmFh0oZpTE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754585; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KSGXmsk3W71ZigGaQDEGitHkLy0FifnfuzNRWcQJsFc=; b=6auGHsc/tDwdYx1qR9bkZA07kvTchS7VX0SCJ+VF2xb2tVyfqFR3mDRO3NHXd7YUUntltT YWjzd8ir9oSxfLCg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu Subject: [PULL 28/30] migration: Harden vmstate_handle_alloc Date: Wed, 26 Aug 2026 11:29:03 -0300 Message-ID: <20260826142905.2315503-29-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 7B74E21274 X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.988]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; MIME_TRACE(0.00)[0:+]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCPT_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:mid,suse.de:email,suse.de:dkim]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] X-Rspamd-Server: rspamd1.dmz-prg2.suse.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=lists1p.gnu.org; Received-SPF: pass client-ip=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754770377158500 Content-Type: text/plain; charset="utf-8" Harden the vmstate_handle_alloc function against overflow of the 64bit integers it consumes and failure to allocate due to an exceedingly large request. Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 51d02b87e7e..1d028bfe009 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -135,16 +135,28 @@ static uint64_t vmstate_size(void *opaque, const VMSt= ateField *field) return size; } =20 -static void vmstate_handle_alloc(void *ptr, const VMStateField *field, - void *opaque) +static bool vmstate_handle_alloc(void *ptr, const VMStateField *field, + uint64_t n, uint64_t size, Error **errp) { + void *p; + if (field->flags & VMS_POINTER && field->flags & VMS_ALLOC) { - uint64_t size =3D vmstate_size(opaque, field); - size *=3D vmstate_n_elems(opaque, field); - if (size) { - *(void **)ptr =3D g_malloc(size); - } + if (size && n) { + if (umul64_overflow(size, n, &size)) { + error_setg(errp, "%s: field '%s' multiply overflow", + __func__, field->name); + return false; + } + p =3D g_try_malloc(size); + if (!p) { + error_setg(errp, "%s: Could not allocate memory for field = '%s'", + __func__, field->name); + return false; + } + *(void **)ptr =3D p; + } } + return true; } =20 static bool vmstate_ptr_marker_load(QEMUFile *f, bool *load_field, @@ -354,7 +366,9 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescri= ption *vmsd, uint64_t n_elems =3D vmstate_n_elems(opaque, field); uint64_t size =3D vmstate_size(opaque, field); =20 - vmstate_handle_alloc(first_elem, field, opaque); + if (!vmstate_handle_alloc(first_elem, field, n_elems, size, er= rp)) { + return false; + } if (field->flags & VMS_POINTER) { first_elem =3D *(void **)first_elem; assert(first_elem || !n_elems || !size); --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754616; cv=none; d=zohomail.com; s=zohoarc; b=M1/hLJuMoD6LSWyr3JWtYmp1yat994asa1wvaTCwiIFzISbH5UJDtwC/64iN/hl+MrWwQLDFLWU0Y1E6YYsheiXr0mVZbf2D4fGD5oBdkE1gV7TPVay7EavUv8ETntm0XBx7h9FSauUcAB0+Q9LWBgdxNybpTca5ZufEzl7uUmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754616; 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=mBG7zgvfo5U/tM0hH20FGaiL9Ze+m0OgHs/aAMimbio=; b=jwXofJ9cRwv9Yn6xzPVGO1pkYDujEsLxdCr64sqS5zXaf7xzsZNevF6nHBBLxkaF0C/36NW5rv/NDynjd8nxRR9L243Bm77qOTKbTJPXloQ/j07ZZCF7jQ197hBn6kIvKpIF0yEcORVLO2OTBt42DpcVi+velGF/+vkYxwNHkMI= 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 1787754616357379.73091574639454; Wed, 26 Aug 2026 07:30:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdf-0001KE-BC; Wed, 26 Aug 2026 10:30:03 -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 1wzEdZ-0001Fn-Nx for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:57 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdY-0002KY-13 for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:57 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 93BB51F83F; Wed, 26 Aug 2026 14:29:46 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D08D613675; Wed, 26 Aug 2026 14:29:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id UPgWKFn4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754590; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mBG7zgvfo5U/tM0hH20FGaiL9Ze+m0OgHs/aAMimbio=; b=ZYqWLbbrtOnGUb5y3dX1ehvM+wnCPWZNzBhr/qZNLiAve48MKa8AnqmFutyHYSwOYmdR6R QqvRdDpljKUKEAfytSD5f6QjUvbH7BcjekEq7YxtI6LeBRcgmHy+ZLLgIOdhU/O+TUddaT eOnEKNCtj49UZRT8XcqPXHY6oqnClFw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754590; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mBG7zgvfo5U/tM0hH20FGaiL9Ze+m0OgHs/aAMimbio=; b=7mmHoBcqA4Iet22wlYBA7H8EjqF8yeinMl1EWpUAnCmLYwht2253plu5PVDByQ2BvXT21h 4muE0xeE0hYUvlBw== Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754586; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mBG7zgvfo5U/tM0hH20FGaiL9Ze+m0OgHs/aAMimbio=; b=WK6SY5KtCuXIoEfx6k2xRKaHXtfhxK7MdNVtQq1I3EstOY0tchYPovoRnOq7mv9apvhaN2 zjtTNVLU9Fw6649KvRqDfXFM9J78zzyp33KQst2zSnsrcxXDEvYq1z8uSD5GlHpVH+xauh y4wBKIKWOz5AoWpeXDNb52GXI9tccZ8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754586; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mBG7zgvfo5U/tM0hH20FGaiL9Ze+m0OgHs/aAMimbio=; b=puJ3uNq4X+8RnjgGb74PQgF4GQn6zxqZCgG4CTBboVeNENl3fB4UmvkhWhWWwZc/2PRM3U Ulj+HqVXEu5FrUCg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu Subject: [PULL 29/30] migration: Harden vmstate_size Date: Wed, 26 Aug 2026 11:29:04 -0300 Message-ID: <20260826142905.2315503-30-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.78 X-Spamd-Result: default: False [-2.78 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.18)[-0.906]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_TWO(0.00)[2]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email,suse.de:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754617223158500 Content-Type: text/plain; charset="utf-8" Protect vmstate_size against overflow of the on-stack 64bit integer during multiplication. The data at size_indirect.offset comes from the migration stream. Acked-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/vmstate.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 1d028bfe009..08548ae7a1f 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -113,14 +113,20 @@ static uint64_t vmstate_n_elems(void *opaque, const V= MStateField *field) return n_elems; } =20 -static uint64_t vmstate_size(void *opaque, const VMStateField *field) +static bool vmstate_size(void *opaque, const VMStateField *field, + uint64_t *sz, Error **errp) { uint64_t size; =20 + *sz =3D 0; + if (field->flags & VMS_VBUFFER) { size =3D vmstate_read_from_offset(&field->size_indirect, opaque); - if (field->flags & VMS_MULTIPLY) { - size *=3D field->size; + if ((field->flags & VMS_MULTIPLY) && + umul64_overflow(size, field->size, &size)) { + error_setg(errp, "%s: VMState field '%s' multiply overflow", + __func__, field->name); + return false; } } else if (field->flags & VMS_ARRAY_OF_POINTER) { /* @@ -132,7 +138,8 @@ static uint64_t vmstate_size(void *opaque, const VMStat= eField *field) size =3D field->size; } =20 - return size; + *sz =3D size; + return true; } =20 static bool vmstate_handle_alloc(void *ptr, const VMStateField *field, @@ -364,7 +371,11 @@ bool vmstate_load_vmsd(QEMUFile *f, const VMStateDescr= iption *vmsd, void *first_elem =3D opaque + field->offset; int i; uint64_t n_elems =3D vmstate_n_elems(opaque, field); - uint64_t size =3D vmstate_size(opaque, field); + uint64_t size; + + if (!vmstate_size(opaque, field, &size, errp)) { + return false; + } =20 if (!vmstate_handle_alloc(first_elem, field, n_elems, size, er= rp)) { return false; @@ -682,9 +693,10 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMS= tateDescription *vmsd, void *first_elem =3D opaque + field->offset; int i; uint64_t n_elems =3D vmstate_n_elems(opaque, field); - uint64_t size =3D vmstate_size(opaque, field); + uint64_t size; JSONWriter *vmdesc_loop =3D vmdesc; bool is_prev_null =3D false; + /* * When this is enabled, it means we will always push a ptr * marker first for each element saying if it's populated. @@ -692,6 +704,10 @@ static bool vmstate_save_vmsd_v(QEMUFile *f, const VMS= tateDescription *vmsd, bool use_dynamic_array =3D field->flags & VMS_ARRAY_OF_POINTER_AUTO_ALLOC; =20 + if (!vmstate_size(opaque, field, &size, errp)) { + return false; + } + trace_vmstate_save_state_loop(vmsd->name, field->name, n_elems= ); if (field->flags & VMS_POINTER) { first_elem =3D *(void **)first_elem; --=20 2.53.0 From nobody Sat Sep 26 23:03:39 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1787754716; cv=none; d=zohomail.com; s=zohoarc; b=OogQFRix3h2mmUVx/aJX3hINm8VJt5O0lkWesv0Bmp4uOjJWmVLqL+YeU0SLx2DjsKYfLpmedlWW8Yz1ZsETn7BtvAq9UcMJbHF0AveTjeUeAhy5Q7MjxB3RbBEtGclOiLwSOPWxapNONIZ1KBgdOXjNFN+94Q9VAZjKWyMn2/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1787754716; 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=Yogt7hp0asx6p9ZHQBFyYyBwc22IVXY4dpf+tsNP4gU=; b=VHDCUOpDqIMQpeBpbLWEDzuOc/5v3QRRewrq95Cf8u88Uv+nBjd1LFXXXUqJK1MVuW6OmZSV4RoTU9WNghtR9yQUv1dWe5Ji5Gnh01GWqh+tdOEABJoeHy132mdi6HBM4TcjCYbKENX+KXkySF3w1vrN9aLX0zQjBMQgliUI7S0= 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 1787754716069645.975933521565; Wed, 26 Aug 2026 07:31:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wzEdj-0001OC-99; Wed, 26 Aug 2026 10:30:09 -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 1wzEdb-0001Gd-2r for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:59 -0400 Received: from smtp-out2.suse.de ([195.135.223.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wzEdZ-0002Lw-Bf for qemu-devel@nongnu.org; Wed, 26 Aug 2026 10:29:58 -0400 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D8E331F822; Wed, 26 Aug 2026 14:29:47 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E8E8D13354; Wed, 26 Aug 2026 14:29:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id oAL9LVr4jmpTJAAAD6G6ig (envelope-from ); Wed, 26 Aug 2026 14:29:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754592; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yogt7hp0asx6p9ZHQBFyYyBwc22IVXY4dpf+tsNP4gU=; b=1EFuM8X0e2pazw+svAYKXcwX0uXoyWuq6xbUQ8oyVJ7+ndlz6JoN6lN7llJ/m0DhpZ011v zoR4Rtc/mMI177tmV2rb1KwLXNf3u/IkNpy49tXWRARUVn75X18VMeH1acGvz0PBH1gbKB oV57yosbpahl+tGL0a0P5wWpOD+89xU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754592; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yogt7hp0asx6p9ZHQBFyYyBwc22IVXY4dpf+tsNP4gU=; b=GmVicwK2uW03IwcThJ47nBs2yT2W2m9v9fuWR7unztvDZnMa8UgETCDESCxBdmVeRgEOXA 3v/jDKA5syZ+iuBA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=pBdakwEH; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=KyfYhy0T DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1787754587; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yogt7hp0asx6p9ZHQBFyYyBwc22IVXY4dpf+tsNP4gU=; b=pBdakwEHvDING+A3Y2Xcr5b0wDjzlg8ecSxQlTs2/2OxlsYlo/+ifv+a+BETBOZvhcrXCK zpjoH1zZ/7hzYXbUcPXUmwn270pJl5Zswk/nUY1NF1Ra+q3Psofy8I7m1itBpzTf3q7D9C oiP+d2H/bKTYta4Iv5sAcQwecFU/Wgs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1787754587; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Yogt7hp0asx6p9ZHQBFyYyBwc22IVXY4dpf+tsNP4gU=; b=KyfYhy0TgMvWSs7U/ShGeAoEzK6zEUGw0jJ3famusvzcXsx5F1r+E/PPqZU9IzkXip/uJY nWlJLn/ckEglM1DA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , hongmianquan Subject: [PULL 30/30] migration/postcopy: fix page_requested leak for vhost-user shared pages Date: Wed, 26 Aug 2026 11:29:05 -0300 Message-ID: <20260826142905.2315503-31-farosas@suse.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260826142905.2315503-1-farosas@suse.de> References: <20260826142905.2315503-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.989]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:email,suse.de:mid,suse.de:dkim,bytedance.com:email]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; URIBL_BLOCKED(0.00)[bytedance.com:email,suse.de:email,suse.de:mid,suse.de:dkim,imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Score: -3.01 X-Rspamd-Queue-Id: D8E331F822 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action 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=195.135.223.131; envelope-from=farosas@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_MED=-2.3, 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 @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1787754717975158501 Content-Type: text/plain; charset="utf-8" From: hongmianquan With postcopy-preempt enabled, a postcopy migration of a guest with a vhost-user device can hang at the very end on the destination, after all pages are transferred (query-migrate: status=3Dpostcopy-active, remaining= =3D0). Root cause is an add/del key mismatch on mis->page_requested: - add: a backend fault goes through postcopy_request_shared_page() -> postcopy_request_page() -> migrate_send_rp_req_pages(), which inserts the request and bumps page_requested_count keyed by client_addr. - del: qemu_ufd_copy_ioctl() removes the entry and drops the counter keyed by this QEMU process's host address for the page. client_addr is a VA in the external vhost-user backend's address space and never equals QEMU's host address, so the removal misses and the counter leaks. postcopy_ram_incoming_cleanup() then waits for it to reach zero forever, which also stalls the source (it waits for the return path). Racing threads: dst: postcopy_ram_listen_thread -> postcopy_ram_incoming_cleanup -> qemu_cond_wait_impl (waits for page_requested_count=3D= =3D0) (postcopy_preempt_thread already placed/woke the pages) src: migration_thread -> migration_completion -> await_return_path_close_on_source -> qemu_thread_join (source_return_path_thread blocked in recvmsg) The leak is only triggered when the vhost-user backend faults on a page that has not been received yet: only then does the request take the shared-fault slow path and register an entry in page_requested. If that page is subsequently delivered while the request is still outstanding, its entry is never removed. (Pages already present when the backend faults just take the wake path and never register.) So a run may leak only a few entries (9 of ~244k requests in our repro) yet still hang. Fix: key the request with the same host address the removal uses (rb->host + aligned_rbo) instead of client_addr. The backend wake still happens at placement time via postcopy_wake_shared(). Signed-off-by: hongmianquan Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/postcopy-ram.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 885ab58fca5..5509cbdcb8d 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1123,7 +1123,20 @@ int postcopy_request_shared_page(struct PostCopyFD *= pcfd, RAMBlock *rb, return postcopy_wake_shared(pcfd, client_addr, rb); } /* TODO: support blocktime tracking */ - postcopy_request_page(mis, rb, aligned_rbo, client_addr, 0); + + /* + * The page will be placed by qemu_ufd_copy_ioctl(), which removes the + * matching entry from mis->page_requested (and drops + * page_requested_count) using this QEMU process's host address for the + * page. Register the request with the same key, rb->host + aligned_rb= o, + * not client_addr: client_addr is a VA in the external vhost-user + * backend's address space and can never equal that host address, so t= he + * removal would miss forever, leaking page_requested_count and hanging + * postcopy teardown. + */ + postcopy_request_page(mis, rb, aligned_rbo, + (uint64_t)(uintptr_t)qemu_ram_get_host_addr(rb) + + aligned_rbo, 0); return 0; } =20 --=20 2.53.0