From nobody Thu Oct 31 22:46:55 2024 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=1708468996; cv=none; d=zohomail.com; s=zohoarc; b=TtNqwub2YPfMtcmetggdRoCG/z5CqKrmvQRQpoFMP1+mJEYAcdjVWkW0mVn1H/oKiISAks1R89UjZl2ArtwTfuuN4A++sU+nN/oaWq8vHKRUb1K1Oo+OZpqVO88wNsu2BX7znij67HYFEkLDilXXd8Bk++RNKIwiUg1p1EJtglo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708468996; 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=1Ns3e94wcRpZlpTXB3fv6AL/hNIEMQlKBtaRwo0ZgqA=; b=B3V3klCsS4NpKKXnlga2JiBwZ/beEv8oHZ92XgRVCfyrkaA4/nlAUcZyJUnC1oUnRp02XXKzFtnEy4RkS7uF69pfGYGVJsLFJK0GJMCLltm3ca1DydeLW4Uz7QJ1LO9l2FZIs8114BXXHYRDdI0mvgvJpzJk+kyymuq0pjrEDnY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708468996401368.99646893853856; Tue, 20 Feb 2024 14:43:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoC-0002rr-Iy; Tue, 20 Feb 2024 17:41:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYo9-0002pb-VY for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:50 -0500 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 1rcYo8-0006DJ-7Z for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:49 -0500 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 BC70D22266; Tue, 20 Feb 2024 22:41: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 28C8313AB8; Tue, 20 Feb 2024 22:41:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id qMYrOKYq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468904; 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=1Ns3e94wcRpZlpTXB3fv6AL/hNIEMQlKBtaRwo0ZgqA=; b=GSltDsXXx1NZht1uwC+n9CLb5wZ0Ya21WMNrZr/nyageGhYTZScQDdAEaR1sDeu9WFsreo kdLqFw9v6CpdF/s/C6UULPbHGS+Kh1O/mq3sXF7Kdj30c5CVZZ4hsQNBjphRGucP2wYxIM fTuYIwQdwk7c4kB8tG6mTAR6abeZqpA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468904; 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=1Ns3e94wcRpZlpTXB3fv6AL/hNIEMQlKBtaRwo0ZgqA=; b=C4dD6n7XeaWtbWaa7hlTdTH7/3E7HEVYogrd3AQSeGVGNcjZ7js1KZlJMHPXdHlHykK3xN 0cP/OjNxo5L2DQAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468904; 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=1Ns3e94wcRpZlpTXB3fv6AL/hNIEMQlKBtaRwo0ZgqA=; b=GSltDsXXx1NZht1uwC+n9CLb5wZ0Ya21WMNrZr/nyageGhYTZScQDdAEaR1sDeu9WFsreo kdLqFw9v6CpdF/s/C6UULPbHGS+Kh1O/mq3sXF7Kdj30c5CVZZ4hsQNBjphRGucP2wYxIM fTuYIwQdwk7c4kB8tG6mTAR6abeZqpA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468904; 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=1Ns3e94wcRpZlpTXB3fv6AL/hNIEMQlKBtaRwo0ZgqA=; b=C4dD6n7XeaWtbWaa7hlTdTH7/3E7HEVYogrd3AQSeGVGNcjZ7js1KZlJMHPXdHlHykK3xN 0cP/OjNxo5L2DQAQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 01/34] docs/devel/migration.rst: Document the file transport Date: Tue, 20 Feb 2024 19:41:05 -0300 Message-Id: <20240220224138.24759-2-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: +++ Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GSltDsXX; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=C4dD6n7X X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [3.43 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.06)[61.83%] X-Spam-Score: 3.43 X-Rspamd-Queue-Id: BC70D22266 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708468997811100001 Content-Type: text/plain; charset="utf-8" When adding the support for file migration with the file: transport, we missed adding documentation for it. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- docs/devel/migration/main.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 331252a92c..8024275d6d 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -41,6 +41,10 @@ over any transport. - exec migration: do the migration using the stdin/stdout through a proces= s. - fd migration: do the migration using a file descriptor that is passed to QEMU. QEMU doesn't care how this file descriptor is opened. +- file migration: do the migration using a file that is passed to QEMU + by path. A file offset option is supported to allow a management + application to add its own metadata to the start of the file without + QEMU interference. =20 In addition, support is included for migration using RDMA, which transports the page data using ``RDMA``, where the hardware takes care of --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469066; cv=none; d=zohomail.com; s=zohoarc; b=eipKPPXwk0jBIlJMG7xhyxBjUKiiylQjU24bxqG8s3NW7kSJHqV4nT2CPpDitaOGRhD78S4pzqMhwMi56w+hB1rUhOnh9bzS4tpLjFHZGYNrB8tk5RYFkV5W4VoXYEDayO8ythQpNmH1V8vCMr0Mc1AuBJw5iWjj/JbY4p+TeCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469066; 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=PrzKURAxvm43FxCx781Pl7eQTWzN+WJW/ce/zhVvRYI=; b=m5rh7YGT6bRBU6vUwY8jbGxE+Bm1AUdUl98vnwcKuYzIbujTF8NzgwhknhS7fUJqJtE6HEjILLPdcpvhuKsr+bmyOEv0O1IlacGkC2bG9pzxT3OR3qMFAFZDaABQEasYY2IC37tAOyrFPQFEjxUFppCZJNkI2pKTluF5hyCsv4U= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469066809979.3802182166396; Tue, 20 Feb 2024 14:44:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoG-0002t4-Bq; Tue, 20 Feb 2024 17:41:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoA-0002pt-Qx for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:51 -0500 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 1rcYo8-0006DS-PW for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:50 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 A25B92225A; Tue, 20 Feb 2024 22:41: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 380E3139D0; Tue, 20 Feb 2024 22:41:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id qPJQAKkq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468907; 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=PrzKURAxvm43FxCx781Pl7eQTWzN+WJW/ce/zhVvRYI=; b=lgJZuxrpux/pwSreO0YOKdIAWD349Gj4+w23coHzgFdXEuQhudSBcE4uh7lKvMxqu+1qz6 57TF626NtL77W2EuuIsv/Q5OUZfEO3/kOyIsoLCl15PyZwn3BHMWPF17QtBYfIMWSrenEF w6WfSA3rG4Hw1G5IaL9JbYhXOa5Wg7s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468907; 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=PrzKURAxvm43FxCx781Pl7eQTWzN+WJW/ce/zhVvRYI=; b=3o6SaXswq3KlIBCFQicbvIwCNL54v3WzZ64jd8eBkzATMCxG1iWJqxY4jx5tihcyCospg+ muzPp5lIgC3H8DAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468907; 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=PrzKURAxvm43FxCx781Pl7eQTWzN+WJW/ce/zhVvRYI=; b=lgJZuxrpux/pwSreO0YOKdIAWD349Gj4+w23coHzgFdXEuQhudSBcE4uh7lKvMxqu+1qz6 57TF626NtL77W2EuuIsv/Q5OUZfEO3/kOyIsoLCl15PyZwn3BHMWPF17QtBYfIMWSrenEF w6WfSA3rG4Hw1G5IaL9JbYhXOa5Wg7s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468907; 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=PrzKURAxvm43FxCx781Pl7eQTWzN+WJW/ce/zhVvRYI=; b=3o6SaXswq3KlIBCFQicbvIwCNL54v3WzZ64jd8eBkzATMCxG1iWJqxY4jx5tihcyCospg+ muzPp5lIgC3H8DAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 02/34] tests/qtest/migration: Rename fd_proto test Date: Tue, 20 Feb 2024 19:41:06 -0300 Message-Id: <20240220224138.24759-3-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 0.86 X-Spamd-Result: default: False [0.86 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.84)[99.31%] Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469068020100005 Content-Type: text/plain; charset="utf-8" Next patch adds another fd test. Rename the existing one closer to what's used on other tests, with the 'precopy' prefix. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- tests/qtest/migration-test.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 8a5bb1752e..b729ce4d22 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2423,7 +2423,7 @@ static void test_migrate_fd_finish_hook(QTestState *f= rom, qobject_unref(rsp); } =20 -static void test_migrate_fd_proto(void) +static void test_migrate_precopy_fd_socket(void) { MigrateCommon args =3D { .listen_uri =3D "defer", @@ -3527,7 +3527,8 @@ int main(int argc, char **argv) =20 /* migration_test_add("/migration/ignore_shared", test_ignore_shared);= */ #ifndef _WIN32 - migration_test_add("/migration/fd_proto", test_migrate_fd_proto); + migration_test_add("/migration/precopy/fd/tcp", + test_migrate_precopy_fd_socket); #endif migration_test_add("/migration/validate_uuid", test_validate_uuid); migration_test_add("/migration/validate_uuid_error", --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708468975; cv=none; d=zohomail.com; s=zohoarc; b=QJyu9B8v0LYc98hno9o4aq5xiMGCQWpio8xJefJiARcibme2OdY6rRudzkdzAt2ZQFOIWZPSZDX4Yo8Cbh+5ett6YVP80+Swq2jUqxkuAZUiZsd5Q8Moh+1PAQaBbdXE0hqJjKRolyNkm8WC9Zt2NHA95BMIZ1FYzsOCkDU61XY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708468975; 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=XlKPYQWsZs/9s2dBARpZuk+jHSmln4GQa0Pkc6kcwiQ=; b=DFJTB8v68NsIhzN5Np7oMsMRS88Bb67UKUQQGE0nbe83RlJPh5nn1iNUf7y5wv/3eYLCnm7WDmGC9c5aQk2N3JjYDxfmiHR9NnOa8+K/uwJiNcK7rkQ3Nsoljqi0RmjpS8uyFIlE7VYelSCovuAvsEFAYUkh1cV2woHL4a7JHQY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708468975333128.6367835057698; Tue, 20 Feb 2024 14:42:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoF-0002sg-74; Tue, 20 Feb 2024 17:41:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoD-0002sF-OE for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:53 -0500 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 1rcYoC-0006E9-0K for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:53 -0500 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 65E971FB40; Tue, 20 Feb 2024 22:41:50 +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 1DD13139D0; Tue, 20 Feb 2024 22:41:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id aIaBNasq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468910; 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=XlKPYQWsZs/9s2dBARpZuk+jHSmln4GQa0Pkc6kcwiQ=; b=Oan0w3eKm1WtDIe6mQUhdhKSpP9MVJGfTEIcJpvLd6FRr2WVsumnR6zai9sh+3nhTsWdsb gz65jehHGCZDys/QaTyVSpgWhYMIoJdyXJ9hTasQ0DG5L9ojPQEuxCAYJAL/yx++OMPxwT RKgUXDdDiZl+BT8rJ5DgJrldo88eWGM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468910; 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=XlKPYQWsZs/9s2dBARpZuk+jHSmln4GQa0Pkc6kcwiQ=; b=KOQOSyP78ELIzL7wJqGDBPgSaCwl6W79pFJHJjWTqczYCpJlGgtfoAMVPlPSlYIwMweUUe CmKZX7vdsK8xHfDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468910; 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=XlKPYQWsZs/9s2dBARpZuk+jHSmln4GQa0Pkc6kcwiQ=; b=Oan0w3eKm1WtDIe6mQUhdhKSpP9MVJGfTEIcJpvLd6FRr2WVsumnR6zai9sh+3nhTsWdsb gz65jehHGCZDys/QaTyVSpgWhYMIoJdyXJ9hTasQ0DG5L9ojPQEuxCAYJAL/yx++OMPxwT RKgUXDdDiZl+BT8rJ5DgJrldo88eWGM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468910; 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=XlKPYQWsZs/9s2dBARpZuk+jHSmln4GQa0Pkc6kcwiQ=; b=KOQOSyP78ELIzL7wJqGDBPgSaCwl6W79pFJHJjWTqczYCpJlGgtfoAMVPlPSlYIwMweUUe CmKZX7vdsK8xHfDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 03/34] tests/qtest/migration: Add a fd + file test Date: Tue, 20 Feb 2024 19:41:07 -0300 Message-Id: <20240220224138.24759-4-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: + Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Oan0w3eK; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=KOQOSyP7 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [1.03 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.46)[97.55%] X-Spam-Score: 1.03 X-Rspamd-Queue-Id: 65E971FB40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708468975701100001 Content-Type: text/plain; charset="utf-8" The fd URI supports an fd that is backed by a file. The code should select between QIOChannelFile and QIOChannelSocket, depending on the type of the fd. Add a test for that. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- tests/qtest/migration-test.c | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index b729ce4d22..83512bce85 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2433,6 +2433,45 @@ static void test_migrate_precopy_fd_socket(void) }; test_precopy_common(&args); } + +static void *migrate_precopy_fd_file_start(QTestState *from, QTestState *t= o) +{ + g_autofree char *file =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + int src_flags =3D O_CREAT | O_RDWR; + int dst_flags =3D O_CREAT | O_RDWR; + int fds[2]; + + fds[0] =3D open(file, src_flags, 0660); + assert(fds[0] !=3D -1); + + fds[1] =3D open(file, dst_flags, 0660); + assert(fds[1] !=3D -1); + + + qtest_qmp_fds_assert_success(to, &fds[0], 1, + "{ 'execute': 'getfd'," + " 'arguments': { 'fdname': 'fd-mig' }}"); + + qtest_qmp_fds_assert_success(from, &fds[1], 1, + "{ 'execute': 'getfd'," + " 'arguments': { 'fdname': 'fd-mig' }}"); + + close(fds[0]); + close(fds[1]); + + return NULL; +} + +static void test_migrate_precopy_fd_file(void) +{ + MigrateCommon args =3D { + .listen_uri =3D "defer", + .connect_uri =3D "fd:fd-mig", + .start_hook =3D migrate_precopy_fd_file_start, + .finish_hook =3D test_migrate_fd_finish_hook + }; + test_file_common(&args, true); +} #endif /* _WIN32 */ =20 static void do_test_validate_uuid(MigrateStart *args, bool should_fail) @@ -3529,6 +3568,8 @@ int main(int argc, char **argv) #ifndef _WIN32 migration_test_add("/migration/precopy/fd/tcp", test_migrate_precopy_fd_socket); + migration_test_add("/migration/precopy/fd/file", + test_migrate_precopy_fd_file); #endif migration_test_add("/migration/validate_uuid", test_validate_uuid); migration_test_add("/migration/validate_uuid_error", --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469001; cv=none; d=zohomail.com; s=zohoarc; b=d/RxM/DdOUplqE0jkB4Z947JdWcOGPkdLFvuFy5sVjiemmnNRFsL7hhKQnfyHRO0GUfeL+6qr7RQNymIKJ+LTodk6SNJgasw8eNdOLJfzSDGDnUeIzV4WCsEH7M58QLfWFYIb4RohacVaRleTMT9ggfO2lnMIPIMbE6aq9xVC08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469001; 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=4+c/ZVDOoCpTXIYlubE8aW4G10xvnHLJuXzfhzZwYOU=; b=XA6NgNsHtF+jBGBnuiQp8MueZYQfApnNdmwUe4olOgGqWF/doA9aBy5rMEloOrjXb9XLtZ50kuxlMkvdlR8waHK35k9IzdJvcu1vw0JUix9CAj1jmGPJHP9KVsQTycLska9TMEYn5oHOEE6DigMnwJABouZ4Kx/gevJ+INY5n94= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469001791995.7941202655915; Tue, 20 Feb 2024 14:43:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoI-0002tc-7w; Tue, 20 Feb 2024 17:41:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoG-0002t8-3x for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:56 -0500 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 1rcYoD-0006Fa-Vk for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:55 -0500 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 8004A1FD3E; Tue, 20 Feb 2024 22:41:52 +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 D4DAF139D0; Tue, 20 Feb 2024 22:41:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id iHKYJq4q1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468912; 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=4+c/ZVDOoCpTXIYlubE8aW4G10xvnHLJuXzfhzZwYOU=; b=0ZCsQ1gX/CBWpWl7arN84jPboBE3AM0vdDj9IvEBOzypMJxKjCPFNTJT2G5/YYU4H5DG4O xV/J347nERJb4Rz6d99tiEFGcL4kw5AFOcPTiOVTv/AjrGr+ofb3uSamNHFk4+UFUuDStG 3R/jIP26f0fPiQOgL4GhKiEdOkufbtk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468912; 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=4+c/ZVDOoCpTXIYlubE8aW4G10xvnHLJuXzfhzZwYOU=; b=Dgxy5Is1ynZ2E71SgpCyzNOcWYTPrSylElfXPTumT+7IFldEkxBtB1duF51aoJ+dzac+q9 gtJ6yEYlARdbkwDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468912; 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=4+c/ZVDOoCpTXIYlubE8aW4G10xvnHLJuXzfhzZwYOU=; b=0ZCsQ1gX/CBWpWl7arN84jPboBE3AM0vdDj9IvEBOzypMJxKjCPFNTJT2G5/YYU4H5DG4O xV/J347nERJb4Rz6d99tiEFGcL4kw5AFOcPTiOVTv/AjrGr+ofb3uSamNHFk4+UFUuDStG 3R/jIP26f0fPiQOgL4GhKiEdOkufbtk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468912; 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=4+c/ZVDOoCpTXIYlubE8aW4G10xvnHLJuXzfhzZwYOU=; b=Dgxy5Is1ynZ2E71SgpCyzNOcWYTPrSylElfXPTumT+7IFldEkxBtB1duF51aoJ+dzac+q9 gtJ6yEYlARdbkwDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 04/34] migration/multifd: Remove p->quit from recv side Date: Tue, 20 Feb 2024 19:41:08 -0300 Message-Id: <20240220224138.24759-5-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=0ZCsQ1gX; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=Dgxy5Is1 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 8004A1FD3E Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469003827100010 Content-Type: text/plain; charset="utf-8" Like we did on the sending side, replace the p->quit per-channel flag with a global atomic 'exiting' flag. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/multifd.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index adfe8c9a0a..fba00b9e8f 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -79,6 +79,19 @@ struct { MultiFDMethods *ops; } *multifd_send_state; =20 +struct { + MultiFDRecvParams *params; + /* number of created threads */ + int count; + /* syncs main thread and channels */ + QemuSemaphore sem_sync; + /* global number of generated multifd packets */ + uint64_t packet_num; + int exiting; + /* multifd ops */ + MultiFDMethods *ops; +} *multifd_recv_state; + /* Multifd without compression */ =20 /** @@ -440,6 +453,11 @@ static bool multifd_send_should_exit(void) return qatomic_read(&multifd_send_state->exiting); } =20 +static bool multifd_recv_should_exit(void) +{ + return qatomic_read(&multifd_recv_state->exiting); +} + /* * The migration thread can wait on either of the two semaphores. This * function can be used to kick the main thread out of waiting on either of @@ -1063,24 +1081,16 @@ bool multifd_send_setup(void) return true; } =20 -struct { - MultiFDRecvParams *params; - /* number of created threads */ - int count; - /* syncs main thread and channels */ - QemuSemaphore sem_sync; - /* global number of generated multifd packets */ - uint64_t packet_num; - /* multifd ops */ - MultiFDMethods *ops; -} *multifd_recv_state; - static void multifd_recv_terminate_threads(Error *err) { int i; =20 trace_multifd_recv_terminate_threads(err !=3D NULL); =20 + if (qatomic_xchg(&multifd_recv_state->exiting, 1)) { + return; + } + if (err) { MigrationState *s =3D migrate_get_current(); migrate_set_error(s, err); @@ -1094,8 +1104,6 @@ static void multifd_recv_terminate_threads(Error *err) for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 - qemu_mutex_lock(&p->mutex); - p->quit =3D true; /* * We could arrive here for two reasons: * - normal quit, i.e. everything went fine, just finished @@ -1105,7 +1113,6 @@ static void multifd_recv_terminate_threads(Error *err) if (p->c) { qio_channel_shutdown(p->c, QIO_CHANNEL_SHUTDOWN_BOTH, NULL); } - qemu_mutex_unlock(&p->mutex); } } =20 @@ -1210,7 +1217,7 @@ static void *multifd_recv_thread(void *opaque) while (true) { uint32_t flags; =20 - if (p->quit) { + if (multifd_recv_should_exit()) { break; } =20 @@ -1274,6 +1281,7 @@ int multifd_recv_setup(Error **errp) multifd_recv_state =3D g_malloc0(sizeof(*multifd_recv_state)); multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); qatomic_set(&multifd_recv_state->count, 0); + qatomic_set(&multifd_recv_state->exiting, 0); qemu_sem_init(&multifd_recv_state->sem_sync, 0); multifd_recv_state->ops =3D multifd_ops[migrate_multifd_compression()]; =20 @@ -1282,7 +1290,6 @@ int multifd_recv_setup(Error **errp) =20 qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem_sync, 0); - p->quit =3D false; p->id =3D i; p->packet_len =3D sizeof(MultiFDPacket_t) + sizeof(uint64_t) * page_count; --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469109; cv=none; d=zohomail.com; s=zohoarc; b=iOMaWbxYpFK87IopC+DovZjU2/3Lzmj6OD+4Yn0S0WdLvACE8wriSshRmc6xXHkMMtPWFKZhQ9QZ/aD0O9KOI34Hu0HZJpfph1JPMB9SsqhwxtIPbLQuhhoymIhT2CKRur2qAG+/3+8KD/iptGrGFPj7IfjzFh0TZleqtke3224= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469109; 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=ljNgan+cQwv4ebUy2rr4IU4JTiPzo1fDfB243/D86oE=; b=K7kQPl0QwRL4X8/vff/4WEjJBqmYWXjpCV5f7V9i/C48dKQAzkXrYdLjKzVdaJnUMFgz9UQHURApeQFwOqnX4XJltkUWbjFQjvdOJAQ+LvQHhGIeiYSB+NTCP42fTDn9Y+C4Jhw1buPb9S+aA3jF9kHhH9xDaT7p7KBYTaGNGXk= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469109326497.22894568352615; Tue, 20 Feb 2024 14:45:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoL-0002ze-PL; Tue, 20 Feb 2024 17:42:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoH-0002ta-CJ for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:58 -0500 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 1rcYoF-0006Hs-Tt for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:57 -0500 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 9419C22260; Tue, 20 Feb 2024 22:41:54 +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 E635A139D0; Tue, 20 Feb 2024 22:41:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id mGDIKrAq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:52 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468914; 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=ljNgan+cQwv4ebUy2rr4IU4JTiPzo1fDfB243/D86oE=; b=aEiOm1l5+mZh3xkcUOYLWGJen/+RNtNKu14CuenE33lYRyRUC6gMF2BL9RrGGnbub5A8yb 8IMpXtIQ7YNQZTOloFymsLRqkz+MzTuQFLXXCWBzK1buJcAwX1j9d/5XXgUyc3gNcUiYmp qFTM7lSw0VKl0mcUDEdxSCbjEI+zpyk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468914; 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=ljNgan+cQwv4ebUy2rr4IU4JTiPzo1fDfB243/D86oE=; b=CTUAPOuXkZ06d/8AQpIgHQPwSjGPuVzjaHlana/2KCdExBHJ79Y8Bpv0w24+YBTpGoOjVj m+6TQA5isxLgv1Aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468914; 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=ljNgan+cQwv4ebUy2rr4IU4JTiPzo1fDfB243/D86oE=; b=aEiOm1l5+mZh3xkcUOYLWGJen/+RNtNKu14CuenE33lYRyRUC6gMF2BL9RrGGnbub5A8yb 8IMpXtIQ7YNQZTOloFymsLRqkz+MzTuQFLXXCWBzK1buJcAwX1j9d/5XXgUyc3gNcUiYmp qFTM7lSw0VKl0mcUDEdxSCbjEI+zpyk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468914; 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=ljNgan+cQwv4ebUy2rr4IU4JTiPzo1fDfB243/D86oE=; b=CTUAPOuXkZ06d/8AQpIgHQPwSjGPuVzjaHlana/2KCdExBHJ79Y8Bpv0w24+YBTpGoOjVj m+6TQA5isxLgv1Aw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 05/34] migration/multifd: Release recv sem_sync earlier Date: Tue, 20 Feb 2024 19:41:09 -0300 Message-Id: <20240220224138.24759-6-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=aEiOm1l5; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=CTUAPOuX X-Spamd-Result: default: False [1.80 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.89)[99.54%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 1.80 X-Rspamd-Queue-Id: 9419C22260 X-Spamd-Bar: + Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469110142100001 Content-Type: text/plain; charset="utf-8" Now that multifd_recv_terminate_threads() is called only once, release the recv side sem_sync earlier like we do for the send side. Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- migration/multifd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index fba00b9e8f..43f0820996 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1104,6 +1104,12 @@ static void multifd_recv_terminate_threads(Error *er= r) for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 + /* + * multifd_recv_thread may hung at MULTIFD_FLAG_SYNC handle code, + * however try to wakeup it without harm in cleanup phase. + */ + qemu_sem_post(&p->sem_sync); + /* * We could arrive here for two reasons: * - normal quit, i.e. everything went fine, just finished @@ -1162,12 +1168,6 @@ void multifd_recv_cleanup(void) for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 - /* - * multifd_recv_thread may hung at MULTIFD_FLAG_SYNC handle code, - * however try to wakeup it without harm in cleanup phase. - */ - qemu_sem_post(&p->sem_sync); - if (p->thread_created) { qemu_thread_join(&p->thread); } --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469041; cv=none; d=zohomail.com; s=zohoarc; b=Ys/v0UNPPKr83esasmowhlCAMB1k4taaSpQuZMc3p98flfkfK4Wa/SkPnqEp3UkSx+vusvWF5sdA6KRwurYqSKZ1vw4SNa22XV48EHsF6/l6yOQsEOnj4Z7aeck50fcf2XW2AwwRDwE3j6H09KJ1v1eWpNM2hHyiUUEQwYPBjsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469041; h=Content-Type: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=qW5yUdTr0mwoltf/iGxZA8snBm043jlfeIZ97rn2OKk=; b=E266YmRrCwzN4wVccgstPfECWlcLYR5xnyVM7pDf/3Qt9gYvtSP/KOro9hh3k6V4UIPcpuy2YukfcrIejoWE3bSimtJQDDVSPFz9Eq+LUaR9yQjcWGe6EaDj4foLTy1LGCZSe46eBJD50cMKnmGda8HnzxdPbPaFxt8AsQSez8g= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469041887575.4702585796628; Tue, 20 Feb 2024 14:44:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoP-00036X-F5; Tue, 20 Feb 2024 17:42:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoK-0002z2-5S for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:00 -0500 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 1rcYoI-0006JH-I3 for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:41:59 -0500 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 D48CD2225A; Tue, 20 Feb 2024 22:41:56 +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 07F34139D0; Tue, 20 Feb 2024 22:41:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id EEgTMLIq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qW5yUdTr0mwoltf/iGxZA8snBm043jlfeIZ97rn2OKk=; b=nWu3/x/PuZo31hdN+4omtKtMnXY6deMInJXs5AUFA8Udj5OzNiGuEBKbh1TF0E5hmpM+98 sfxQfbAeRI6TeckfRRg9JU+eBsNWMmLQa0KmGN6AiGuINCJgwpOwRDXtG6PF7qUg47/Yzi BCL2CCZdmAA40jSeGV+wr4rwoZk+zfw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468917; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qW5yUdTr0mwoltf/iGxZA8snBm043jlfeIZ97rn2OKk=; b=OTHGo48D7b78k0iQ0BUBaTTJZeTPRWQqe/h1eP7LinSA6VC+CsHIljaTy+BRlqT4y2z9H2 9uHJgIgEYDXnc/CA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468916; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qW5yUdTr0mwoltf/iGxZA8snBm043jlfeIZ97rn2OKk=; b=ZuNkI9bkCCl5nVWCQrIgNNtKTw3uRMz20tYYoD7BmYkbv6vEPICCmgTg9sRGEkNuq6UTyN gtWguCAI8QYqyjws14DGLgXSa4ktQGGbqboR3+17TMJdEAsXiZEIo+uOpNTILocKNznW0b t888RdAuB/E/VdiN9CTaWWcPpHcgAco= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468916; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qW5yUdTr0mwoltf/iGxZA8snBm043jlfeIZ97rn2OKk=; b=+UznWy41uJdfX14KFZ6y09GUnCdfM3VRoLTTlHGRlEAXlQodkZFt3gzcfPflNkumK3McSc Bwf6CQOouElR0qDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Nikolay Borisov Subject: [PATCH v4 06/34] io: add and implement QIO_CHANNEL_FEATURE_SEEKABLE for channel file Date: Tue, 20 Feb 2024 19:41:10 -0300 Message-Id: <20240220224138.24759-7-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ZuNkI9bk; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+UznWy41 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.25 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.74)[98.87%] X-Spam-Score: -3.25 X-Rspamd-Queue-Id: D48CD2225A Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1708469043995100003 From: Nikolay Borisov Add a generic QIOChannel feature SEEKABLE which would be used by the qemu_file* apis. For the time being this will be only implemented for file channels. Signed-off-by: Nikolay Borisov Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/io/channel.h | 1 + io/channel-file.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/io/channel.h b/include/io/channel.h index 5f9dbaab65..fcb19fd672 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -44,6 +44,7 @@ enum QIOChannelFeature { QIO_CHANNEL_FEATURE_LISTEN, QIO_CHANNEL_FEATURE_WRITE_ZERO_COPY, QIO_CHANNEL_FEATURE_READ_MSG_PEEK, + QIO_CHANNEL_FEATURE_SEEKABLE, }; =20 =20 diff --git a/io/channel-file.c b/io/channel-file.c index 4a12c61886..f91bf6db1c 100644 --- a/io/channel-file.c +++ b/io/channel-file.c @@ -36,6 +36,10 @@ qio_channel_file_new_fd(int fd) =20 ioc->fd =3D fd; =20 + if (lseek(fd, 0, SEEK_CUR) !=3D (off_t)-1) { + qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_SEEK= ABLE); + } + trace_qio_channel_file_new_fd(ioc, fd); =20 return ioc; @@ -60,6 +64,10 @@ qio_channel_file_new_path(const char *path, return NULL; } =20 + if (lseek(ioc->fd, 0, SEEK_CUR) !=3D (off_t)-1) { + qio_channel_set_feature(QIO_CHANNEL(ioc), QIO_CHANNEL_FEATURE_SEEK= ABLE); + } + trace_qio_channel_file_new_path(ioc, path, flags, mode, ioc->fd); =20 return ioc; --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469055; cv=none; d=zohomail.com; s=zohoarc; b=melW0xXL6iB0kqhSzLLDDim3bbXfvdKx75HIptajwgw44TKA7K/QsKGBmXVFvhdz7XweZLzpTe92Gsq0njKw1qCU9otdz+yxBMeNWpQm83RdjVDL70FFG+TsPXNsVSoobGhnvRtwKm9mOMvXxHAEo+LiirAyLzncVgAx8Bzvvks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469055; h=Content-Type: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=M8ETURXN4D66D0HrOGgTSooAccnh4vOt0f/y/PDYZ9Q=; b=WBHigpHgvx0hwSwPHwOHEzmoZdZ4BwOMjzd7iltn+EcP7WncnLShPIYsuhv/7a4/E5SmAadqTRkxmzUnLpnpW70a0e23KGh5pmshEpi80m5Z+8xBr680d1fpjllpblZqlBoivawVBsiBGKDOeAsG3cm11hOBI7JtiimJfCN0Gm4= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469055034553.7461493556832; Tue, 20 Feb 2024 14:44:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoV-0003BH-G8; Tue, 20 Feb 2024 17:42:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoM-00033V-9q for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:02 -0500 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 1rcYoK-0006Jz-Fx for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:02 -0500 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 2AD0622260; Tue, 20 Feb 2024 22:41:59 +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 53937139D0; Tue, 20 Feb 2024 22:41:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id INv9BrUq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M8ETURXN4D66D0HrOGgTSooAccnh4vOt0f/y/PDYZ9Q=; b=GqoGqajP0rsr0wHxU6KRCTqedFBj5HT+idQNmE2RyaJIpjwTEVKmJ5s8eNzp+qrK7ukP2M lFY4oA8HGZmFMwXp+rN2/FckuKKMfv+JaHJI+mdJYKdyAfp2Topnkj3dgIjhx78IJF9Gbs QPxwOGrd8Taqfdl3CxF42ys0vlMCJJc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M8ETURXN4D66D0HrOGgTSooAccnh4vOt0f/y/PDYZ9Q=; b=mGr17hZPRwP8dlkELO3/1xnyipTzMAX9JWjEh2+tAV9XB/Q0MVcEUFtjRkegpG0MBam8+5 SPI4RbaphUKxjdCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M8ETURXN4D66D0HrOGgTSooAccnh4vOt0f/y/PDYZ9Q=; b=GqoGqajP0rsr0wHxU6KRCTqedFBj5HT+idQNmE2RyaJIpjwTEVKmJ5s8eNzp+qrK7ukP2M lFY4oA8HGZmFMwXp+rN2/FckuKKMfv+JaHJI+mdJYKdyAfp2Topnkj3dgIjhx78IJF9Gbs QPxwOGrd8Taqfdl3CxF42ys0vlMCJJc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468919; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M8ETURXN4D66D0HrOGgTSooAccnh4vOt0f/y/PDYZ9Q=; b=mGr17hZPRwP8dlkELO3/1xnyipTzMAX9JWjEh2+tAV9XB/Q0MVcEUFtjRkegpG0MBam8+5 SPI4RbaphUKxjdCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Nikolay Borisov Subject: [PATCH v4 07/34] io: Add generic pwritev/preadv interface Date: Tue, 20 Feb 2024 19:41:11 -0300 Message-Id: <20240220224138.24759-8-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=GqoGqajP; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=mGr17hZP X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.51 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: -3.51 X-Rspamd-Queue-Id: 2AD0622260 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469055993100001 From: Nikolay Borisov Introduce basic pwritev/preadv support in the generic channel layer. Specific implementation will follow for the file channel as this is required in order to support migration streams with fixed location of each ram page. Signed-off-by: Nikolay Borisov Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- include/io/channel.h | 82 ++++++++++++++++++++++++++++++++++++++++++++ io/channel.c | 58 +++++++++++++++++++++++++++++++ 2 files changed, 140 insertions(+) diff --git a/include/io/channel.h b/include/io/channel.h index fcb19fd672..7986c49c71 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -131,6 +131,16 @@ struct QIOChannelClass { Error **errp); =20 /* Optional callbacks */ + ssize_t (*io_pwritev)(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp); + ssize_t (*io_preadv)(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp); int (*io_shutdown)(QIOChannel *ioc, QIOChannelShutdown how, Error **errp); @@ -529,6 +539,78 @@ void qio_channel_set_follow_coroutine_ctx(QIOChannel *= ioc, bool enabled); int qio_channel_close(QIOChannel *ioc, Error **errp); =20 +/** + * qio_channel_pwritev + * @ioc: the channel object + * @iov: the array of memory regions to write data from + * @niov: the length of the @iov array + * @offset: offset in the channel where writes should begin + * @errp: pointer to a NULL-initialized error object + * + * Not all implementations will support this facility, so may report + * an error. To avoid errors, the caller may check for the feature + * flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method. + * + * Behaves as qio_channel_writev_full, apart from not supporting + * sending of file handles as well as beginning the write at the + * passed @offset + * + */ +ssize_t qio_channel_pwritev(QIOChannel *ioc, const struct iovec *iov, + size_t niov, off_t offset, Error **errp); + +/** + * qio_channel_pwrite + * @ioc: the channel object + * @buf: the memory region to write data into + * @buflen: the number of bytes to @buf + * @offset: offset in the channel where writes should begin + * @errp: pointer to a NULL-initialized error object + * + * Not all implementations will support this facility, so may report + * an error. To avoid errors, the caller may check for the feature + * flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method. + * + */ +ssize_t qio_channel_pwrite(QIOChannel *ioc, char *buf, size_t buflen, + off_t offset, Error **errp); + +/** + * qio_channel_preadv + * @ioc: the channel object + * @iov: the array of memory regions to read data into + * @niov: the length of the @iov array + * @offset: offset in the channel where writes should begin + * @errp: pointer to a NULL-initialized error object + * + * Not all implementations will support this facility, so may report + * an error. To avoid errors, the caller may check for the feature + * flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method. + * + * Behaves as qio_channel_readv_full, apart from not supporting + * receiving of file handles as well as beginning the read at the + * passed @offset + * + */ +ssize_t qio_channel_preadv(QIOChannel *ioc, const struct iovec *iov, + size_t niov, off_t offset, Error **errp); + +/** + * qio_channel_pread + * @ioc: the channel object + * @buf: the memory region to write data into + * @buflen: the number of bytes to @buf + * @offset: offset in the channel where writes should begin + * @errp: pointer to a NULL-initialized error object + * + * Not all implementations will support this facility, so may report + * an error. To avoid errors, the caller may check for the feature + * flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method. + * + */ +ssize_t qio_channel_pread(QIOChannel *ioc, char *buf, size_t buflen, + off_t offset, Error **errp); + /** * qio_channel_shutdown: * @ioc: the channel object diff --git a/io/channel.c b/io/channel.c index 86c5834510..a1f12f8e90 100644 --- a/io/channel.c +++ b/io/channel.c @@ -454,6 +454,64 @@ GSource *qio_channel_add_watch_source(QIOChannel *ioc, } =20 =20 +ssize_t qio_channel_pwritev(QIOChannel *ioc, const struct iovec *iov, + size_t niov, off_t offset, Error **errp) +{ + QIOChannelClass *klass =3D QIO_CHANNEL_GET_CLASS(ioc); + + if (!klass->io_pwritev) { + error_setg(errp, "Channel does not support pwritev"); + return -1; + } + + if (!qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_SEEKABLE)) { + error_setg_errno(errp, EINVAL, "Requested channel is not seekable"= ); + return -1; + } + + return klass->io_pwritev(ioc, iov, niov, offset, errp); +} + +ssize_t qio_channel_pwrite(QIOChannel *ioc, char *buf, size_t buflen, + off_t offset, Error **errp) +{ + struct iovec iov =3D { + .iov_base =3D buf, + .iov_len =3D buflen + }; + + return qio_channel_pwritev(ioc, &iov, 1, offset, errp); +} + +ssize_t qio_channel_preadv(QIOChannel *ioc, const struct iovec *iov, + size_t niov, off_t offset, Error **errp) +{ + QIOChannelClass *klass =3D QIO_CHANNEL_GET_CLASS(ioc); + + if (!klass->io_preadv) { + error_setg(errp, "Channel does not support preadv"); + return -1; + } + + if (!qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_SEEKABLE)) { + error_setg_errno(errp, EINVAL, "Requested channel is not seekable"= ); + return -1; + } + + return klass->io_preadv(ioc, iov, niov, offset, errp); +} + +ssize_t qio_channel_pread(QIOChannel *ioc, char *buf, size_t buflen, + off_t offset, Error **errp) +{ + struct iovec iov =3D { + .iov_base =3D buf, + .iov_len =3D buflen + }; + + return qio_channel_preadv(ioc, &iov, 1, offset, errp); +} + int qio_channel_shutdown(QIOChannel *ioc, QIOChannelShutdown how, Error **errp) --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469096; cv=none; d=zohomail.com; s=zohoarc; b=lqlshiDnHJfqkumOqwIlc2IkzKsn/M1isL3QbA5vnh1FU7mFWc2d24KVmHg8UUN4cNzPAFZNREqi5VLwTqf7MdJMzzu/tS0ieiy9qeZ43Y/YfS/1N4WzZLbVia6GiATh9j6B70x2hj0KEIGWL2fQPcOHka+EXtT3z1VXRn3hCUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469096; h=Content-Type: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=lPACBFbu+mEdE4yRrCKi6tDvBD3TRxs7CrJgni1wwhU=; b=WA7Hg1cJv7ucDfJhHx/oAc7EopO/58hrhHx1/kx9fMrsu+xJ6Wsg7uvdJyQBfOxGI+v5Ah19T2lYoedEDJ3a2HBAkkufhKpgq5sZ1iV2jw54ju2sE0kGm1VSCiBN+CYUFNbu+NnGDhvF8M7bumwoa4rdw6krO5/+ubNW4b6h8UQ= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469096312963.5053040266477; Tue, 20 Feb 2024 14:44:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoW-0003Fn-Gd; Tue, 20 Feb 2024 17:42:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoO-000390-Bt for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:05 -0500 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 1rcYoM-0006KB-ST for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:04 -0500 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 731FA1FB53; Tue, 20 Feb 2024 22:42:01 +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 9CBA5139D0; Tue, 20 Feb 2024 22:41:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id cGpxGLcq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:41:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lPACBFbu+mEdE4yRrCKi6tDvBD3TRxs7CrJgni1wwhU=; b=jyMz/QepDfkdfkMO20qifKZWI2pmoQz37I5/ooZnsorDkreKrJ6yjQqxZwrgwHWrHAV8rp 2sUgkRgdzlsJjzFN/Lt2zolaoXtLl8WqXG0DsFx7UWAoHZ5Cut8om+h7SdkwQqaMmc+/Oo WTis3Uxvyq7fMhpOJ3O62qtCAnW5pow= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lPACBFbu+mEdE4yRrCKi6tDvBD3TRxs7CrJgni1wwhU=; b=HZ4wgERp0a6Jj5lbEawy3zWKTGA8EUpVCqJuxWmcnIqysEx5m72DtjmSyIVpbwzCZjGVLI LE1NLgR74CSP2jCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lPACBFbu+mEdE4yRrCKi6tDvBD3TRxs7CrJgni1wwhU=; b=jyMz/QepDfkdfkMO20qifKZWI2pmoQz37I5/ooZnsorDkreKrJ6yjQqxZwrgwHWrHAV8rp 2sUgkRgdzlsJjzFN/Lt2zolaoXtLl8WqXG0DsFx7UWAoHZ5Cut8om+h7SdkwQqaMmc+/Oo WTis3Uxvyq7fMhpOJ3O62qtCAnW5pow= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468921; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lPACBFbu+mEdE4yRrCKi6tDvBD3TRxs7CrJgni1wwhU=; b=HZ4wgERp0a6Jj5lbEawy3zWKTGA8EUpVCqJuxWmcnIqysEx5m72DtjmSyIVpbwzCZjGVLI LE1NLgR74CSP2jCQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Nikolay Borisov Subject: [PATCH v4 08/34] io: implement io_pwritev/preadv for QIOChannelFile Date: Tue, 20 Feb 2024 19:41:12 -0300 Message-Id: <20240220224138.24759-9-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="jyMz/Qep"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=HZ4wgERp X-Spamd-Result: default: False [-1.98 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.67)[98.56%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 731FA1FB53 X-Spam-Score: -1.98 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469098068100003 From: Nikolay Borisov The upcoming 'fixed-ram' feature will require qemu to write data to (and restore from) specific offsets of the migration file. Add a minimal implementation of pwritev/preadv and expose them via the io_pwritev and io_preadv interfaces. Signed-off-by: Nikolay Borisov Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- io/channel-file.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/io/channel-file.c b/io/channel-file.c index f91bf6db1c..a6ad7770c6 100644 --- a/io/channel-file.c +++ b/io/channel-file.c @@ -146,6 +146,58 @@ static ssize_t qio_channel_file_writev(QIOChannel *ioc, return ret; } =20 +#ifdef CONFIG_PREADV +static ssize_t qio_channel_file_preadv(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp) +{ + QIOChannelFile *fioc =3D QIO_CHANNEL_FILE(ioc); + ssize_t ret; + + retry: + ret =3D preadv(fioc->fd, iov, niov, offset); + if (ret < 0) { + if (errno =3D=3D EAGAIN) { + return QIO_CHANNEL_ERR_BLOCK; + } + if (errno =3D=3D EINTR) { + goto retry; + } + + error_setg_errno(errp, errno, "Unable to read from file"); + return -1; + } + + return ret; +} + +static ssize_t qio_channel_file_pwritev(QIOChannel *ioc, + const struct iovec *iov, + size_t niov, + off_t offset, + Error **errp) +{ + QIOChannelFile *fioc =3D QIO_CHANNEL_FILE(ioc); + ssize_t ret; + + retry: + ret =3D pwritev(fioc->fd, iov, niov, offset); + if (ret <=3D 0) { + if (errno =3D=3D EAGAIN) { + return QIO_CHANNEL_ERR_BLOCK; + } + if (errno =3D=3D EINTR) { + goto retry; + } + error_setg_errno(errp, errno, "Unable to write to file"); + return -1; + } + return ret; +} +#endif /* CONFIG_PREADV */ + static int qio_channel_file_set_blocking(QIOChannel *ioc, bool enabled, Error **errp) @@ -231,6 +283,10 @@ static void qio_channel_file_class_init(ObjectClass *k= lass, ioc_klass->io_writev =3D qio_channel_file_writev; ioc_klass->io_readv =3D qio_channel_file_readv; ioc_klass->io_set_blocking =3D qio_channel_file_set_blocking; +#ifdef CONFIG_PREADV + ioc_klass->io_pwritev =3D qio_channel_file_pwritev; + ioc_klass->io_preadv =3D qio_channel_file_preadv; +#endif ioc_klass->io_seek =3D qio_channel_file_seek; ioc_klass->io_close =3D qio_channel_file_close; ioc_klass->io_create_watch =3D qio_channel_file_create_watch; --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469185; cv=none; d=zohomail.com; s=zohoarc; b=MZ5cpAziaHTnIlYVM0i3Cr5GgeLbxaA3lTLQ9H4PbP/BOXuWjDypVkET9zF+df4me4/VdMV3sVlZTZwCLbBfMOYMPFIy1i5Gsl+AQDOmyWfgy7MMQluXy4CM2FF+SW4dOF7+acCsqRZl0TctVfs6jkMbhk0usc5pECY3db7pEVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469185; h=Content-Type: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=XYDo3cJ7Gj35k+6IouB+z3ra8IA1Tj4jwzWBGYzRy/A=; b=mFlh6MNaS8jYqlYFZ/bMvWSEAG/LhvhAKiTjONek5Dqhr3rtvAmCsFTiVUgftUgL7L8dFRLgiz/7ypKvMMr6IqF+pg90s4NflnZziUomErioEJWEoV/7J+ME8BaQoR9D1yiaQLCup0m1c9YTX4AlxJyOZelNNolJLpL5jv04QwI= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469185174447.61645688138776; Tue, 20 Feb 2024 14:46:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoX-0003GC-7J; Tue, 20 Feb 2024 17:42:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoQ-0003A2-GS for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:07 -0500 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 1rcYoP-0006KM-3Z for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:06 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 8227A2225A; Tue, 20 Feb 2024 22:42:03 +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 E4456139D0; Tue, 20 Feb 2024 22:42:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id oGIFKrkq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468923; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XYDo3cJ7Gj35k+6IouB+z3ra8IA1Tj4jwzWBGYzRy/A=; b=vwbN/x2zz8xV/62gORQQEgCeRlPqR6/D7LNkrBdik+RlYbfjKNtzjVK5if+Hr3/1YeMXbE C+VjHh4O7Im5pyvKCN+FRyoL6QDFgxjFvIeSE8IWMHg+PNwE+OGtB1ZPzM4Vlvix44WgHr nNQ5Mmb9VSmMaiRD72x3X9tpPAtJl84= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468923; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XYDo3cJ7Gj35k+6IouB+z3ra8IA1Tj4jwzWBGYzRy/A=; b=G8TjkpODQjCmT8eAg9fErpxxsKhgoZ3npJsAxv19RIBhH51YEkxYz/DE6pT42yJm4PWkM7 N5vSgAJ/WycBxNBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468923; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XYDo3cJ7Gj35k+6IouB+z3ra8IA1Tj4jwzWBGYzRy/A=; b=vwbN/x2zz8xV/62gORQQEgCeRlPqR6/D7LNkrBdik+RlYbfjKNtzjVK5if+Hr3/1YeMXbE C+VjHh4O7Im5pyvKCN+FRyoL6QDFgxjFvIeSE8IWMHg+PNwE+OGtB1ZPzM4Vlvix44WgHr nNQ5Mmb9VSmMaiRD72x3X9tpPAtJl84= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468923; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XYDo3cJ7Gj35k+6IouB+z3ra8IA1Tj4jwzWBGYzRy/A=; b=G8TjkpODQjCmT8eAg9fErpxxsKhgoZ3npJsAxv19RIBhH51YEkxYz/DE6pT42yJm4PWkM7 N5vSgAJ/WycBxNBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 09/34] io: fsync before closing a file channel Date: Tue, 20 Feb 2024 19:41:13 -0300 Message-Id: <20240220224138.24759-10-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: -1.73 X-Spamd-Result: default: False [-1.73 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-1.43)[91.18%] Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469186331100003 Make sure the data is flushed to disk before closing file channels. This is to ensure data is on disk and not lost in the event of a host crash. This is currently being implemented to affect the migration code when migrating to a file, but all QIOChannelFile users should benefit from the change. Reviewed-by: Daniel P. Berrang=C3=A9 Acked-by: Daniel P. Berrang=C3=A9 Signed-off-by: Fabiano Rosas --- - improved commit message --- io/channel-file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/io/channel-file.c b/io/channel-file.c index a6ad7770c6..d4706fa592 100644 --- a/io/channel-file.c +++ b/io/channel-file.c @@ -242,6 +242,11 @@ static int qio_channel_file_close(QIOChannel *ioc, { QIOChannelFile *fioc =3D QIO_CHANNEL_FILE(ioc); =20 + if (qemu_fdatasync(fioc->fd) < 0) { + error_setg_errno(errp, errno, + "Unable to synchronize file data with storage dev= ice"); + return -1; + } if (qemu_close(fioc->fd) < 0) { error_setg_errno(errp, errno, "Unable to close file"); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469113; cv=none; d=zohomail.com; s=zohoarc; b=L5cvWGhf0JN6ULRs/YAs10pXch9RAf0rM6R6Q+ffGLRBxzVXtWHi6mJAMa5V+zWuRfMCC+V8YLbjYsjiv2m8c+FNxmhMaYFA303UYvUhNQ5XxHzL9kQRcHrMa/SAuEHrZwQncpuVJrnJm41BGXQp372iUF2DNptnZzi9Ux7JAyw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469113; h=Content-Type: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=7SO+bxJtiGsvDF/g59UKVu7ECe/ndyMpnLx6uJ7EF0c=; b=nuXcwn39Pwn9oDolo+sYQPXGK71auf9c2GBVDX2LAsGUkijxdskT0ytJBuWozxcgi3oFaMeaUGapjKtxJDX5b+eol2y6UlBx1dp0c05pgQKUC0rYLjxGEdiR6LQK3LF3R/An3xCdB/BhWrN+6gg6yhpD0cgYhLqo0/2C3giy/NY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469113883888.9452250066993; Tue, 20 Feb 2024 14:45:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoW-0003G4-Uy; Tue, 20 Feb 2024 17:42:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoS-0003BJ-Ja for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:09 -0500 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 1rcYoQ-0006Ka-Se for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:08 -0500 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 97C0122260; Tue, 20 Feb 2024 22:42:05 +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 02A5E139D0; Tue, 20 Feb 2024 22:42:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id AFTSLrsq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468925; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7SO+bxJtiGsvDF/g59UKVu7ECe/ndyMpnLx6uJ7EF0c=; b=Sc+LfWtFtalcwcBWWs/DurYzmBRinTEvgR3tBzQbRiJOPji2ZdYCOAq60BWy8QMSgyPyXJ tesf3Pi3N53Fx/yaIE2KD08uI0zEt1sktX+k+ctjZPeq7OCab8i4DWnj+gCluS6MNBwwoo WHYCv8i8QWSwKa1CF0IKL0Y7m+ghjmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468925; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7SO+bxJtiGsvDF/g59UKVu7ECe/ndyMpnLx6uJ7EF0c=; b=gtCzvQDpckoHMTF8Ey2WHJ02shTjl1VFyEcYPPOWbr8spb5BX7XbFeI47rKrsbZQCK5gNx tJKru0ZSOc8rxVCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468925; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7SO+bxJtiGsvDF/g59UKVu7ECe/ndyMpnLx6uJ7EF0c=; b=Sc+LfWtFtalcwcBWWs/DurYzmBRinTEvgR3tBzQbRiJOPji2ZdYCOAq60BWy8QMSgyPyXJ tesf3Pi3N53Fx/yaIE2KD08uI0zEt1sktX+k+ctjZPeq7OCab8i4DWnj+gCluS6MNBwwoo WHYCv8i8QWSwKa1CF0IKL0Y7m+ghjmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468925; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7SO+bxJtiGsvDF/g59UKVu7ECe/ndyMpnLx6uJ7EF0c=; b=gtCzvQDpckoHMTF8Ey2WHJ02shTjl1VFyEcYPPOWbr8spb5BX7XbFeI47rKrsbZQCK5gNx tJKru0ZSOc8rxVCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 10/34] migration/qemu-file: add utility methods for working with seekable channels Date: Tue, 20 Feb 2024 19:41:14 -0300 Message-Id: <20240220224138.24759-11-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=Sc+LfWtF; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=gtCzvQDp X-Spamd-Result: default: False [-2.31 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 97C0122260 X-Spam-Score: -2.31 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469114191100001 Add utility methods that will be needed when implementing 'fixed-ram' migration capability. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 --- - handling EAGAIN and partial reads/writes - removed the list of functions from the commit message --- include/migration/qemu-file-types.h | 2 + migration/qemu-file.c | 106 ++++++++++++++++++++++++++++ migration/qemu-file.h | 6 ++ 3 files changed, 114 insertions(+) diff --git a/include/migration/qemu-file-types.h b/include/migration/qemu-f= ile-types.h index 9ba163f333..adec5abc07 100644 --- a/include/migration/qemu-file-types.h +++ b/include/migration/qemu-file-types.h @@ -50,6 +50,8 @@ unsigned int qemu_get_be16(QEMUFile *f); unsigned int qemu_get_be32(QEMUFile *f); uint64_t qemu_get_be64(QEMUFile *f); =20 +bool qemu_file_is_seekable(QEMUFile *f); + static inline void qemu_put_be64s(QEMUFile *f, const uint64_t *pv) { qemu_put_be64(f, *pv); diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 94231ff295..b10c882629 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -33,6 +33,7 @@ #include "options.h" #include "qapi/error.h" #include "rdma.h" +#include "io/channel-file.h" =20 #define IO_BUF_SIZE 32768 #define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64) @@ -255,6 +256,10 @@ static void qemu_iovec_release_ram(QEMUFile *f) memset(f->may_free, 0, sizeof(f->may_free)); } =20 +bool qemu_file_is_seekable(QEMUFile *f) +{ + return qio_channel_has_feature(f->ioc, QIO_CHANNEL_FEATURE_SEEKABLE); +} =20 /** * Flushes QEMUFile buffer @@ -447,6 +452,107 @@ void qemu_put_buffer(QEMUFile *f, const uint8_t *buf,= size_t size) } } =20 +void qemu_put_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, + off_t pos) +{ + Error *err =3D NULL; + size_t ret; + + if (f->last_error) { + return; + } + + qemu_fflush(f); + ret =3D qio_channel_pwrite(f->ioc, (char *)buf, buflen, pos, &err); + + if (err) { + qemu_file_set_error_obj(f, -EIO, err); + return; + } + + if ((ssize_t)ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + qemu_file_set_error_obj(f, -EAGAIN, NULL); + return; + } + + if (ret !=3D buflen) { + error_setg(&err, "Partial write of size %zu, expected %zu", ret, + buflen); + qemu_file_set_error_obj(f, -EIO, err); + return; + } + + stat64_add(&mig_stats.qemu_file_transferred, buflen); + + return; +} + + +size_t qemu_get_buffer_at(QEMUFile *f, const uint8_t *buf, size_t buflen, + off_t pos) +{ + Error *err =3D NULL; + size_t ret; + + if (f->last_error) { + return 0; + } + + ret =3D qio_channel_pread(f->ioc, (char *)buf, buflen, pos, &err); + + if ((ssize_t)ret =3D=3D -1 || err) { + qemu_file_set_error_obj(f, -EIO, err); + return 0; + } + + if ((ssize_t)ret =3D=3D QIO_CHANNEL_ERR_BLOCK) { + qemu_file_set_error_obj(f, -EAGAIN, NULL); + return 0; + } + + if (ret !=3D buflen) { + error_setg(&err, "Partial read of size %zu, expected %zu", ret, bu= flen); + qemu_file_set_error_obj(f, -EIO, err); + return 0; + } + + return ret; +} + +void qemu_set_offset(QEMUFile *f, off_t off, int whence) +{ + Error *err =3D NULL; + off_t ret; + + if (qemu_file_is_writable(f)) { + qemu_fflush(f); + } else { + /* Drop all cached buffers if existed; will trigger a re-fill late= r */ + f->buf_index =3D 0; + f->buf_size =3D 0; + } + + ret =3D qio_channel_io_seek(f->ioc, off, whence, &err); + if (ret =3D=3D (off_t)-1) { + qemu_file_set_error_obj(f, -EIO, err); + } +} + +off_t qemu_get_offset(QEMUFile *f) +{ + Error *err =3D NULL; + off_t ret; + + qemu_fflush(f); + + ret =3D qio_channel_io_seek(f->ioc, 0, SEEK_CUR, &err); + if (ret =3D=3D (off_t)-1) { + qemu_file_set_error_obj(f, -EIO, err); + } + return ret; +} + + void qemu_put_byte(QEMUFile *f, int v) { if (f->last_error) { diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 8aec9fabf7..32fd4a34fd 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -75,6 +75,12 @@ QEMUFile *qemu_file_get_return_path(QEMUFile *f); int qemu_fflush(QEMUFile *f); void qemu_file_set_blocking(QEMUFile *f, bool block); int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t size); +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, const uint8_t *buf, size_t buflen, + off_t pos); =20 QIOChannel *qemu_file_get_ioc(QEMUFile *file); =20 --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469064; cv=none; d=zohomail.com; s=zohoarc; b=LDnzfLA48k7O8+6TCBLdwCOZBLhh48A6CNiYU/3KOvRmmUXc+jBCh94+WqbvA/1UQmkWK1TgSw38rrNoQCoqNCac3wOG+s2GsY+tQ+scrRS/J4/Pxa708cWlUeQRz0HPfzaFpY+RckUNoVO+jPVML++Fa0NJF1Jyhv2ZSojnUG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469064; 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=4rMZwnsxGPC46xABnLIzuiIVK2s50sf9Lrt0fRlj+Nw=; b=HH4Hvxf444sr4b7VI3iyVC5+Qq4QQAkgcBnXCbJxNHPNaUfXKMy6O4GLnafsWQhbQ9hzx57+9hd64Pka9ln4Hsc5IHQ3Nn9cAq2O4Hl8faj5manoV9x3n6a3fl/VKKR2ojV4UK+1Nds+UD3Iyn4oYIhxRdqDAXGkUktxBluVtGQ= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469064100440.423880574097; Tue, 20 Feb 2024 14:44:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoY-0003GU-7M; Tue, 20 Feb 2024 17:42:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoV-0003FR-Bz for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:12 -0500 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 1rcYoT-0006Kn-3p for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:11 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 F16AF1FB40; Tue, 20 Feb 2024 22:42:07 +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 1C4F6139D0; Tue, 20 Feb 2024 22:42:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id eAo0Nb0q1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468928; 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=4rMZwnsxGPC46xABnLIzuiIVK2s50sf9Lrt0fRlj+Nw=; b=vG0C7tfs5Cuw7i4mRTM/xLtP5V/TZayTbcYktw0jYYrjLEJpGgwByLHY8IGLyK7FjtDGdg 0f6CetfdKuA6/0KuqH+OAf4psRHAINIZwy50PXPbnDpEnHQmmgVjyf1MHJImGITlj3tPW2 HwwJQ4mX3KNtGbgxxYd1k1ZO6R16hpQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468928; 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=4rMZwnsxGPC46xABnLIzuiIVK2s50sf9Lrt0fRlj+Nw=; b=6GEy2wyY7K9U9vv2sdM3nfeCs73dMrJRaj1J5oeiK34WoiCNDIE2vAw5tE5w0mLhu6EUQw QejuQcO2VDwk0NDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468927; 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=4rMZwnsxGPC46xABnLIzuiIVK2s50sf9Lrt0fRlj+Nw=; b=Vge+bEPz4hsNC2A7GJ/MBbZvDhzBtzgVE++y5BnFmNJwMkC7c+9LTUtVFbYmFjhyx/wLS6 NHrOIoH2bdxHps8mMbZskG/5Rfn14ebBBCOdJOCl9tRlF6kd3wYHGFn4uoDiTotUY9b4RX VPMGWCp8mzcFzEscOKuxPsyX8M342JI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468927; 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=4rMZwnsxGPC46xABnLIzuiIVK2s50sf9Lrt0fRlj+Nw=; b=EOp35z02SsxbRyuCUDPgEg+WYWAmNnqUtVlAjOsTnmBYsrS1U9TDh45YL9aMkHJiEGKJAY APacNNBwUgUpQwBg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Eric Blake Subject: [PATCH v4 11/34] migration/ram: Introduce 'fixed-ram' migration capability Date: Tue, 20 Feb 2024 19:41:15 -0300 Message-Id: <20240220224138.24759-12-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [1.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 1.90 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1708469066018100003 Content-Type: text/plain; charset="utf-8" Add a new migration capability 'fixed-ram'. The core of the feature is to ensure that each RAM page has a specific offset in the resulting migration stream. The reasons why we'd want such behavior are: - The resulting file will have a bounded size, since pages which are dirtied multiple times will always go to a fixed location in the file, rather than constantly being added to a sequential stream. This eliminates cases where a VM with, say, 1G of RAM can result in a migration file that's 10s of GBs, provided that the workload constantly redirties memory. - It paves the way to implement O_DIRECT-enabled save/restore of the migration stream as the pages are ensured to be written at aligned offsets. - It allows the usage of multifd so we can write RAM pages to the migration file in parallel. For now, enabling the capability has no effect. The next couple of patches implement the core functionality. Signed-off-by: Fabiano Rosas Acked-by: Markus Armbruster --- - update migration.json to 9.0 and improve wording - move docs to a separate file and add use cases information --- docs/devel/migration/features.rst | 1 + docs/devel/migration/fixed-ram.rst | 137 +++++++++++++++++++++++++++++ migration/options.c | 34 +++++++ migration/options.h | 1 + migration/savevm.c | 1 + qapi/migration.json | 6 +- 6 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 docs/devel/migration/fixed-ram.rst diff --git a/docs/devel/migration/features.rst b/docs/devel/migration/featu= res.rst index a9acaf618e..4c708b679a 100644 --- a/docs/devel/migration/features.rst +++ b/docs/devel/migration/features.rst @@ -10,3 +10,4 @@ Migration has plenty of features to support different use= cases. dirty-limit vfio virtio + fixed-ram diff --git a/docs/devel/migration/fixed-ram.rst b/docs/devel/migration/fixe= d-ram.rst new file mode 100644 index 0000000000..a6c0e5a360 --- /dev/null +++ b/docs/devel/migration/fixed-ram.rst @@ -0,0 +1,137 @@ +Fixed-ram +=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Fixed-ram is a new stream format for the RAM section designed to +supplement the existing ``file:`` migration and make it compatible +with ``multifd``. This enables parallel migration of a guest's RAM to +a file. + +The core of the feature is to ensure that each RAM page has a specific +offset in the resulting migration file. This enables the ``multifd`` +threads to write exclusively to those offsets even if the guest is +constantly dirtying pages (i.e. live migration). Another benefit is +that the resulting file will have a bounded size, since pages which +are dirtied multiple times will always go to a fixed location in the +file, rather than constantly being added to a sequential +stream. Having the pages at fixed offsets also allows the usage of +O_DIRECT for save/restore of the migration stream as the pages are +ensured to be written respecting O_DIRECT alignment restrictions. + +Usage +----- + +On both source and destination, enable the ``multifd`` and +``fixed-ram`` capabilities: + + ``migrate_set_capability multifd on`` + + ``migrate_set_capability fixed-ram on`` + +Use a ``file:`` URL for migration: + + ``migrate file:/path/to/migration/file`` + +Fixed-ram migration is best done non-live, i.e. by stopping the VM on +the source side before migrating. + +For best performance enable the ``direct-io`` capability as well: + + ``migrate_set_capability direct-io on`` + +Use-cases +--------- + +The fixed-ram feature was designed for use cases where the migration +stream will be directed to a file in the filesystem and not +immediately restored on the destination VM [#]_. These could be +thought of as snapshots. We can further categorize them into live and +non-live. + +- Non-live snapshot + +If the use case requires a VM to be stopped before taking a snapshot, +that's the ideal scenario for fixed-ram migration. Not having to track +dirty pages, the migration will write the RAM pages to the disk as +fast as it can. + +Note: if a snapshot is taken of a running VM, but the VM will be +stopped after the snapshot by the admin, then consider stopping it +right before the snapshot to take benefit of the performance gains +mentioned above. + +- Live snapshot + +If the use case requires that the VM keeps running during and after +the snapshot operation, then fixed-ram migration can still be used, +but will be less performant. Other strategies such as +background-snapshot should be evaluated as well. One benefit of +fixed-ram in this scenario is portability since background-snapshot +depends on async dirty tracking (KVM_GET_DIRTY_LOG) which is not +supported outside of Linux. + +.. [#] While this same effect could be obtained with the usage of + snapshots or the ``file:`` migration alone, fixed-ram provides + a performance increase for VMs with larger RAM sizes (10s to + 100s of GiBs), specially if the VM has been stopped beforehand. + +RAM section format +------------------ + +Instead of having a sequential stream of pages that follow the +RAMBlock headers, the dirty pages for a RAMBlock follow its header +instead. This ensures that each RAM page has a fixed offset in the +resulting migration file. + +A bitmap is introduced to track which pages have been written in the +migration file. Pages are written at a fixed location for every +ramblock. Zero pages are ignored as they'd be zero in the destination +migration as well. + +:: + + Without fixed-ram: With fixed-ram: + + --------------------- -------------------------------- + | ramblock 1 header | | ramblock 1 header | + --------------------- -------------------------------- + | ramblock 2 header | | ramblock 1 fixed-ram header | + --------------------- -------------------------------- + | ... | | padding to next 1MB boundary | + --------------------- | ... | + | ramblock n header | -------------------------------- + --------------------- | ramblock 1 pages | + | RAM_SAVE_FLAG_EOS | | ... | + --------------------- -------------------------------- + | stream of pages | | ramblock 2 header | + | (iter 1) | -------------------------------- + | ... | | ramblock 2 fixed-ram header | + --------------------- -------------------------------- + | RAM_SAVE_FLAG_EOS | | padding to next 1MB boundary | + --------------------- | ... | + | stream of pages | -------------------------------- + | (iter 2) | | ramblock 2 pages | + | ... | | ... | + --------------------- -------------------------------- + | ... | | ... | + --------------------- -------------------------------- + | RAM_SAVE_FLAG_EOS | + -------------------------------- + | ... | + -------------------------------- + + where: + - ramblock header: the generic information for a ramblock, such as + idstr, used_len, etc. + + - ramblock fixed-ram header: the information added by this feature: + bitmap of pages written, bitmap size and offset of pages in the + migration file. + +Restrictions +------------ + +Since pages are written to their relative offsets and out of order +(due to the memory dirtying patterns), streaming channels such as +sockets are not supported. A seekable channel such as a file is +required. This can be verified in the QIOChannel by the presence of +the QIO_CHANNEL_FEATURE_SEEKABLE. diff --git a/migration/options.c b/migration/options.c index 3e3e0b93b4..4909e5c72a 100644 --- a/migration/options.c +++ b/migration/options.c @@ -204,6 +204,7 @@ Property migration_properties[] =3D { DEFINE_PROP_MIG_CAP("x-switchover-ack", MIGRATION_CAPABILITY_SWITCHOVER_ACK), DEFINE_PROP_MIG_CAP("x-dirty-limit", MIGRATION_CAPABILITY_DIRTY_LIMIT), + DEFINE_PROP_MIG_CAP("x-fixed-ram", MIGRATION_CAPABILITY_FIXED_RAM), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -263,6 +264,13 @@ bool migrate_events(void) return s->capabilities[MIGRATION_CAPABILITY_EVENTS]; } =20 +bool migrate_fixed_ram(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->capabilities[MIGRATION_CAPABILITY_FIXED_RAM]; +} + bool migrate_ignore_shared(void) { MigrationState *s =3D migrate_get_current(); @@ -645,6 +653,32 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps= , Error **errp) } } =20 + if (new_caps[MIGRATION_CAPABILITY_FIXED_RAM]) { + if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) { + error_setg(errp, + "Fixed-ram migration is incompatible with multifd"); + return false; + } + + if (new_caps[MIGRATION_CAPABILITY_XBZRLE]) { + error_setg(errp, + "Fixed-ram migration is incompatible with xbzrle"); + return false; + } + + if (new_caps[MIGRATION_CAPABILITY_COMPRESS]) { + error_setg(errp, + "Fixed-ram migration is incompatible with compressi= on"); + return false; + } + + if (new_caps[MIGRATION_CAPABILITY_POSTCOPY_RAM]) { + error_setg(errp, + "Fixed-ram migration is incompatible with postcopy = ram"); + return false; + } + } + return true; } =20 diff --git a/migration/options.h b/migration/options.h index 246c160aee..8680a10b79 100644 --- a/migration/options.h +++ b/migration/options.h @@ -31,6 +31,7 @@ bool migrate_compress(void); bool migrate_dirty_bitmaps(void); bool migrate_dirty_limit(void); bool migrate_events(void); +bool migrate_fixed_ram(void); bool migrate_ignore_shared(void); bool migrate_late_block_activate(void); bool migrate_multifd(void); diff --git a/migration/savevm.c b/migration/savevm.c index d612c8a902..4b928dd6bb 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -245,6 +245,7 @@ static bool should_validate_capability(int capability) /* Validate only new capabilities to keep compatibility. */ switch (capability) { case MIGRATION_CAPABILITY_X_IGNORE_SHARED: + case MIGRATION_CAPABILITY_FIXED_RAM: return true; default: return false; diff --git a/qapi/migration.json b/qapi/migration.json index 5a565d9b8d..3fce5fe53e 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -531,6 +531,10 @@ # and can result in more stable read performance. Requires KVM # with accelerator property "dirty-ring-size" set. (Since 8.1) # +# @fixed-ram: Migrate using fixed offsets in the migration file for +# each RAM page. Requires a migration URI that supports seeking, +# such as a file. (since 9.0) +# # Features: # # @deprecated: Member @block is deprecated. Use blockdev-mirror with @@ -555,7 +559,7 @@ { 'name': 'x-ignore-shared', 'features': [ 'unstable' ] }, 'validate-uuid', 'background-snapshot', 'zero-copy-send', 'postcopy-preempt', 'switchover-ack', - 'dirty-limit'] } + 'dirty-limit', 'fixed-ram'] } =20 ## # @MigrationCapabilityStatus: --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708468993; cv=none; d=zohomail.com; s=zohoarc; b=Zg6fbggWGBLXzJdU3Oyg48azCoZ0g11ElEKeexxh7uuzb8JMR38Vrn8S8ScMy5oJtvvdigLbnhjE2BN/YojmLE0Hp08PIo7iZF0Zt+rl1B0r9OK96biTYRB7u53pviauBC9zV+1GZK/y86xc7D4QBFQxwInl8g5V54dad/tSkbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708468993; h=Content-Type: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=900XvnPK2l/P0GLLO6Va4KDZ6PV5wQ65E53gkQyrLFA=; b=M4aYWPNS7tNk+HbvpIHbNCvhTtWVhRbu37sLPeqNVoJTsyyYPEn3RLj+mlmiVMc3ltnHw1qjDbx9YbABmmhdDWtPBMVD6DLCo+xuaGxwQItKzOXX5kj6tptmYtzQytAuSOIjxXJOwEE5lif4GxtonKDGkJMh6y1XLsCFtYvnEEg= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708468993365388.0716024706254; Tue, 20 Feb 2024 14:43:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoa-0003Hv-1B; Tue, 20 Feb 2024 17:42:16 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoW-0003G5-Tf for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:12 -0500 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 1rcYoV-0006Kx-5f for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:12 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 0CCBA2225A; Tue, 20 Feb 2024 22:42: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 6DBB3139D0; Tue, 20 Feb 2024 22:42:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id GLJkDcAq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=900XvnPK2l/P0GLLO6Va4KDZ6PV5wQ65E53gkQyrLFA=; b=wuN/uzEnDnYhbhGwuNxGTBpkMh542IXvbcfmYux1qWx/v9wp/BIw7hGdAr8DdwFPpKD5mz 2bkn/7zvKJlYvLyK6On0kkNR4ci9zu4mFxGB5KhRxwaXIJBgRp0y50EenfjFsD6ILFj9va aC64dt8JidL/hi4+n787To/MsJlOZyQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=900XvnPK2l/P0GLLO6Va4KDZ6PV5wQ65E53gkQyrLFA=; b=8EKwWSm3k7gkWAQ5UxSu5nSDNFcnbhUGsGtwKlUIHvNEOGWVYhLfZniEnkAXgT1+WSrPS9 sAzT6Sy3i1q8xIDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=900XvnPK2l/P0GLLO6Va4KDZ6PV5wQ65E53gkQyrLFA=; b=wuN/uzEnDnYhbhGwuNxGTBpkMh542IXvbcfmYux1qWx/v9wp/BIw7hGdAr8DdwFPpKD5mz 2bkn/7zvKJlYvLyK6On0kkNR4ci9zu4mFxGB5KhRxwaXIJBgRp0y50EenfjFsD6ILFj9va aC64dt8JidL/hi4+n787To/MsJlOZyQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468930; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=900XvnPK2l/P0GLLO6Va4KDZ6PV5wQ65E53gkQyrLFA=; b=8EKwWSm3k7gkWAQ5UxSu5nSDNFcnbhUGsGtwKlUIHvNEOGWVYhLfZniEnkAXgT1+WSrPS9 sAzT6Sy3i1q8xIDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 12/34] migration: Add fixed-ram URI compatibility check Date: Tue, 20 Feb 2024 19:41:16 -0300 Message-Id: <20240220224138.24759-13-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: -3.30 X-Spamd-Result: default: False [-3.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[99.99%] Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708468993816100005 The fixed-ram migration format needs a channel that supports seeking to be able to write each page to an arbitrary offset in the migration stream. Signed-off-by: Fabiano Rosas Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu --- migration/migration.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index ab21de2cad..16da269847 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -142,10 +142,39 @@ static bool transport_supports_multi_channels(Migrati= onAddress *addr) return false; } =20 +static bool migration_needs_seekable_channel(void) +{ + return migrate_fixed_ram(); +} + +static bool transport_supports_seeking(MigrationAddress *addr) +{ + if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_FILE) { + return true; + } + + /* + * At this point, the user might not yet have passed the file + * descriptor to QEMU, so we cannot know for sure whether it + * refers to a plain file or a socket. Let it through anyway. + */ + if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_SOCKET) { + return addr->u.socket.type =3D=3D SOCKET_ADDRESS_TYPE_FD; + } + + return false; +} + static bool migration_channels_and_transport_compatible(MigrationAddress *addr, Error **errp) { + if (migration_needs_seekable_channel() && + !transport_supports_seeking(addr)) { + error_setg(errp, "Migration requires seekable transport (e.g. file= )"); + return false; + } + if (migration_needs_multiple_sockets() && !transport_supports_multi_channels(addr)) { error_setg(errp, "Migration requires multi-channel URIs (e.g. tcp)= "); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469115; cv=none; d=zohomail.com; s=zohoarc; b=ELQqkrpcckAzbkm3pcoHE+Q1Gr6kzrI7MrSH97IB4FkDydZcTzo15JkK2jlJJbyrtrqHkrmozCrGzyT3vA/hYfD+Vl3ggpdZvRNc0nSHeRSgGhjvSv1Gk88XKZuZNQnSoXBd72eQOO2W0PAjb9vppdq7ZRhXxScN2BA4N7rSXxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469115; 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=dsdfzeVUIMcwHpSV4jaq8/QQV9ry7HhGM9RIxHRPMfE=; b=Dlm63BtUNoe3HFjrtS5AxHh5orCJnkqN0EDRnagumCMXm5qLTCmj+TOZ0DUnx8bMRUytOZb9xb/OIDF6VA11oMK64xRGQg6kbTVrqYQksHCqxMqjhI3Af2v6hz3Zy7eOwOXwPyZKZJDSoZk2YhQ1Et6EihR1dOEPANp/r/fjw/I= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469115243215.15263022207466; Tue, 20 Feb 2024 14:45:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoc-0003J7-Vf; Tue, 20 Feb 2024 17:42:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoa-0003IW-Jy for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:16 -0500 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 1rcYoY-0006LH-4g for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:15 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 09D642225A; Tue, 20 Feb 2024 22:42: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 7F8C2139D0; Tue, 20 Feb 2024 22:42:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id GMWxEcIq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468933; 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=dsdfzeVUIMcwHpSV4jaq8/QQV9ry7HhGM9RIxHRPMfE=; b=AhTXhR9tSGw+wPJW1yggkxh/hAmIwpreATPP1P9EjGZY5cfPpumvK4ROl9Gi9IzhJOc/Mv 9oZq+uexFZkMHgHvsiL3wdbMfFJtySlARgTvnthIffO7uDIQRhvWO1Hy3+1grzRiOppri0 dgHQDtUgAug9g1noU/ZuQnoqfCcInxY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468933; 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=dsdfzeVUIMcwHpSV4jaq8/QQV9ry7HhGM9RIxHRPMfE=; b=eUSTJH626iKmPVUfYiU2uqI4piC28vz5XkL1yIbN7c/PwwP6iKZlyKX4tB+u06GJm08roo mk8Zq/WlAdVqSZDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468933; 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=dsdfzeVUIMcwHpSV4jaq8/QQV9ry7HhGM9RIxHRPMfE=; b=AhTXhR9tSGw+wPJW1yggkxh/hAmIwpreATPP1P9EjGZY5cfPpumvK4ROl9Gi9IzhJOc/Mv 9oZq+uexFZkMHgHvsiL3wdbMfFJtySlARgTvnthIffO7uDIQRhvWO1Hy3+1grzRiOppri0 dgHQDtUgAug9g1noU/ZuQnoqfCcInxY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468933; 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=dsdfzeVUIMcwHpSV4jaq8/QQV9ry7HhGM9RIxHRPMfE=; b=eUSTJH626iKmPVUfYiU2uqI4piC28vz5XkL1yIbN7c/PwwP6iKZlyKX4tB+u06GJm08roo mk8Zq/WlAdVqSZDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Nikolay Borisov , Paolo Bonzini , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 13/34] migration/ram: Add outgoing 'fixed-ram' migration Date: Tue, 20 Feb 2024 19:41:17 -0300 Message-Id: <20240220224138.24759-14-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[9]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.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=lists.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: -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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469116171100005 Content-Type: text/plain; charset="utf-8" Implement the outgoing migration side for the 'fixed-ram' capability. A bitmap is introduced to track which pages have been written in the migration file. Pages are written at a fixed location for every ramblock. Zero pages are ignored as they'd be zero in the destination migration as well. The migration stream is altered to put the dirty pages for a ramblock after its header instead of having a sequential stream of pages that follow the ramblock headers. Without fixed-ram (current): With fixed-ram (new): --------------------- -------------------------------- | ramblock 1 header | | ramblock 1 header | --------------------- -------------------------------- | ramblock 2 header | | ramblock 1 fixed-ram header | --------------------- -------------------------------- | ... | | padding to next 1MB boundary | --------------------- | ... | | ramblock n header | -------------------------------- --------------------- | ramblock 1 pages | | RAM_SAVE_FLAG_EOS | | ... | --------------------- -------------------------------- | stream of pages | | ramblock 2 header | | (iter 1) | -------------------------------- | ... | | ramblock 2 fixed-ram header | --------------------- -------------------------------- | RAM_SAVE_FLAG_EOS | | padding to next 1MB boundary | --------------------- | ... | | stream of pages | -------------------------------- | (iter 2) | | ramblock 2 pages | | ... | | ... | --------------------- -------------------------------- | ... | | ... | --------------------- -------------------------------- | RAM_SAVE_FLAG_EOS | -------------------------------- | ... | -------------------------------- where: - ramblock header: the generic information for a ramblock, such as idstr, used_len, etc. - ramblock fixed-ram header: the new information added by this feature: bitmap of pages written, bitmap size and offset of pages in the migration file. Signed-off-by: Nikolay Borisov Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- include/exec/ramblock.h | 13 ++++ migration/ram.c | 131 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 135 insertions(+), 9 deletions(-) diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h index 3eb79723c6..6a66301219 100644 --- a/include/exec/ramblock.h +++ b/include/exec/ramblock.h @@ -44,6 +44,19 @@ struct RAMBlock { size_t page_size; /* dirty bitmap used during migration */ unsigned long *bmap; + + /* + * Below fields are only used by fixed-ram migration + */ + /* bitmap of pages present in the migration file */ + unsigned long *file_bmap; + /* + * offset in the file pages belonging to this ramblock are saved, + * used only during migration to a file. + */ + off_t bitmap_offset; + uint64_t pages_offset; + /* bitmap of already received pages in postcopy */ unsigned long *receivedmap; =20 diff --git a/migration/ram.c b/migration/ram.c index 4649a81204..84c531722c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -94,6 +94,18 @@ #define RAM_SAVE_FLAG_MULTIFD_FLUSH 0x200 /* We can't use any flag that is bigger than 0x200 */ =20 +/* + * fixed-ram migration supports O_DIRECT, so we need to make sure the + * userspace buffer, the IO operation size and the file offset are + * aligned according to the underlying device's block size. The first + * two are already aligned to page size, but we need to add padding to + * the file to align the offset. We cannot read the block size + * dynamically because the migration file can be moved between + * different systems, so use 1M to cover most block sizes and to keep + * the file offset aligned at page size as well. + */ +#define FIXED_RAM_FILE_OFFSET_ALIGNMENT 0x100000 + XBZRLECacheStats xbzrle_counters; =20 /* used by the search for pages to send */ @@ -1127,12 +1139,18 @@ static int save_zero_page(RAMState *rs, PageSearchS= tatus *pss, return 0; } =20 + stat64_add(&mig_stats.zero_pages, 1); + + if (migrate_fixed_ram()) { + /* zero pages are not transferred with fixed-ram */ + clear_bit(offset >> TARGET_PAGE_BITS, pss->block->file_bmap); + return 1; + } + len +=3D save_page_header(pss, file, pss->block, offset | RAM_SAVE_FLA= G_ZERO); qemu_put_byte(file, 0); len +=3D 1; ram_release_page(pss->block->idstr, offset); - - stat64_add(&mig_stats.zero_pages, 1); ram_transferred_add(len); =20 /* @@ -1190,14 +1208,20 @@ static int save_normal_page(PageSearchStatus *pss, = RAMBlock *block, { QEMUFile *file =3D pss->pss_channel; =20 - ram_transferred_add(save_page_header(pss, pss->pss_channel, block, - offset | RAM_SAVE_FLAG_PAGE)); - if (async) { - qemu_put_buffer_async(file, buf, TARGET_PAGE_SIZE, - migrate_release_ram() && - migration_in_postcopy()); + if (migrate_fixed_ram()) { + qemu_put_buffer_at(file, buf, TARGET_PAGE_SIZE, + block->pages_offset + offset); + set_bit(offset >> TARGET_PAGE_BITS, block->file_bmap); } else { - qemu_put_buffer(file, buf, TARGET_PAGE_SIZE); + ram_transferred_add(save_page_header(pss, pss->pss_channel, block, + offset | RAM_SAVE_FLAG_PAGE)); + if (async) { + qemu_put_buffer_async(file, buf, TARGET_PAGE_SIZE, + migrate_release_ram() && + migration_in_postcopy()); + } else { + qemu_put_buffer(file, buf, TARGET_PAGE_SIZE); + } } ram_transferred_add(TARGET_PAGE_SIZE); stat64_add(&mig_stats.normal_pages, 1); @@ -2412,6 +2436,8 @@ static void ram_save_cleanup(void *opaque) block->clear_bmap =3D NULL; g_free(block->bmap); block->bmap =3D NULL; + g_free(block->file_bmap); + block->file_bmap =3D NULL; } =20 xbzrle_cleanup(); @@ -2779,6 +2805,9 @@ static void ram_list_init_bitmaps(void) */ block->bmap =3D bitmap_new(pages); bitmap_set(block->bmap, 0, pages); + if (migrate_fixed_ram()) { + block->file_bmap =3D bitmap_new(pages); + } block->clear_bmap_shift =3D shift; block->clear_bmap =3D bitmap_new(clear_bmap_size(pages, shift)= ); } @@ -2916,6 +2945,60 @@ void qemu_guest_free_page_hint(void *addr, size_t le= n) } } =20 +#define FIXED_RAM_HDR_VERSION 1 +struct FixedRamHeader { + uint32_t version; + /* + * The target's page size, so we know how many pages are in the + * bitmap. + */ + uint64_t page_size; + /* + * The offset in the migration file where the pages bitmap is + * stored. + */ + uint64_t bitmap_offset; + /* + * The offset in the migration file where the actual pages (data) + * are stored. + */ + uint64_t pages_offset; +} QEMU_PACKED; +typedef struct FixedRamHeader FixedRamHeader; + +static void fixed_ram_setup_ramblock(QEMUFile *file, RAMBlock *block) +{ + g_autofree FixedRamHeader *header =3D NULL; + size_t header_size, bitmap_size; + long num_pages; + + header =3D g_new0(FixedRamHeader, 1); + header_size =3D sizeof(FixedRamHeader); + + num_pages =3D block->used_length >> TARGET_PAGE_BITS; + bitmap_size =3D BITS_TO_LONGS(num_pages) * sizeof(unsigned long); + + /* + * Save the file offsets of where the bitmap and the pages should + * go as they are written at the end of migration and during the + * iterative phase, respectively. + */ + block->bitmap_offset =3D qemu_get_offset(file) + header_size; + block->pages_offset =3D ROUND_UP(block->bitmap_offset + + bitmap_size, + FIXED_RAM_FILE_OFFSET_ALIGNMENT); + + header->version =3D cpu_to_be32(FIXED_RAM_HDR_VERSION); + header->page_size =3D cpu_to_be64(TARGET_PAGE_SIZE); + header->bitmap_offset =3D cpu_to_be64(block->bitmap_offset); + header->pages_offset =3D cpu_to_be64(block->pages_offset); + + qemu_put_buffer(file, (uint8_t *) header, header_size); + + /* prepare offset for next ramblock */ + qemu_set_offset(file, block->pages_offset + block->used_length, SEEK_S= ET); +} + /* * Each of ram_save_setup, ram_save_iterate and ram_save_complete has * long-running RCU critical section. When rcu-reclaims in the code @@ -2965,6 +3048,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) if (migrate_ignore_shared()) { qemu_put_be64(f, block->mr->addr); } + + if (migrate_fixed_ram()) { + fixed_ram_setup_ramblock(f, block); + } } } =20 @@ -2998,6 +3085,20 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return qemu_fflush(f); } =20 +static void ram_save_file_bmap(QEMUFile *f) +{ + RAMBlock *block; + + RAMBLOCK_FOREACH_MIGRATABLE(block) { + long num_pages =3D block->used_length >> TARGET_PAGE_BITS; + long bitmap_size =3D BITS_TO_LONGS(num_pages) * sizeof(unsigned lo= ng); + + qemu_put_buffer_at(f, (uint8_t *)block->file_bmap, bitmap_size, + block->bitmap_offset); + ram_transferred_add(bitmap_size); + } +} + /** * ram_save_iterate: iterative stage for migration * @@ -3187,6 +3288,18 @@ static int ram_save_complete(QEMUFile *f, void *opaq= ue) return ret; } =20 + if (migrate_fixed_ram()) { + ram_save_file_bmap(f); + + if (qemu_file_get_error(f)) { + Error *local_err =3D NULL; + int err =3D qemu_file_get_error_obj(f, &local_err); + + error_reportf_err(local_err, "Failed to write bitmap to file: = "); + return -err; + } + } + if (migrate_multifd() && !migrate_multifd_flush_after_each_section()) { qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); } --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708468993; cv=none; d=zohomail.com; s=zohoarc; b=UEL/lVCjhs+QguWHcsJGZrcYJ49xxn6nLgFP6RZaNJaZ81XVh+jerQaM7AM7sucK7U0JGrCbD0p6yPR8UL+f7RtI2HhGcrtxXF4k9hNhMEhVj75psGH+uzDoZr22viY47eQH9iUw4xrfpF51Dqss2GutVIXaAmuXAx7jXUo+4yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708468993; 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=cQNRoHYuB++Eh5nfWUoZCZ7UX52WxIgAI8EzqW+fFsk=; b=EM3xgwjrCLQwo4kWskOkoY1Je1BO69BAVU3vCHWttRpRdMM1iqDpDTyKSJMtECUZZy9j9G8H1WbvaHTWAiprfcaUghjjIC1nbO1Bvac9fd0qDoZ0ybXhQabSs01OFsdGNwZiuJOhsC3MZfNi3ij9vlKuay5MWDbvvV1465oiLdo= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708468993476430.7637191387132; Tue, 20 Feb 2024 14:43:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoi-0003KQ-Bz; Tue, 20 Feb 2024 17:42:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoc-0003Iq-NW for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:18 -0500 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 1rcYoa-0006LP-Jv for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:18 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 51E4B22260; Tue, 20 Feb 2024 22:42: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 7AD48139D0; Tue, 20 Feb 2024 22:42:13 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id QImyEMUq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468935; 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=cQNRoHYuB++Eh5nfWUoZCZ7UX52WxIgAI8EzqW+fFsk=; b=L9PlXIaUHsA636xpuPorfsMn7HQ26TaPBXFXfFM2GE0DUt2CQhr9I9m2AncwIBTbU1p4lw 6D/w2hCTLwKnk62zkERhefC+TgexpyNNsjnrtXjXaoh9d3G0q0sLEWmt1GeD1zg6OUP7b4 HzXuBlWM6xpR9v6V5yU2qh6cUl0/9/A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468935; 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=cQNRoHYuB++Eh5nfWUoZCZ7UX52WxIgAI8EzqW+fFsk=; b=9WyOEJ7aGKIIcId4jb5Rq3PX36dxTHG2SfIbK3FchrzSkEwy0+/FhlxeIML/V52Ye2/Kju 8FRrrh+TWOniiwBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468935; 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=cQNRoHYuB++Eh5nfWUoZCZ7UX52WxIgAI8EzqW+fFsk=; b=L9PlXIaUHsA636xpuPorfsMn7HQ26TaPBXFXfFM2GE0DUt2CQhr9I9m2AncwIBTbU1p4lw 6D/w2hCTLwKnk62zkERhefC+TgexpyNNsjnrtXjXaoh9d3G0q0sLEWmt1GeD1zg6OUP7b4 HzXuBlWM6xpR9v6V5yU2qh6cUl0/9/A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468935; 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=cQNRoHYuB++Eh5nfWUoZCZ7UX52WxIgAI8EzqW+fFsk=; b=9WyOEJ7aGKIIcId4jb5Rq3PX36dxTHG2SfIbK3FchrzSkEwy0+/FhlxeIML/V52Ye2/Kju 8FRrrh+TWOniiwBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Nikolay Borisov Subject: [PATCH v4 14/34] migration/ram: Add incoming 'fixed-ram' migration Date: Tue, 20 Feb 2024 19:41:18 -0300 Message-Id: <20240220224138.24759-15-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[6]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:email,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.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=lists.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708468993889100007 Content-Type: text/plain; charset="utf-8" Add the necessary code to parse the format changes for the 'fixed-ram' capability. One of the more notable changes in behavior is that in the 'fixed-ram' case ram pages are restored in one go rather than constantly looping through the migration stream. Signed-off-by: Nikolay Borisov Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- - added error propagation for read_ramblock_fixed_ram() - removed buf_size variable --- migration/ram.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 142 insertions(+) diff --git a/migration/ram.c b/migration/ram.c index 84c531722c..5932e1b8e1 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -106,6 +106,12 @@ */ #define FIXED_RAM_FILE_OFFSET_ALIGNMENT 0x100000 =20 +/* + * When doing fixed-ram migration, this is the amount we read from the + * pages region in the migration file at a time. + */ +#define FIXED_RAM_LOAD_BUF_SIZE 0x100000 + XBZRLECacheStats xbzrle_counters; =20 /* used by the search for pages to send */ @@ -2999,6 +3005,35 @@ static void fixed_ram_setup_ramblock(QEMUFile *file,= RAMBlock *block) qemu_set_offset(file, block->pages_offset + block->used_length, SEEK_S= ET); } =20 +static bool fixed_ram_read_header(QEMUFile *file, FixedRamHeader *header, + Error **errp) +{ + size_t ret, header_size =3D sizeof(FixedRamHeader); + + ret =3D qemu_get_buffer(file, (uint8_t *)header, header_size); + if (ret !=3D header_size) { + error_setg(errp, "Could not read whole fixed-ram migration header " + "(expected %zd, got %zd bytes)", header_size, ret); + return false; + } + + /* migration stream is big-endian */ + header->version =3D be32_to_cpu(header->version); + + if (header->version > FIXED_RAM_HDR_VERSION) { + error_setg(errp, "Migration fixed-ram capability version mismatch " + "(expected %d, got %d)", FIXED_RAM_HDR_VERSION, + header->version); + return false; + } + + header->page_size =3D be64_to_cpu(header->page_size); + header->bitmap_offset =3D be64_to_cpu(header->bitmap_offset); + header->pages_offset =3D be64_to_cpu(header->pages_offset); + + return true; +} + /* * Each of ram_save_setup, ram_save_iterate and ram_save_complete has * long-running RCU critical section. When rcu-reclaims in the code @@ -3900,6 +3935,102 @@ void colo_flush_ram_cache(void) trace_colo_flush_ram_cache_end(); } =20 +static bool read_ramblock_fixed_ram(QEMUFile *f, RAMBlock *block, + long num_pages, unsigned long *bitmap, + Error **errp) +{ + ERRP_GUARD(); + unsigned long set_bit_idx, clear_bit_idx; + ram_addr_t offset; + void *host; + size_t read, unread, size; + + for (set_bit_idx =3D find_first_bit(bitmap, num_pages); + set_bit_idx < num_pages; + set_bit_idx =3D find_next_bit(bitmap, num_pages, clear_bit_idx + = 1)) { + + clear_bit_idx =3D find_next_zero_bit(bitmap, num_pages, set_bit_id= x + 1); + + unread =3D TARGET_PAGE_SIZE * (clear_bit_idx - set_bit_idx); + offset =3D set_bit_idx << TARGET_PAGE_BITS; + + while (unread > 0) { + host =3D host_from_ram_block_offset(block, offset); + if (!host) { + error_setg(errp, "page outside of ramblock %s range", + block->idstr); + return false; + } + + size =3D MIN(unread, FIXED_RAM_LOAD_BUF_SIZE); + + read =3D qemu_get_buffer_at(f, host, size, + block->pages_offset + offset); + if (!read) { + goto err; + } + offset +=3D read; + unread -=3D read; + } + } + + return true; + +err: + qemu_file_get_error_obj(f, errp); + error_prepend(errp, "(%s) failed to read page " RAM_ADDR_FMT + "from file offset %" PRIx64 ": ", block->idstr, offset, + block->pages_offset + offset); + return false; +} + +static void parse_ramblock_fixed_ram(QEMUFile *f, RAMBlock *block, + ram_addr_t length, Error **errp) +{ + g_autofree unsigned long *bitmap =3D NULL; + FixedRamHeader header; + size_t bitmap_size; + long num_pages; + + if (!fixed_ram_read_header(f, &header, errp)) { + return; + } + + block->pages_offset =3D header.pages_offset; + + /* + * Check the alignment of the file region that contains pages. We + * don't enforce FIXED_RAM_FILE_OFFSET_ALIGNMENT to allow that + * value to change in the future. Do only a sanity check with page + * size alignment. + */ + if (!QEMU_IS_ALIGNED(block->pages_offset, TARGET_PAGE_SIZE)) { + error_setg(errp, + "Error reading ramblock %s pages, region has bad alignm= ent", + block->idstr); + return; + } + + num_pages =3D length / header.page_size; + bitmap_size =3D BITS_TO_LONGS(num_pages) * sizeof(unsigned long); + + bitmap =3D g_malloc0(bitmap_size); + if (qemu_get_buffer_at(f, (uint8_t *)bitmap, bitmap_size, + header.bitmap_offset) !=3D bitmap_size) { + error_setg(errp, "Error reading dirty bitmap"); + return; + } + + if (!read_ramblock_fixed_ram(f, block, num_pages, bitmap, errp)) { + return; + } + + /* Skip pages array */ + qemu_set_offset(f, block->pages_offset + length, SEEK_SET); + + return; +} + static int parse_ramblock(QEMUFile *f, RAMBlock *block, ram_addr_t length) { int ret =3D 0; @@ -3908,6 +4039,17 @@ static int parse_ramblock(QEMUFile *f, RAMBlock *blo= ck, ram_addr_t length) =20 assert(block); =20 + if (migrate_fixed_ram()) { + Error *local_err =3D NULL; + + parse_ramblock_fixed_ram(f, block, length, &local_err); + if (local_err) { + error_report_err(local_err); + return -EINVAL; + } + return 0; + } + if (!qemu_ram_is_migratable(block)) { error_report("block %s should not be migrated !", block->idstr); return -EINVAL; --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708468976; cv=none; d=zohomail.com; s=zohoarc; b=dq/5qvIb9ucQrR/Bxumf3TBJbynsT3KzuP299LshzHYNJpce+7+ek8mIXsVCVvzqFESzq5GpA2BitHK3EMnzTEw2V/akNaIWTMa0XSqW0xDkzYxWzZ04zoSTH3PNqpimkWBNBweIhBBjKISFYfzr8jNhZlqaH1i0ECZcoAoHLss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708468976; 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=LSbiTWWDbTpy9l2roNT+qTSBnWkmKZrMhXNYrciFAWY=; b=gA07OUiD+oAjgPyqFDYUWRa+FiV1ezYM/BVx2DLv3+TcdLYcn7HHSq9lJJSL7w3yXIV4CQKUIrhhoplF0++PxA8Bp37rVcgQbo5ox24rIXwJJdwf95vBahctR0OPuv5LedxU/4xEZqNkDa+l8ymhDDxwwv9WRCcLUdxE4PWLBsU= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708468976254185.9620271285272; Tue, 20 Feb 2024 14:42:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoi-0003KW-DM; Tue, 20 Feb 2024 17:42:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoe-0003KI-UG for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:21 -0500 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 1rcYod-0006Ld-Bs for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:20 -0500 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 192BB1FB40; Tue, 20 Feb 2024 22:42:18 +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 C403F139D0; Tue, 20 Feb 2024 22:42:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id YAtoIscq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468938; 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=LSbiTWWDbTpy9l2roNT+qTSBnWkmKZrMhXNYrciFAWY=; b=DA3bnF1ti6pMi8KGBvh9f3g9/sScVWcj8PfMEl+K6BrbWsKvduERYdsxMKoe11XMPOHKkx YLErO7nI2fZKYQU6O1tzAviaglAXx3Vwygqcgr+iUoOMAt9gFsk6MownC545yD1SAb4Tdr 3xVhaZKS40N3jwgxTG7N8pRlpWvlMwo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468938; 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=LSbiTWWDbTpy9l2roNT+qTSBnWkmKZrMhXNYrciFAWY=; b=L/C2xDhkZGOg+NtseWDv7hqPrGKCJ0Te4Th0oKgCN1A7Vk3oROr3p9HG9Tl30hb5mCPQwa yS1kATYT+84GD7CQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468938; 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=LSbiTWWDbTpy9l2roNT+qTSBnWkmKZrMhXNYrciFAWY=; b=DA3bnF1ti6pMi8KGBvh9f3g9/sScVWcj8PfMEl+K6BrbWsKvduERYdsxMKoe11XMPOHKkx YLErO7nI2fZKYQU6O1tzAviaglAXx3Vwygqcgr+iUoOMAt9gFsk6MownC545yD1SAb4Tdr 3xVhaZKS40N3jwgxTG7N8pRlpWvlMwo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468938; 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=LSbiTWWDbTpy9l2roNT+qTSBnWkmKZrMhXNYrciFAWY=; b=L/C2xDhkZGOg+NtseWDv7hqPrGKCJ0Te4Th0oKgCN1A7Vk3oROr3p9HG9Tl30hb5mCPQwa yS1kATYT+84GD7CQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 15/34] tests/qtest/migration: Add tests for fixed-ram file-based migration Date: Tue, 20 Feb 2024 19:41:19 -0300 Message-Id: <20240220224138.24759-16-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DA3bnF1t; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="L/C2xDhk" X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 192BB1FB40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708468977660100009 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- tests/qtest/migration-test.c | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 83512bce85..d61f93b151 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2200,6 +2200,14 @@ static void *test_mode_reboot_start(QTestState *from= , QTestState *to) return NULL; } =20 +static void *migrate_fixed_ram_start(QTestState *from, QTestState *to) +{ + migrate_set_capability(from, "fixed-ram", true); + migrate_set_capability(to, "fixed-ram", true); + + return NULL; +} + static void test_mode_reboot(void) { g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, @@ -2214,6 +2222,32 @@ static void test_mode_reboot(void) test_file_common(&args, true); } =20 +static void test_precopy_file_fixed_ram_live(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D migrate_fixed_ram_start, + }; + + test_file_common(&args, false); +} + +static void test_precopy_file_fixed_ram(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D migrate_fixed_ram_start, + }; + + test_file_common(&args, true); +} + static void test_precopy_tcp_plain(void) { MigrateCommon args =3D { @@ -2462,6 +2496,13 @@ static void *migrate_precopy_fd_file_start(QTestStat= e *from, QTestState *to) return NULL; } =20 +static void *migrate_fd_file_fixed_ram_start(QTestState *from, QTestState = *to) +{ + migrate_fixed_ram_start(from, to); + + return migrate_precopy_fd_file_start(from, to); +} + static void test_migrate_precopy_fd_file(void) { MigrateCommon args =3D { @@ -2472,6 +2513,17 @@ static void test_migrate_precopy_fd_file(void) }; test_file_common(&args, true); } + +static void test_migrate_precopy_fd_file_fixed_ram(void) +{ + MigrateCommon args =3D { + .listen_uri =3D "defer", + .connect_uri =3D "fd:fd-mig", + .start_hook =3D migrate_fd_file_fixed_ram_start, + .finish_hook =3D test_migrate_fd_finish_hook + }; + test_file_common(&args, true); +} #endif /* _WIN32 */ =20 static void do_test_validate_uuid(MigrateStart *args, bool should_fail) @@ -3509,6 +3561,11 @@ int main(int argc, char **argv) migration_test_add("/migration/mode/reboot", test_mode_reboot); } =20 + migration_test_add("/migration/precopy/file/fixed-ram", + test_precopy_file_fixed_ram); + migration_test_add("/migration/precopy/file/fixed-ram/live", + test_precopy_file_fixed_ram_live); + #ifdef CONFIG_GNUTLS migration_test_add("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); @@ -3570,6 +3627,8 @@ int main(int argc, char **argv) test_migrate_precopy_fd_socket); migration_test_add("/migration/precopy/fd/file", test_migrate_precopy_fd_file); + migration_test_add("/migration/precopy/fd/file/fixed-ram", + test_migrate_precopy_fd_file_fixed_ram); #endif migration_test_add("/migration/validate_uuid", test_validate_uuid); migration_test_add("/migration/validate_uuid_error", --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469099; cv=none; d=zohomail.com; s=zohoarc; b=An8tWVRVK/tpYDO3lAYzlpboJcPHQaQgG9RRYYAlLNqHnD1hdGwPjTM3b588OETU8+WuuK1F0fQuOWA5O/oY08fNAg+40At+Bpvo+GCftjz3P8d28x0BA9EPlGQrkFBxTdbF5gNFwIQEUTYymx5y09he1q7woXMq3Og/OHxXJc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469099; 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=JgoMAKXxfuxsoYEwezCWyudDOGjW1OZjXZ8SKMknqd8=; b=gF9DmC2xU4sXWkBiRpgd/Ml5MM58j3fuluj8y75mnFZeme+kvxt+m/908yNgPEQTRlO/DLBwt6M7GkSwDc5mKEXbkzDVSebxsYBTfyh1I0d7zuu1b7WlP3RFb4h/zuHGHw8RH2KqH+tn41YESuR3/yo1posZyH70tZYldFc+3+I= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469099377683.475287856511; Tue, 20 Feb 2024 14:44:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoj-0003L6-Cd; Tue, 20 Feb 2024 17:42:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoh-0003KZ-BQ for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:23 -0500 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 1rcYof-0006Lq-G2 for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:23 -0500 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 2ED6F22260; Tue, 20 Feb 2024 22:42: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 8C707139D0; Tue, 20 Feb 2024 22:42:18 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id YIv6FMoq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468940; 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=JgoMAKXxfuxsoYEwezCWyudDOGjW1OZjXZ8SKMknqd8=; b=jnR4v8XMs/qsvULFV8K3FmVrS2+SRyIRr0mG7ukGTLPB10PfjqSSW62pn6irPv3AncTLw+ nIwfjW7AtxMHDtETCWKXVyg32jMg50rIgTn22of9g6pwhuQzBOeg0qyljul1qR7iCSOHA5 K0VZID5ARv1dhyydxdr8gvw9OLWdZIs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468940; 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=JgoMAKXxfuxsoYEwezCWyudDOGjW1OZjXZ8SKMknqd8=; b=i4bBQz1kvdlNiER0B98oa/p+ouQc60Uih4AKJevBVFm8X7eOz/ClisqCGHEkwyYSSoFXsF Lb6GDwCaUDZv5lDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468940; 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=JgoMAKXxfuxsoYEwezCWyudDOGjW1OZjXZ8SKMknqd8=; b=jnR4v8XMs/qsvULFV8K3FmVrS2+SRyIRr0mG7ukGTLPB10PfjqSSW62pn6irPv3AncTLw+ nIwfjW7AtxMHDtETCWKXVyg32jMg50rIgTn22of9g6pwhuQzBOeg0qyljul1qR7iCSOHA5 K0VZID5ARv1dhyydxdr8gvw9OLWdZIs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468940; 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=JgoMAKXxfuxsoYEwezCWyudDOGjW1OZjXZ8SKMknqd8=; b=i4bBQz1kvdlNiER0B98oa/p+ouQc60Uih4AKJevBVFm8X7eOz/ClisqCGHEkwyYSSoFXsF Lb6GDwCaUDZv5lDA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 16/34] migration/multifd: Rename MultiFDSend|RecvParams::data to compress_data Date: Tue, 20 Feb 2024 19:41:20 -0300 Message-Id: <20240220224138.24759-17-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=jnR4v8XM; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=i4bBQz1k X-Spamd-Result: default: False [1.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 1.69 X-Rspamd-Queue-Id: 2ED6F22260 X-Spamd-Bar: + Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469100157100001 Content-Type: text/plain; charset="utf-8" Use a more specific name for the compression data so we can use the generic for the multifd core code. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/multifd-zlib.c | 20 ++++++++++---------- migration/multifd-zstd.c | 20 ++++++++++---------- migration/multifd.h | 4 ++-- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 012e3bdea1..2a8f5fc9a6 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -69,7 +69,7 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **= errp) err_msg =3D "out of memory for buf"; goto err_free_zbuff; } - p->data =3D z; + p->compress_data =3D z; return 0; =20 err_free_zbuff: @@ -92,15 +92,15 @@ err_free_z: */ static void zlib_send_cleanup(MultiFDSendParams *p, Error **errp) { - struct zlib_data *z =3D p->data; + struct zlib_data *z =3D p->compress_data; =20 deflateEnd(&z->zs); g_free(z->zbuff); z->zbuff =3D NULL; g_free(z->buf); z->buf =3D NULL; - g_free(p->data); - p->data =3D NULL; + g_free(p->compress_data); + p->compress_data =3D NULL; } =20 /** @@ -117,7 +117,7 @@ static void zlib_send_cleanup(MultiFDSendParams *p, Err= or **errp) static int zlib_send_prepare(MultiFDSendParams *p, Error **errp) { MultiFDPages_t *pages =3D p->pages; - struct zlib_data *z =3D p->data; + struct zlib_data *z =3D p->compress_data; z_stream *zs =3D &z->zs; uint32_t out_size =3D 0; int ret; @@ -194,7 +194,7 @@ static int zlib_recv_setup(MultiFDRecvParams *p, Error = **errp) struct zlib_data *z =3D g_new0(struct zlib_data, 1); z_stream *zs =3D &z->zs; =20 - p->data =3D z; + p->compress_data =3D z; zs->zalloc =3D Z_NULL; zs->zfree =3D Z_NULL; zs->opaque =3D Z_NULL; @@ -224,13 +224,13 @@ static int zlib_recv_setup(MultiFDRecvParams *p, Erro= r **errp) */ static void zlib_recv_cleanup(MultiFDRecvParams *p) { - struct zlib_data *z =3D p->data; + struct zlib_data *z =3D p->compress_data; =20 inflateEnd(&z->zs); g_free(z->zbuff); z->zbuff =3D NULL; - g_free(p->data); - p->data =3D NULL; + g_free(p->compress_data); + p->compress_data =3D NULL; } =20 /** @@ -246,7 +246,7 @@ static void zlib_recv_cleanup(MultiFDRecvParams *p) */ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp) { - struct zlib_data *z =3D p->data; + struct zlib_data *z =3D p->compress_data; z_stream *zs =3D &z->zs; uint32_t in_size =3D p->next_packet_size; /* we measure the change of total_out */ diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index dc8fe43e94..593cf290ad 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -52,7 +52,7 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **= errp) struct zstd_data *z =3D g_new0(struct zstd_data, 1); int res; =20 - p->data =3D z; + p->compress_data =3D z; z->zcs =3D ZSTD_createCStream(); if (!z->zcs) { g_free(z); @@ -90,14 +90,14 @@ static int zstd_send_setup(MultiFDSendParams *p, Error = **errp) */ static void zstd_send_cleanup(MultiFDSendParams *p, Error **errp) { - struct zstd_data *z =3D p->data; + struct zstd_data *z =3D p->compress_data; =20 ZSTD_freeCStream(z->zcs); z->zcs =3D NULL; g_free(z->zbuff); z->zbuff =3D NULL; - g_free(p->data); - p->data =3D NULL; + g_free(p->compress_data); + p->compress_data =3D NULL; } =20 /** @@ -114,7 +114,7 @@ static void zstd_send_cleanup(MultiFDSendParams *p, Err= or **errp) static int zstd_send_prepare(MultiFDSendParams *p, Error **errp) { MultiFDPages_t *pages =3D p->pages; - struct zstd_data *z =3D p->data; + struct zstd_data *z =3D p->compress_data; int ret; uint32_t i; =20 @@ -183,7 +183,7 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Error = **errp) struct zstd_data *z =3D g_new0(struct zstd_data, 1); int ret; =20 - p->data =3D z; + p->compress_data =3D z; z->zds =3D ZSTD_createDStream(); if (!z->zds) { g_free(z); @@ -221,14 +221,14 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Erro= r **errp) */ static void zstd_recv_cleanup(MultiFDRecvParams *p) { - struct zstd_data *z =3D p->data; + struct zstd_data *z =3D p->compress_data; =20 ZSTD_freeDStream(z->zds); z->zds =3D NULL; g_free(z->zbuff); z->zbuff =3D NULL; - g_free(p->data); - p->data =3D NULL; + g_free(p->compress_data); + p->compress_data =3D NULL; } =20 /** @@ -248,7 +248,7 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error = **errp) uint32_t out_size =3D 0; uint32_t expected_size =3D p->normal_num * p->page_size; uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; - struct zstd_data *z =3D p->data; + struct zstd_data *z =3D p->compress_data; int ret; int i; =20 diff --git a/migration/multifd.h b/migration/multifd.h index 8a1cad0996..6c18732827 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -129,7 +129,7 @@ typedef struct { /* number of iovs used */ uint32_t iovs_num; /* used for compression methods */ - void *data; + void *compress_data; } MultiFDSendParams; =20 typedef struct { @@ -185,7 +185,7 @@ typedef struct { /* num of non zero pages */ uint32_t normal_num; /* used for de-compression methods */ - void *data; + void *compress_data; } MultiFDRecvParams; =20 typedef struct { --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469046; cv=none; d=zohomail.com; s=zohoarc; b=lhg5Wr7AkiNTbq2ebHsQQN1ih+b6dNM7URM7sA1DKUc6a1BvWoG9mLgfkJb1TooMaIq6gKNTyFRv9WuJzUFxGYw61gJ+asnEErVhTufr6lHc5tHekFB8c+5BBCzefZmalU3lAryRyLBxoWCz94cRIR1eLnIHD9YIBreZNmALFGE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469046; 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=SvJm8I1xBXaGK0Zp2EyoFRQ4F01lLsPXXzvB131Og8Q=; b=A535vgp/P2i+o/J79hzyMLMk4W4/0GHLr/dFyFymPUnzWeGFt0+9hqOJq6Z/SWXG93azvi0PwjNTpCT+MGOfiXNn+fGhapzpzOTWWVNqh24xkadoLv3Cbjr2NqS0bh62zz/ulB0rUWaFXz3Pd+lfHus+0RNjkslnYnpH1KWTkts= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469046149189.58753010348653; Tue, 20 Feb 2024 14:44:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYom-0003Wg-9P; Tue, 20 Feb 2024 17:42:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYok-0003QS-Iu for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:26 -0500 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 1rcYoh-0006M1-JZ for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:25 -0500 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 478C022266; Tue, 20 Feb 2024 22:42:22 +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 A4B9E139D0; Tue, 20 Feb 2024 22:42:20 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id 4JagGswq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468942; 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=SvJm8I1xBXaGK0Zp2EyoFRQ4F01lLsPXXzvB131Og8Q=; b=ozp4hK7nr3R2hwqZL2nAcvb88evWoEEML75LTepl1EMwFuPrAe2HUkg2K/g2r13NkzgkbK Z3ECn2mRq/Mr33OiaxyyEI/MByqI+CpTtwCEslOAj63grf0xv4iz3xUXaiT9MEhpBBHobW Z+REQSytW6j/o7fRHS6xpuvLtagLyPk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468942; 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=SvJm8I1xBXaGK0Zp2EyoFRQ4F01lLsPXXzvB131Og8Q=; b=w7epwd7wYU/HdKsAPWzccHmIsuRqKPMvKqH/WNkZgXxMYXMpMbOi7HFgXMTZGSN7LRhYSh cBLboWwUjNiP5wAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468942; 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=SvJm8I1xBXaGK0Zp2EyoFRQ4F01lLsPXXzvB131Og8Q=; b=ozp4hK7nr3R2hwqZL2nAcvb88evWoEEML75LTepl1EMwFuPrAe2HUkg2K/g2r13NkzgkbK Z3ECn2mRq/Mr33OiaxyyEI/MByqI+CpTtwCEslOAj63grf0xv4iz3xUXaiT9MEhpBBHobW Z+REQSytW6j/o7fRHS6xpuvLtagLyPk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468942; 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=SvJm8I1xBXaGK0Zp2EyoFRQ4F01lLsPXXzvB131Og8Q=; b=w7epwd7wYU/HdKsAPWzccHmIsuRqKPMvKqH/WNkZgXxMYXMpMbOi7HFgXMTZGSN7LRhYSh cBLboWwUjNiP5wAg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 17/34] migration/multifd: Decouple recv method from pages Date: Tue, 20 Feb 2024 19:41:21 -0300 Message-Id: <20240220224138.24759-18-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=ozp4hK7n; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=w7epwd7w X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 478C022266 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469047962100011 Content-Type: text/plain; charset="utf-8" Next patch will abstract the type of data being received by the channels, so do some cleanup now to remove references to pages and dependency on 'normal_num'. Reviewed-by: Peter Xu Signed-off-by: Fabiano Rosas --- migration/multifd-zlib.c | 6 +++--- migration/multifd-zstd.c | 6 +++--- migration/multifd.c | 13 ++++++++----- migration/multifd.h | 4 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c index 2a8f5fc9a6..6120faad65 100644 --- a/migration/multifd-zlib.c +++ b/migration/multifd-zlib.c @@ -234,7 +234,7 @@ static void zlib_recv_cleanup(MultiFDRecvParams *p) } =20 /** - * zlib_recv_pages: read the data from the channel into actual pages + * zlib_recv: read the data from the channel into actual pages * * Read the compressed buffer, and uncompress it into the actual * pages. @@ -244,7 +244,7 @@ static void zlib_recv_cleanup(MultiFDRecvParams *p) * @p: Params for the channel that we are using * @errp: pointer to an error */ -static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp) +static int zlib_recv(MultiFDRecvParams *p, Error **errp) { struct zlib_data *z =3D p->compress_data; z_stream *zs =3D &z->zs; @@ -319,7 +319,7 @@ static MultiFDMethods multifd_zlib_ops =3D { .send_prepare =3D zlib_send_prepare, .recv_setup =3D zlib_recv_setup, .recv_cleanup =3D zlib_recv_cleanup, - .recv_pages =3D zlib_recv_pages + .recv =3D zlib_recv }; =20 static void multifd_zlib_register(void) diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c index 593cf290ad..cac236833d 100644 --- a/migration/multifd-zstd.c +++ b/migration/multifd-zstd.c @@ -232,7 +232,7 @@ static void zstd_recv_cleanup(MultiFDRecvParams *p) } =20 /** - * zstd_recv_pages: read the data from the channel into actual pages + * zstd_recv: read the data from the channel into actual pages * * Read the compressed buffer, and uncompress it into the actual * pages. @@ -242,7 +242,7 @@ static void zstd_recv_cleanup(MultiFDRecvParams *p) * @p: Params for the channel that we are using * @errp: pointer to an error */ -static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp) +static int zstd_recv(MultiFDRecvParams *p, Error **errp) { uint32_t in_size =3D p->next_packet_size; uint32_t out_size =3D 0; @@ -310,7 +310,7 @@ static MultiFDMethods multifd_zstd_ops =3D { .send_prepare =3D zstd_send_prepare, .recv_setup =3D zstd_recv_setup, .recv_cleanup =3D zstd_recv_cleanup, - .recv_pages =3D zstd_recv_pages + .recv =3D zstd_recv }; =20 static void multifd_zstd_register(void) diff --git a/migration/multifd.c b/migration/multifd.c index 43f0820996..5a38cb222f 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -197,7 +197,7 @@ static void nocomp_recv_cleanup(MultiFDRecvParams *p) } =20 /** - * nocomp_recv_pages: read the data from the channel into actual pages + * nocomp_recv: read the data from the channel * * For no compression we just need to read things into the correct place. * @@ -206,7 +206,7 @@ static void nocomp_recv_cleanup(MultiFDRecvParams *p) * @p: Params for the channel that we are using * @errp: pointer to an error */ -static int nocomp_recv_pages(MultiFDRecvParams *p, Error **errp) +static int nocomp_recv(MultiFDRecvParams *p, Error **errp) { uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; =20 @@ -228,7 +228,7 @@ static MultiFDMethods multifd_nocomp_ops =3D { .send_prepare =3D nocomp_send_prepare, .recv_setup =3D nocomp_recv_setup, .recv_cleanup =3D nocomp_recv_cleanup, - .recv_pages =3D nocomp_recv_pages + .recv =3D nocomp_recv }; =20 static MultiFDMethods *multifd_ops[MULTIFD_COMPRESSION__MAX] =3D { @@ -1216,6 +1216,8 @@ static void *multifd_recv_thread(void *opaque) =20 while (true) { uint32_t flags; + bool has_data =3D false; + p->normal_num =3D 0; =20 if (multifd_recv_should_exit()) { break; @@ -1237,10 +1239,11 @@ static void *multifd_recv_thread(void *opaque) flags =3D p->flags; /* recv methods don't know how to handle the SYNC flag */ p->flags &=3D ~MULTIFD_FLAG_SYNC; + has_data =3D !!p->normal_num; qemu_mutex_unlock(&p->mutex); =20 - if (p->normal_num) { - ret =3D multifd_recv_state->ops->recv_pages(p, &local_err); + if (has_data) { + ret =3D multifd_recv_state->ops->recv(p, &local_err); if (ret !=3D 0) { break; } diff --git a/migration/multifd.h b/migration/multifd.h index 6c18732827..9a6a7a72df 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -199,8 +199,8 @@ typedef struct { int (*recv_setup)(MultiFDRecvParams *p, Error **errp); /* Cleanup for receiving side */ void (*recv_cleanup)(MultiFDRecvParams *p); - /* Read all pages */ - int (*recv_pages)(MultiFDRecvParams *p, Error **errp); + /* Read all data */ + int (*recv)(MultiFDRecvParams *p, Error **errp); } MultiFDMethods; =20 void multifd_register_ops(int method, MultiFDMethods *ops); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708468984; cv=none; d=zohomail.com; s=zohoarc; b=nnnLrk7ZaClgKQ8hFixwVCGOJq9ZCx9lSNpMJIxRbJpjfcZjY11rzOB5znc9bwcvR1o2EgVVal8S4+wjene0z3UePUTz20+SHGK5THVo7l8UybZ06RwDjyzAeF+9+baq03QHazMr27L4GDSWnOLSSgKMBykrdWlY8u2HpDp743k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708468984; 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=roA3OXpZofT2fbHnP+m3tl4hTXx3L+tbHCf+EzzaWDE=; b=UDJ7g51TxBlVxqwQK2MP04GEvq0kZufyD1r9YteGFhfnIu6F+NoY7fan+zg0c7nPxVqGpTNQTcKC5Ksrc0kLhTnZu5zL18l2tD06aLxca40Ggx/+DdLdaSYEx29+esCvVidW1jQ83Bo6WTNhgrM3RCJy3/P+Z7EkY3SJtTJ4krQ= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708468984954247.20513816124947; Tue, 20 Feb 2024 14:43:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoq-0003fF-Mz; Tue, 20 Feb 2024 17:42:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYom-0003YB-Iz for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:29 -0500 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 1rcYok-0006MD-9D for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:28 -0500 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 5B8DF22260; Tue, 20 Feb 2024 22:42: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 B8852139D0; Tue, 20 Feb 2024 22:42:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id gDK/H84q1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468944; 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=roA3OXpZofT2fbHnP+m3tl4hTXx3L+tbHCf+EzzaWDE=; b=wJEvdIbU2iY4lIivQhQHQMja2xX+cLghPmjqLUkdXXwtmvFJS75Iyrh86KAy+OF09Y0pML an5eiZ692AGdN7NSVf9b50GR0U5TRm96Zb4vaRH4pNmJTNjnGfxJvm4z9KYMOhhxCBlg63 dpdLir6Abyf9RLDVpm153ReNUK4LroU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468944; 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=roA3OXpZofT2fbHnP+m3tl4hTXx3L+tbHCf+EzzaWDE=; b=j0r4Cqd5E2b1d95eSjWsnUJ312xx7wocuxE2WFmvXzMxlGQqXGDrRXRHmrHlxJGuVUYWUr rDF6KWLU4B0himDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468944; 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=roA3OXpZofT2fbHnP+m3tl4hTXx3L+tbHCf+EzzaWDE=; b=wJEvdIbU2iY4lIivQhQHQMja2xX+cLghPmjqLUkdXXwtmvFJS75Iyrh86KAy+OF09Y0pML an5eiZ692AGdN7NSVf9b50GR0U5TRm96Zb4vaRH4pNmJTNjnGfxJvm4z9KYMOhhxCBlg63 dpdLir6Abyf9RLDVpm153ReNUK4LroU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468944; 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=roA3OXpZofT2fbHnP+m3tl4hTXx3L+tbHCf+EzzaWDE=; b=j0r4Cqd5E2b1d95eSjWsnUJ312xx7wocuxE2WFmvXzMxlGQqXGDrRXRHmrHlxJGuVUYWUr rDF6KWLU4B0himDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 18/34] migration/multifd: Allow multifd without packets Date: Tue, 20 Feb 2024 19:41:22 -0300 Message-Id: <20240220224138.24759-19-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=wJEvdIbU; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=j0r4Cqd5 X-Spamd-Result: default: False [1.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; R_RATELIMIT(0.00)[to_ip_from(RLi3368pnyb3ujpcs6u1hud8b3)]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 1.69 X-Rspamd-Queue-Id: 5B8DF22260 X-Spamd-Bar: + Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708468985817100001 Content-Type: text/plain; charset="utf-8" For the upcoming support to the new 'fixed-ram' migration stream format, we cannot use multifd packets because each write into the ramblock section in the migration file is expected to contain only the guest pages. They are written at their respective offsets relative to the ramblock section header. There is no space for the packet information and the expected gains from the new approach come partly from being able to write the pages sequentially without extraneous data in between. The new format also simply doesn't need the packets and all necessary information can be taken from the standard migration headers with some (future) changes to multifd code. Use the presence of the fixed-ram capability to decide whether to send packets. This only moves code under multifd_use_packets(), it has no effect for now as fixed-ram cannot yet be enabled with multifd. Signed-off-by: Fabiano Rosas --- migration/multifd.c | 188 +++++++++++++++++++++++++++----------------- 1 file changed, 117 insertions(+), 71 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 5a38cb222f..0a5279314d 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -92,6 +92,11 @@ struct { MultiFDMethods *ops; } *multifd_recv_state; =20 +static bool multifd_use_packets(void) +{ + return !migrate_fixed_ram(); +} + /* Multifd without compression */ =20 /** @@ -136,10 +141,11 @@ static void nocomp_send_cleanup(MultiFDSendParams *p,= Error **errp) static int nocomp_send_prepare(MultiFDSendParams *p, Error **errp) { bool use_zero_copy_send =3D migrate_zero_copy_send(); + bool use_packets =3D multifd_use_packets(); MultiFDPages_t *pages =3D p->pages; int ret; =20 - if (!use_zero_copy_send) { + if (!use_zero_copy_send && use_packets) { /* * Only !zerocopy needs the header in IOV; zerocopy will * send it separately. @@ -156,14 +162,16 @@ static int nocomp_send_prepare(MultiFDSendParams *p, = Error **errp) p->next_packet_size =3D pages->num * p->page_size; p->flags |=3D MULTIFD_FLAG_NOCOMP; =20 - multifd_send_fill_packet(p); + if (use_packets) { + multifd_send_fill_packet(p); =20 - if (use_zero_copy_send) { - /* Send header first, without zerocopy */ - ret =3D qio_channel_write_all(p->c, (void *)p->packet, - p->packet_len, errp); - if (ret !=3D 0) { - return -1; + if (use_zero_copy_send) { + /* Send header first, without zerocopy */ + ret =3D qio_channel_write_all(p->c, (void *)p->packet, + p->packet_len, errp); + if (ret !=3D 0) { + return -1; + } } } =20 @@ -215,11 +223,16 @@ static int nocomp_recv(MultiFDRecvParams *p, Error **= errp) p->id, flags, MULTIFD_FLAG_NOCOMP); return -1; } - for (int i =3D 0; i < p->normal_num; i++) { - p->iov[i].iov_base =3D p->host + p->normal[i]; - p->iov[i].iov_len =3D p->page_size; + + if (multifd_use_packets()) { + for (int i =3D 0; i < p->normal_num; i++) { + p->iov[i].iov_base =3D p->host + p->normal[i]; + p->iov[i].iov_len =3D p->page_size; + } + return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); } - return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); + + return 0; } =20 static MultiFDMethods multifd_nocomp_ops =3D { @@ -799,15 +812,18 @@ static void *multifd_send_thread(void *opaque) MigrationThread *thread =3D NULL; Error *local_err =3D NULL; int ret =3D 0; + bool use_packets =3D multifd_use_packets(); =20 thread =3D migration_threads_add(p->name, qemu_get_thread_id()); =20 trace_multifd_send_thread_start(p->id); rcu_register_thread(); =20 - if (multifd_send_initial_packet(p, &local_err) < 0) { - ret =3D -1; - goto out; + if (use_packets) { + if (multifd_send_initial_packet(p, &local_err) < 0) { + ret =3D -1; + goto out; + } } =20 while (true) { @@ -858,16 +874,20 @@ static void *multifd_send_thread(void *opaque) * it doesn't require explicit memory barriers. */ assert(qatomic_read(&p->pending_sync)); - p->flags =3D MULTIFD_FLAG_SYNC; - multifd_send_fill_packet(p); - ret =3D qio_channel_write_all(p->c, (void *)p->packet, - p->packet_len, &local_err); - if (ret !=3D 0) { - break; + + if (use_packets) { + p->flags =3D MULTIFD_FLAG_SYNC; + multifd_send_fill_packet(p); + ret =3D qio_channel_write_all(p->c, (void *)p->packet, + p->packet_len, &local_err); + if (ret !=3D 0) { + break; + } + /* p->next_packet_size will always be zero for a SYNC pack= et */ + stat64_add(&mig_stats.multifd_bytes, p->packet_len); + p->flags =3D 0; } - /* p->next_packet_size will always be zero for a SYNC packet */ - stat64_add(&mig_stats.multifd_bytes, p->packet_len); - p->flags =3D 0; + qatomic_set(&p->pending_sync, false); qemu_sem_post(&p->sem_sync); } @@ -1016,6 +1036,7 @@ bool multifd_send_setup(void) Error *local_err =3D NULL; int thread_count, ret =3D 0; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + bool use_packets =3D multifd_use_packets(); uint8_t i; =20 if (!migrate_multifd()) { @@ -1038,27 +1059,35 @@ bool multifd_send_setup(void) qemu_sem_init(&p->sem_sync, 0); p->id =3D i; p->pages =3D multifd_pages_init(page_count); - p->packet_len =3D sizeof(MultiFDPacket_t) - + sizeof(uint64_t) * page_count; - p->packet =3D g_malloc0(p->packet_len); - p->packet->magic =3D cpu_to_be32(MULTIFD_MAGIC); - p->packet->version =3D cpu_to_be32(MULTIFD_VERSION); + + if (use_packets) { + p->packet_len =3D sizeof(MultiFDPacket_t) + + sizeof(uint64_t) * page_count; + p->packet =3D g_malloc0(p->packet_len); + p->packet->magic =3D cpu_to_be32(MULTIFD_MAGIC); + p->packet->version =3D cpu_to_be32(MULTIFD_VERSION); + + /* We need one extra place for the packet header */ + p->iov =3D g_new0(struct iovec, page_count + 1); + } else { + p->iov =3D g_new0(struct iovec, page_count); + } p->name =3D g_strdup_printf("multifdsend_%d", i); - /* We need one extra place for the packet header */ - p->iov =3D g_new0(struct iovec, page_count + 1); p->page_size =3D qemu_target_page_size(); p->page_count =3D page_count; p->write_flags =3D 0; multifd_new_send_channel_create(p); } =20 - /* - * Wait until channel creation has started for all channels. The - * creation can still fail, but no more channels will be created - * past this point. - */ - for (i =3D 0; i < thread_count; i++) { - qemu_sem_wait(&multifd_send_state->channels_created); + if (use_packets) { + /* + * Wait until channel creation has started for all channels. The + * creation can still fail, but no more channels will be created + * past this point. + */ + for (i =3D 0; i < thread_count; i++) { + qemu_sem_wait(&multifd_send_state->channels_created); + } } =20 for (i =3D 0; i < thread_count; i++) { @@ -1108,7 +1137,9 @@ static void multifd_recv_terminate_threads(Error *err) * multifd_recv_thread may hung at MULTIFD_FLAG_SYNC handle code, * however try to wakeup it without harm in cleanup phase. */ - qemu_sem_post(&p->sem_sync); + if (multifd_use_packets()) { + qemu_sem_post(&p->sem_sync); + } =20 /* * We could arrive here for two reasons: @@ -1182,7 +1213,7 @@ void multifd_recv_sync_main(void) { int i; =20 - if (!migrate_multifd()) { + if (!migrate_multifd() || !multifd_use_packets()) { return; } for (i =3D 0; i < migrate_multifd_channels(); i++) { @@ -1209,13 +1240,14 @@ static void *multifd_recv_thread(void *opaque) { MultiFDRecvParams *p =3D opaque; Error *local_err =3D NULL; + bool use_packets =3D multifd_use_packets(); int ret; =20 trace_multifd_recv_thread_start(p->id); rcu_register_thread(); =20 while (true) { - uint32_t flags; + uint32_t flags =3D 0; bool has_data =3D false; p->normal_num =3D 0; =20 @@ -1223,25 +1255,27 @@ static void *multifd_recv_thread(void *opaque) break; } =20 - ret =3D qio_channel_read_all_eof(p->c, (void *)p->packet, - p->packet_len, &local_err); - if (ret =3D=3D 0 || ret =3D=3D -1) { /* 0: EOF -1: Error */ - break; - } + if (use_packets) { + ret =3D qio_channel_read_all_eof(p->c, (void *)p->packet, + p->packet_len, &local_err); + if (ret =3D=3D 0 || ret =3D=3D -1) { /* 0: EOF -1: Error */ + break; + } =20 - qemu_mutex_lock(&p->mutex); - ret =3D multifd_recv_unfill_packet(p, &local_err); - if (ret) { + qemu_mutex_lock(&p->mutex); + ret =3D multifd_recv_unfill_packet(p, &local_err); + if (ret) { + qemu_mutex_unlock(&p->mutex); + break; + } + + flags =3D p->flags; + /* recv methods don't know how to handle the SYNC flag */ + p->flags &=3D ~MULTIFD_FLAG_SYNC; + has_data =3D !!p->normal_num; qemu_mutex_unlock(&p->mutex); - break; } =20 - flags =3D p->flags; - /* recv methods don't know how to handle the SYNC flag */ - p->flags &=3D ~MULTIFD_FLAG_SYNC; - has_data =3D !!p->normal_num; - qemu_mutex_unlock(&p->mutex); - if (has_data) { ret =3D multifd_recv_state->ops->recv(p, &local_err); if (ret !=3D 0) { @@ -1249,9 +1283,11 @@ static void *multifd_recv_thread(void *opaque) } } =20 - if (flags & MULTIFD_FLAG_SYNC) { - qemu_sem_post(&multifd_recv_state->sem_sync); - qemu_sem_wait(&p->sem_sync); + if (use_packets) { + if (flags & MULTIFD_FLAG_SYNC) { + qemu_sem_post(&multifd_recv_state->sem_sync); + qemu_sem_wait(&p->sem_sync); + } } } =20 @@ -1270,6 +1306,7 @@ int multifd_recv_setup(Error **errp) { int thread_count; uint32_t page_count =3D MULTIFD_PACKET_SIZE / qemu_target_page_size(); + bool use_packets =3D multifd_use_packets(); uint8_t i; =20 /* @@ -1294,9 +1331,12 @@ int multifd_recv_setup(Error **errp) qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem_sync, 0); p->id =3D i; - p->packet_len =3D sizeof(MultiFDPacket_t) - + sizeof(uint64_t) * page_count; - p->packet =3D g_malloc0(p->packet_len); + + if (use_packets) { + p->packet_len =3D sizeof(MultiFDPacket_t) + + sizeof(uint64_t) * page_count; + p->packet =3D g_malloc0(p->packet_len); + } p->name =3D g_strdup_printf("multifdrecv_%d", i); p->iov =3D g_new0(struct iovec, page_count); p->normal =3D g_new0(ram_addr_t, page_count); @@ -1340,18 +1380,24 @@ void multifd_recv_new_channel(QIOChannel *ioc, Erro= r **errp) { MultiFDRecvParams *p; Error *local_err =3D NULL; + bool use_packets =3D multifd_use_packets(); int id; =20 - id =3D multifd_recv_initial_packet(ioc, &local_err); - if (id < 0) { - multifd_recv_terminate_threads(local_err); - error_propagate_prepend(errp, local_err, - "failed to receive packet" - " via multifd channel %d: ", - qatomic_read(&multifd_recv_state->count)); - return; + if (use_packets) { + id =3D multifd_recv_initial_packet(ioc, &local_err); + if (id < 0) { + multifd_recv_terminate_threads(local_err); + error_propagate_prepend(errp, local_err, + "failed to receive packet" + " via multifd channel %d: ", + qatomic_read(&multifd_recv_state->coun= t)); + return; + } + trace_multifd_recv_new_channel(id); + } else { + /* next patch gives this a meaningful value */ + id =3D 0; } - trace_multifd_recv_new_channel(id); =20 p =3D &multifd_recv_state->params[id]; if (p->c !=3D NULL) { --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469020; cv=none; d=zohomail.com; s=zohoarc; b=VbsqOkA7KapD+//DbngLGZvSjN326VNG20PJIeHtyjCw23GTcyWxjFwdFIaF24McBH0FjC0deSVb/u3xthY4XVI7OXs3Qswr8+/9Bv1WmTp+nYlyc9KM7wRcMrdtXvo/Qr0U30Qm7jivP9NoYKeVB9OtpOV66Xpf/uQY2EQ59SU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469020; 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=UenDAZ738sri/YmAXwitcXH7YXeGtm0e2QfiSBYnaYc=; b=fk3TWlOrmd2N/z5wYc8s5MstDS/OW7IkgUeGU7KtJqVks/TWS/SYbG8RVOJQLFHsPvkTYQ9RJsejsVDhwOUVnzRehNJvVINGAli50YrZA/Kmd4S280O0Ke6jYdpSJxzjWUT/sRIBhaHM7KLjbugq8i2yDw63ts4YAuMHorTkzr4= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170846902029553.000560242904044; Tue, 20 Feb 2024 14:43:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYou-0004Fd-V9; Tue, 20 Feb 2024 17:42:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYop-0003fl-Dh for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:32 -0500 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 1rcYol-0006MN-QA for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:30 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 7DE031FB40; Tue, 20 Feb 2024 22:42:26 +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 D28C0139D0; Tue, 20 Feb 2024 22:42:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id CHd+JdAq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468946; 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=UenDAZ738sri/YmAXwitcXH7YXeGtm0e2QfiSBYnaYc=; b=L4ONCg7Ic5eKWt4l18yl1QMJ0YKGH76gu6ol/6TSck/Bqvrm3K/JDmCkELQCeOWdOd4As1 PjQvYePTq65XWNKHb+ZM8WRATZqYaQOnRRyxz01OrEMaZSgTumuTyg7w5sIhFEwsQUXeUJ IHyGQNokYIQvG7obqobcEIAqV/a7zug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468946; 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=UenDAZ738sri/YmAXwitcXH7YXeGtm0e2QfiSBYnaYc=; b=7n1f76YQ6DlVBlWWkHIjQJCRSru3yiQ73Rglx51hAVQF5qMMfncpOH459J3u4xYKhB4Nz2 j5HxJglnkYZ+1OAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468946; 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=UenDAZ738sri/YmAXwitcXH7YXeGtm0e2QfiSBYnaYc=; b=L4ONCg7Ic5eKWt4l18yl1QMJ0YKGH76gu6ol/6TSck/Bqvrm3K/JDmCkELQCeOWdOd4As1 PjQvYePTq65XWNKHb+ZM8WRATZqYaQOnRRyxz01OrEMaZSgTumuTyg7w5sIhFEwsQUXeUJ IHyGQNokYIQvG7obqobcEIAqV/a7zug= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468946; 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=UenDAZ738sri/YmAXwitcXH7YXeGtm0e2QfiSBYnaYc=; b=7n1f76YQ6DlVBlWWkHIjQJCRSru3yiQ73Rglx51hAVQF5qMMfncpOH459J3u4xYKhB4Nz2 j5HxJglnkYZ+1OAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 19/34] migration/multifd: Allow receiving pages without packets Date: Tue, 20 Feb 2024 19:41:23 -0300 Message-Id: <20240220224138.24759-20-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [1.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 1.90 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469021929100001 Content-Type: text/plain; charset="utf-8" Currently multifd does not need to have knowledge of pages on the receiving side because all the information needed is within the packets that come in the stream. We're about to add support to fixed-ram migration, which cannot use packets because it expects the ramblock section in the migration file to contain only the guest pages data. Add a data structure to transfer pages between the ram migration code and the multifd receiving threads. We don't want to reuse MultiFDPages_t for two reasons: a) multifd threads don't really need to know about the data they're receiving. b) the receiving side has to be stopped to load the pages, which means we can experiment with larger granularities than page size when transferring data. Signed-off-by: Fabiano Rosas --- @Peter: a 'quit' flag cannot be used instead of pending_job. The receiving thread needs know there's no more data coming. If the migration thread sets a 'quit' flag, the multifd thread would see the flag right away and exit. The only way is to clear pending_job on the thread and spin once more. --- migration/file.c | 1 + migration/multifd.c | 122 +++++++++++++++++++++++++++++++++++++++++--- migration/multifd.h | 15 ++++++ 3 files changed, 131 insertions(+), 7 deletions(-) diff --git a/migration/file.c b/migration/file.c index 5d4975f43e..22d052a71f 100644 --- a/migration/file.c +++ b/migration/file.c @@ -6,6 +6,7 @@ */ =20 #include "qemu/osdep.h" +#include "exec/ramblock.h" #include "qemu/cutils.h" #include "qapi/error.h" #include "channel.h" diff --git a/migration/multifd.c b/migration/multifd.c index 0a5279314d..45a0c7aaa8 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -81,9 +81,15 @@ struct { =20 struct { MultiFDRecvParams *params; + MultiFDRecvData *data; /* number of created threads */ int count; - /* syncs main thread and channels */ + /* + * For sockets: this is posted once for each MULTIFD_FLAG_SYNC flag. + * + * For files: this is only posted at the end of the file load to mark + * completion of the load process. + */ QemuSemaphore sem_sync; /* global number of generated multifd packets */ uint64_t packet_num; @@ -1110,6 +1116,53 @@ bool multifd_send_setup(void) return true; } =20 +bool multifd_recv(void) +{ + int i; + static int next_recv_channel; + MultiFDRecvParams *p =3D NULL; + MultiFDRecvData *data =3D multifd_recv_state->data; + + /* + * next_channel can remain from a previous migration that was + * using more channels, so ensure it doesn't overflow if the + * limit is lower now. + */ + next_recv_channel %=3D migrate_multifd_channels(); + for (i =3D next_recv_channel;; i =3D (i + 1) % migrate_multifd_channel= s()) { + if (multifd_recv_should_exit()) { + return false; + } + + p =3D &multifd_recv_state->params[i]; + + /* + * Safe to read atomically without a lock because the flag is + * only set by this function below. Reading an old value of + * true is not an issue because it would only send us looking + * for the next idle channel. + */ + if (qatomic_read(&p->pending_job) =3D=3D false) { + next_recv_channel =3D (i + 1) % migrate_multifd_channels(); + break; + } + } + + assert(!p->data->size); + multifd_recv_state->data =3D p->data; + p->data =3D data; + + qatomic_set(&p->pending_job, true); + qemu_sem_post(&p->sem); + + return true; +} + +MultiFDRecvData *multifd_get_recv_data(void) +{ + return multifd_recv_state->data; +} + static void multifd_recv_terminate_threads(Error *err) { int i; @@ -1134,11 +1187,26 @@ static void multifd_recv_terminate_threads(Error *e= rr) MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 /* - * multifd_recv_thread may hung at MULTIFD_FLAG_SYNC handle code, - * however try to wakeup it without harm in cleanup phase. + * The migration thread and channels interact differently + * depending on the presence of packets. */ if (multifd_use_packets()) { + /* + * The channel receives as long as there are packets. When + * packets end (i.e. MULTIFD_FLAG_SYNC is reached), the + * channel waits for the migration thread to sync. If the + * sync never happens, do it here. + */ qemu_sem_post(&p->sem_sync); + } else { + /* + * The channel waits for the migration thread to give it + * work. When the migration thread runs out of work, it + * releases the channel and waits for any pending work to + * finish. If we reach here (e.g. due to error) before the + * work runs out, release the channel. + */ + qemu_sem_post(&p->sem); } =20 /* @@ -1167,6 +1235,7 @@ static void multifd_recv_cleanup_channel(MultiFDRecvP= arams *p) p->c =3D NULL; qemu_mutex_destroy(&p->mutex); qemu_sem_destroy(&p->sem_sync); + qemu_sem_destroy(&p->sem); g_free(p->name); p->name =3D NULL; p->packet_len =3D 0; @@ -1184,6 +1253,8 @@ static void multifd_recv_cleanup_state(void) qemu_sem_destroy(&multifd_recv_state->sem_sync); g_free(multifd_recv_state->params); multifd_recv_state->params =3D NULL; + g_free(multifd_recv_state->data); + multifd_recv_state->data =3D NULL; g_free(multifd_recv_state); multifd_recv_state =3D NULL; } @@ -1251,11 +1322,11 @@ static void *multifd_recv_thread(void *opaque) bool has_data =3D false; p->normal_num =3D 0; =20 - if (multifd_recv_should_exit()) { - break; - } - if (use_packets) { + if (multifd_recv_should_exit()) { + break; + } + ret =3D qio_channel_read_all_eof(p->c, (void *)p->packet, p->packet_len, &local_err); if (ret =3D=3D 0 || ret =3D=3D -1) { /* 0: EOF -1: Error */ @@ -1274,6 +1345,26 @@ static void *multifd_recv_thread(void *opaque) p->flags &=3D ~MULTIFD_FLAG_SYNC; has_data =3D !!p->normal_num; qemu_mutex_unlock(&p->mutex); + } else { + /* + * No packets, so we need to wait for the vmstate code to + * give us work. + */ + qemu_sem_wait(&p->sem); + + if (multifd_recv_should_exit()) { + break; + } + + /* + * Migration thread did not send work, break and signal + * sem_sync so it knows we're not lagging behind. + */ + if (!qatomic_read(&p->pending_job)) { + break; + } + + has_data =3D !!p->data->size; } =20 if (has_data) { @@ -1288,9 +1379,17 @@ static void *multifd_recv_thread(void *opaque) qemu_sem_post(&multifd_recv_state->sem_sync); qemu_sem_wait(&p->sem_sync); } + } else { + p->total_normal_pages +=3D p->data->size / qemu_target_page_si= ze(); + p->data->size =3D 0; + qatomic_set(&p->pending_job, false); } } =20 + if (!use_packets) { + qemu_sem_post(&p->sem_sync); + } + if (local_err) { multifd_recv_terminate_threads(local_err); error_free(local_err); @@ -1320,6 +1419,10 @@ int multifd_recv_setup(Error **errp) thread_count =3D migrate_multifd_channels(); multifd_recv_state =3D g_malloc0(sizeof(*multifd_recv_state)); multifd_recv_state->params =3D g_new0(MultiFDRecvParams, thread_count); + + multifd_recv_state->data =3D g_new0(MultiFDRecvData, 1); + multifd_recv_state->data->size =3D 0; + qatomic_set(&multifd_recv_state->count, 0); qatomic_set(&multifd_recv_state->exiting, 0); qemu_sem_init(&multifd_recv_state->sem_sync, 0); @@ -1330,8 +1433,13 @@ int multifd_recv_setup(Error **errp) =20 qemu_mutex_init(&p->mutex); qemu_sem_init(&p->sem_sync, 0); + qemu_sem_init(&p->sem, 0); + p->pending_job =3D false; p->id =3D i; =20 + p->data =3D g_new0(MultiFDRecvData, 1); + p->data->size =3D 0; + if (use_packets) { p->packet_len =3D sizeof(MultiFDPacket_t) + sizeof(uint64_t) * page_count; diff --git a/migration/multifd.h b/migration/multifd.h index 9a6a7a72df..19188815a3 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -13,6 +13,8 @@ #ifndef QEMU_MIGRATION_MULTIFD_H #define QEMU_MIGRATION_MULTIFD_H =20 +typedef struct MultiFDRecvData MultiFDRecvData; + bool multifd_send_setup(void); void multifd_send_shutdown(void); int multifd_recv_setup(Error **errp); @@ -23,6 +25,8 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error **er= rp); void multifd_recv_sync_main(void); int multifd_send_sync_main(void); bool multifd_queue_page(RAMBlock *block, ram_addr_t offset); +bool multifd_recv(void); +MultiFDRecvData *multifd_get_recv_data(void); =20 /* Multifd Compression flags */ #define MULTIFD_FLAG_SYNC (1 << 0) @@ -63,6 +67,13 @@ typedef struct { RAMBlock *block; } MultiFDPages_t; =20 +struct MultiFDRecvData { + void *opaque; + size_t size; + /* for preadv */ + off_t file_offset; +}; + typedef struct { /* Fields are only written at creating/deletion time */ /* No lock required for them, they are read only */ @@ -154,6 +165,8 @@ typedef struct { =20 /* syncs main thread and channels */ QemuSemaphore sem_sync; + /* sem where to wait for more work */ + QemuSemaphore sem; =20 /* this mutex protects the following parameters */ QemuMutex mutex; @@ -163,6 +176,8 @@ typedef struct { uint32_t flags; /* global number of generated multifd packets */ uint64_t packet_num; + int pending_job; + MultiFDRecvData *data; =20 /* thread local variables. No locking required */ =20 --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469001; cv=none; d=zohomail.com; s=zohoarc; b=WnSuKJF8yTKisAhQU+605A87w1nrh2Th7yVszEvTild7+DywHMuwCMs9PX4umcwR6N33Ef7s6ZUxhPoKOzEelU6n2lB/ovGqvcxlfLjurzHXZEMejRJYQLMzQOE7b9J/J+w8nsrz1+icW3v3bq1vccmYY2KaYZaVoe40PfOBQW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469001; 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=ohuWdlJcu0dwg63rQ3ay7lscIVfrPEECXbytyXa4Byw=; b=I6OY57M05l/XhA7T7VMtKSQavh46CHFhxC7aZDXXvUN89JPxIprHJ6chMVf7np33ZQHgP+YhL+g60St/XDivQcv60BavDaA3TpNOr9rx8wJsX9hUQ304xq9Ee2y+GRXPeI/Xd+6dqr9qLopxDjSGsF5mqNCSHl4hGiPjYq3HECc= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469001491366.7269085302312; Tue, 20 Feb 2024 14:43:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYos-0003y3-1y; Tue, 20 Feb 2024 17:42:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYop-0003lc-Vw for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:32 -0500 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 1rcYon-0006MW-VP for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:31 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 892771FD64; Tue, 20 Feb 2024 22:42: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 E9814139D0; Tue, 20 Feb 2024 22:42:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id uPRjK9Iq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468948; 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=ohuWdlJcu0dwg63rQ3ay7lscIVfrPEECXbytyXa4Byw=; b=vzSJjL7oaYezfUeGKKsClcvWOsdX4jPOKFZcGDSLkvxq/qED2+dCHp1sWgMZc6dzedKteU GNWQ34ChppQKAESkGQTpTdXvO1xa8GO44EBFBM/NCD+2a3cjzw8xu55Lb6O98AAOYzV47m 53Kva+3gx68c4mLvbFFd1PL86iP2xsw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468948; 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=ohuWdlJcu0dwg63rQ3ay7lscIVfrPEECXbytyXa4Byw=; b=Z0VGOhAK6eyxeDnqW8ZogkQWNrqwP8wD8q3pWGPITYZToMX74wgN6XYfgWh4Ibl7cOOGnc /WpkuN0G09KOqKDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468948; 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=ohuWdlJcu0dwg63rQ3ay7lscIVfrPEECXbytyXa4Byw=; b=vzSJjL7oaYezfUeGKKsClcvWOsdX4jPOKFZcGDSLkvxq/qED2+dCHp1sWgMZc6dzedKteU GNWQ34ChppQKAESkGQTpTdXvO1xa8GO44EBFBM/NCD+2a3cjzw8xu55Lb6O98AAOYzV47m 53Kva+3gx68c4mLvbFFd1PL86iP2xsw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468948; 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=ohuWdlJcu0dwg63rQ3ay7lscIVfrPEECXbytyXa4Byw=; b=Z0VGOhAK6eyxeDnqW8ZogkQWNrqwP8wD8q3pWGPITYZToMX74wgN6XYfgWh4Ibl7cOOGnc /WpkuN0G09KOqKDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 20/34] migration/multifd: Add outgoing QIOChannelFile support Date: Tue, 20 Feb 2024 19:41:24 -0300 Message-Id: <20240220224138.24759-21-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [1.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 1.90 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469001930100001 Content-Type: text/plain; charset="utf-8" Allow multifd to open file-backed channels. This will be used when enabling the fixed-ram migration stream format which expects a seekable transport. The QIOChannel read and write methods will use the preadv/pwritev versions which don't update the file offset at each call so we can reuse the fd without re-opening for every channel. Contrary to the socket migration, the file migration doesn't need an asynchronous channel creation process, so expose multifd_channel_connect() and call it directly. Note that this is just setup code and multifd cannot yet make use of the file channels. Signed-off-by: Fabiano Rosas --- migration/file.c | 40 ++++++++++++++++++++++++++++++++++++++-- migration/file.h | 5 +++++ migration/multifd.c | 27 ++++++++++++++++++++++----- migration/multifd.h | 2 ++ 4 files changed, 67 insertions(+), 7 deletions(-) diff --git a/migration/file.c b/migration/file.c index 22d052a71f..ac9f6ae40a 100644 --- a/migration/file.c +++ b/migration/file.c @@ -12,12 +12,17 @@ #include "channel.h" #include "file.h" #include "migration.h" +#include "multifd.h" #include "io/channel-file.h" #include "io/channel-util.h" #include "trace.h" =20 #define OFFSET_OPTION ",offset=3D" =20 +static struct FileOutgoingArgs { + char *fname; +} outgoing_args; + /* Remove the offset option from @filespec and return it in @offsetp. */ =20 int file_parse_offset(char *filespec, uint64_t *offsetp, Error **errp) @@ -37,6 +42,34 @@ int file_parse_offset(char *filespec, uint64_t *offsetp,= Error **errp) return 0; } =20 +int file_send_channel_destroy(QIOChannel *ioc) +{ + if (ioc) { + qio_channel_close(ioc, NULL); + } + g_free(outgoing_args.fname); + outgoing_args.fname =3D NULL; + + return 0; +} + +bool file_send_channel_create(gpointer opaque, Error **errp) +{ + QIOChannelFile *ioc; + int flags =3D O_WRONLY; + + ioc =3D qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp); + if (!ioc) { + return false; + } + + if (!multifd_channel_connect(opaque, QIO_CHANNEL(ioc), errp)) { + return false; + } + + return true; +} + void file_start_outgoing_migration(MigrationState *s, FileMigrationArgs *file_args, Error **e= rrp) { @@ -44,15 +77,18 @@ void file_start_outgoing_migration(MigrationState *s, g_autofree char *filename =3D g_strdup(file_args->filename); uint64_t offset =3D file_args->offset; QIOChannel *ioc; + int flags =3D O_CREAT | O_TRUNC | O_WRONLY; + mode_t mode =3D 0660; =20 trace_migration_file_outgoing(filename); =20 - fioc =3D qio_channel_file_new_path(filename, O_CREAT | O_WRONLY | O_TR= UNC, - 0600, errp); + fioc =3D qio_channel_file_new_path(filename, flags, mode, errp); if (!fioc) { return; } =20 + outgoing_args.fname =3D g_strdup(filename); + ioc =3D QIO_CHANNEL(fioc); if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) { return; diff --git a/migration/file.h b/migration/file.h index 37d6a08bfc..90794b494b 100644 --- a/migration/file.h +++ b/migration/file.h @@ -9,10 +9,15 @@ #define QEMU_MIGRATION_FILE_H =20 #include "qapi/qapi-types-migration.h" +#include "io/task.h" +#include "channel.h" =20 void file_start_incoming_migration(FileMigrationArgs *file_args, Error **e= rrp); =20 void file_start_outgoing_migration(MigrationState *s, FileMigrationArgs *file_args, Error **e= rrp); int file_parse_offset(char *filespec, uint64_t *offsetp, Error **errp); + +bool file_send_channel_create(gpointer opaque, Error **errp); +int file_send_channel_destroy(QIOChannel *ioc); #endif diff --git a/migration/multifd.c b/migration/multifd.c index 45a0c7aaa8..507b497d52 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -17,6 +17,7 @@ #include "exec/ramblock.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "file.h" #include "ram.h" #include "migration.h" #include "migration-stats.h" @@ -28,6 +29,7 @@ #include "threadinfo.h" #include "options.h" #include "qemu/yank.h" +#include "io/channel-file.h" #include "io/channel-socket.h" #include "yank_functions.h" =20 @@ -680,6 +682,9 @@ static void multifd_send_terminate_threads(void) =20 static int multifd_send_channel_destroy(QIOChannel *send) { + if (!multifd_use_packets()) { + return file_send_channel_destroy(send); + } return socket_send_channel_destroy(send); } =20 @@ -959,9 +964,8 @@ static bool multifd_tls_channel_connect(MultiFDSendPara= ms *p, return true; } =20 -static bool multifd_channel_connect(MultiFDSendParams *p, - QIOChannel *ioc, - Error **errp) +bool multifd_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, + Error **errp) { qio_channel_set_delay(ioc, false); =20 @@ -1031,9 +1035,14 @@ out: error_free(local_err); } =20 -static void multifd_new_send_channel_create(gpointer opaque) +static bool multifd_new_send_channel_create(gpointer opaque, Error **errp) { + if (!multifd_use_packets()) { + return file_send_channel_create(opaque, errp); + } + socket_send_channel_create(multifd_new_send_channel_async, opaque); + return true; } =20 bool multifd_send_setup(void) @@ -1082,7 +1091,15 @@ bool multifd_send_setup(void) p->page_size =3D qemu_target_page_size(); p->page_count =3D page_count; p->write_flags =3D 0; - multifd_new_send_channel_create(p); + + if (!multifd_new_send_channel_create(p, &local_err)) { + /* + * File channel creation is synchronous, we don't need the + * semaphore below, it's safe to return now. + */ + assert(migrate_fixed_ram()); + return -1; + } } =20 if (use_packets) { diff --git a/migration/multifd.h b/migration/multifd.h index 19188815a3..135f6ed098 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -228,5 +228,7 @@ static inline void multifd_send_prepare_header(MultiFDS= endParams *p) p->iovs_num++; } =20 +bool multifd_channel_connect(MultiFDSendParams *p, QIOChannel *ioc, + Error **errp); =20 #endif --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708468991; cv=none; d=zohomail.com; s=zohoarc; b=dPpxLRl0MdSwuJNYyt3aM+iEsMdKGpyrvYnql36bj0s9DYlGTwBw2GqOZQ+hkmW75LibnxlCe5SITlWfAek0hL93GTxn2aWd2ZrrC3X/FXtHiwW34h938ysHrDRdli9JBoZKkUr9P6MJNUAVeZKLbX2hkuSGotyHFjX8s0uWXd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708468991; 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=9NW4wBImTHg6GaLO/Ipo8LiOt/sZO9kIS4jSjTP4QKw=; b=YcRDOlmK1jLU8/ippYWZiOj/gn8S3r2BcXq0AnPx5WRWV9ybPwrzLGDa46VWu6aVkaeqe0dEBQBw/2o2K1ButvguggRF27483ajwXYI7bq0m7oF/OYkbcIsukYj9xwZfe0g6E1YFfZVatvKuemtLkUtdZEIwEDVv9qkdHhkTX3E= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708468991539217.15457568175543; Tue, 20 Feb 2024 14:43:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYot-00045T-28; Tue, 20 Feb 2024 17:42:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYor-0003vY-JO for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:33 -0500 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 1rcYop-0006Mc-Tl for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:33 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 A1D9322260; Tue, 20 Feb 2024 22:42: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 09EF1139D0; Tue, 20 Feb 2024 22:42:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id QIauMNQq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:28 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468950; 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=9NW4wBImTHg6GaLO/Ipo8LiOt/sZO9kIS4jSjTP4QKw=; b=sy0I7eevI9diJZn5aYenYTJ08qfJQiGLd0UpiuGLU9ayWURtHTnMxio+CL0Xgd+YkNV9DT r9ifzmi+0K72zjDS5ZVFLCYL9T9BpsMRBTATrQUMYOEZSMj8FmVFAhxKroRzw59cLXCOfi iIshB1yB9+4E4Nnjt7gqSl+oPXRNlFM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468950; 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=9NW4wBImTHg6GaLO/Ipo8LiOt/sZO9kIS4jSjTP4QKw=; b=bShqVBcW1vp1H0Wc6u+/w2w9UYSscXzXOiAM/MP0E9Y0FYTpmHkBCl0mWvzAr6CdUwpP4c bIhwPBTIV9XQ8TBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468950; 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=9NW4wBImTHg6GaLO/Ipo8LiOt/sZO9kIS4jSjTP4QKw=; b=sy0I7eevI9diJZn5aYenYTJ08qfJQiGLd0UpiuGLU9ayWURtHTnMxio+CL0Xgd+YkNV9DT r9ifzmi+0K72zjDS5ZVFLCYL9T9BpsMRBTATrQUMYOEZSMj8FmVFAhxKroRzw59cLXCOfi iIshB1yB9+4E4Nnjt7gqSl+oPXRNlFM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468950; 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=9NW4wBImTHg6GaLO/Ipo8LiOt/sZO9kIS4jSjTP4QKw=; b=bShqVBcW1vp1H0Wc6u+/w2w9UYSscXzXOiAM/MP0E9Y0FYTpmHkBCl0mWvzAr6CdUwpP4c bIhwPBTIV9XQ8TBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 21/34] migration/multifd: Add incoming QIOChannelFile support Date: Tue, 20 Feb 2024 19:41:25 -0300 Message-Id: <20240220224138.24759-22-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [1.90 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: 1.90 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708468991887100001 Content-Type: text/plain; charset="utf-8" On the receiving side we don't need to differentiate between main channel and threads, so whichever channel is defined first gets to be the main one. And since there are no packets, use the atomic channel count to index into the params array. Signed-off-by: Fabiano Rosas --- migration/file.c | 34 ++++++++++++++++++++++++++-------- migration/migration.c | 3 ++- migration/multifd.c | 3 +-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/migration/file.c b/migration/file.c index ac9f6ae40a..a186dc592a 100644 --- a/migration/file.c +++ b/migration/file.c @@ -8,6 +8,7 @@ #include "qemu/osdep.h" #include "exec/ramblock.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "channel.h" #include "file.h" @@ -15,6 +16,7 @@ #include "multifd.h" #include "io/channel-file.h" #include "io/channel-util.h" +#include "options.h" #include "trace.h" =20 #define OFFSET_OPTION ",offset=3D" @@ -111,7 +113,8 @@ void file_start_incoming_migration(FileMigrationArgs *f= ile_args, Error **errp) g_autofree char *filename =3D g_strdup(file_args->filename); QIOChannelFile *fioc =3D NULL; uint64_t offset =3D file_args->offset; - QIOChannel *ioc; + int channels =3D 1; + int i =3D 0, fd; =20 trace_migration_file_incoming(filename); =20 @@ -120,13 +123,28 @@ void file_start_incoming_migration(FileMigrationArgs = *file_args, Error **errp) return; } =20 - ioc =3D QIO_CHANNEL(fioc); - if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) { + if (offset && + qio_channel_io_seek(QIO_CHANNEL(fioc), offset, SEEK_SET, errp) < 0= ) { return; } - qio_channel_set_name(QIO_CHANNEL(ioc), "migration-file-incoming"); - qio_channel_add_watch_full(ioc, G_IO_IN, - file_accept_incoming_migration, - NULL, NULL, - g_main_context_get_thread_default()); + + if (migrate_multifd()) { + channels +=3D migrate_multifd_channels(); + } + + fd =3D fioc->fd; + + do { + QIOChannel *ioc =3D QIO_CHANNEL(fioc); + + qio_channel_set_name(ioc, "migration-file-incoming"); + qio_channel_add_watch_full(ioc, G_IO_IN, + file_accept_incoming_migration, + NULL, NULL, + g_main_context_get_thread_default()); + } while (++i < channels && (fioc =3D qio_channel_file_new_fd(fd))); + + if (!fioc) { + error_setg(errp, "Error creating migration incoming channel"); + } } diff --git a/migration/migration.c b/migration/migration.c index 16da269847..e2218b9de7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -896,7 +896,8 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Er= ror **errp) uint32_t channel_magic =3D 0; int ret =3D 0; =20 - if (migrate_multifd() && !migrate_postcopy_ram() && + if (migrate_multifd() && !migrate_fixed_ram() && + !migrate_postcopy_ram() && qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_READ_MSG_PEEK)) { /* * With multiple channels, it is possible that we receive channels diff --git a/migration/multifd.c b/migration/multifd.c index 507b497d52..cb5f4fb3e0 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -1520,8 +1520,7 @@ void multifd_recv_new_channel(QIOChannel *ioc, Error = **errp) } trace_multifd_recv_new_channel(id); } else { - /* next patch gives this a meaningful value */ - id =3D 0; + id =3D qatomic_read(&multifd_recv_state->count); } =20 p =3D &multifd_recv_state->params[id]; --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469013; cv=none; d=zohomail.com; s=zohoarc; b=DausMCi/iUYr1r1zsHbV/oc5i+zj2X2p4RDXKfGedKKmw0UScwOxBkIvDwU4dy+i/tF4f85HVCbqMYiKnn9U7yaKN2IThpQGE5Tdux3mCWi2VPaXF6O5P/yGEyL32HNYF2fxgJEbIwkLgw3YpmHVTX9ii4wzj0MKf5/nafdneZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469013; 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=T38rM69ROJQVSeYZIjGBwQIEL5BPGuUihlczQiACezo=; b=I9ZfUKO7lHWEy095Dhnt+cYHT/o3Z9eTWxffMOIPI9n/79JQMFyu3zlIzYGHT7kayDqdwyuOS5rKD/6/AeYDCX7NkSAeZhevYRmGQHSdl7TNtmMt8ZZ4UXGKaP52uUjC8tBxfC9hwgiz58KFOGL35GvZ8JQRkpRFxG7Kxs6Ubt4= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469013823470.6744724318046; Tue, 20 Feb 2024 14:43:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYow-0004O8-H9; Tue, 20 Feb 2024 17:42:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYot-0004BC-Le for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:35 -0500 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 1rcYor-0006Mu-VB for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:35 -0500 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 BFF852226D; Tue, 20 Feb 2024 22:42: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 1F660139D0; Tue, 20 Feb 2024 22:42:30 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id kPCKNdYq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468952; 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=T38rM69ROJQVSeYZIjGBwQIEL5BPGuUihlczQiACezo=; b=cwHgLiroF/31HlEiA2Avkm60PaKPL8rUIixuml9C+HMf6WoJi0eMHe2P2hYUGefaKDmn08 i6zZiRY+EbACM10I5tRzJ7uX1B0H4bBT+7rwY4bksj+evlU3Xo3OjCmgl51ZKupajiaWym caxoDKLJQvDdGhAJTgBn7lZAY7+3a4U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468952; 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=T38rM69ROJQVSeYZIjGBwQIEL5BPGuUihlczQiACezo=; b=0RAew5s9p07FZEKUBwO82/6oeSrRdtVsaHulue3ONIcEJ/XDXeUfnW3uEIHhXBQzxmraBC uKoyWhxDbmGIFiCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468952; 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=T38rM69ROJQVSeYZIjGBwQIEL5BPGuUihlczQiACezo=; b=cwHgLiroF/31HlEiA2Avkm60PaKPL8rUIixuml9C+HMf6WoJi0eMHe2P2hYUGefaKDmn08 i6zZiRY+EbACM10I5tRzJ7uX1B0H4bBT+7rwY4bksj+evlU3Xo3OjCmgl51ZKupajiaWym caxoDKLJQvDdGhAJTgBn7lZAY7+3a4U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468952; 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=T38rM69ROJQVSeYZIjGBwQIEL5BPGuUihlczQiACezo=; b=0RAew5s9p07FZEKUBwO82/6oeSrRdtVsaHulue3ONIcEJ/XDXeUfnW3uEIHhXBQzxmraBC uKoyWhxDbmGIFiCw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 22/34] migration/multifd: Prepare multifd sync for fixed-ram migration Date: Tue, 20 Feb 2024 19:41:26 -0300 Message-Id: <20240220224138.24759-23-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=cwHgLiro; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0RAew5s9 X-Spamd-Result: default: False [1.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 1.69 X-Rspamd-Queue-Id: BFF852226D X-Spamd-Bar: + Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469015892100019 Content-Type: text/plain; charset="utf-8" The fixed-ram migration can be performed live or non-live, but it is always asynchronous, i.e. the source machine and the destination machine are not migrating at the same time. We only need some pieces of the multifd sync operations. multifd_send_sync_main() ------------------------ Issued by the ram migration code on the migration thread, causes the multifd send channels to synchronize with the migration thread and makes the sending side emit a packet with the MULTIFD_FLUSH flag. With fixed-ram we want to maintain the sync on the sending side because that provides ordering between the rounds of dirty pages when migrating live. MULTIFD_FLUSH ------------- On the receiving side, the presence of the MULTIFD_FLUSH flag on a packet causes the receiving channels to start synchronizing with the main thread. We're not using packets with fixed-ram, so there's no MULTIFD_FLUSH flag and therefore no channel sync on the receiving side. multifd_recv_sync_main() ------------------------ Issued by the migration thread when the ram migration flag RAM_SAVE_FLAG_MULTIFD_FLUSH is received, causes the migration thread on the receiving side to start synchronizing with the recv channels. Due to compatibility, this is also issued when RAM_SAVE_FLAG_EOS is received. For fixed-ram we only need to synchronize the channels at the end of migration to avoid doing cleanup before the channels have finished their IO. Make sure the multifd syncs are only issued at the appropriate times. Note that due to pre-existing backward compatibility issues, we have the multifd_flush_after_each_section property that enables an older behavior of synchronizing channels more frequently (and inefficiently). Fixed-ram should always run with that property disabled (default). Signed-off-by: Fabiano Rosas --- migration/ram.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 5932e1b8e1..c7050f6f68 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1369,8 +1369,11 @@ static int find_dirty_block(RAMState *rs, PageSearch= Status *pss) if (ret < 0) { return ret; } - qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); - qemu_fflush(f); + + if (!migrate_fixed_ram()) { + qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); + qemu_fflush(f); + } } /* * If memory migration starts over, we will meet a dirtied page @@ -3112,7 +3115,8 @@ static int ram_save_setup(QEMUFile *f, void *opaque) return ret; } =20 - if (migrate_multifd() && !migrate_multifd_flush_after_each_section()) { + if (migrate_multifd() && !migrate_multifd_flush_after_each_section() + && !migrate_fixed_ram()) { qemu_put_be64(f, RAM_SAVE_FLAG_MULTIFD_FLUSH); } =20 @@ -4253,6 +4257,15 @@ static int ram_load_precopy(QEMUFile *f) break; case RAM_SAVE_FLAG_EOS: /* normal exit */ + if (migrate_fixed_ram()) { + /* + * The EOS flag appears multiple times on the + * stream. Fixed-ram needs only one sync at the + * end. It will be done on the flush flag above. + */ + break; + } + if (migrate_multifd() && migrate_multifd_flush_after_each_section()) { multifd_recv_sync_main(); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469012; cv=none; d=zohomail.com; s=zohoarc; b=UrG19/jKRiwZ3tlnIAWdsKr1WdCLoT6Aq51+1dGHDC2ndkJtn9NQjoKoexsnKteqiTrWMUVOV37TX6g9gGl+V4rwluWhw3xkhkvDpwoCN4GXd/Kh9AdoHRE6yRyGDiYPJOy7ifZVWEhsf1aggx3bqgiYOq+bE1Z4ua/9jXZgysM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469012; 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=GIWKDS5RdPD0pFa/iHUsG8bbCSX9Sw6MlmVEUq8G1A4=; b=QW/MEjF6V9G3HRFC8WQ9c1Th5ZaRnmim54Tl736S7vvHkYqErtx7J+356apfIFkfLmqCLKegVel/+AyO8A1TBDHm2bFjTp8kXMHk9xKJ33u/jWpIDHBLWu24jF5cSed/AsRY+xWQ761iR/jyEAxgeWl9x7vLohV2XVwB6tHCCTc= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469012024564.2124621117132; Tue, 20 Feb 2024 14:43:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoz-0004eQ-UE; Tue, 20 Feb 2024 17:42:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYox-0004Sp-CI for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:39 -0500 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 1rcYov-0006Oa-6C for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:39 -0500 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 D254722260; Tue, 20 Feb 2024 22:42: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 3DA3F139D0; Tue, 20 Feb 2024 22:42:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id IBypAdkq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468954; 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=GIWKDS5RdPD0pFa/iHUsG8bbCSX9Sw6MlmVEUq8G1A4=; b=v0nuNVrXl3V9vRz8BZriAKwwnKEk0+W2WL1Wj9kt88H5VxfAWEgMW/hCFux49abYGaoD2I 2aU+NxK/LEsM9Zj2BPQywEFFPJXUjAXOqf4cyhzkirUSrstNtTrL3ItaTb/BdfkQb7uEid oP4rRpL84hf4JH9KdKy/gGK4H71oZeg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468954; 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=GIWKDS5RdPD0pFa/iHUsG8bbCSX9Sw6MlmVEUq8G1A4=; b=umJ7UyC/F53g5oviSdGHYHl176xg9mDjZ+1jVHqrtEBDFUdc3sQ3Z6P4xmjyBqSj1YsU+n l+ZKToPlU3yyIDAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468954; 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=GIWKDS5RdPD0pFa/iHUsG8bbCSX9Sw6MlmVEUq8G1A4=; b=v0nuNVrXl3V9vRz8BZriAKwwnKEk0+W2WL1Wj9kt88H5VxfAWEgMW/hCFux49abYGaoD2I 2aU+NxK/LEsM9Zj2BPQywEFFPJXUjAXOqf4cyhzkirUSrstNtTrL3ItaTb/BdfkQb7uEid oP4rRpL84hf4JH9KdKy/gGK4H71oZeg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468954; 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=GIWKDS5RdPD0pFa/iHUsG8bbCSX9Sw6MlmVEUq8G1A4=; b=umJ7UyC/F53g5oviSdGHYHl176xg9mDjZ+1jVHqrtEBDFUdc3sQ3Z6P4xmjyBqSj1YsU+n l+ZKToPlU3yyIDAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 23/34] migration/multifd: Support outgoing fixed-ram stream format Date: Tue, 20 Feb 2024 19:41:27 -0300 Message-Id: <20240220224138.24759-24-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=v0nuNVrX; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="umJ7UyC/" X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: D254722260 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469013885100012 Content-Type: text/plain; charset="utf-8" The new fixed-ram stream format uses a file transport and puts ram pages in the migration file at their respective offsets and can be done in parallel by using the pwritev system call which takes iovecs and an offset. Add support to enabling the new format along with multifd to make use of the threading and page handling already in place. This requires multifd to stop sending headers and leaving the stream format to the fixed-ram code. When it comes time to write the data, we need to call a version of qio_channel_write that can take an offset. Usage on HMP is: (qemu) stop (qemu) migrate_set_capability multifd on (qemu) migrate_set_capability fixed-ram on (qemu) migrate_set_parameter max-bandwidth 0 (qemu) migrate_set_parameter multifd-channels 8 (qemu) migrate file:migfile Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- include/qemu/bitops.h | 13 ++++++++++++ migration/file.c | 47 +++++++++++++++++++++++++++++++++++++++++++ migration/file.h | 2 ++ migration/migration.c | 12 ++++++----- migration/multifd.c | 24 ++++++++++++++++++++-- migration/options.c | 14 +++++++------ migration/ram.c | 17 +++++++++++++--- migration/ram.h | 1 + 8 files changed, 114 insertions(+), 16 deletions(-) diff --git a/include/qemu/bitops.h b/include/qemu/bitops.h index cb3526d1f4..2c0a2fe751 100644 --- a/include/qemu/bitops.h +++ b/include/qemu/bitops.h @@ -67,6 +67,19 @@ static inline void clear_bit(long nr, unsigned long *add= r) *p &=3D ~mask; } =20 +/** + * clear_bit_atomic - Clears a bit in memory atomically + * @nr: Bit to clear + * @addr: Address to start counting from + */ +static inline void clear_bit_atomic(long nr, unsigned long *addr) +{ + unsigned long mask =3D BIT_MASK(nr); + unsigned long *p =3D addr + BIT_WORD(nr); + + return qatomic_and(p, ~mask); +} + /** * change_bit - Toggle a bit in memory * @nr: Bit to change diff --git a/migration/file.c b/migration/file.c index a186dc592a..94e8e08363 100644 --- a/migration/file.c +++ b/migration/file.c @@ -148,3 +148,50 @@ void file_start_incoming_migration(FileMigrationArgs *= file_args, Error **errp) error_setg(errp, "Error creating migration incoming channel"); } } + +int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, + int niov, RAMBlock *block, Error **errp) +{ + ssize_t ret =3D -1; + int i, slice_idx, slice_num; + uintptr_t base, next, offset; + size_t len; + + slice_idx =3D 0; + slice_num =3D 1; + + /* + * If the iov array doesn't have contiguous elements, we need to + * split it in slices because we only have one file offset for the + * whole iov. Do this here so callers don't need to break the iov + * array themselves. + */ + for (i =3D 0; i < niov; i++, slice_num++) { + base =3D (uintptr_t) iov[i].iov_base; + + if (i !=3D niov - 1) { + len =3D iov[i].iov_len; + next =3D (uintptr_t) iov[i + 1].iov_base; + + if (base + len =3D=3D next) { + continue; + } + } + + /* + * Use the offset of the first element of the segment that + * we're sending. + */ + offset =3D (uintptr_t) iov[slice_idx].iov_base - (uintptr_t) block= ->host; + ret =3D qio_channel_pwritev(ioc, &iov[slice_idx], slice_num, + block->pages_offset + offset, errp); + if (ret < 0) { + break; + } + + slice_idx +=3D slice_num; + slice_num =3D 0; + } + + return (ret < 0) ? -1 : 0; +} diff --git a/migration/file.h b/migration/file.h index 90794b494b..390dcc6821 100644 --- a/migration/file.h +++ b/migration/file.h @@ -20,4 +20,6 @@ int file_parse_offset(char *filespec, uint64_t *offsetp, = Error **errp); =20 bool file_send_channel_create(gpointer opaque, Error **errp); int file_send_channel_destroy(QIOChannel *ioc); +int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, + int niov, RAMBlock *block, Error **errp); #endif diff --git a/migration/migration.c b/migration/migration.c index e2218b9de7..32b291a282 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -134,12 +134,14 @@ static bool transport_supports_multi_channels(Migrati= onAddress *addr) if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_SOCKET) { SocketAddress *saddr =3D &addr->u.socket; =20 - return saddr->type =3D=3D SOCKET_ADDRESS_TYPE_INET || - saddr->type =3D=3D SOCKET_ADDRESS_TYPE_UNIX || - saddr->type =3D=3D SOCKET_ADDRESS_TYPE_VSOCK; + return (saddr->type =3D=3D SOCKET_ADDRESS_TYPE_INET || + saddr->type =3D=3D SOCKET_ADDRESS_TYPE_UNIX || + saddr->type =3D=3D SOCKET_ADDRESS_TYPE_VSOCK); + } else if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_FILE) { + return migrate_fixed_ram(); + } else { + return false; } - - return false; } =20 static bool migration_needs_seekable_channel(void) diff --git a/migration/multifd.c b/migration/multifd.c index cb5f4fb3e0..b251c58ec2 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -105,6 +105,17 @@ static bool multifd_use_packets(void) return !migrate_fixed_ram(); } =20 +static void multifd_set_file_bitmap(MultiFDSendParams *p) +{ + MultiFDPages_t *pages =3D p->pages; + + assert(pages->block); + + for (int i =3D 0; i < p->pages->num; i++) { + ramblock_set_file_bmap_atomic(pages->block, pages->offset[i]); + } +} + /* Multifd without compression */ =20 /** @@ -181,6 +192,8 @@ static int nocomp_send_prepare(MultiFDSendParams *p, Er= ror **errp) return -1; } } + } else { + multifd_set_file_bitmap(p); } =20 return 0; @@ -860,8 +873,15 @@ static void *multifd_send_thread(void *opaque) break; } =20 - ret =3D qio_channel_writev_full_all(p->c, p->iov, p->iovs_num,= NULL, - 0, p->write_flags, &local_er= r); + if (migrate_fixed_ram()) { + ret =3D file_write_ramblock_iov(p->c, p->iov, p->iovs_num, + p->pages->block, &local_err); + } else { + ret =3D qio_channel_writev_full_all(p->c, p->iov, p->iovs_= num, + NULL, 0, p->write_flags, + &local_err); + } + if (ret !=3D 0) { break; } diff --git a/migration/options.c b/migration/options.c index 4909e5c72a..bfcd2d7132 100644 --- a/migration/options.c +++ b/migration/options.c @@ -654,12 +654,6 @@ bool migrate_caps_check(bool *old_caps, bool *new_caps= , Error **errp) } =20 if (new_caps[MIGRATION_CAPABILITY_FIXED_RAM]) { - if (new_caps[MIGRATION_CAPABILITY_MULTIFD]) { - error_setg(errp, - "Fixed-ram migration is incompatible with multifd"); - return false; - } - if (new_caps[MIGRATION_CAPABILITY_XBZRLE]) { error_setg(errp, "Fixed-ram migration is incompatible with xbzrle"); @@ -1252,6 +1246,14 @@ bool migrate_params_check(MigrationParameters *param= s, Error **errp) } #endif =20 + if (migrate_fixed_ram() && + ((params->has_multifd_compression && params->multifd_compression) = || + (params->tls_creds && *params->tls_creds))) { + error_setg(errp, + "Fixed-ram only available for non-compressed non-TLS mu= ltifd migration"); + return false; + } + if (params->has_x_vcpu_dirty_limit_period && (params->x_vcpu_dirty_limit_period < 1 || params->x_vcpu_dirty_limit_period > 1000)) { diff --git a/migration/ram.c b/migration/ram.c index c7050f6f68..ad540ae9ce 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1149,7 +1149,7 @@ static int save_zero_page(RAMState *rs, PageSearchSta= tus *pss, =20 if (migrate_fixed_ram()) { /* zero pages are not transferred with fixed-ram */ - clear_bit(offset >> TARGET_PAGE_BITS, pss->block->file_bmap); + clear_bit_atomic(offset >> TARGET_PAGE_BITS, pss->block->file_bmap= ); return 1; } =20 @@ -2445,8 +2445,6 @@ static void ram_save_cleanup(void *opaque) block->clear_bmap =3D NULL; g_free(block->bmap); block->bmap =3D NULL; - g_free(block->file_bmap); - block->file_bmap =3D NULL; } =20 xbzrle_cleanup(); @@ -3135,9 +3133,22 @@ static void ram_save_file_bmap(QEMUFile *f) qemu_put_buffer_at(f, (uint8_t *)block->file_bmap, bitmap_size, block->bitmap_offset); ram_transferred_add(bitmap_size); + + /* + * Free the bitmap here to catch any synchronization issues + * with multifd channels. No channels should be sending pages + * after we've written the bitmap to file. + */ + g_free(block->file_bmap); + block->file_bmap =3D NULL; } } =20 +void ramblock_set_file_bmap_atomic(RAMBlock *block, ram_addr_t offset) +{ + set_bit_atomic(offset >> TARGET_PAGE_BITS, block->file_bmap); +} + /** * ram_save_iterate: iterative stage for migration * diff --git a/migration/ram.h b/migration/ram.h index 9b937a446b..b9ac0da587 100644 --- a/migration/ram.h +++ b/migration/ram.h @@ -75,6 +75,7 @@ bool ram_dirty_bitmap_reload(MigrationState *s, RAMBlock = *rb, Error **errp); bool ramblock_page_is_discarded(RAMBlock *rb, ram_addr_t start); void postcopy_preempt_shutdown_file(MigrationState *s); void *postcopy_preempt_thread(void *opaque); +void ramblock_set_file_bmap_atomic(RAMBlock *block, ram_addr_t offset); =20 /* ram cache */ int colo_init_ram_cache(void); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469043; cv=none; d=zohomail.com; s=zohoarc; b=IIelXfiiNzMWFYb+VKwbD6gw/AnTC9QVCigNNs3TITGuSW+aE+FHtdxyDuHybJdBeX84xmdzLCYoyEwRhr7tUfLXdDjf0vNBnyUY0YfPzdjNZA0lSsiz745vycREs4lU+sSCh4D/CzLJiRCBMZpjAoX2he7HM2S46Hx+DYvTI44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469043; 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=sAg0vZ2AkAqEr9iarG65lBvVOz1QUC0pH+GKvCN79M4=; b=Dbtj8kokgzmEUZ8DwyV71opNCf+Qu/f9UZyMG48KahgBOS1p2S9GPUsCAOUuhm0cUVUOTOyhafCueYv+8ytY7L89VwdO1nu6aK4FEGbBK2CW5eLaTbmqs9EGOnemnGcosDdvj1JIMVKuchaqieu/yvjLjARDDTB6llkYEWIaNB8= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170846904351020.823856976719867; Tue, 20 Feb 2024 14:44:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYoz-0004dm-5K; Tue, 20 Feb 2024 17:42:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYoy-0004XV-0H for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:40 -0500 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 1rcYow-0006Oo-7t for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:39 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 E7D611FB40; Tue, 20 Feb 2024 22:42: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 5530B139D0; Tue, 20 Feb 2024 22:42:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id eKlyB9sq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468957; 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=sAg0vZ2AkAqEr9iarG65lBvVOz1QUC0pH+GKvCN79M4=; b=fznh/MI8nF1M01KkW7knTf9XEizn/b3lcyoDbvJWsziJ1ukW7v77t0oyt3X6Dhe1IOHtig l9aoMJeXd7BdQFipUjgjNSI0PDj+M1skBmB32O4SkYE9CU76wHZAkOg4AqRInrAppF9nRx 6BDT6oJBgg+aQS5W5oxZlbt3BZQtaOs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468957; 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=sAg0vZ2AkAqEr9iarG65lBvVOz1QUC0pH+GKvCN79M4=; b=LcAEDRSLqSsYmOEwbNq031QSM27Xq3zmzW1kZBJe44O/XVcLZDA5Z+vDN3GB/0qLww7pYM CDW60A8hY+IJluAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468956; 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=sAg0vZ2AkAqEr9iarG65lBvVOz1QUC0pH+GKvCN79M4=; b=PvnZZ7jPlIFUoFgEY67J0QztD79ninGYzjcNOJiGBXkavq2t54H12MwmeOhvOOOcuVGAT8 rBK8bAEMoN/nOiv3lfxGWPTxvV6CFILTtWWcYI9xmIqOeaWfy6kllFMz0IngTM2W9vZxEJ xOR7fbNCucWv1ab6gnGGs8/brpd33mM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468956; 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=sAg0vZ2AkAqEr9iarG65lBvVOz1QUC0pH+GKvCN79M4=; b=AjeS7jBFQJUscLqZ9pkKAYj6LeJ0i6JOM2HDM6nTwJppXJ9uCM2pY3W1I+X/4uyGUmx6iI ZNZ/9YAHY18sDcAw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 24/34] migration/multifd: Support incoming fixed-ram stream format Date: Tue, 20 Feb 2024 19:41:28 -0300 Message-Id: <20240220224138.24759-25-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [1.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 1.90 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) (identity @suse.de) X-ZM-MESSAGEID: 1708469044027100004 Content-Type: text/plain; charset="utf-8" For the incoming fixed-ram migration we need to read the ramblock headers, get the pages bitmap and send the host address of each non-zero page to the multifd channel thread for writing. Usage on HMP is: (qemu) migrate_set_capability multifd on (qemu) migrate_set_capability fixed-ram on (qemu) migrate_incoming file:migfile (the ram.h include needs to move because we've been previously relying on it being included from migration.c. Now file.h will start including multifd.h before migration.o is processed) Signed-off-by: Fabiano Rosas --- migration/file.c | 25 ++++++++++++++++++++++++- migration/file.h | 2 ++ migration/multifd.c | 34 ++++++++++++++++++++++++++++++---- migration/multifd.h | 2 ++ migration/ram.c | 36 +++++++++++++++++++++++++++++++++--- 5 files changed, 91 insertions(+), 8 deletions(-) diff --git a/migration/file.c b/migration/file.c index 94e8e08363..1a18e608fc 100644 --- a/migration/file.c +++ b/migration/file.c @@ -13,7 +13,6 @@ #include "channel.h" #include "file.h" #include "migration.h" -#include "multifd.h" #include "io/channel-file.h" #include "io/channel-util.h" #include "options.h" @@ -195,3 +194,27 @@ int file_write_ramblock_iov(QIOChannel *ioc, const str= uct iovec *iov, =20 return (ret < 0) ? -1 : 0; } + +int multifd_file_recv_data(MultiFDRecvParams *p, Error **errp) +{ + MultiFDRecvData *data =3D p->data; + size_t ret; + uint32_t flags =3D p->flags & MULTIFD_FLAG_COMPRESSION_MASK; + + if (flags !=3D MULTIFD_FLAG_NOCOMP) { + error_setg(errp, "multifd %u: flags received %x flags expected %x", + p->id, flags, MULTIFD_FLAG_NOCOMP); + return -1; + } + + ret =3D qio_channel_pread(p->c, (char *) data->opaque, + data->size, data->file_offset, errp); + if (ret !=3D data->size) { + error_prepend(errp, + "multifd recv (%u): read 0x%zx, expected 0x%zx", + p->id, ret, data->size); + return -1; + } + + return 0; +} diff --git a/migration/file.h b/migration/file.h index 390dcc6821..9fe8af73fc 100644 --- a/migration/file.h +++ b/migration/file.h @@ -11,6 +11,7 @@ #include "qapi/qapi-types-migration.h" #include "io/task.h" #include "channel.h" +#include "multifd.h" =20 void file_start_incoming_migration(FileMigrationArgs *file_args, Error **e= rrp); =20 @@ -22,4 +23,5 @@ bool file_send_channel_create(gpointer opaque, Error **er= rp); int file_send_channel_destroy(QIOChannel *ioc); int file_write_ramblock_iov(QIOChannel *ioc, const struct iovec *iov, int niov, RAMBlock *block, Error **errp); +int multifd_file_recv_data(MultiFDRecvParams *p, Error **errp); #endif diff --git a/migration/multifd.c b/migration/multifd.c index b251c58ec2..a0202b5661 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -18,7 +18,6 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "file.h" -#include "ram.h" #include "migration.h" #include "migration-stats.h" #include "socket.h" @@ -251,9 +250,9 @@ static int nocomp_recv(MultiFDRecvParams *p, Error **er= rp) p->iov[i].iov_len =3D p->page_size; } return qio_channel_readv_all(p->c, p->iov, p->normal_num, errp); + } else { + return multifd_file_recv_data(p, errp); } - - return 0; } =20 static MultiFDMethods multifd_nocomp_ops =3D { @@ -1317,13 +1316,40 @@ void multifd_recv_cleanup(void) multifd_recv_cleanup_state(); } =20 + +/* + * Wait until all channels have finished receiving data. Once this + * function returns, cleanup routines are safe to run. + */ +static void multifd_file_recv_sync(void) +{ + int i; + + for (i =3D 0; i < migrate_multifd_channels(); i++) { + MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; + + trace_multifd_recv_sync_main_wait(p->id); + + qemu_sem_post(&p->sem); + + trace_multifd_recv_sync_main_signal(p->id); + qemu_sem_wait(&p->sem_sync); + } + return; +} + void multifd_recv_sync_main(void) { int i; =20 - if (!migrate_multifd() || !multifd_use_packets()) { + if (!migrate_multifd()) { return; } + + if (!multifd_use_packets()) { + return multifd_file_recv_sync(); + } + for (i =3D 0; i < migrate_multifd_channels(); i++) { MultiFDRecvParams *p =3D &multifd_recv_state->params[i]; =20 diff --git a/migration/multifd.h b/migration/multifd.h index 135f6ed098..8f89199721 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -13,6 +13,8 @@ #ifndef QEMU_MIGRATION_MULTIFD_H #define QEMU_MIGRATION_MULTIFD_H =20 +#include "ram.h" + typedef struct MultiFDRecvData MultiFDRecvData; =20 bool multifd_send_setup(void); diff --git a/migration/ram.c b/migration/ram.c index ad540ae9ce..826ac745a0 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -111,6 +111,7 @@ * pages region in the migration file at a time. */ #define FIXED_RAM_LOAD_BUF_SIZE 0x100000 +#define FIXED_RAM_MULTIFD_LOAD_BUF_SIZE 0x100000 =20 XBZRLECacheStats xbzrle_counters; =20 @@ -3950,6 +3951,27 @@ void colo_flush_ram_cache(void) trace_colo_flush_ram_cache_end(); } =20 +static size_t ram_load_multifd_pages(void *host_addr, size_t size, + uint64_t offset) +{ + MultiFDRecvData *data =3D multifd_get_recv_data(); + + /* + * Pointing the opaque directly to the host buffer, no + * preprocessing needed. + */ + data->opaque =3D host_addr; + + data->file_offset =3D offset; + data->size =3D size; + + if (!multifd_recv()) { + return 0; + } + + return size; +} + static bool read_ramblock_fixed_ram(QEMUFile *f, RAMBlock *block, long num_pages, unsigned long *bitmap, Error **errp) @@ -3959,6 +3981,8 @@ static bool read_ramblock_fixed_ram(QEMUFile *f, RAMB= lock *block, ram_addr_t offset; void *host; size_t read, unread, size; + size_t buf_size =3D (migrate_multifd() ? FIXED_RAM_MULTIFD_LOAD_BUF_SI= ZE : + FIXED_RAM_LOAD_BUF_SIZE); =20 for (set_bit_idx =3D find_first_bit(bitmap, num_pages); set_bit_idx < num_pages; @@ -3977,10 +4001,16 @@ static bool read_ramblock_fixed_ram(QEMUFile *f, RA= MBlock *block, return false; } =20 - size =3D MIN(unread, FIXED_RAM_LOAD_BUF_SIZE); + size =3D MIN(unread, buf_size); + + if (migrate_multifd()) { + read =3D ram_load_multifd_pages(host, size, + block->pages_offset + offset= ); + } else { + read =3D qemu_get_buffer_at(f, host, size, + block->pages_offset + offset); + } =20 - read =3D qemu_get_buffer_at(f, host, size, - block->pages_offset + offset); if (!read) { goto err; } --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469031; cv=none; d=zohomail.com; s=zohoarc; b=etrKcIqaWMSyhRWbzQgWMB1T3OojhBcHxkQitHxjxr08ZKEIfRC2o217FS1cj5ai+CyPQSu1eeLOa0u6PTOK0TxbCa2VYUvCWQvfGCiO0AYlhoym67m2ir9Rbfn+ZpV5OGIYsLHkMjI5yB5Stev6ib7U2jlJrgAkCIW8dSXQHyA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469031; 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=087pFkDPQX1LVXFotOh4QCXvp5YTxQZVjf2xUD+QFvM=; b=jE/5SvC17vHylZ1ZsXoiXE1a17gXIaMRD76ykSlpFSJOAICuLbWaF2qG97Kn8NYPquN8OIiOo+CBjMD8E4hezLoaeJqBDCa4oSxNO88uSYWa/dlBanVi5B4Hkj3xLF9iOxC58Agre0iNqxtLbuZgV0ZR2B+WNSIGGhqn6Zh3Zl8= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469031622113.63359537058318; Tue, 20 Feb 2024 14:43:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYp1-0004lz-S3; Tue, 20 Feb 2024 17:42:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYp0-0004eX-5j for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:42 -0500 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 1rcYoy-0006P4-Iu for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:41 -0500 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 140CE1FB53; Tue, 20 Feb 2024 22:42: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 6E247139D0; Tue, 20 Feb 2024 22:42:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id KAU0Dd0q1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468959; 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=087pFkDPQX1LVXFotOh4QCXvp5YTxQZVjf2xUD+QFvM=; b=s8QSInhartax+2OgLzD8+SSn07+gd2mLy8q9Uw2VY4N3xFCIL2FvWZ2cdeLfNNhve9fRxg Zf2OyfhM9RDSdU4Img4mUCFu1PLhPOtOa2xUNX+2FZ5wBhE6jIBZBbfFiFAOkuyET/IOV/ pT0OwDm4VyDAYSvi2ILxkZSi6HZdH2w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468959; 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=087pFkDPQX1LVXFotOh4QCXvp5YTxQZVjf2xUD+QFvM=; b=clhNsi7360tSL5xPGEVrZDjHQ0V5mBBoMFFGL7EIIbDofNqvN60o6YR6fakTMwg/cCX/xH L2mr7WwTfZkyJ1Aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468959; 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=087pFkDPQX1LVXFotOh4QCXvp5YTxQZVjf2xUD+QFvM=; b=s8QSInhartax+2OgLzD8+SSn07+gd2mLy8q9Uw2VY4N3xFCIL2FvWZ2cdeLfNNhve9fRxg Zf2OyfhM9RDSdU4Img4mUCFu1PLhPOtOa2xUNX+2FZ5wBhE6jIBZBbfFiFAOkuyET/IOV/ pT0OwDm4VyDAYSvi2ILxkZSi6HZdH2w= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468959; 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=087pFkDPQX1LVXFotOh4QCXvp5YTxQZVjf2xUD+QFvM=; b=clhNsi7360tSL5xPGEVrZDjHQ0V5mBBoMFFGL7EIIbDofNqvN60o6YR6fakTMwg/cCX/xH L2mr7WwTfZkyJ1Aw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 25/34] migration/multifd: Add fixed-ram support to fd: URI Date: Tue, 20 Feb 2024 19:41:29 -0300 Message-Id: <20240220224138.24759-26-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=s8QSInha; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=clhNsi73 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 140CE1FB53 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469031922100001 Content-Type: text/plain; charset="utf-8" If we receive a file descriptor that points to a regular file, there's nothing stopping us from doing multifd migration with fixed-ram to that file. Enable the fd: URI to work with multifd + fixed-ram. Signed-off-by: Fabiano Rosas --- migration/fd.c | 30 ++++++++++++++++++++++++++++++ migration/fd.h | 1 + migration/file.c | 12 +++++++++--- migration/migration.c | 4 ++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/migration/fd.c b/migration/fd.c index 0eb677dcae..b7e4d071a4 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -19,14 +19,28 @@ #include "fd.h" #include "migration.h" #include "monitor/monitor.h" +#include "io/channel-file.h" #include "io/channel-util.h" +#include "options.h" #include "trace.h" =20 =20 +static struct FdOutgoingArgs { + int fd; +} outgoing_args; + +int fd_args_get_fd(void) +{ + return outgoing_args.fd; +} + void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Er= ror **errp) { QIOChannel *ioc; int fd =3D monitor_get_fd(monitor_cur(), fdname, errp); + + outgoing_args.fd =3D -1; + if (fd =3D=3D -1) { return; } @@ -38,6 +52,8 @@ void fd_start_outgoing_migration(MigrationState *s, const= char *fdname, Error ** return; } =20 + outgoing_args.fd =3D fd; + qio_channel_set_name(ioc, "migration-fd-outgoing"); migration_channel_connect(s, ioc, NULL, NULL); object_unref(OBJECT(ioc)); @@ -73,4 +89,18 @@ void fd_start_incoming_migration(const char *fdname, Err= or **errp) fd_accept_incoming_migration, NULL, NULL, g_main_context_get_thread_default()); + + if (migrate_multifd()) { + int channels =3D migrate_multifd_channels(); + + while (channels--) { + ioc =3D QIO_CHANNEL(qio_channel_file_new_fd(fd)); + + qio_channel_set_name(ioc, "migration-fd-incoming"); + qio_channel_add_watch_full(ioc, G_IO_IN, + fd_accept_incoming_migration, + NULL, NULL, + g_main_context_get_thread_default()= ); + } + } } diff --git a/migration/fd.h b/migration/fd.h index b901bc014e..1be980c130 100644 --- a/migration/fd.h +++ b/migration/fd.h @@ -20,4 +20,5 @@ void fd_start_incoming_migration(const char *fdname, Erro= r **errp); =20 void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp); +int fd_args_get_fd(void); #endif diff --git a/migration/file.c b/migration/file.c index 1a18e608fc..27ccfc6a1d 100644 --- a/migration/file.c +++ b/migration/file.c @@ -11,6 +11,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "channel.h" +#include "fd.h" #include "file.h" #include "migration.h" #include "io/channel-file.h" @@ -58,10 +59,15 @@ bool file_send_channel_create(gpointer opaque, Error **= errp) { QIOChannelFile *ioc; int flags =3D O_WRONLY; + int fd =3D fd_args_get_fd(); =20 - ioc =3D qio_channel_file_new_path(outgoing_args.fname, flags, 0, errp); - if (!ioc) { - return false; + if (fd && fd !=3D -1) { + ioc =3D qio_channel_file_new_fd(fd); + } else { + ioc =3D qio_channel_file_new_path(outgoing_args.fname, flags, 0, e= rrp); + if (!ioc) { + return false; + } } =20 if (!multifd_channel_connect(opaque, QIO_CHANNEL(ioc), errp)) { diff --git a/migration/migration.c b/migration/migration.c index 32b291a282..ce7e6f5065 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -134,6 +134,10 @@ static bool transport_supports_multi_channels(Migratio= nAddress *addr) if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_SOCKET) { SocketAddress *saddr =3D &addr->u.socket; =20 + if (saddr->type =3D=3D SOCKET_ADDRESS_TYPE_FD) { + return migrate_fixed_ram(); + } + return (saddr->type =3D=3D SOCKET_ADDRESS_TYPE_INET || saddr->type =3D=3D SOCKET_ADDRESS_TYPE_UNIX || saddr->type =3D=3D SOCKET_ADDRESS_TYPE_VSOCK); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469099; cv=none; d=zohomail.com; s=zohoarc; b=aUMYetdjYS1eumpp4RdJmkp3T+MNYLSER9cc7DeRAoRJtKlzV5GqxeDXHUG8bv6AAZjPt4B1JK9Ah8SJ1KGcC4Djqlsa1ZQYFJ6xcWN8FUztepKZ2s9xKPf6vPYDYMnP/k9ofgbhP0n8QNoTWjnKLFW+mFSTPdl7gZMOg2saZ5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469099; 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=lmN+8g3IkE0gK4pYYloQr/EKxmp7jCS7BEijCqqLFhU=; b=dmQdq2bRCMogHNG6z7Q8D1H1OGkXZYEw5iJbsaO9vRcSnBAXrTIaSN6o3jop8vu7e7pO86iuSpt8AHv+ix6m9y21b022bNtlTat0eooEIiYaimstyF2oMq6dEeeViEZPEFZQ3Wk17K06QMVB8BsIR/hlZaBiLC58BZYr+KURbz8= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469099219405.6825690256411; Tue, 20 Feb 2024 14:44:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYp4-0004ue-1R; Tue, 20 Feb 2024 17:42:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYp2-0004ol-GY for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:44 -0500 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 1rcYp1-0006PJ-0J for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:44 -0500 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 D084E1FB40; Tue, 20 Feb 2024 22:42: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 8647E139D0; Tue, 20 Feb 2024 22:42:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id +Jz4Et8q1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468961; 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=lmN+8g3IkE0gK4pYYloQr/EKxmp7jCS7BEijCqqLFhU=; b=J+gYxEE69Mh6pyeXuh3W4XnULqIQqCqH0+tr/BJIG+9DpwBUTkolHp16uXb0DP5tE/qZvH y8QGk5DZBPeus0uo9nWKy76lDmg45vK86JL99XUb8yIGkHAicH3ZiPxGJlEI8jZtGsFubK HXbuQ/mWBBDyCywDihMDvh28myvF6QY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468961; 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=lmN+8g3IkE0gK4pYYloQr/EKxmp7jCS7BEijCqqLFhU=; b=0j6dnyY1TNHE5GR5An5yxJzb1XG9iwxzQmpUeYH089zPaa3EH0ErDtrWaMPvFi3VV6TxvS sF8sIjh2b2GNj0Aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468961; 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=lmN+8g3IkE0gK4pYYloQr/EKxmp7jCS7BEijCqqLFhU=; b=J+gYxEE69Mh6pyeXuh3W4XnULqIQqCqH0+tr/BJIG+9DpwBUTkolHp16uXb0DP5tE/qZvH y8QGk5DZBPeus0uo9nWKy76lDmg45vK86JL99XUb8yIGkHAicH3ZiPxGJlEI8jZtGsFubK HXbuQ/mWBBDyCywDihMDvh28myvF6QY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468961; 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=lmN+8g3IkE0gK4pYYloQr/EKxmp7jCS7BEijCqqLFhU=; b=0j6dnyY1TNHE5GR5An5yxJzb1XG9iwxzQmpUeYH089zPaa3EH0ErDtrWaMPvFi3VV6TxvS sF8sIjh2b2GNj0Aw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 26/34] tests/qtest/migration: Add a multifd + fixed-ram migration test Date: Tue, 20 Feb 2024 19:41:30 -0300 Message-Id: <20240220224138.24759-27-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=J+gYxEE6; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=0j6dnyY1 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: D084E1FB40 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469100160100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fabiano Rosas Reviewed-by: Peter Xu --- tests/qtest/migration-test.c | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index d61f93b151..cb9f16f78e 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2248,6 +2248,46 @@ static void test_precopy_file_fixed_ram(void) test_file_common(&args, true); } =20 +static void *migrate_multifd_fixed_ram_start(QTestState *from, QTestState = *to) +{ + migrate_fixed_ram_start(from, to); + + migrate_set_parameter_int(from, "multifd-channels", 4); + migrate_set_parameter_int(to, "multifd-channels", 4); + + migrate_set_capability(from, "multifd", true); + migrate_set_capability(to, "multifd", true); + + return NULL; +} + +static void test_multifd_file_fixed_ram_live(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D migrate_multifd_fixed_ram_start, + }; + + test_file_common(&args, false); +} + +static void test_multifd_file_fixed_ram(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D migrate_multifd_fixed_ram_start, + }; + + test_file_common(&args, true); +} + + static void test_precopy_tcp_plain(void) { MigrateCommon args =3D { @@ -2524,6 +2564,25 @@ static void test_migrate_precopy_fd_file_fixed_ram(v= oid) }; test_file_common(&args, true); } + +static void *migrate_multifd_fd_fixed_ram_start(QTestState *from, + QTestState *to) +{ + migrate_multifd_fixed_ram_start(from, to); + return migrate_precopy_fd_file_start(from, to); +} + +static void test_multifd_fd_fixed_ram(void) +{ + MigrateCommon args =3D { + .connect_uri =3D "fd:fd-mig", + .listen_uri =3D "defer", + .start_hook =3D migrate_multifd_fd_fixed_ram_start, + .finish_hook =3D test_migrate_fd_finish_hook + }; + + test_file_common(&args, true); +} #endif /* _WIN32 */ =20 static void do_test_validate_uuid(MigrateStart *args, bool should_fail) @@ -3566,6 +3625,15 @@ int main(int argc, char **argv) migration_test_add("/migration/precopy/file/fixed-ram/live", test_precopy_file_fixed_ram_live); =20 + migration_test_add("/migration/multifd/file/fixed-ram", + test_multifd_file_fixed_ram); + migration_test_add("/migration/multifd/file/fixed-ram/live", + test_multifd_file_fixed_ram_live); +#ifndef _WIN32 + migration_test_add("/migration/multifd/fd/fixed-ram", + test_multifd_fd_fixed_ram); +#endif + #ifdef CONFIG_GNUTLS migration_test_add("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469120; cv=none; d=zohomail.com; s=zohoarc; b=ZogjDcZp2xqJgeorGbKE9A1PNkDIGutxr5hGofD1iFl36McUIpdlU47xMX+2zvhFfubwlETDn9pMA55sZpb1RLTauDJ4pt/8tOXgyUoVqo3DbeDZHmv/8yNgdHvesnz7SVadUCLpPZMb9GmQ1NGU42psb9lu0do+NtlOfxfOyHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469120; 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=hfxk7AwQkvxyEfclM3uo109mvNYDQUaIrrIjIu9TT3o=; b=V/5NYkH3A8NhZesgv7//IjeplDI3kh53JJFdsNf4NwYs4v/LlBvn4r2dr6QkYdd7sqTWUDzoh9rSqjvw/0zZi78Kb3d0KoI2nNUrsTxwCBHAuGkBiaESAzE+bZxm2ozGOAG7BtMsDg0qUGPz/UUVhk7g02HsF+1e0x/gZb4Q9f0= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469120894317.35136293503933; Tue, 20 Feb 2024 14:45:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYp6-0004w6-O2; Tue, 20 Feb 2024 17:42:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYp5-0004vt-EX for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:47 -0500 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 1rcYp3-0006Pa-HD for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:47 -0500 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 295FA1FB53; Tue, 20 Feb 2024 22:42: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 52F8D139D0; Tue, 20 Feb 2024 22:42:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id uEHNBuIq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468964; 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=hfxk7AwQkvxyEfclM3uo109mvNYDQUaIrrIjIu9TT3o=; b=dRB3ISp5eTV4at/r3qBC1YWz7+QcWoWBbBndtEs4EwQqSwluyMuNEtvaSHhR1wtmPYAovV 9CljS+UJi82RfGj1Bj23Z8BrhxXdmu7VVZmSlANvMa0QfY/030h8Seh2heQj4iLsc60wkc xSYB7B4LGtV8WCnozXhPrO415wAD5lI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468964; 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=hfxk7AwQkvxyEfclM3uo109mvNYDQUaIrrIjIu9TT3o=; b=nBNANta2en4x7uVK12ICJ7J7s5iei56N3VLveS+GEovENC0tES3k2GKLdQEPDlGWHhL57M z9VCliFmrMTNUMAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468964; 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=hfxk7AwQkvxyEfclM3uo109mvNYDQUaIrrIjIu9TT3o=; b=dRB3ISp5eTV4at/r3qBC1YWz7+QcWoWBbBndtEs4EwQqSwluyMuNEtvaSHhR1wtmPYAovV 9CljS+UJi82RfGj1Bj23Z8BrhxXdmu7VVZmSlANvMa0QfY/030h8Seh2heQj4iLsc60wkc xSYB7B4LGtV8WCnozXhPrO415wAD5lI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468964; 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=hfxk7AwQkvxyEfclM3uo109mvNYDQUaIrrIjIu9TT3o=; b=nBNANta2en4x7uVK12ICJ7J7s5iei56N3VLveS+GEovENC0tES3k2GKLdQEPDlGWHhL57M z9VCliFmrMTNUMAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Eric Blake Subject: [PATCH v4 27/34] migration: Add direct-io parameter Date: Tue, 20 Feb 2024 19:41:31 -0300 Message-Id: <20240220224138.24759-28-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=dRB3ISp5; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nBNANta2 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[6]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 295FA1FB53 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469122381100005 Content-Type: text/plain; charset="utf-8" Add the direct-io migration parameter that tells the migration code to use O_DIRECT when opening the migration stream file whenever possible. This is currently only used with the fixed-ram migration that has a clear window guaranteed to perform aligned writes. Signed-off-by: Fabiano Rosas Acked-by: Markus Armbruster --- include/qemu/osdep.h | 2 ++ migration/migration-hmp-cmds.c | 11 +++++++++++ migration/options.c | 30 ++++++++++++++++++++++++++++++ qapi/migration.json | 18 +++++++++++++++--- 4 files changed, 58 insertions(+), 3 deletions(-) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index c7053cdc2b..645c14a65d 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -612,6 +612,8 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t le= n, bool exclusive); bool qemu_has_ofd_lock(void); #endif =20 +bool qemu_has_direct_io(void); + #if defined(__HAIKU__) && defined(__i386__) #define FMT_pid "%ld" #elif defined(WIN64) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 99b49df5dd..77313346c2 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -392,6 +392,13 @@ void hmp_info_migrate_parameters(Monitor *mon, const Q= Dict *qdict) monitor_printf(mon, "%s: %s\n", MigrationParameter_str(MIGRATION_PARAMETER_MODE), qapi_enum_lookup(&MigMode_lookup, params->mode)); + + if (params->has_direct_io) { + monitor_printf(mon, "%s: %s\n", + MigrationParameter_str( + MIGRATION_PARAMETER_DIRECT_IO), + params->direct_io ? "on" : "off"); + } } =20 qapi_free_MigrationParameters(params); @@ -681,6 +688,10 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDi= ct *qdict) p->has_mode =3D true; visit_type_MigMode(v, param, &p->mode, &err); break; + case MIGRATION_PARAMETER_DIRECT_IO: + p->has_direct_io =3D true; + visit_type_bool(v, param, &p->direct_io, &err); + break; default: assert(0); } diff --git a/migration/options.c b/migration/options.c index bfcd2d7132..b347dbc670 100644 --- a/migration/options.c +++ b/migration/options.c @@ -823,6 +823,22 @@ int migrate_decompress_threads(void) return s->parameters.decompress_threads; } =20 +bool migrate_direct_io(void) +{ + MigrationState *s =3D migrate_get_current(); + + /* For now O_DIRECT is only supported with fixed-ram */ + if (!s->capabilities[MIGRATION_CAPABILITY_FIXED_RAM]) { + return false; + } + + if (s->parameters.has_direct_io) { + return s->parameters.direct_io; + } + + return false; +} + uint64_t migrate_downtime_limit(void) { MigrationState *s =3D migrate_get_current(); @@ -1042,6 +1058,11 @@ MigrationParameters *qmp_query_migrate_parameters(Er= ror **errp) params->has_mode =3D true; params->mode =3D s->parameters.mode; =20 + if (s->parameters.has_direct_io) { + params->has_direct_io =3D true; + params->direct_io =3D s->parameters.direct_io; + } + return params; } =20 @@ -1077,6 +1098,7 @@ void migrate_params_init(MigrationParameters *params) params->has_x_vcpu_dirty_limit_period =3D true; params->has_vcpu_dirty_limit =3D true; params->has_mode =3D true; + params->has_direct_io =3D qemu_has_direct_io(); } =20 /* @@ -1386,6 +1408,10 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, if (params->has_mode) { dest->mode =3D params->mode; } + + if (params->has_direct_io) { + dest->direct_io =3D params->direct_io; + } } =20 static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) @@ -1530,6 +1556,10 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) if (params->has_mode) { s->parameters.mode =3D params->mode; } + + if (params->has_direct_io) { + s->parameters.direct_io =3D params->direct_io; + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/qapi/migration.json b/qapi/migration.json index 3fce5fe53e..41241a2178 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -878,6 +878,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# requires that the 'fixed-ram' capability is enabled. (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -911,7 +914,8 @@ 'block-bitmap-mapping', { 'name': 'x-vcpu-dirty-limit-period', 'features': ['unstable']= }, 'vcpu-dirty-limit', - 'mode'] } + 'mode', + 'direct-io'] } =20 ## # @MigrateSetParameters: @@ -1070,6 +1074,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# requires that the 'fixed-ram' capability is enabled. (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1123,7 +1130,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*direct-io': 'bool' } } =20 ## # @migrate-set-parameters: @@ -1298,6 +1306,9 @@ # @mode: Migration mode. See description in @MigMode. Default is 'normal'. # (Since 8.2) # +# @direct-io: Open migration files with O_DIRECT when possible. This +# requires that the 'fixed-ram' capability is enabled. (since 9.0) +# # Features: # # @deprecated: Member @block-incremental is deprecated. Use @@ -1348,7 +1359,8 @@ '*x-vcpu-dirty-limit-period': { 'type': 'uint64', 'features': [ 'unstable' ] }, '*vcpu-dirty-limit': 'uint64', - '*mode': 'MigMode'} } + '*mode': 'MigMode', + '*direct-io': 'bool' } } =20 ## # @query-migrate-parameters: --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469012; cv=none; d=zohomail.com; s=zohoarc; b=ZgitCW816PehnP8J0lLtuqaITxrbNtK7qixnxBehPgHzPkaZA0gwtBofBttZTKIs1zaAqsgRaCjwnepuEogVxZB5PkyaMOpR0l0wSDpjh0b1pFUui+KvaGw2trHv8M1NSEQ1iqvVUXzTNApnTTTfUDw/HmFb3QtC6wU4whXiARg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469012; 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=nEMp533j+rVmmPUsPXVwKF9cSEceWEIkMA6JpwQJszU=; b=Xnhry9N7FruSjqCagTiE1kFV0SRQZN94dgw900nFLo5RDUPzbnFefRek984a0u3+W0wOimF5L8lORy9kgx7ylcaQAa1hz46LGiLwmkuJbHgSTJxef6QBPRbPFVFwxbjo4dWuK/SxQujlhqWa8ymfuJhZPTv4etl+/tWTdRunLcY= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469012492983.7134728376639; Tue, 20 Feb 2024 14:43:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYp8-00052q-FJ; Tue, 20 Feb 2024 17:42:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYp7-0004zM-3U for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:49 -0500 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 1rcYp5-0006Pe-Dx for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:48 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 4C4391FB40; Tue, 20 Feb 2024 22:42: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 9F591139D0; Tue, 20 Feb 2024 22:42:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id YEcXGeQq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468966; 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=nEMp533j+rVmmPUsPXVwKF9cSEceWEIkMA6JpwQJszU=; b=S2+U/ZJxjeJLSIbTNTM7IR7xdT49Uhii/ngb6SML/TfY853uID1MnqnEiUa2h38+gx3giG TE9vnnoDarwlgiEUxs0E5UFnfssw4DGQE3/QM3hhh+dSBroYThGsntJMSHsTi5UjvgGerj x39RCr1hBU5FUu+G6iwDKdiSZDlJxZI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468966; 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=nEMp533j+rVmmPUsPXVwKF9cSEceWEIkMA6JpwQJszU=; b=mnQgrmHLfk+z+h98f7hXJsragas9HP+Hp1x7PKZ4m2a3W+5NDoKa9ekjwiaTHhda7uhErf LnTGtTvNsfBf6VBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468966; 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=nEMp533j+rVmmPUsPXVwKF9cSEceWEIkMA6JpwQJszU=; b=S2+U/ZJxjeJLSIbTNTM7IR7xdT49Uhii/ngb6SML/TfY853uID1MnqnEiUa2h38+gx3giG TE9vnnoDarwlgiEUxs0E5UFnfssw4DGQE3/QM3hhh+dSBroYThGsntJMSHsTi5UjvgGerj x39RCr1hBU5FUu+G6iwDKdiSZDlJxZI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468966; 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=nEMp533j+rVmmPUsPXVwKF9cSEceWEIkMA6JpwQJszU=; b=mnQgrmHLfk+z+h98f7hXJsragas9HP+Hp1x7PKZ4m2a3W+5NDoKa9ekjwiaTHhda7uhErf LnTGtTvNsfBf6VBw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 28/34] migration/multifd: Add direct-io support Date: Tue, 20 Feb 2024 19:41:32 -0300 Message-Id: <20240220224138.24759-29-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [1.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 1.90 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469013858100011 Content-Type: text/plain; charset="utf-8" Signed-off-by: Fabiano Rosas --- migration/file.c | 18 +++++++++++++++++- migration/migration.c | 24 ++++++++++++++++++++++++ migration/options.h | 1 + util/osdep.c | 9 +++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/migration/file.c b/migration/file.c index 27ccfc6a1d..f1c7615fb6 100644 --- a/migration/file.c +++ b/migration/file.c @@ -57,10 +57,26 @@ int file_send_channel_destroy(QIOChannel *ioc) =20 bool file_send_channel_create(gpointer opaque, Error **errp) { - QIOChannelFile *ioc; + QIOChannelFile *ioc =3D NULL; int flags =3D O_WRONLY; int fd =3D fd_args_get_fd(); =20 + if (migrate_direct_io()) { +#ifdef O_DIRECT + /* + * Enable O_DIRECT for the secondary channels. These are used + * for sending ram pages and writes should be guaranteed to be + * aligned to at least page size. + */ + flags |=3D O_DIRECT; +#else + error_setg(errp, "System does not support O_DIRECT"); + error_append_hint(errp, + "Try disabling direct-io migration capability\n"= ); + return false; +#endif + } + if (fd && fd !=3D -1) { ioc =3D qio_channel_file_new_fd(fd); } else { diff --git a/migration/migration.c b/migration/migration.c index ce7e6f5065..ecc07c4847 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -153,6 +153,16 @@ static bool migration_needs_seekable_channel(void) return migrate_fixed_ram(); } =20 +static bool migration_needs_multiple_fds(void) +{ + /* + * When doing direct-io, multifd requires two different, + * non-duplicated file descriptors so we can use one of them for + * unaligned IO. + */ + return migrate_multifd() && migrate_direct_io(); +} + static bool transport_supports_seeking(MigrationAddress *addr) { if (addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_FILE) { @@ -171,6 +181,12 @@ static bool transport_supports_seeking(MigrationAddres= s *addr) return false; } =20 +static bool transport_supports_multiple_fds(MigrationAddress *addr) +{ + /* file: works because QEMU can open it multiple times */ + return addr->transport =3D=3D MIGRATION_ADDRESS_TYPE_FILE; +} + static bool migration_channels_and_transport_compatible(MigrationAddress *addr, Error **errp) @@ -187,6 +203,14 @@ migration_channels_and_transport_compatible(MigrationA= ddress *addr, return false; } =20 + if (migration_needs_multiple_fds() && + !transport_supports_multiple_fds(addr)) { + error_setg(errp, + "Migration with direct-io is incompatible with the fd: = URI," + " use file: instead"); + return false; + } + return true; } =20 diff --git a/migration/options.h b/migration/options.h index 8680a10b79..39cbc171f7 100644 --- a/migration/options.h +++ b/migration/options.h @@ -79,6 +79,7 @@ uint8_t migrate_cpu_throttle_increment(void); uint8_t migrate_cpu_throttle_initial(void); bool migrate_cpu_throttle_tailslow(void); int migrate_decompress_threads(void); +bool migrate_direct_io(void); uint64_t migrate_downtime_limit(void); uint8_t migrate_max_cpu_throttle(void); uint64_t migrate_max_bandwidth(void); diff --git a/util/osdep.c b/util/osdep.c index e996c4744a..d0227a60ab 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -277,6 +277,15 @@ int qemu_lock_fd_test(int fd, int64_t start, int64_t l= en, bool exclusive) } #endif =20 +bool qemu_has_direct_io(void) +{ +#ifdef O_DIRECT + return true; +#else + return false; +#endif +} + static int qemu_open_cloexec(const char *name, int flags, mode_t mode) { int ret; --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469010; cv=none; d=zohomail.com; s=zohoarc; b=UmJVSUVhFf67rYnUDutD4bOx7MWsWDQg8A5Oat5JK6uROX3MQCbqGt7HTd+Hs0LzXvUXPliP+KIkfEZ6Mg9XR49QCOloSqfk55/isT4l3SptsWFwvmCkLXHbjCdibQMxL4Mtm1jiXHvwAG6IqA8umS+QonsM2/ASoKu+K1Ya5Lg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469010; 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=dPAHdaGFdW4w3s6ID5VjcrLWEBT0QNsGCvQOEWygsr8=; b=IoOVVMzH7zXrYHWa0SkN6C0JYCHCxP6DaaH2N5Z4KXi9fWxFiaVSN0el5aFaygrh2aBK2wsZ47gOJyDfIrLAXoO+yrQnApS0Vccx32zebz2DZLiZgvWsvJ5ggB0SjtyPvHkvLA3vc21kvBOirMlKyNpVEJEwug52rhtb6DIEXSE= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469010538847.1070413278591; Tue, 20 Feb 2024 14:43:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYpC-000574-RS; Tue, 20 Feb 2024 17:42:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYp9-000542-R3 for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:51 -0500 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 1rcYp8-0006Pu-5T for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:51 -0500 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 0ABED1FB53; Tue, 20 Feb 2024 22:42:49 +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 B6800139D0; Tue, 20 Feb 2024 22:42:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id gK9CH+Yq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468969; 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=dPAHdaGFdW4w3s6ID5VjcrLWEBT0QNsGCvQOEWygsr8=; b=EohtdBrNfX22UTaKaOUXeSRcDvcyIGPfkzRhaJfCRKzInAjtHfvXHPNJURR0dlM0hYS6r7 DGULqossVw4dPWEt/dwt3UV+wAHwc+W/8xBCT+kQoWyANHBDgWp61SsAszfsMv9QSJ31uE SBis7WDsPrn0ifIYF8hGkV9lbLrbDLQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468969; 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=dPAHdaGFdW4w3s6ID5VjcrLWEBT0QNsGCvQOEWygsr8=; b=uWSty5EDLufWHyzEMmpHNH4PFOXVaQlFg/N8xq4g30+oRC12PkarJujD8pCopaiQcLntaZ qq8MUIurfK460PDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468969; 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=dPAHdaGFdW4w3s6ID5VjcrLWEBT0QNsGCvQOEWygsr8=; b=EohtdBrNfX22UTaKaOUXeSRcDvcyIGPfkzRhaJfCRKzInAjtHfvXHPNJURR0dlM0hYS6r7 DGULqossVw4dPWEt/dwt3UV+wAHwc+W/8xBCT+kQoWyANHBDgWp61SsAszfsMv9QSJ31uE SBis7WDsPrn0ifIYF8hGkV9lbLrbDLQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468969; 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=dPAHdaGFdW4w3s6ID5VjcrLWEBT0QNsGCvQOEWygsr8=; b=uWSty5EDLufWHyzEMmpHNH4PFOXVaQlFg/N8xq4g30+oRC12PkarJujD8pCopaiQcLntaZ qq8MUIurfK460PDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 29/34] tests/qtest/migration: Add tests for file migration with direct-io Date: Tue, 20 Feb 2024 19:41:33 -0300 Message-Id: <20240220224138.24759-30-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=EohtdBrN; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=uWSty5ED X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 0ABED1FB53 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:2; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469011865100005 Content-Type: text/plain; charset="utf-8" The tests are only allowed to run in systems that know and in filesystems which support O_DIRECT. Signed-off-by: Fabiano Rosas --- tests/qtest/migration-helpers.c | 39 ++++++++++++++++++++++++++++++ tests/qtest/migration-helpers.h | 1 + tests/qtest/migration-test.c | 42 +++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index e451dbdbed..4ae43db1ca 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -323,3 +323,42 @@ void migration_test_add(const char *path, void (*fn)(v= oid)) qtest_add_data_func_full(path, test, migration_test_wrapper, migration_test_destroy); } + +#ifdef O_DIRECT +/* + * Probe for O_DIRECT support on the filesystem. Since this is used + * for tests, be conservative, if anything fails, assume it's + * unsupported. + */ +bool probe_o_direct_support(const char *tmpfs) +{ + g_autofree char *filename =3D g_strdup_printf("%s/probe-o-direct", tmp= fs); + int fd, flags =3D O_CREAT | O_RDWR | O_DIRECT; + void *buf; + ssize_t ret, len; + uint64_t offset; + + fd =3D open(filename, flags, 0660); + if (fd < 0) { + unlink(filename); + return false; + } + + /* + * Assuming 4k should be enough to satisfy O_DIRECT alignment + * requirements. The migration code uses 1M to be conservative. + */ + len =3D 0x100000; + offset =3D 0x100000; + + buf =3D g_malloc0(len); + ret =3D pwrite(fd, buf, len, offset); + unlink(filename); + + if (ret < 0) { + return false; + } + + return true; +} +#endif diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helper= s.h index 3bf7ded1b9..d4d641899a 100644 --- a/tests/qtest/migration-helpers.h +++ b/tests/qtest/migration-helpers.h @@ -52,5 +52,6 @@ char *find_common_machine_version(const char *mtype, cons= t char *var1, const char *var2); char *resolve_machine_version(const char *alias, const char *var1, const char *var2); +bool probe_o_direct_support(const char *tmpfs); void migration_test_add(const char *path, void (*fn)(void)); #endif /* MIGRATION_HELPERS_H */ diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index cb9f16f78e..0931ba18df 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2287,6 +2287,43 @@ static void test_multifd_file_fixed_ram(void) test_file_common(&args, true); } =20 +#ifdef O_DIRECT +static void *migrate_fixed_ram_dio_start(QTestState *from, + QTestState *to) +{ + migrate_fixed_ram_start(from, to); + migrate_set_parameter_bool(from, "direct-io", true); + migrate_set_parameter_bool(to, "direct-io", true); + + return NULL; +} + +static void *migrate_multifd_fixed_ram_dio_start(QTestState *from, + QTestState *to) +{ + migrate_multifd_fixed_ram_start(from, to); + return migrate_fixed_ram_dio_start(from, to); +} + +static void test_multifd_file_fixed_ram_dio(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:%s/%s", tmpfs, + FILE_TEST_FILENAME); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D migrate_multifd_fixed_ram_dio_start, + }; + + if (!probe_o_direct_support(tmpfs)) { + g_test_skip("Filesystem does not support O_DIRECT"); + return; + } + + test_file_common(&args, true); +} + +#endif /* O_DIRECT */ =20 static void test_precopy_tcp_plain(void) { @@ -3634,6 +3671,11 @@ int main(int argc, char **argv) test_multifd_fd_fixed_ram); #endif =20 +#ifdef O_DIRECT + migration_test_add("/migration/multifd/file/fixed-ram/dio", + test_multifd_file_fixed_ram_dio); +#endif + #ifdef CONFIG_GNUTLS migration_test_add("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469002; cv=none; d=zohomail.com; s=zohoarc; b=VLt/Ywcy+g8qN5NvMb6EHGgz4Hyl2jFQ596Upw67fuwT1ayzrSTqRBnKvlkA3UMWMQf/ZYGF6wy5PTDXBb/yPcw/xBeZsvP6uwG/E9nTyReEFXzOrbuozlX8gb+ntzUvPQNuTnNKV5p6ro1Uv9/2Y4CPlwNlGdQk6gx3JQenDI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469002; 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=/G6ThC3N+nnfX7FJ2t0KT5ydaj0Xe0MiFJ+bC9uw3Bk=; b=cF+5xyQ1Px8cuQC41vN8ZVk7vILe/O9jdSN3Y5WzLBM8+4T059UYd+prVXfLEwcEagmVAWMqKWhs9MZ5i6qJFP576rx2cr0cgvHSBMp0Z3yRDeK1Kt1UIlwwzXeOqfSxqhX19K7KbspH6HC05m2c2gTDrbjgAmKeRNFc2uFtuUs= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469002181448.59805648632516; Tue, 20 Feb 2024 14:43:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYpE-0005Ar-1w; Tue, 20 Feb 2024 17:42:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYpB-000548-Ib for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:53 -0500 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 1rcYpA-0006Q3-5y for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:53 -0500 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 19EC522260; Tue, 20 Feb 2024 22:42:51 +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 7AF99139D0; Tue, 20 Feb 2024 22:42:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id EKOvEOkq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468971; 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=/G6ThC3N+nnfX7FJ2t0KT5ydaj0Xe0MiFJ+bC9uw3Bk=; b=nM1y/GoKo65bryCqtQ78BdeRrjgDM7nCc2rTqHH/Dnns3M/pwC4njLRnkbf2Cqe51ZdlPA KrXC4yF6Rl3fDCQKg5U8hyvB5gFvoIVSVEemyra4iDfTCDKJKv8HDgwOXCxZrpYyYxJ4PZ LsCBHsDZJBXpos8KFxuIWEHCYEcCn70= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468971; 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=/G6ThC3N+nnfX7FJ2t0KT5ydaj0Xe0MiFJ+bC9uw3Bk=; b=wTaoonG7gCrkU4Fsbog2NmlIf7YjBIKW709owkqiOCBlmq6nrbT1nB83leT274yB8DlPVg JoppppUBaLGY6oAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468971; 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=/G6ThC3N+nnfX7FJ2t0KT5ydaj0Xe0MiFJ+bC9uw3Bk=; b=nM1y/GoKo65bryCqtQ78BdeRrjgDM7nCc2rTqHH/Dnns3M/pwC4njLRnkbf2Cqe51ZdlPA KrXC4yF6Rl3fDCQKg5U8hyvB5gFvoIVSVEemyra4iDfTCDKJKv8HDgwOXCxZrpYyYxJ4PZ LsCBHsDZJBXpos8KFxuIWEHCYEcCn70= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468971; 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=/G6ThC3N+nnfX7FJ2t0KT5ydaj0Xe0MiFJ+bC9uw3Bk=; b=wTaoonG7gCrkU4Fsbog2NmlIf7YjBIKW709owkqiOCBlmq6nrbT1nB83leT274yB8DlPVg JoppppUBaLGY6oAA== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 30/34] monitor: Honor QMP request for fd removal immediately Date: Tue, 20 Feb 2024 19:41:34 -0300 Message-Id: <20240220224138.24759-31-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="nM1y/GoK"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wTaoonG7 X-Spamd-Result: default: False [4.39 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.30)[75.09%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 4.39 X-Rspamd-Queue-Id: 19EC522260 X-Spamd-Bar: ++++ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469003821100009 Content-Type: text/plain; charset="utf-8" We're currently only removing an fd from the fdset if the VM is running. This causes a QMP call to "remove-fd" to not actually remove the fd if the VM happens to be stopped. While the fd would eventually be removed when monitor_fdset_cleanup() is called again, the user request should be honored and the fd actually removed. Calling remove-fd + query-fdset shows a recently removed fd still present. The runstate_is_running() check was introduced by commit ebe52b592d ("monitor: Prevent removing fd from set during init"), which by the shortlog indicates that they were trying to avoid removing an yet-unduplicated fd too early. I don't see why an fd explicitly removed with qmp_remove_fd() should be under runstate_is_running(). I'm assuming this was a mistake when adding the parenthesis around the expression. Move the runstate_is_running() check to apply only to the QLIST_EMPTY(dup_fds) side of the expression and ignore it when mon_fdset_fd->removed has been explicitly set. Signed-off-by: Fabiano Rosas --- monitor/fds.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monitor/fds.c b/monitor/fds.c index d86c2c674c..4ec3b7eea9 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -173,9 +173,9 @@ static void monitor_fdset_cleanup(MonFdset *mon_fdset) MonFdsetFd *mon_fdset_fd_next; =20 QLIST_FOREACH_SAFE(mon_fdset_fd, &mon_fdset->fds, next, mon_fdset_fd_n= ext) { - if ((mon_fdset_fd->removed || - (QLIST_EMPTY(&mon_fdset->dup_fds) && mon_refcount =3D=3D 0= )) && - runstate_is_running()) { + if (mon_fdset_fd->removed || + (QLIST_EMPTY(&mon_fdset->dup_fds) && mon_refcount =3D=3D 0 && + runstate_is_running())) { close(mon_fdset_fd->fd); g_free(mon_fdset_fd->opaque); QLIST_REMOVE(mon_fdset_fd, next); --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469058; cv=none; d=zohomail.com; s=zohoarc; b=O5mFv1rCOkvv93rsXSij/LW/rxa92K3BiDYir2nk+J1uSPqNW7X5HGMjm/MOK5Dd1nwOZWzN/2MvIKFKHB8o/yFF/kDpykrjC1nIH/hFC5mzgnfR7KFGxC2aMSaAsf9o1A0tDcrk75zRo5xJ8dR3UnawHl5hHlxIMiAMcw3PomI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469058; 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=teigS40Z9XH923OGo7nijlRjRuL+JJjtabkdVm33NUY=; b=i5WcXskeM5QFCzmNF+Z7tjzEdgwS1cs/KnDD0IYy1xXe4SAr8eS8+m/z9JoMxjNwJf72MJiG6zv8+aKKXzAj4T30RKZKNUVdZvgoxjvq1aVE4Gi1ufSR5ScimzW69RFLutrhlY3cXp2vht+KeDn92OArWnpXhvSVqlyaT0V/i0I= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469058953212.23258823098604; Tue, 20 Feb 2024 14:44:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYpG-0005RQ-49; Tue, 20 Feb 2024 17:42:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYpE-0005FZ-6c for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:56 -0500 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 1rcYpC-0006QF-Er for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:55 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 373EC1FB53; Tue, 20 Feb 2024 22:42:53 +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 8B0D1139D0; Tue, 20 Feb 2024 22:42:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id MNqGFOsq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468973; 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=teigS40Z9XH923OGo7nijlRjRuL+JJjtabkdVm33NUY=; b=lioPgZc2SveRk9lJJQs/PtMN88/CCwcQdhgZnQwsOqLaiCwZZlufaJ4j1+Bu0XnFmMMgez IELq/YtI5DoIYpBRJKD58qvfTxMCBQEDlqlVSG25DR90vvIKF2Q8A4dlT6YZFPrbGgX47Q zD+BZ6OMMeZkdECYpv+kT+TKLmeYbmI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468973; 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=teigS40Z9XH923OGo7nijlRjRuL+JJjtabkdVm33NUY=; b=f3RQxj+6waEXUXldKCMWYf9erv+zuT+MH/74b8essjunEb36CS31uXfRrrvGh9rE+JFTeK uAFjngFm7lD7AyDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468973; 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=teigS40Z9XH923OGo7nijlRjRuL+JJjtabkdVm33NUY=; b=lioPgZc2SveRk9lJJQs/PtMN88/CCwcQdhgZnQwsOqLaiCwZZlufaJ4j1+Bu0XnFmMMgez IELq/YtI5DoIYpBRJKD58qvfTxMCBQEDlqlVSG25DR90vvIKF2Q8A4dlT6YZFPrbGgX47Q zD+BZ6OMMeZkdECYpv+kT+TKLmeYbmI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468973; 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=teigS40Z9XH923OGo7nijlRjRuL+JJjtabkdVm33NUY=; b=f3RQxj+6waEXUXldKCMWYf9erv+zuT+MH/74b8essjunEb36CS31uXfRrrvGh9rE+JFTeK uAFjngFm7lD7AyDg== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 31/34] monitor: Extract fdset fd flags comparison into a function Date: Tue, 20 Feb 2024 19:41:35 -0300 Message-Id: <20240220224138.24759-32-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 3.70 X-Spamd-Result: default: False [3.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[41.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=lists.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469059963100001 Content-Type: text/plain; charset="utf-8" We're about to add one more condition to the flags comparison that requires an ifdef. Move the code into a separate function now to make it cleaner after the next patch. Signed-off-by: Fabiano Rosas --- monitor/fds.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/monitor/fds.c b/monitor/fds.c index 4ec3b7eea9..9a28e4b72b 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -406,6 +406,19 @@ AddfdInfo *monitor_fdset_add_fd(int fd, bool has_fdset= _id, int64_t fdset_id, return fdinfo; } =20 +#ifndef _WIN32 +static bool monitor_fdset_flags_match(int flags, int fd_flags) +{ + bool match =3D false; + + if ((flags & O_ACCMODE) =3D=3D (fd_flags & O_ACCMODE)) { + match =3D true; + } + + return match; +} +#endif + int monitor_fdset_dup_fd_add(int64_t fdset_id, int flags) { #ifdef _WIN32 @@ -431,7 +444,7 @@ int monitor_fdset_dup_fd_add(int64_t fdset_id, int flag= s) return -1; } =20 - if ((flags & O_ACCMODE) =3D=3D (mon_fd_flags & O_ACCMODE)) { + if (monitor_fdset_flags_match(flags, mon_fd_flags)) { fd =3D mon_fdset_fd->fd; break; } --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469009; cv=none; d=zohomail.com; s=zohoarc; b=Ix5G/dWUQIBDijx3J7c4lYcyVI2UqMz38j5Yw+TUHwbjZFaHgEEKe8Sw14iE+LZu/kNqR8QA1xq+OdpCV9A+3eBrc64MwhD49PcwHne+VwPk4PdgpSuFMA5g+wI/STFVKzN2r6tjzr+vwj4uOMJDhP/BvvUrAhHAbGmJcbuQjic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469009; 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=SZVp1Kh9ePdTIP4PY9Va+CuAtPIW5XqjAK0WxIkPuas=; b=k7prw0ZxfuYtnHyOsL5IMBJbDxdfEU7ozdWUB7nhta4p47q3wVgD4Xn80ie2d4G3unsP//mZegSq3XyNHSfbkidKY4SiQY5VZeL8tD09Px4YjbudgRLcyXBzuiLBl/PdD6Y11V5/JXMRRNQjJJ4nOMUmZ66cy7xYgOujKYfUtNA= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469009205450.5493530844917; Tue, 20 Feb 2024 14:43:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYpN-0005X3-BK; Tue, 20 Feb 2024 17:43:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYpG-0005Rr-44 for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:58 -0500 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 1rcYpE-0006QY-JD for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:42:57 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 3D4C11FB40; Tue, 20 Feb 2024 22:42:55 +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 9CF78139D0; Tue, 20 Feb 2024 22:42:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id 8EnpGO0q1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468975; 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=SZVp1Kh9ePdTIP4PY9Va+CuAtPIW5XqjAK0WxIkPuas=; b=POIH8eOQwPNWwTz31GTJxLqNRG6MVwjcyau7weBBpESlEu+bBg0Qv34g1Q2uCheG6rxa9F U4ed+o4aj8xUJ5MIf6d3gU1Ylzx6AZTVdS77Bc5s0tkHuUxtAgjmml/otGXU/8nIRPl9il kJlrD17KvYao0RQTMy/n7vWUz9RzpeI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468975; 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=SZVp1Kh9ePdTIP4PY9Va+CuAtPIW5XqjAK0WxIkPuas=; b=8pX3M0tcQnRNFaWt5BcyYr77OulewM9BsInN0kb4zc0Vgl0Gd9rc0lrg7cwxcUuUOzQwtZ vORSl0NIqtOn1xDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468975; 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=SZVp1Kh9ePdTIP4PY9Va+CuAtPIW5XqjAK0WxIkPuas=; b=POIH8eOQwPNWwTz31GTJxLqNRG6MVwjcyau7weBBpESlEu+bBg0Qv34g1Q2uCheG6rxa9F U4ed+o4aj8xUJ5MIf6d3gU1Ylzx6AZTVdS77Bc5s0tkHuUxtAgjmml/otGXU/8nIRPl9il kJlrD17KvYao0RQTMy/n7vWUz9RzpeI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468975; 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=SZVp1Kh9ePdTIP4PY9Va+CuAtPIW5XqjAK0WxIkPuas=; b=8pX3M0tcQnRNFaWt5BcyYr77OulewM9BsInN0kb4zc0Vgl0Gd9rc0lrg7cwxcUuUOzQwtZ vORSl0NIqtOn1xDQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 32/34] monitor: fdset: Match against O_DIRECT Date: Tue, 20 Feb 2024 19:41:36 -0300 Message-Id: <20240220224138.24759-33-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: 3.70 X-Spamd-Result: default: False [3.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[39.01%] Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469009840100001 Content-Type: text/plain; charset="utf-8" We're about to enable the use of O_DIRECT in the migration code and due to the alignment restrictions imposed by filesystems we need to make sure the flag is only used when doing aligned IO. The migration will do parallel IO to different regions of a file, so we need to use more than one file descriptor. Those cannot be obtained by duplicating (dup()) since duplicated file descriptors share the file status flags, including O_DIRECT. If one migration channel does unaligned IO while another sets O_DIRECT to do aligned IO, the filesystem would fail the unaligned operation. The add-fd QMP command along with the fdset code are specifically designed to allow the user to pass a set of file descriptors with different access flags into QEMU to be later fetched by code that needs to alternate between those flags when doing IO. Extend the fdset matching function to behave the same with the O_DIRECT flag. Signed-off-by: Fabiano Rosas --- monitor/fds.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/monitor/fds.c b/monitor/fds.c index 9a28e4b72b..42bf3eb982 100644 --- a/monitor/fds.c +++ b/monitor/fds.c @@ -413,6 +413,12 @@ static bool monitor_fdset_flags_match(int flags, int f= d_flags) =20 if ((flags & O_ACCMODE) =3D=3D (fd_flags & O_ACCMODE)) { match =3D true; + +#ifdef O_DIRECT + if ((flags & O_DIRECT) !=3D (fd_flags & O_DIRECT)) { + match =3D false; + } +#endif } =20 return match; --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469100; cv=none; d=zohomail.com; s=zohoarc; b=kg0DeS2wowaPPjDHS0KS4RcnGHftuJ173e+S8nYpcrP0JnJwzxPQXwO0X52Gw4PPM4qfX/f3Ot3YP+aGeXkBnY5x9KXWElEJ5bF5wCOurDQ8Db4BceKporUoPy/YFIw2IpXJcToS437HtlbTJu8+pPTobtmDd7GMfwOr6rsiQXc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469100; 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=m5C9w2KATBwTJIbNr5Ug7RH1uQzsJk6+jTIElw4CtlY=; b=YgHRhDBcNLZ58g8TXWsm67qvUPRrSZNwNjVvwdUDYxQYbA7OHmOsc5mlUGpoztmAlN8DolPdPeBsZuAJwDBwkAHUKbIqouu/hB7k5hLjiLHmu8Mbeb9Ikx39EAxvX29EXBwNSFas+zinx925ay87VDiJiImzAdxtlYjygtrWE0U= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469100971953.6279990016478; Tue, 20 Feb 2024 14:45:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYpZ-0005tM-6W; Tue, 20 Feb 2024 17:43:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYpI-0005Sq-CR for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:43:01 -0500 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 1rcYpG-0006Ql-Ip for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:43:00 -0500 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 4F66D22260; Tue, 20 Feb 2024 22:42:57 +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 AED88139D0; Tue, 20 Feb 2024 22:42:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id KEZbHe8q1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468977; 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=m5C9w2KATBwTJIbNr5Ug7RH1uQzsJk6+jTIElw4CtlY=; b=hoSCAQ2fDSZEzM9sOa8+hNde47bWCSpkBQyXaukT/h/WMLWEhkSzsubmHI8Iodwo8x1N25 NvK1hUX62yqsIVO5MkNLtGU/ERmy1s5wHkbF4+ST+Mmz83cT1TTyrnafSCh8meunPXE8xg Q+0KAp2JXlosSJK/GScvSE04DHzLwEo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468977; 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=m5C9w2KATBwTJIbNr5Ug7RH1uQzsJk6+jTIElw4CtlY=; b=rLbkNN5mYFjx2MvLTNNQY33lMKp2YcxY8Fi6ZoSwWTRxU42yntKlza0MLbkjPszM8waOTD wTiw9UD6LkpMJrBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468977; 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=m5C9w2KATBwTJIbNr5Ug7RH1uQzsJk6+jTIElw4CtlY=; b=hoSCAQ2fDSZEzM9sOa8+hNde47bWCSpkBQyXaukT/h/WMLWEhkSzsubmHI8Iodwo8x1N25 NvK1hUX62yqsIVO5MkNLtGU/ERmy1s5wHkbF4+ST+Mmz83cT1TTyrnafSCh8meunPXE8xg Q+0KAp2JXlosSJK/GScvSE04DHzLwEo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468977; 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=m5C9w2KATBwTJIbNr5Ug7RH1uQzsJk6+jTIElw4CtlY=; b=rLbkNN5mYFjx2MvLTNNQY33lMKp2YcxY8Fi6ZoSwWTRxU42yntKlza0MLbkjPszM8waOTD wTiw9UD6LkpMJrBQ== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana Subject: [PATCH v4 33/34] migration: Add support for fdset with multifd + file Date: Tue, 20 Feb 2024 19:41:37 -0300 Message-Id: <20240220224138.24759-34-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=hoSCAQ2f; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=rLbkNN5m X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_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:+]; MX_GOOD(-0.01)[]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: 4F66D22260 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a07:de40:b251:101:10:150:64:1; 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469102099100012 Content-Type: text/plain; charset="utf-8" Allow multifd to use an fdset when migrating to a file. This is useful for the scenario where the management layer wants to have control over the migration file. By receiving the file descriptors directly, QEMU can delegate some high level operating system operations to the management layer (such as mandatory access control). The management layer might also want to add its own headers before the migration stream. Enable the "file:/dev/fdset/#" syntax for the multifd migration with fixed-ram. The requirements for the fdset mechanism are: On the migration source side: - the fdset must contain two fds that are not duplicates between themselves; - if direct-io is to be used, exactly one of the fds must have the O_DIRECT flag set; - the file must be opened with WRONLY both times. On the migration destination side: - the fdset must contain one fd; - the file must be opened with RDONLY. Signed-off-by: Fabiano Rosas --- docs/devel/migration/main.rst | 18 +++++++ migration/file.c | 97 +++++++++++++++++++++++++++++++++-- 2 files changed, 111 insertions(+), 4 deletions(-) diff --git a/docs/devel/migration/main.rst b/docs/devel/migration/main.rst index 8024275d6d..ac6b6a8eb0 100644 --- a/docs/devel/migration/main.rst +++ b/docs/devel/migration/main.rst @@ -46,6 +46,24 @@ over any transport. application to add its own metadata to the start of the file without QEMU interference. =20 + The file migration also supports using a file that has already been + opened. A set of file descriptors is passed to QEMU via an "fdset" + (see add-fd QMP command documentation). This method allows a + management application to have control over the migration file + opening operation. There are, however, strict requirements to this + interface: + + On the migration source side: + - the fdset must contain two file descriptors that are not + duplicates between themselves; + - if the direct-io capability is to be used, exactly one of the + file descriptors must have the O_DIRECT flag set; + - the file must be opened with WRONLY both times. + + On the migration destination side: + - the fdset must contain one file descriptor; + - the file must be opened with RDONLY. + In addition, support is included for migration using RDMA, which transports the page data using ``RDMA``, where the hardware takes care of transporting the pages, and the load on the CPU is much lower. While the diff --git a/migration/file.c b/migration/file.c index f1c7615fb6..95f3210faf 100644 --- a/migration/file.c +++ b/migration/file.c @@ -10,12 +10,14 @@ #include "qemu/cutils.h" #include "qemu/error-report.h" #include "qapi/error.h" +#include "qapi/qapi-commands-misc.h" #include "channel.h" #include "fd.h" #include "file.h" #include "migration.h" #include "io/channel-file.h" #include "io/channel-util.h" +#include "monitor/monitor.h" #include "options.h" #include "trace.h" =20 @@ -23,6 +25,7 @@ =20 static struct FileOutgoingArgs { char *fname; + int64_t fdset_id; } outgoing_args; =20 /* Remove the offset option from @filespec and return it in @offsetp. */ @@ -44,6 +47,84 @@ int file_parse_offset(char *filespec, uint64_t *offsetp,= Error **errp) return 0; } =20 +/* + * If the open flags and file status flags from the file descriptors + * in the fdset don't match what QEMU expects, errno gets set to + * EACCES. Let's provide a more user-friendly message. + */ +static void file_fdset_error(int flags, Error **errp) +{ + ERRP_GUARD(); + + if (errno =3D=3D EACCES) { + /* ditch the previous error */ + error_free(*errp); + *errp =3D NULL; + + error_setg(errp, "Fdset is missing a file descriptor with flags: 0= x%x", + flags); + } +} + +static void file_remove_fdset(void) +{ + if (outgoing_args.fdset_id !=3D -1) { + qmp_remove_fd(outgoing_args.fdset_id, false, -1, NULL); + outgoing_args.fdset_id =3D -1; + } +} + +/* + * Due to the behavior of the dup() system call, we need the fdset to + * have two non-duplicate fds so we can enable direct IO in the + * secondary channels without affecting the main channel. + */ +static bool file_parse_fdset(const char *filename, int64_t *fdset_id, + Error **errp) +{ + FdsetInfoList *fds_info; + FdsetFdInfoList *fd_info; + const char *fdset_id_str; + int nfds =3D 0; + + *fdset_id =3D -1; + + if (!strstart(filename, "/dev/fdset/", &fdset_id_str)) { + return true; + } + + if (!migrate_multifd()) { + error_setg(errp, "fdset is only supported with multifd"); + return false; + } + + *fdset_id =3D qemu_parse_fd(fdset_id_str); + + for (fds_info =3D qmp_query_fdsets(NULL); fds_info; + fds_info =3D fds_info->next) { + + if (*fdset_id !=3D fds_info->value->fdset_id) { + continue; + } + + for (fd_info =3D fds_info->value->fds; fd_info; fd_info =3D fd_inf= o->next) { + if (nfds++ > 2) { + break; + } + } + } + + if (nfds !=3D 2) { + error_setg(errp, "Outgoing migration needs two fds in the fdset, " + "got %d", nfds); + qmp_remove_fd(*fdset_id, false, -1, NULL); + *fdset_id =3D -1; + return false; + } + + return true; +} + int file_send_channel_destroy(QIOChannel *ioc) { if (ioc) { @@ -52,6 +133,7 @@ int file_send_channel_destroy(QIOChannel *ioc) g_free(outgoing_args.fname); outgoing_args.fname =3D NULL; =20 + file_remove_fdset(); return 0; } =20 @@ -82,6 +164,7 @@ bool file_send_channel_create(gpointer opaque, Error **e= rrp) } else { ioc =3D qio_channel_file_new_path(outgoing_args.fname, flags, 0, e= rrp); if (!ioc) { + file_fdset_error(flags, errp); return false; } } @@ -105,13 +188,18 @@ void file_start_outgoing_migration(MigrationState *s, =20 trace_migration_file_outgoing(filename); =20 - fioc =3D qio_channel_file_new_path(filename, flags, mode, errp); - if (!fioc) { + if (!file_parse_fdset(filename, &outgoing_args.fdset_id, errp)) { return; } =20 outgoing_args.fname =3D g_strdup(filename); =20 + fioc =3D qio_channel_file_new_path(filename, flags, mode, errp); + if (!fioc) { + file_fdset_error(flags, errp); + return; + } + ioc =3D QIO_CHANNEL(fioc); if (offset && qio_channel_io_seek(ioc, offset, SEEK_SET, errp) < 0) { return; @@ -135,12 +223,13 @@ void file_start_incoming_migration(FileMigrationArgs = *file_args, Error **errp) QIOChannelFile *fioc =3D NULL; uint64_t offset =3D file_args->offset; int channels =3D 1; - int i =3D 0, fd; + int i =3D 0, fd, flags =3D O_RDONLY; =20 trace_migration_file_incoming(filename); =20 - fioc =3D qio_channel_file_new_path(filename, O_RDONLY, 0, errp); + fioc =3D qio_channel_file_new_path(filename, flags, 0, errp); if (!fioc) { + file_fdset_error(flags, errp); return; } =20 --=20 2.35.3 From nobody Thu Oct 31 22:46:55 2024 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=1708469100; cv=none; d=zohomail.com; s=zohoarc; b=NA8AwPNcq1Fan1leY06c33DNKxgVbAaebR7IrgoIL0yDweeNAAQ/0M81EMPbICSUiwwQ+QW60kgcHUT9IfezdavzqXthxWSJrqhxs+NqA7AehSBgPoJGMmuzDit/ANxoOl2DvtwZKZ9VKX4kevWcuQfcMWy4fOelVWPnR95skiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708469100; 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=/bqsL4TSA8Dqux1adZGwZXXH6/cNEaOyfd9a7LIUFWU=; b=QOC5fqJsWXLsJTXPu4vfZcRfcZ/2zR8ANoABHmzEbhIRybxdhnOiJCoZddWOuqoCF7Ehpuy6nGFcbM42/meuI0U9L9rWtX/TPVFSJpbgmI8ipfSE8thZ3VmQPMmiV7XOirgbXqf9JAe1mHUykLhl6XKZsmaO+DlMvoqIA2rUm+I= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708469100237697.3153157600557; Tue, 20 Feb 2024 14:45:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcYpV-0005k2-8I; Tue, 20 Feb 2024 17:43:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rcYpL-0005Wp-Gi for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:43:05 -0500 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 1rcYpJ-0006R5-Rj for qemu-devel@nongnu.org; Tue, 20 Feb 2024 17:43:03 -0500 Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 14BE822269; Tue, 20 Feb 2024 22:43:00 +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 C18C1139D0; Tue, 20 Feb 2024 22:42:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap1.dmz-prg2.suse.org with ESMTPSA id cPjKIfEq1WUlKwAAD6G6ig (envelope-from ); Tue, 20 Feb 2024 22:42:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468980; 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=/bqsL4TSA8Dqux1adZGwZXXH6/cNEaOyfd9a7LIUFWU=; b=EKV/Qyi4Xw+4o+gVaZZDgzYUhXKEj0jdxqEu8dNQpV7HMVYtwunU0cZ69hRNSPl0d/oN7w ubVaGoGoiPa8mLLKJJhPfDI8meJhUkZN+y5QC8Og07LSpHnKTYAIm9i/KwAvBpFoYPLEmI oKCV/n79elaPYAEzkdBC3MLRJi/96aY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468980; 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=/bqsL4TSA8Dqux1adZGwZXXH6/cNEaOyfd9a7LIUFWU=; b=SW2N1wXs8mGqN2gWWByDhLinLx6UC9YlnlmPN54VG7ddb+AdJxR4pUmO26bXGm98Wqk34h R/azv5/BrrRM3+Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708468980; 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=/bqsL4TSA8Dqux1adZGwZXXH6/cNEaOyfd9a7LIUFWU=; b=EKV/Qyi4Xw+4o+gVaZZDgzYUhXKEj0jdxqEu8dNQpV7HMVYtwunU0cZ69hRNSPl0d/oN7w ubVaGoGoiPa8mLLKJJhPfDI8meJhUkZN+y5QC8Og07LSpHnKTYAIm9i/KwAvBpFoYPLEmI oKCV/n79elaPYAEzkdBC3MLRJi/96aY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708468980; 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=/bqsL4TSA8Dqux1adZGwZXXH6/cNEaOyfd9a7LIUFWU=; b=SW2N1wXs8mGqN2gWWByDhLinLx6UC9YlnlmPN54VG7ddb+AdJxR4pUmO26bXGm98Wqk34h R/azv5/BrrRM3+Ag== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: berrange@redhat.com, armbru@redhat.com, Peter Xu , Claudio Fontana , Thomas Huth , Laurent Vivier , Paolo Bonzini Subject: [PATCH v4 34/34] tests/qtest/migration: Add a test for fixed-ram with passing of fds Date: Tue, 20 Feb 2024 19:41:38 -0300 Message-Id: <20240220224138.24759-35-farosas@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240220224138.24759-1-farosas@suse.de> References: <20240220224138.24759-1-farosas@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.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=lists.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1708469102096100011 Content-Type: text/plain; charset="utf-8" Add a multifd test for fixed-ram with passing of fds into QEMU. This is how libvirt will consume the feature. There are a couple of details to the fdset mechanism: - multifd needs two distinct file descriptors (not duplicated with dup()) on the outgoing side so it can enable O_DIRECT only on the channels that write with alignment. The dup() system call creates file descriptors that share status flags, of which O_DIRECT is one. the incoming side doesn't set O_DIRECT, so it can dup() fds and therefore can receive only one in the fdset. - the open() access mode flags used for the fds passed into QEMU need to match the flags QEMU uses to open the file. Currently O_WRONLY for src and O_RDONLY for dst. O_DIRECT is not supported on all systems/filesystems, so run the fdset test without O_DIRECT if that's the case. The migration code should still work in that scenario. Signed-off-by: Fabiano Rosas --- tests/qtest/migration-helpers.c | 7 ++- tests/qtest/migration-test.c | 88 +++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 2 deletions(-) diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helper= s.c index 4ae43db1ca..3990da3c16 100644 --- a/tests/qtest/migration-helpers.c +++ b/tests/qtest/migration-helpers.c @@ -333,7 +333,7 @@ void migration_test_add(const char *path, void (*fn)(vo= id)) bool probe_o_direct_support(const char *tmpfs) { g_autofree char *filename =3D g_strdup_printf("%s/probe-o-direct", tmp= fs); - int fd, flags =3D O_CREAT | O_RDWR | O_DIRECT; + int fd, flags =3D O_CREAT | O_RDWR | O_TRUNC | O_DIRECT; void *buf; ssize_t ret, len; uint64_t offset; @@ -351,9 +351,12 @@ bool probe_o_direct_support(const char *tmpfs) len =3D 0x100000; offset =3D 0x100000; =20 - buf =3D g_malloc0(len); + buf =3D aligned_alloc(len, len); + g_assert(buf); + ret =3D pwrite(fd, buf, len, offset); unlink(filename); + g_free(buf); =20 if (ret < 0) { return false; diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 0931ba18df..8c5536958d 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -2323,8 +2323,91 @@ static void test_multifd_file_fixed_ram_dio(void) test_file_common(&args, true); } =20 +static void migrate_multifd_fixed_ram_fdset_dio_end(QTestState *from, + QTestState *to, + void *opaque) +{ + QDict *resp; + QList *fdsets; + + /* + * Check that we removed the fdsets after migration, otherwise a + * second migration would fail due to too many fdsets. + */ + + resp =3D qtest_qmp(from, "{'execute': 'query-fdsets', " + "'arguments': {}}"); + g_assert(qdict_haskey(resp, "return")); + fdsets =3D qdict_get_qlist(resp, "return"); + g_assert(fdsets && qlist_empty(fdsets)); +} #endif /* O_DIRECT */ =20 +#ifndef _WIN32 +static void *migrate_multifd_fixed_ram_fdset(QTestState *from, QTestState = *to) +{ + g_autofree char *file =3D g_strdup_printf("%s/%s", tmpfs, FILE_TEST_FI= LENAME); + int fds[3]; + int src_flags =3D O_CREAT | O_WRONLY; + int dst_flags =3D O_CREAT | O_RDONLY; + + /* main outgoing channel: no O_DIRECT */ + fds[0] =3D open(file, src_flags, 0660); + assert(fds[0] !=3D -1); + +#ifdef O_DIRECT + src_flags |=3D O_DIRECT; +#endif + + /* secondary outgoing channels */ + fds[1] =3D open(file, src_flags, 0660); + assert(fds[1] !=3D -1); + + qtest_qmp_fds_assert_success(from, &fds[0], 1, "{'execute': 'add-fd', " + "'arguments': {'fdset-id': 1}}"); + + qtest_qmp_fds_assert_success(from, &fds[1], 1, "{'execute': 'add-fd', " + "'arguments': {'fdset-id': 1}}"); + + /* incoming channel */ + fds[2] =3D open(file, dst_flags, 0660); + assert(fds[2] !=3D -1); + + qtest_qmp_fds_assert_success(to, &fds[2], 1, "{'execute': 'add-fd', " + "'arguments': {'fdset-id': 1}}"); + +#ifdef O_DIRECT + migrate_multifd_fixed_ram_dio_start(from, to); +#else + migrate_multifd_fixed_ram_start(from, to); +#endif + + return NULL; +} + +static void test_multifd_file_fixed_ram_fdset(void) +{ + g_autofree char *uri =3D g_strdup_printf("file:/dev/fdset/1,offset=3D0= x100"); + MigrateCommon args =3D { + .connect_uri =3D uri, + .listen_uri =3D "defer", + .start_hook =3D migrate_multifd_fixed_ram_fdset, +#ifdef O_DIRECT + .finish_hook =3D migrate_multifd_fixed_ram_fdset_dio_end, +#endif + }; + +#ifdef O_DIRECT + if (!probe_o_direct_support(tmpfs)) { + g_test_skip("Filesystem does not support O_DIRECT"); + return; + } +#endif + + test_file_common(&args, true); +} +#endif /* _WIN32 */ + static void test_precopy_tcp_plain(void) { MigrateCommon args =3D { @@ -3676,6 +3759,11 @@ int main(int argc, char **argv) test_multifd_file_fixed_ram_dio); #endif =20 +#ifndef _WIN32 + qtest_add_func("/migration/multifd/file/fixed-ram/fdset", + test_multifd_file_fixed_ram_fdset); +#endif + #ifdef CONFIG_GNUTLS migration_test_add("/migration/precopy/unix/tls/psk", test_precopy_unix_tls_psk); --=20 2.35.3