From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097271; cv=none; d=zohomail.com; s=zohoarc; b=kYs+K1KiFCCaYgY2uiW23rwbGe+dY3XzYSHpoCa8A0CvZybAGYgxcSptwUob38pDT5Xye/4EGAmUJrmIRNGvq+ht+0zl8DAdWdtyGqwuCsUhSPnrtN4YqzQkuWCQm2pHLa4heUU2XFPvguaL2eRfBOnLl3cJCI8Dp/jiVcoa04s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097271; 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=nKBXyoo6H3FnuIUhAhVzSn4lKRTtLIfs/jNVHpKxL/g=; b=A8A0/jOsZ/jonBHitiNKnhJsh3AdXnPNB0Ym7X4xBUUDXopXVmKWxUEd6NAGYH8JutoyIseS1VX8gFDnygxqsDlA1EKkm6HwpdUqfh9WrBow0+keQUCv1SxvON2vfEbm/vYjGuDoAMfd9jmgSHsbuUJU1ePjNNMzeqEGZSd1/bo= 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 1709097271662308.15503171186333; Tue, 27 Feb 2024 21:14:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCGL-00064w-2r; Wed, 28 Feb 2024 00:13:49 -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 1rfCGG-00064F-Hi for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:13:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCGD-0006XO-9K for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:13:43 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-407-57A-BRE0P7qF5I2Bg3_h0g-1; Wed, 28 Feb 2024 00:13:35 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D17B3816D8A; Wed, 28 Feb 2024 05:13:35 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id A57FB1C117A0; Wed, 28 Feb 2024 05:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097220; h=from:from:reply-to:subject:subject: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=nKBXyoo6H3FnuIUhAhVzSn4lKRTtLIfs/jNVHpKxL/g=; b=SNlENMxhe0Ue9PqKWhxpafDv6wLKSgR+t2puliZJkuX9V4lFilcOUVaMNd4wTjLMNpbHxL wxcS/ebv/ycbARtnlMA8bQvstNo1bw4RMmSsFy6F2NrPbHWy1IEuHLhZCPQaIfl5znO9E7 B6jW/gqwv1XaTsvUWsOO2R4Iin5NC2c= X-MC-Unique: 57A-BRE0P7qF5I2Bg3_h0g-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 01/25] docs/devel/migration.rst: Document the file transport Date: Wed, 28 Feb 2024 13:12:51 +0800 Message-ID: <20240228051315.400759-2-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097273024100014 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas 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 Link: https://lore.kernel.org/r/20240220224138.24759-2-farosas@suse.de Signed-off-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.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097271; cv=none; d=zohomail.com; s=zohoarc; b=oFWSXvkM35iFXcNy9ZViQtZ7Yob7JDGP/Zi6l4C91VpsgBSJC+p1oTfBxgtrWk0m+pXEoabxgx63hzZoHk+l7dpHMLkEy3K3HCkqNLkODINaxxBbHzaiagHmcUxjZVZ4PU+gkMea8I0hZO8nSsXqZM90AuCzIvceQLopByHNUeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097271; 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=ou0+l1TL5ZvPMR5RIKeuu5a0TGjAtqAmdALvxQk8yDE=; b=KlzXnEonNIbUs8dG7sc9aM+a4nlgNRBMa406TiuH/CD9Gmd9Ec4iY2h09EmNThhG2w6eR6Y3X7VCYPzAa5EyLwHgAmFZ9NQtiRy2i9K6mHZ40LE7Ll5trogoQHQClPxrQefTmddOlKPg3BTVGR4H5Q77SYQKVd9Tw0d1LHNrKD0= 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 1709097271831530.5485056791978; Tue, 27 Feb 2024 21:14:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCGR-00065j-QD; Wed, 28 Feb 2024 00:13: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 1rfCGO-00065A-Q3 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:13:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCGN-0006Xs-9f for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:13:52 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384--HESMPqbOZynho1Oqyo9Sg-1; Wed, 28 Feb 2024 00:13:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96389800074; Wed, 28 Feb 2024 05:13:44 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id F3B991C060AF; Wed, 28 Feb 2024 05:13:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097228; h=from:from:reply-to:subject:subject: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=ou0+l1TL5ZvPMR5RIKeuu5a0TGjAtqAmdALvxQk8yDE=; b=Cfm23jfWZg1SnKVKowoSvD1ujlis/O2DkcSC6K1rlQnFU8a9W5dCL9zfZscd4sHcG/LHqB +W8dex1Lf0eIvMs4a80zwwa7LaK3qYvLE4kbvOgLIGDUJE9bf2bqz4BmOBYn4TtHuAD+nb p1MFdc9u2XzqOLQqw8BwAHlh5DnYves= X-MC-Unique: -HESMPqbOZynho1Oqyo9Sg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 02/25] tests/qtest/migration: Rename fd_proto test Date: Wed, 28 Feb 2024 13:12:52 +0800 Message-ID: <20240228051315.400759-3-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097272962100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas 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 Link: https://lore.kernel.org/r/20240220224138.24759-3-farosas@suse.de Signed-off-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.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097298; cv=none; d=zohomail.com; s=zohoarc; b=T5Isu7+W8Mi5Qdfaq/2IN+34MsgdVE2ooL5xbuR8v/k3Cji7sXTwsDpR3Ee0y4Nt/vFL8idJPRTpaaiyRsh433hvcgnWuNF/7WJIkJMyE22H/eKG6Tgwz/nemCVBZd/ZOdzltGt17KcMoeAHr4+z+HGx4OBG3ntYN6j+tKoT2WI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097298; 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=aFBChA6Pf8ctw/89whLUFElcoGbqgkZihXOVnPxEzMk=; b=UnU0dhAdzkRoFeqHgpAJyjr2+d4lkmcxOVufVwJ2cMiqRDB0lRgCs8hYPhy50LgatzHCqGha+/vasJ7Otku8Efs5+KJUkQbrd3aAWqz/Xrzb91W38CjFf7f7QSoQHYewjhKHE1laLhZV+ge1yDFlE/U4hw+5fmWFL/UTl2sEuMo= 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 1709097298359225.83716395479428; Tue, 27 Feb 2024 21:14:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCGk-0006Ba-BK; Wed, 28 Feb 2024 00:14: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 1rfCGi-0006An-GZ for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCGU-0006Ym-Is for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:12 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-673-eZjJWsDUMbiJDKtTi-4xjA-1; Wed, 28 Feb 2024 00:13:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD5CD83B86A; Wed, 28 Feb 2024 05:13:53 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 658941C06713; Wed, 28 Feb 2024 05:13:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097237; h=from:from:reply-to:subject:subject: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=aFBChA6Pf8ctw/89whLUFElcoGbqgkZihXOVnPxEzMk=; b=jFFexl6KgTIkV0vo4N9Hsu7Tu2qNQR+4e9eZrcjtdPd9lB2stlJjYwoIv3GKrkWaMBCbix yFSf4xQwNa8lu1q/OFvH5BgzWCjWtk3hbaYkBvg5gD+UKc83rUoH17+JEtVFSjpFAoEKnb GeZValdlRqlbG5qhjENkjwJHdH0jPiw= X-MC-Unique: eZjJWsDUMbiJDKtTi-4xjA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 03/25] tests/qtest/migration: Add a fd + file test Date: Wed, 28 Feb 2024 13:12:53 +0800 Message-ID: <20240228051315.400759-4-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097298987100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas 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 Link: https://lore.kernel.org/r/20240220224138.24759-4-farosas@suse.de Signed-off-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.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097271; cv=none; d=zohomail.com; s=zohoarc; b=OUEqck8l4ATXttswviETf23Rwq+UqAIbODD1Ud6+4hnU9AX4uTaeHfn7RzNLScZJEfe5RhrdoXVZaMYuzP3nznLdPYFfJvGhYefXearGq/dvWhX8coY8BhegE/VsV1RsGY/1vGjQzJ0Qtqg+VrGRjS/QRLdu8Mzg8ukjZi9kJ1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097271; 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=/YsYcd0edDyziUKc6khHo12W22MFhpxORoWGUlgvu5s=; b=Kno2vBc6u/msVTdxLj0ZDchHuVL98tVLf3jeHA+p4goW55PFd3dw7pEJg84ZLp2a7x929reD7N79/vcQns2fypnxL53pAeEZfvS4lcyXkWTee0l/Cjby8utRmTATMB76Gv6VBCPN6k4OjfXVrHCPayVBtZht39Qyta6QXAk8BlI= 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 1709097271685771.4454805698917; Tue, 27 Feb 2024 21:14:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCGh-0006AN-Mm; Wed, 28 Feb 2024 00:14:11 -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 1rfCGf-0006A2-TN for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCGd-0006Zg-Ma for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:09 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-ngPV9SR9P8WuJuxHtJ5_yg-1; Wed, 28 Feb 2024 00:14:03 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E70A438212D8; Wed, 28 Feb 2024 05:14:02 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E6911C060AF; Wed, 28 Feb 2024 05:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097247; h=from:from:reply-to:subject:subject: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=/YsYcd0edDyziUKc6khHo12W22MFhpxORoWGUlgvu5s=; b=i9spdH2Sz2DBppxUysaPoM59Bt26Y/ZRLtFl076vcjCNjBxFKJVlDO9Rad5DaKJjalLFNe +LL9BdNamsTdlJJQ2c9sE6iJTPny2jWVefrTX9Tc3s5AodkPVv7vmAdiHH0hbIBEd6HnC2 CDVu3BUypAveg93sylRJsfMOjBQpai8= X-MC-Unique: ngPV9SR9P8WuJuxHtJ5_yg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 04/25] migration/multifd: Remove p->quit from recv side Date: Wed, 28 Feb 2024 13:12:54 +0800 Message-ID: <20240228051315.400759-5-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097272977100002 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas 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 Link: https://lore.kernel.org/r/20240220224138.24759-5-farosas@suse.de Signed-off-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.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097470; cv=none; d=zohomail.com; s=zohoarc; b=BIFjkoxUEHr+wcpquT6SrKDK6RiZLZT4Z7rAoAJntlFLANRHOzaGfKVok9cb+DiMlz4jxoiQbmgCO4/5l6gfntu6b5w5H3P5xpqyjlKLSU9rU/zFghpngMNt9NIXh6hdxuudN06CNqccphCzvUUkwy8gWoamMe8xur7wQORSfgY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097470; 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=MBrazfDRoZkEUceQ/1b+YmkYOb1klxQSqOkJeUMhIFY=; b=mYMxRNBwBf4s35pwgnIzVEzzWDbC6ZMuxpVKXSWIsr4ZYTkr/iXFSDe8xvs7X23mmMExuuF0/1qmLmmrSJuhJ3gWjBJKy1N6p443NtOcuXVuBmfKgEq+8uwIvpwTxcH8k09v1OsHf08lt0ZxZV8j+5+Y9+6So2LNpLevzUww/2M= 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 1709097470675243.4529575024702; Tue, 27 Feb 2024 21:17:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCHJ-0006dE-KU; Wed, 28 Feb 2024 00:14:49 -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 1rfCHH-0006YA-9k for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCGp-0006bf-UF for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:46 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-197-anuIpOtrOVKrTRPiKInttg-1; Wed, 28 Feb 2024 00:14:12 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7299E811E79; Wed, 28 Feb 2024 05:14:12 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6C4A1C060AF; Wed, 28 Feb 2024 05:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097256; h=from:from:reply-to:subject:subject: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=MBrazfDRoZkEUceQ/1b+YmkYOb1klxQSqOkJeUMhIFY=; b=dcCEmmkM5bgHZkODoXW711aZhSfW5tW7IRKGnI5mXuekt0ELU2l5VBHReD2biJ/XhwGDjA LgD3LXSyE8CKQnR3VEuFGFMM2NjERj6PwsI8O3mMdHoOtUHCRM8df8T6Hh0ucdVqhL7UsS 1BpSU+tyLamwWlGwDQmiQQ0q/TQReV8= X-MC-Unique: anuIpOtrOVKrTRPiKInttg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 05/25] migration/multifd: Release recv sem_sync earlier Date: Wed, 28 Feb 2024 13:12:55 +0800 Message-ID: <20240228051315.400759-6-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097471839100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas 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 Link: https://lore.kernel.org/r/20240220224138.24759-6-farosas@suse.de Signed-off-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.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097465; cv=none; d=zohomail.com; s=zohoarc; b=SXndcMLs0jqbqUU6M+Tk0EhaBYFAFhCd1YhD3I6qx4HSig99RhMdiJdy/PuVJBBfchigDpkeH2Qab0r1dVMVY1G45zkDm1a+6ukliYR76bBioEMJAH5/Eo0iBfOlauyd982ysb+xQTcv5w4KCQ3SE48TEmj2JODF+XlwiRYAleg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097465; 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=wExLy3AKx0EGsAonwI9YK2ZuyIYTZqi6zUyh5A8Ohtw=; b=UmsFs49fB5P7nmIWBvO7urKdFSIcs51pJTKTVs6i40bIEKVbfnDNgcpwHvZjeyyQALkKUZE1L8uNlrxboWMhyENt+7D8zHUE1QWr+swmvRgVZ9ceDyLf3BbZvUx7sEpm6liDdOTNMBpGmLRqSi91VFl/bzyOvTjnDfUPi57hBi4= 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 1709097465389679.7168016792887; Tue, 27 Feb 2024 21:17:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCHJ-0006cd-2c; Wed, 28 Feb 2024 00:14:49 -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 1rfCHH-0006YB-A0 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCH1-0006cI-5y for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:42 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-689-9nZywqdrNHyX6BveCwyZJw-1; Wed, 28 Feb 2024 00:14:21 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 754A0800074; Wed, 28 Feb 2024 05:14:21 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 291541C060AF; Wed, 28 Feb 2024 05:14:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097264; h=from:from:reply-to:subject:subject: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=wExLy3AKx0EGsAonwI9YK2ZuyIYTZqi6zUyh5A8Ohtw=; b=iux2E/7KsCxwYKtONyxPYxBnVLv9FY0DecJVPSDBYWTi3E1qCTUbA0DS8ppOQ4dgXfUFVj 1vWw3VovSDvKjY8D+D//gUoU/3bZ9bWJSBaGdRmeqgwPp/PkkOeGjRk7Sor+bqW3y0d5aU 2OC5V0KdfDmn6x0qxu9oZGv7ODyGaVA= X-MC-Unique: 9nZywqdrNHyX6BveCwyZJw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 06/25] migration/multifd: Cleanup TLS iochannel referencing Date: Wed, 28 Feb 2024 13:12:56 +0800 Message-ID: <20240228051315.400759-7-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097465810100012 Content-Type: text/plain; charset="utf-8" From: Peter Xu Commit a1af605bd5 ("migration/multifd: fix hangup with TLS-Multifd due to blocking handshake") introduced a thread for TLS channels, which will resolve the issue on blocking the main thread. However in the same commit p->c is slightly abused just to be able to pass over the pointer "p" into the thread. That's the major reason we'll need to conditionally free the io channel in the fault paths. To clean it up, using a separate structure to pass over both "p" and "tioc" in the tls handshake thread. Then we can make it a rule that p->c will never be set until the channel is completely setup. With that, we can drop the tricky conditional unref of the io channel in the error path. Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240222095301.171137-2-peterx@redhat.com Signed-off-by: Peter Xu --- migration/multifd.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 43f0820996..84a6b9e58f 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -891,16 +891,22 @@ out: =20 static void multifd_new_send_channel_async(QIOTask *task, gpointer opaque); =20 +typedef struct { + MultiFDSendParams *p; + QIOChannelTLS *tioc; +} MultiFDTLSThreadArgs; + static void *multifd_tls_handshake_thread(void *opaque) { - MultiFDSendParams *p =3D opaque; - QIOChannelTLS *tioc =3D QIO_CHANNEL_TLS(p->c); + MultiFDTLSThreadArgs *args =3D opaque; =20 - qio_channel_tls_handshake(tioc, + qio_channel_tls_handshake(args->tioc, multifd_new_send_channel_async, - p, + args->p, NULL, NULL); + g_free(args); + return NULL; } =20 @@ -910,6 +916,7 @@ static bool multifd_tls_channel_connect(MultiFDSendPara= ms *p, { MigrationState *s =3D migrate_get_current(); const char *hostname =3D s->hostname; + MultiFDTLSThreadArgs *args; QIOChannelTLS *tioc; =20 tioc =3D migration_tls_client_create(ioc, hostname, errp); @@ -924,11 +931,14 @@ static bool multifd_tls_channel_connect(MultiFDSendPa= rams *p, object_unref(OBJECT(ioc)); trace_multifd_tls_outgoing_handshake_start(ioc, tioc, hostname); qio_channel_set_name(QIO_CHANNEL(tioc), "multifd-tls-outgoing"); - p->c =3D QIO_CHANNEL(tioc); + + args =3D g_new0(MultiFDTLSThreadArgs, 1); + args->tioc =3D tioc; + args->p =3D p; =20 p->tls_thread_created =3D true; qemu_thread_create(&p->tls_thread, "multifd-tls-handshake-worker", - multifd_tls_handshake_thread, p, + multifd_tls_handshake_thread, args, QEMU_THREAD_JOINABLE); return true; } @@ -941,6 +951,7 @@ static bool multifd_channel_connect(MultiFDSendParams *= p, =20 migration_ioc_register_yank(ioc); p->registered_yank =3D true; + /* Setup p->c only if the channel is completely setup */ p->c =3D ioc; =20 p->thread_created =3D true; @@ -994,14 +1005,12 @@ out: =20 trace_multifd_new_send_channel_async_error(p->id, local_err); multifd_send_set_error(local_err); - if (!p->c) { - /* - * If no channel has been created, drop the initial - * reference. Otherwise cleanup happens at - * multifd_send_channel_destroy() - */ - object_unref(OBJECT(ioc)); - } + /* + * For error cases (TLS or non-TLS), IO channel is always freed here + * rather than when cleanup multifd: since p->c is not set, multifd + * cleanup code doesn't even know its existence. + */ + object_unref(OBJECT(ioc)); error_free(local_err); } =20 --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097368; cv=none; d=zohomail.com; s=zohoarc; b=OCtWwA9VFHNarUoQs8yIgzi9q0np82oOZmOUwvglmsPgTGWcqdULqFsZ3hFzkK1c8gseUoLNogWIA/8gVpUv6hYWtHn01p8TXVxqK0ZBL0lBemd08I7OMSYzmJDV+NFIbJm83V2OuZ+WsjYU2OIop/p3X4XcvbTFiOfxFy2qTTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097368; 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=mfy7kxCg3orBGddHhphJ6WF0fxLiKSCCVijlA5ohHsM=; b=nIjFNaeu5AvFVrwi0OuwjkQM3kbyDWynPWZ67Qplqv1CMkU+d+5P/Y/1AHYX1yf0ucjhYQVd0ICS2qvdiErm+KY2EQUfAXVwfrrLMRoWRd4+ZF84XEPQ8Dr2YrCaF/hKO2BZPUvcqYZ2e9J17m8flgiegxM17gOxGx8Hj7DGTwY= 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 1709097367998907.7083209900044; Tue, 27 Feb 2024 21:16:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCHJ-0006ce-3r; Wed, 28 Feb 2024 00:14:49 -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 1rfCHH-0006Z3-IC for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCH5-0006d0-Qu for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:47 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-xsJrgnSlPl2VmFw8hneq9A-1; Wed, 28 Feb 2024 00:14:30 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7946138212C6; Wed, 28 Feb 2024 05:14:30 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2BEEF1C060AF; Wed, 28 Feb 2024 05:14:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097274; h=from:from:reply-to:subject:subject: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=mfy7kxCg3orBGddHhphJ6WF0fxLiKSCCVijlA5ohHsM=; b=hX7Fu/sc7Zkk4alaqXlOtbheyQhACNPFShmjb4eYxOHcvVMsNsgFEhcbW+5/VyADhunt3d J9/v2UdmXP4LCgrct0BSqVbkw5nlTzn/yRfdtbTWQj02PjK9q15fdz5u7lbrpSyTye7GR0 8RX1OLG/cx7wHSX5yh3FAQAPT2AyUZE= X-MC-Unique: xsJrgnSlPl2VmFw8hneq9A-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 07/25] migration/multifd: Drop registered_yank Date: Wed, 28 Feb 2024 13:12:57 +0800 Message-ID: <20240228051315.400759-8-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097369257100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu With a clear definition of p->c protocol, where we only set it up if the channel is fully established (TLS or non-TLS), registered_yank boolean will have equal meaning of "p->c !=3D NULL". Drop registered_yank by checking p->c instead. Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240222095301.171137-3-peterx@redhat.com Signed-off-by: Peter Xu --- migration/multifd.h | 2 -- migration/multifd.c | 7 +++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/migration/multifd.h b/migration/multifd.h index 8a1cad0996..b3fe27ae93 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -78,8 +78,6 @@ typedef struct { bool tls_thread_created; /* communication channel */ QIOChannel *c; - /* is the yank function registered */ - bool registered_yank; /* packet allocated len */ uint32_t packet_len; /* guest page size */ diff --git a/migration/multifd.c b/migration/multifd.c index 84a6b9e58f..1d039a4840 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -666,11 +666,11 @@ static int multifd_send_channel_destroy(QIOChannel *s= end) =20 static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **err= p) { - if (p->registered_yank) { + if (p->c) { migration_ioc_unregister_yank(p->c); + multifd_send_channel_destroy(p->c); + p->c =3D NULL; } - multifd_send_channel_destroy(p->c); - p->c =3D NULL; qemu_sem_destroy(&p->sem); qemu_sem_destroy(&p->sem_sync); g_free(p->name); @@ -950,7 +950,6 @@ static bool multifd_channel_connect(MultiFDSendParams *= p, qio_channel_set_delay(ioc, false); =20 migration_ioc_register_yank(ioc); - p->registered_yank =3D true; /* Setup p->c only if the channel is completely setup */ p->c =3D ioc; =20 --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097325; cv=none; d=zohomail.com; s=zohoarc; b=DjWEfo8rTcAGJUZIZzwS0X1bqE4i6giRcLbbN9sbhx7KBLl95SOnAdFd6onIz04PoYoyrOKWOPfXep4z9EAxINnJHLM6tNSlClR0V6SwNNFptOiOVH6IHt9kkgwF4m0QX3hhfL2KzaIkW1d2pHpdv3ekBIFIkCFTjtpCRu5r5CY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097325; 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=MyuZGRl81JGzv7LwUgH1Jmnf+FHnqS6dNGM75RP2SxY=; b=beN5W5ZhH4XWrP5yrRvUdENnGJDoKSDcdlW3FIJ/mrhHtp6P3Iqgd0zUyrosCk909ZYanyEi7GNFzQg7L/Z8lrMBSzMaIXdTXDu1JEQcFYF4ovdFzEgWjrC0uc5VQtnOQlyR1miBCCZG9761vYr3uJ/wbs0q/vYy2vJw3dZXReY= 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 1709097325631481.7791708679001; Tue, 27 Feb 2024 21:15:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCHM-0006gD-Pv; Wed, 28 Feb 2024 00:14: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 1rfCHL-0006eq-Ka for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCHG-0006dk-Uc for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:51 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-255-zycjznXENaqSK05ZT_WfLw-1; Wed, 28 Feb 2024 00:14:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DFC151071CE0; Wed, 28 Feb 2024 05:14:39 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A8F1C060AF; Wed, 28 Feb 2024 05:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097283; h=from:from:reply-to:subject:subject: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=MyuZGRl81JGzv7LwUgH1Jmnf+FHnqS6dNGM75RP2SxY=; b=c1ecsQzLmOcansLHCx/pSr5RY1nbZMxvDTRBrWB7RgjKi0/16iGWPhst53XYCD/Wwehc0n WyDo9I3VyzIsF7GeUtEdoxKLeYPEjLsAFzSglnRe22/11TbmtrPnUdpqgdhrUXveaxWMtJ K8+Ad9gUclwFODy8CGLDEw0sKItoV9s= X-MC-Unique: zycjznXENaqSK05ZT_WfLw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Avihai Horon Subject: [PULL 08/25] migration/multifd: Make multifd_channel_connect() return void Date: Wed, 28 Feb 2024 13:12:58 +0800 Message-ID: <20240228051315.400759-9-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097327209100002 Content-Type: text/plain; charset="utf-8" From: Peter Xu It never fails, drop the retval and also the Error**. Suggested-by: Avihai Horon Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240222095301.171137-4-peterx@redhat.com Signed-off-by: Peter Xu --- migration/multifd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/migration/multifd.c b/migration/multifd.c index 1d039a4840..af89e05915 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -943,9 +943,7 @@ static bool multifd_tls_channel_connect(MultiFDSendPara= ms *p, return true; } =20 -static bool multifd_channel_connect(MultiFDSendParams *p, - QIOChannel *ioc, - Error **errp) +static void multifd_channel_connect(MultiFDSendParams *p, QIOChannel *ioc) { qio_channel_set_delay(ioc, false); =20 @@ -956,7 +954,6 @@ static bool multifd_channel_connect(MultiFDSendParams *= p, p->thread_created =3D true; qemu_thread_create(&p->thread, p->name, multifd_send_thread, p, QEMU_THREAD_JOINABLE); - return true; } =20 /* @@ -988,7 +985,8 @@ static void multifd_new_send_channel_async(QIOTask *tas= k, gpointer opaque) return; } } else { - ret =3D multifd_channel_connect(p, ioc, &local_err); + multifd_channel_connect(p, ioc); + ret =3D true; } =20 out: --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097313; cv=none; d=zohomail.com; s=zohoarc; b=d0/mZIslPmk6o1YtaMhhyy19hUcoWShu8MwYoG1fKxFDLWSE++SXgdUlSa08zbTUwTgkFk3z+Kx3Y/1m2mbMVCzeT+DLHS59NMsUz7qUbVdRUcuYqpriTWo/1XLR6JK9CzZkmdt4xB8dhBSk6hhCRcQA01yomHJ6+qi1hKitr+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097313; 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=iKLOjP6Vqfp6rSbYaqpDtf5DO20+UXqF1gUTY7yRzzY=; b=igj9bg9W2TpiUl/Wm1AGnfldkgWDJCOm+C4y5FHNXEOWK1iCUz4pzTZOea3B1ApIt/W/+HoTXO1nbPawNbRqpxS1USHHt4l/GUToCHIpRBqUNmpTDWGUYYX4m5WaNEZdSzkyfhlhTbb6oZTmuaQ4rxIH92Ow60f+a9qCLoevuaM= 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 1709097313821249.0688087384417; Tue, 27 Feb 2024 21:15:13 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCHR-0006vq-Pr; Wed, 28 Feb 2024 00:14:57 -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 1rfCHQ-0006lY-9d for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:56 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCHO-0006eo-Ky for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:14:55 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-217-bVEClmLnPWGe0xlk4dLQjQ-1; Wed, 28 Feb 2024 00:14:49 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE6D285A58A; Wed, 28 Feb 2024 05:14:48 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99AA81C060AF; Wed, 28 Feb 2024 05:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097292; h=from:from:reply-to:subject:subject: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=iKLOjP6Vqfp6rSbYaqpDtf5DO20+UXqF1gUTY7yRzzY=; b=YmS7iti6VNV1kBpGpnGp1BMStc94z+lKla0ivOWxeIw7g4j4igMwC/5ZCoC+uZBQ9E7vRh 9oXbfCLpElOW2T6pt1UzX6aiFnllqx29BMa/dOrKwl6gewQdvKKThfG5LYpXxXxwcizk35 Aknlb0swDuPa0cCk06nPtPxhdtVtcNU= X-MC-Unique: bVEClmLnPWGe0xlk4dLQjQ-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 09/25] migration/multifd: Cleanup outgoing_args in state destroy Date: Wed, 28 Feb 2024 13:12:59 +0800 Message-ID: <20240228051315.400759-10-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097315117100002 Content-Type: text/plain; charset="utf-8" From: Peter Xu outgoing_args is a global cache of socket address to be reused in multifd. Freeing the cache in per-channel destructor is more or less a hack. Move it to multifd_send_cleanup_state() so it only get checked once. Use a small helper to do so because it's internal of socket.c. Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240222095301.171137-5-peterx@redhat.com Signed-off-by: Peter Xu --- migration/socket.h | 2 ++ migration/multifd.c | 1 + migration/socket.c | 12 ++++++++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/migration/socket.h b/migration/socket.h index 5e4c33b8ea..5f52eddd4c 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -29,4 +29,6 @@ void socket_start_incoming_migration(SocketAddress *saddr= , Error **errp); =20 void socket_start_outgoing_migration(MigrationState *s, SocketAddress *saddr, Error **errp); +void socket_cleanup_outgoing_migration(void); + #endif diff --git a/migration/multifd.c b/migration/multifd.c index af89e05915..fa33fd98b4 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -689,6 +689,7 @@ static bool multifd_send_cleanup_channel(MultiFDSendPar= ams *p, Error **errp) =20 static void multifd_send_cleanup_state(void) { + socket_cleanup_outgoing_migration(); qemu_sem_destroy(&multifd_send_state->channels_created); qemu_sem_destroy(&multifd_send_state->channels_ready); g_free(multifd_send_state->params); diff --git a/migration/socket.c b/migration/socket.c index 98e3ea1514..3184c7c3c1 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -64,10 +64,6 @@ int socket_send_channel_destroy(QIOChannel *send) { /* Remove channel */ object_unref(OBJECT(send)); - if (outgoing_args.saddr) { - qapi_free_SocketAddress(outgoing_args.saddr); - outgoing_args.saddr =3D NULL; - } return 0; } =20 @@ -137,6 +133,14 @@ void socket_start_outgoing_migration(MigrationState *s, NULL); } =20 +void socket_cleanup_outgoing_migration(void) +{ + if (outgoing_args.saddr) { + qapi_free_SocketAddress(outgoing_args.saddr); + outgoing_args.saddr =3D NULL; + } +} + static void socket_accept_incoming_migration(QIONetListener *listener, QIOChannelSocket *cioc, gpointer opaque) --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097474; cv=none; d=zohomail.com; s=zohoarc; b=GIPYTNJHTc8l0X6K6pGA/x8RBgVvqJRLeksToij5royCBJGlu0k57hzBJH1UnCe/a2r96fpz+ABdY0nZb7SWk2G7h2lfD61WEYe9TvimTxWNd+yMxWc2GdjIcVb6IY+67vcCVTTSVCyGrD1Bh2CVgcfaVpxiTVLZxpGh5QZs7r8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097474; 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=J1Vi2VYmdQgFvbilKpbKfSDnUAxZu1Rt48EmQaB8wVw=; b=EojxmThrHQrSfGr+BYulwvbUXWFRJT0g/5+XieJ5ixP2b4a0NvVPj9XKenxQgT3Wtl8Hig+MzOmo+NXqv7NooNJugN8nUPLtScuo8M06ETOYyzwVHkSTpc/CSbtr02arwI+W/FZLr1W2a6AD3cWgtwqr1WKduB7uyBa94f/u7WE= 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 1709097474159465.78225690008924; Tue, 27 Feb 2024 21:17:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCHy-0008N6-36; Wed, 28 Feb 2024 00:15:30 -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 1rfCHa-0007vO-PZ for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:08 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCHW-0006fs-ML for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:05 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-467-Y0Y3uIZxOCyGVOoMa7C-wg-1; Wed, 28 Feb 2024 00:14:58 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 177C5811E79; Wed, 28 Feb 2024 05:14:58 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F01F1C060B1; Wed, 28 Feb 2024 05:14:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097301; h=from:from:reply-to:subject:subject: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=J1Vi2VYmdQgFvbilKpbKfSDnUAxZu1Rt48EmQaB8wVw=; b=YVjA0/X91jOzwgGUPqOH2EjzpBUSi2zg/U6rUFBIvd9RP4DrF5CYLT/yhA04MV72YdRMST 6u4tecUULGhauinXXI8veG73e694aODaQeX4Fd49Voa69avTA1KVuBbpbp9HLcdciKg5T7 dNJt4NB0+pGjiXbyG5G96nC1VGfpbbQ= X-MC-Unique: Y0Y3uIZxOCyGVOoMa7C-wg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 10/25] migration/multifd: Drop unnecessary helper to destroy IOC Date: Wed, 28 Feb 2024 13:13:00 +0800 Message-ID: <20240228051315.400759-11-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097475811100013 Content-Type: text/plain; charset="utf-8" From: Peter Xu Both socket_send_channel_destroy() and multifd_send_channel_destroy() are unnecessary wrappers to destroy an IOC, as the only thing to do is to release the final IOC reference. We have plenty of code that destroys an IOC using direct unref() already; keep that style. Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240222095301.171137-6-peterx@redhat.com Signed-off-by: Peter Xu --- migration/socket.h | 1 - migration/multifd.c | 7 +------ migration/socket.c | 7 ------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/migration/socket.h b/migration/socket.h index 5f52eddd4c..46c233ecd2 100644 --- a/migration/socket.h +++ b/migration/socket.h @@ -23,7 +23,6 @@ =20 void socket_send_channel_create(QIOTaskFunc f, void *data); QIOChannel *socket_send_channel_create_sync(Error **errp); -int socket_send_channel_destroy(QIOChannel *send); =20 void socket_start_incoming_migration(SocketAddress *saddr, Error **errp); =20 diff --git a/migration/multifd.c b/migration/multifd.c index fa33fd98b4..6c07f19af1 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -659,16 +659,11 @@ static void multifd_send_terminate_threads(void) } } =20 -static int multifd_send_channel_destroy(QIOChannel *send) -{ - return socket_send_channel_destroy(send); -} - static bool multifd_send_cleanup_channel(MultiFDSendParams *p, Error **err= p) { if (p->c) { migration_ioc_unregister_yank(p->c); - multifd_send_channel_destroy(p->c); + object_unref(OBJECT(p->c)); p->c =3D NULL; } qemu_sem_destroy(&p->sem); diff --git a/migration/socket.c b/migration/socket.c index 3184c7c3c1..9ab89b1e08 100644 --- a/migration/socket.c +++ b/migration/socket.c @@ -60,13 +60,6 @@ QIOChannel *socket_send_channel_create_sync(Error **errp) return QIO_CHANNEL(sioc); } =20 -int socket_send_channel_destroy(QIOChannel *send) -{ - /* Remove channel */ - object_unref(OBJECT(send)); - return 0; -} - struct SocketConnectData { MigrationState *s; char *hostname; --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097384; cv=none; d=zohomail.com; s=zohoarc; b=XxTAICg/e3M1ktf3luMAZbSg/lfKse4DwD+Anqh9iAVhkpOxcUZxymXjZdcTFreW9oWxbnnNT+5zy7qMC3Cpi7/wM91er32vzEsm1WLvHmgsLUGWz27ZToXuYC9+7z85oAmYUhWutPDe2hb3GhZ82dx3A7cSDqtLYI16I3iwL2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097384; 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=k9J0QDXBWyQDq5N2g2mm0OQe1YMBW0IeKpsBQMUDkGU=; b=ND8sAW4NXR0ZkrAVdtnHyoP1ihvxoeoe0XLU7U4c7PTbdda+VeWraTOIzgmzpC9h3PfShDD2/e1iNknvicTYEEFuv6JUTKto+3RXspHIM0ZKmJ7BKExNr0tb85BvCZaWEBtzYJsVMbHFL0xkyJZza1UzY4h69aoyZfGiTEk1ITM= 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 170909738398785.91408661017215; Tue, 27 Feb 2024 21:16:23 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCI3-0000Fm-Fn; Wed, 28 Feb 2024 00:15:40 -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 1rfCHl-0008L7-Qy for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCHf-0006gj-UA for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:17 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-j8a1JoTZOeWSCUUozwR12Q-1; Wed, 28 Feb 2024 00:15:08 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAABF3C11CC3; Wed, 28 Feb 2024 05:15:07 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD7C41C06710; Wed, 28 Feb 2024 05:14:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097309; h=from:from:reply-to:subject:subject: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=k9J0QDXBWyQDq5N2g2mm0OQe1YMBW0IeKpsBQMUDkGU=; b=N+x6s16hu2f5h46zgPt6hPJy8SkvDbqqxPiHkBeAFX+1oNCM3jF+ODIFM41RdpGiwSwqNE arSjF0wIvioUzu3QCANKG4rjMhbdfKoYe4g3+wqb6PEyp6X0RESxfDrQvLRc+CQqnkxge/ v+kEnEBF6w3vh23s3SBwOhY2B42jLsg= X-MC-Unique: j8a1JoTZOeWSCUUozwR12Q-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 11/25] notify: pass error to notifier with return Date: Wed, 28 Feb 2024 13:13:01 +0800 Message-ID: <20240228051315.400759-12-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097385317100001 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Pass an error object as the third parameter to "notifier with return" notifiers, so clients no longer need to bundle an error object in the opaque data. The new parameter is used in a later patch. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/1708622920-68779-2-git-send-email-steven.si= stare@oracle.com Signed-off-by: Peter Xu --- include/qemu/notify.h | 7 +++++-- hw/virtio/vhost-user.c | 2 +- hw/virtio/virtio-balloon.c | 3 ++- migration/postcopy-ram.c | 2 +- migration/ram.c | 2 +- util/notify.c | 5 +++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/qemu/notify.h b/include/qemu/notify.h index bcfa70fb2e..9a85631864 100644 --- a/include/qemu/notify.h +++ b/include/qemu/notify.h @@ -45,12 +45,15 @@ bool notifier_list_empty(NotifierList *list); /* Same as Notifier but allows .notify() to return errors */ typedef struct NotifierWithReturn NotifierWithReturn; =20 +typedef int (*NotifierWithReturnFunc)(NotifierWithReturn *notifier, void *= data, + Error **errp); + struct NotifierWithReturn { /** * Return 0 on success (next notifier will be invoked), otherwise * notifier_with_return_list_notify() will stop and return the value. */ - int (*notify)(NotifierWithReturn *notifier, void *data); + NotifierWithReturnFunc notify; QLIST_ENTRY(NotifierWithReturn) node; }; =20 @@ -69,6 +72,6 @@ void notifier_with_return_list_add(NotifierWithReturnList= *list, void notifier_with_return_remove(NotifierWithReturn *notifier); =20 int notifier_with_return_list_notify(NotifierWithReturnList *list, - void *data); + void *data, Error **errp); =20 #endif diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f214df804b..f502345f37 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2084,7 +2084,7 @@ static int vhost_user_postcopy_end(struct vhost_dev *= dev, Error **errp) } =20 static int vhost_user_postcopy_notifier(NotifierWithReturn *notifier, - void *opaque) + void *opaque, Error **errp) { struct PostcopyNotifyData *pnd =3D opaque; struct vhost_user *u =3D container_of(notifier, struct vhost_user, diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c index 486fe3da32..89f853fa9e 100644 --- a/hw/virtio/virtio-balloon.c +++ b/hw/virtio/virtio-balloon.c @@ -633,7 +633,8 @@ static void virtio_balloon_free_page_done(VirtIOBalloon= *s) } =20 static int -virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data) +virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data, + Error **errp) { VirtIOBalloon *dev =3D container_of(n, VirtIOBalloon, free_page_hint_n= otify); VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 893ec8fa89..3ab2f6b8fd 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -80,7 +80,7 @@ int postcopy_notify(enum PostcopyNotifyReason reason, Err= or **errp) pnd.errp =3D errp; =20 return notifier_with_return_list_notify(&postcopy_notifier_list, - &pnd); + &pnd, errp); } =20 /* diff --git a/migration/ram.c b/migration/ram.c index 4649a81204..5b6b09edd9 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -428,7 +428,7 @@ int precopy_notify(PrecopyNotifyReason reason, Error **= errp) pnd.reason =3D reason; pnd.errp =3D errp; =20 - return notifier_with_return_list_notify(&precopy_notifier_list, &pnd); + return notifier_with_return_list_notify(&precopy_notifier_list, &pnd, = errp); } =20 uint64_t ram_bytes_remaining(void) diff --git a/util/notify.c b/util/notify.c index 76bab212ae..c6e158ffb3 100644 --- a/util/notify.c +++ b/util/notify.c @@ -61,13 +61,14 @@ void notifier_with_return_remove(NotifierWithReturn *no= tifier) QLIST_REMOVE(notifier, node); } =20 -int notifier_with_return_list_notify(NotifierWithReturnList *list, void *d= ata) +int notifier_with_return_list_notify(NotifierWithReturnList *list, void *d= ata, + Error **errp) { NotifierWithReturn *notifier, *next; int ret =3D 0; =20 QLIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) { - ret =3D notifier->notify(notifier, data); + ret =3D notifier->notify(notifier, data, errp); if (ret !=3D 0) { break; } --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097461; cv=none; d=zohomail.com; s=zohoarc; b=QxiSSO7RCTi9P6GTvHpn5VCQqu4ndCgNMv7bJHagK2UCR11wcw2tfSxSGagCjfoOiMdcHr3cMC+0Eda6cLe/uaYSes4inyffpD15tMHDHk6ffq9RQ+Pi43gA0vzyxfUjcBLElqVBvb5kCf6Jwy2q2uGChH0GliAUwfqTfit7KYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097461; 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=7WmBFm2fHdY4EPa57HeU0g1kLg5q4DnLUdY/1J2BYCE=; b=glnLMpBuB28rtgAnkOpJ8C8EGktzrURVdFKX73YB3o93TERpE+o5uS+6ycs7GuCZYZE6q6s5djrBw05jmSoGC+/6Yjee7O2fqP0OFoprNdrT4v9+3RXEH8lwNjYFd/ap4vSVqQBo1gP5jgd4qXexM8XYqJtCGsq5VZSzHmtAYSo= 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 1709097461483506.74510156645215; Tue, 27 Feb 2024 21:17:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCIN-0000Yy-93; Wed, 28 Feb 2024 00:16: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 1rfCHt-0008Re-1T for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCHq-0006tv-49 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:24 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-Ui_mVdT7PM2OA9tdUHblrA-1; Wed, 28 Feb 2024 00:15:17 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 605C7185A787; Wed, 28 Feb 2024 05:15:17 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A6911C060AF; Wed, 28 Feb 2024 05:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097321; h=from:from:reply-to:subject:subject: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=7WmBFm2fHdY4EPa57HeU0g1kLg5q4DnLUdY/1J2BYCE=; b=PbxEInpzh8pRXvWTwSwN84Ztl/XVsRuOOlnSDbpfhVizDio0JV2gv3pjXgBtxIMuaNXZp9 mbRDdKV0yHLL5VLM2IMid9d7g1R9c1yvNb9c9uxuLAp7jEW1O+LG1EphF7n9ohuVnTFZaH m7CgRqY5ZsTmM4I7XG/KqpIWaXAmtNs= X-MC-Unique: Ui_mVdT7PM2OA9tdUHblrA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 12/25] migration: remove error from notifier data Date: Wed, 28 Feb 2024 13:13:02 +0800 Message-ID: <20240228051315.400759-13-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097461806100001 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Remove the error object from opaque data passed to notifiers. Use the new error parameter passed to the notifier instead. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/1708622920-68779-3-git-send-email-steven.si= stare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 - migration/postcopy-ram.h | 1 - hw/virtio/vhost-user.c | 8 ++++---- migration/postcopy-ram.c | 1 - migration/ram.c | 1 - 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 1bc8902e6d..5e65c18f1a 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -31,7 +31,6 @@ typedef enum PrecopyNotifyReason { =20 typedef struct PrecopyNotifyData { enum PrecopyNotifyReason reason; - Error **errp; } PrecopyNotifyData; =20 void precopy_infrastructure_init(void); diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 442ab89752..ecae941211 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -128,7 +128,6 @@ enum PostcopyNotifyReason { =20 struct PostcopyNotifyData { enum PostcopyNotifyReason reason; - Error **errp; }; =20 void postcopy_add_notifier(NotifierWithReturn *nn); diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index f502345f37..a1eea8547e 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -2096,20 +2096,20 @@ static int vhost_user_postcopy_notifier(NotifierWit= hReturn *notifier, if (!virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_PAGEFAULT)) { /* TODO: Get the device name into this error somehow */ - error_setg(pnd->errp, + error_setg(errp, "vhost-user backend not capable of postcopy"); return -ENOENT; } break; =20 case POSTCOPY_NOTIFY_INBOUND_ADVISE: - return vhost_user_postcopy_advise(dev, pnd->errp); + return vhost_user_postcopy_advise(dev, errp); =20 case POSTCOPY_NOTIFY_INBOUND_LISTEN: - return vhost_user_postcopy_listen(dev, pnd->errp); + return vhost_user_postcopy_listen(dev, errp); =20 case POSTCOPY_NOTIFY_INBOUND_END: - return vhost_user_postcopy_end(dev, pnd->errp); + return vhost_user_postcopy_end(dev, errp); =20 default: /* We ignore notifications we don't know */ diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 3ab2f6b8fd..0273dc6a94 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -77,7 +77,6 @@ int postcopy_notify(enum PostcopyNotifyReason reason, Err= or **errp) { struct PostcopyNotifyData pnd; pnd.reason =3D reason; - pnd.errp =3D errp; =20 return notifier_with_return_list_notify(&postcopy_notifier_list, &pnd, errp); diff --git a/migration/ram.c b/migration/ram.c index 5b6b09edd9..45a00b45ed 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -426,7 +426,6 @@ int precopy_notify(PrecopyNotifyReason reason, Error **= errp) { PrecopyNotifyData pnd; pnd.reason =3D reason; - pnd.errp =3D errp; =20 return notifier_with_return_list_notify(&precopy_notifier_list, &pnd, = errp); } --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097460; cv=none; d=zohomail.com; s=zohoarc; b=QcxAggUDEG0qDnRt/+oPOjg0uwuUIhUl//vXDvWGEEiqESQtqgFuU8r9Ya8T/qVNTz1BbFu3lfImrqlWB34Qb2B/bOcLXFa/ijjsEigS9ohwXUKWxBrYJSDjGylEnqqK01gPfhj2UPU7LXWOL7DP2SDHtphJsQ9+lOg7j7DiRzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097460; 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=YO0QxHUKB0AsGIn6Pnka0iwoxzS4NVkRToYE9m6xvc8=; b=H4PVtxu4oGjF0U/rLYJsO5LCfR6dFUu+jPdw9TOXjvMpcmcVyNbT5c0IxhAdMpt45H96/j8yFVKeqIMYpQV1peEAl5bFR4aKkPyL4UsbMc9v7b/GCfaTCxQ8UF88QECmeE05/xXCb/6wlfNB83RrBL/Oj43Kmj6aO1LrQuoPSFk= 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 1709097460601528.6220136023343; Tue, 27 Feb 2024 21:17:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJc-0001rb-EG; Wed, 28 Feb 2024 00:17: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 1rfCI4-0000Qe-RD for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCHz-0006ul-NP for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:36 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-662-tXLUCgjNPcOiBZb_OIY6SQ-1; Wed, 28 Feb 2024 00:15:27 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F05938212DF; Wed, 28 Feb 2024 05:15:27 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FB491C060AF; Wed, 28 Feb 2024 05:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097331; h=from:from:reply-to:subject:subject: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=YO0QxHUKB0AsGIn6Pnka0iwoxzS4NVkRToYE9m6xvc8=; b=K0P15POzLhud1iLs/InbKMMitTuCX0Fec4R0azb5iuUn+Akt2KmSc44fCCbuQdbPHpzwP4 FnFOsw7LjVcrnq7yv8o3FbLui+Xqb1nIjvnRXWC0A7fF7zO3ivHXEC5L1bNhysSNZG4Oqe T/ANe5O5IxtPU3rWeG6euGvTeh8ZeEw= X-MC-Unique: tXLUCgjNPcOiBZb_OIY6SQ-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 13/25] migration: convert to NotifierWithReturn Date: Wed, 28 Feb 2024 13:13:03 +0800 Message-ID: <20240228051315.400759-14-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097461844100003 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Change all migration notifiers to type NotifierWithReturn, so notifiers can return an error status in a future patch. For now, pass NULL for the notifier error parameter, and do not check the return value. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/1708622920-68779-4-git-send-email-steven.si= stare@oracle.com [peterx: dropped unexpected update to roms/seabios-hppa] Signed-off-by: Peter Xu --- include/hw/vfio/vfio-common.h | 2 +- include/hw/virtio/virtio-net.h | 2 +- include/migration/misc.h | 6 +++--- include/qemu/notify.h | 1 + hw/net/virtio-net.c | 4 +++- hw/vfio/migration.c | 4 +++- migration/migration.c | 16 ++++++++-------- net/vhost-vdpa.c | 6 ++++-- ui/spice-core.c | 8 +++++--- 9 files changed, 29 insertions(+), 20 deletions(-) diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 9b7ef7d02b..4a6c262f77 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -62,7 +62,7 @@ typedef struct VFIORegion { typedef struct VFIOMigration { struct VFIODevice *vbasedev; VMChangeStateEntry *vm_state; - Notifier migration_state; + NotifierWithReturn migration_state; uint32_t device_state; int data_fd; void *data_buffer; diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 55977f01f0..eaee8f4243 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -221,7 +221,7 @@ struct VirtIONet { DeviceListener primary_listener; QDict *primary_opts; bool primary_opts_from_json; - Notifier migration_state; + NotifierWithReturn migration_state; VirtioNetRssData rss_data; struct NetRxPkt *rx_pkt; struct EBPFRSSContext ebpf_rss; diff --git a/include/migration/misc.h b/include/migration/misc.h index 5e65c18f1a..b62e351d96 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,9 +60,9 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); -void migration_add_notifier(Notifier *notify, - void (*func)(Notifier *notifier, void *data)); -void migration_remove_notifier(Notifier *notify); +void migration_add_notifier(NotifierWithReturn *notify, + NotifierWithReturnFunc func); +void migration_remove_notifier(NotifierWithReturn *notify); void migration_call_notifiers(MigrationState *s); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); diff --git a/include/qemu/notify.h b/include/qemu/notify.h index 9a85631864..abf18dbf59 100644 --- a/include/qemu/notify.h +++ b/include/qemu/notify.h @@ -45,6 +45,7 @@ bool notifier_list_empty(NotifierList *list); /* Same as Notifier but allows .notify() to return errors */ typedef struct NotifierWithReturn NotifierWithReturn; =20 +/* Return int to allow for different failure modes and recovery actions */ typedef int (*NotifierWithReturnFunc)(NotifierWithReturn *notifier, void *= data, Error **errp); =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 5a79bc3a3a..75f4e8664d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3534,11 +3534,13 @@ static void virtio_net_handle_migration_primary(Vir= tIONet *n, MigrationState *s) } } =20 -static void virtio_net_migration_state_notifier(Notifier *notifier, void *= data) +static int virtio_net_migration_state_notifier(NotifierWithReturn *notifie= r, + void *data, Error **errp) { MigrationState *s =3D data; VirtIONet *n =3D container_of(notifier, VirtIONet, migration_state); virtio_net_handle_migration_primary(n, s); + return 0; } =20 static bool failover_hide_primary_device(DeviceListener *listener, diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 70e6b1a709..6b6acc4140 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -754,7 +754,8 @@ static void vfio_vmstate_change(void *opaque, bool runn= ing, RunState state) mig_state_to_str(new_state)); } =20 -static void vfio_migration_state_notifier(Notifier *notifier, void *data) +static int vfio_migration_state_notifier(NotifierWithReturn *notifier, + void *data, Error **errp) { MigrationState *s =3D data; VFIOMigration *migration =3D container_of(notifier, VFIOMigration, @@ -770,6 +771,7 @@ static void vfio_migration_state_notifier(Notifier *not= ifier, void *data) case MIGRATION_STATUS_FAILED: vfio_migration_set_state_or_reset(vbasedev, VFIO_DEVICE_STATE_RUNN= ING); } + return 0; } =20 static void vfio_migration_free(VFIODevice *vbasedev) diff --git a/migration/migration.c b/migration/migration.c index ab21de2cad..6d4072e8e9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -69,8 +69,8 @@ #include "qemu/sockets.h" #include "sysemu/kvm.h" =20 -static NotifierList migration_state_notifiers =3D - NOTIFIER_LIST_INITIALIZER(migration_state_notifiers); +static NotifierWithReturnList migration_state_notifiers =3D + NOTIFIER_WITH_RETURN_LIST_INITIALIZER(migration_state_notifiers); =20 /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { @@ -1459,24 +1459,24 @@ static void migrate_fd_cancel(MigrationState *s) } } =20 -void migration_add_notifier(Notifier *notify, - void (*func)(Notifier *notifier, void *data)) +void migration_add_notifier(NotifierWithReturn *notify, + NotifierWithReturnFunc func) { notify->notify =3D func; - notifier_list_add(&migration_state_notifiers, notify); + notifier_with_return_list_add(&migration_state_notifiers, notify); } =20 -void migration_remove_notifier(Notifier *notify) +void migration_remove_notifier(NotifierWithReturn *notify) { if (notify->notify) { - notifier_remove(notify); + notifier_with_return_remove(notify); notify->notify =3D NULL; } } =20 void migration_call_notifiers(MigrationState *s) { - notifier_list_notify(&migration_state_notifiers, s); + notifier_with_return_list_notify(&migration_state_notifiers, s, 0); } =20 bool migration_in_setup(MigrationState *s) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 3726ee5d67..1c00519f10 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -34,7 +34,7 @@ typedef struct VhostVDPAState { NetClientState nc; struct vhost_vdpa vhost_vdpa; - Notifier migration_state; + NotifierWithReturn migration_state; VHostNetState *vhost_net; =20 /* Control commands shadow buffers */ @@ -322,7 +322,8 @@ static void vhost_vdpa_net_log_global_enable(VhostVDPAS= tate *s, bool enable) } } =20 -static void vdpa_net_migration_state_notifier(Notifier *notifier, void *da= ta) +static int vdpa_net_migration_state_notifier(NotifierWithReturn *notifier, + void *data, Error **errp) { MigrationState *migration =3D data; VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, @@ -333,6 +334,7 @@ static void vdpa_net_migration_state_notifier(Notifier = *notifier, void *data) } else if (migration_has_failed(migration)) { vhost_vdpa_net_log_global_enable(s, false); } + return 0; } =20 static void vhost_vdpa_net_data_start_first(VhostVDPAState *s) diff --git a/ui/spice-core.c b/ui/spice-core.c index 37b277fd09..b3cd229023 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -42,7 +42,7 @@ /* core bits */ =20 static SpiceServer *spice_server; -static Notifier migration_state; +static NotifierWithReturn migration_state; static const char *auth =3D "spice"; static char *auth_passwd; static time_t auth_expires =3D TIME_MAX; @@ -568,12 +568,13 @@ static SpiceInfo *qmp_query_spice_real(Error **errp) return info; } =20 -static void migration_state_notifier(Notifier *notifier, void *data) +static int migration_state_notifier(NotifierWithReturn *notifier, + void *data, Error **errp) { MigrationState *s =3D data; =20 if (!spice_have_target_host) { - return; + return 0; } =20 if (migration_in_setup(s)) { @@ -586,6 +587,7 @@ static void migration_state_notifier(Notifier *notifier= , void *data) spice_server_migrate_end(spice_server, false); spice_have_target_host =3D false; } + return 0; } =20 int qemu_spice_migrate_info(const char *hostname, int port, int tls_port, --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097746; cv=none; d=zohomail.com; s=zohoarc; b=k8vdk/QAci8nX08SCYLe4sLHfdfryc6bTrQoOhnuKOUdP2tHgcw8dEu17QrIOnwcj/3IeYDrYrgIC90RTAnGiEcz77L4RPHCuHqHvmTyk4QbZwK9wHk/NlvHw3VkOZP4h1oMy7eh1Ew27WQi/+4TQ1D/8Y+qlf8kqj4yTn0L2Yo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097746; 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=15Vi8iKrrKtjdGksBgiWczidIHqvhphywpKv1t8TsM8=; b=LBX3Y27WDgqRf8J03/ftzUkY66MEEXyUkPTynUEi1wLXubf1Onm3z/gUHxaC4mxSgcAA9pyYIPyJLuYex0+sf2/baber6djFJjzHC9MeTvTGblASExBfdrpsEIap3XVL4bWfsJeVlphwZWgNrAOW/eo5IDfh/qIqhd5c9fRCacI= 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 170909774660592.78635619667273; Tue, 27 Feb 2024 21:22:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJ2-00019s-UC; Wed, 28 Feb 2024 00:16:39 -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 1rfCIC-0000Yr-M5 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:47 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCI8-0006vK-FH for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:44 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-65-mZAMKIV_PhG-6YuJtdol_w-1; Wed, 28 Feb 2024 00:15:37 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D4693C11CC5; Wed, 28 Feb 2024 05:15:37 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EB9B1C06710; Wed, 28 Feb 2024 05:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097339; h=from:from:reply-to:subject:subject: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=15Vi8iKrrKtjdGksBgiWczidIHqvhphywpKv1t8TsM8=; b=Lndc/gvNbTW4ogcQPs9uCwPpoLAX//+95FkFeZz+uyuHOBP9vK/syW7SbHkvvODg+eOEc/ sRvjNjLNFOA4MwhuGevTMoRkrWgJV0sACDzGYCDxDqk+Oh9kwBNawZCemD534x9U64fCFQ jS4nRPRAocuCEztaaxMvgB3iwdjqKg0= X-MC-Unique: mZAMKIV_PhG-6YuJtdol_w-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 14/25] migration: MigrationEvent for notifiers Date: Wed, 28 Feb 2024 13:13:04 +0800 Message-ID: <20240228051315.400759-15-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097748559100003 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Passing MigrationState to notifiers is unsound because they could access unstable migration state internals or even modify the state. Instead, pass the minimal info needed in a new MigrationEvent struct, which could be extended in the future if needed. Suggested-by: Peter Xu Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/1708622920-68779-5-git-send-email-steven.si= stare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 23 ++++++++++++++++++++++- hw/net/virtio-net.c | 11 ++++++----- hw/vfio/migration.c | 10 +++------- migration/migration.c | 17 ++++++++++++----- net/vhost-vdpa.c | 6 +++--- ui/spice-core.c | 9 ++++----- hw/vfio/trace-events | 2 +- 7 files changed, 51 insertions(+), 27 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index b62e351d96..9e4abae97f 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,10 +60,31 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); + +typedef enum MigrationEventType { + MIG_EVENT_PRECOPY_SETUP, + MIG_EVENT_PRECOPY_DONE, + MIG_EVENT_PRECOPY_FAILED, + MIG_EVENT_MAX +} MigrationEventType; + +typedef struct MigrationEvent { + MigrationEventType type; +} MigrationEvent; + +/* + * Register the notifier @notify to be called when a migration event occurs + * for MIG_MODE_NORMAL, as specified by the MigrationEvent passed to @func. + * Notifiers may receive events in any of the following orders: + * - MIG_EVENT_PRECOPY_SETUP -> MIG_EVENT_PRECOPY_DONE + * - MIG_EVENT_PRECOPY_SETUP -> MIG_EVENT_PRECOPY_FAILED + * - MIG_EVENT_PRECOPY_FAILED + */ void migration_add_notifier(NotifierWithReturn *notify, NotifierWithReturnFunc func); + void migration_remove_notifier(NotifierWithReturn *notify); -void migration_call_notifiers(MigrationState *s); +void migration_call_notifiers(MigrationState *s, MigrationEventType type); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 75f4e8664d..e803f98c3a 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3504,7 +3504,7 @@ out: return !err; } =20 -static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationSta= te *s) +static void virtio_net_handle_migration_primary(VirtIONet *n, MigrationEve= nt *e) { bool should_be_hidden; Error *err =3D NULL; @@ -3516,7 +3516,7 @@ static void virtio_net_handle_migration_primary(VirtI= ONet *n, MigrationState *s) =20 should_be_hidden =3D qatomic_read(&n->failover_primary_hidden); =20 - if (migration_in_setup(s) && !should_be_hidden) { + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP && !should_be_hidden) { if (failover_unplug_primary(n, dev)) { vmstate_unregister(VMSTATE_IF(dev), qdev_get_vmsd(dev), dev); qapi_event_send_unplug_primary(dev->id); @@ -3524,7 +3524,7 @@ static void virtio_net_handle_migration_primary(VirtI= ONet *n, MigrationState *s) } else { warn_report("couldn't unplug primary device"); } - } else if (migration_has_failed(s)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { /* We already unplugged the device let's plug it back */ if (!failover_replug_primary(n, dev, &err)) { if (err) { @@ -3537,9 +3537,10 @@ static void virtio_net_handle_migration_primary(Virt= IONet *n, MigrationState *s) static int virtio_net_migration_state_notifier(NotifierWithReturn *notifie= r, void *data, Error **errp) { - MigrationState *s =3D data; + MigrationEvent *e =3D data; + VirtIONet *n =3D container_of(notifier, VirtIONet, migration_state); - virtio_net_handle_migration_primary(n, s); + virtio_net_handle_migration_primary(n, e); return 0; } =20 diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 6b6acc4140..869d8417d6 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -757,18 +757,14 @@ static void vfio_vmstate_change(void *opaque, bool ru= nning, RunState state) static int vfio_migration_state_notifier(NotifierWithReturn *notifier, void *data, Error **errp) { - MigrationState *s =3D data; + MigrationEvent *e =3D data; VFIOMigration *migration =3D container_of(notifier, VFIOMigration, migration_state); VFIODevice *vbasedev =3D migration->vbasedev; =20 - trace_vfio_migration_state_notifier(vbasedev->name, - MigrationStatus_str(s->state)); + trace_vfio_migration_state_notifier(vbasedev->name, e->type); =20 - switch (s->state) { - case MIGRATION_STATUS_CANCELLING: - case MIGRATION_STATUS_CANCELLED: - case MIGRATION_STATUS_FAILED: + if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { vfio_migration_set_state_or_reset(vbasedev, VFIO_DEVICE_STATE_RUNN= ING); } return 0; diff --git a/migration/migration.c b/migration/migration.c index 6d4072e8e9..4650c21f67 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1319,6 +1319,8 @@ void migrate_set_state(int *state, int old_state, int= new_state) =20 static void migrate_fd_cleanup(MigrationState *s) { + MigrationEventType type; + g_free(s->hostname); s->hostname =3D NULL; json_writer_free(s->vmdesc); @@ -1367,7 +1369,9 @@ static void migrate_fd_cleanup(MigrationState *s) /* It is used on info migrate. We can't free it */ error_report_err(error_copy(s->error)); } - migration_call_notifiers(s); + type =3D migration_has_failed(s) ? MIG_EVENT_PRECOPY_FAILED : + MIG_EVENT_PRECOPY_DONE; + migration_call_notifiers(s, type); block_cleanup_parameters(); yank_unregister_instance(MIGRATION_YANK_INSTANCE); } @@ -1474,9 +1478,12 @@ void migration_remove_notifier(NotifierWithReturn *n= otify) } } =20 -void migration_call_notifiers(MigrationState *s) +void migration_call_notifiers(MigrationState *s, MigrationEventType type) { - notifier_with_return_list_notify(&migration_state_notifiers, s, 0); + MigrationEvent e; + + e.type =3D type; + notifier_with_return_list_notify(&migration_state_notifiers, &e, 0); } =20 bool migration_in_setup(MigrationState *s) @@ -2537,7 +2544,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * spice needs to trigger a transition now */ ms->postcopy_after_devices =3D true; - migration_call_notifiers(ms); + migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE); =20 migration_downtime_end(ms); =20 @@ -3601,7 +3608,7 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) rate_limit =3D migrate_max_bandwidth(); =20 /* Notify before starting migration thread */ - migration_call_notifiers(s); + migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP); } =20 migration_rate_set(rate_limit); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 1c00519f10..a29d18a9ef 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -325,13 +325,13 @@ static void vhost_vdpa_net_log_global_enable(VhostVDP= AState *s, bool enable) static int vdpa_net_migration_state_notifier(NotifierWithReturn *notifier, void *data, Error **errp) { - MigrationState *migration =3D data; + MigrationEvent *e =3D data; VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, migration_state); =20 - if (migration_in_setup(migration)) { + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP) { vhost_vdpa_net_log_global_enable(s, true); - } else if (migration_has_failed(migration)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { vhost_vdpa_net_log_global_enable(s, false); } return 0; diff --git a/ui/spice-core.c b/ui/spice-core.c index b3cd229023..0a59876da2 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -571,19 +571,18 @@ static SpiceInfo *qmp_query_spice_real(Error **errp) static int migration_state_notifier(NotifierWithReturn *notifier, void *data, Error **errp) { - MigrationState *s =3D data; + MigrationEvent *e =3D data; =20 if (!spice_have_target_host) { return 0; } =20 - if (migration_in_setup(s)) { + if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP) { spice_server_migrate_start(spice_server); - } else if (migration_has_finished(s) || - migration_in_postcopy_after_devices(s)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_DONE) { spice_server_migrate_end(spice_server, true); spice_have_target_host =3D false; - } else if (migration_has_failed(s)) { + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { spice_server_migrate_end(spice_server, false); spice_have_target_host =3D false; } diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 8fdde54456..f0474b244b 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -153,7 +153,7 @@ vfio_load_state(const char *name, uint64_t data) " (%s)= data 0x%"PRIx64 vfio_load_state_device_data(const char *name, uint64_t data_size, int ret)= " (%s) size 0x%"PRIx64" ret %d" vfio_migration_realize(const char *name) " (%s)" vfio_migration_set_state(const char *name, const char *state) " (%s) state= %s" -vfio_migration_state_notifier(const char *name, const char *state) " (%s) = state %s" +vfio_migration_state_notifier(const char *name, int state) " (%s) state %d" vfio_save_block(const char *name, int data_size) " (%s) data_size %d" vfio_save_cleanup(const char *name) " (%s)" vfio_save_complete_precopy(const char *name, int ret) " (%s) ret %d" --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097465; cv=none; d=zohomail.com; s=zohoarc; b=RKgSfGqVytd9EFndJ5CWr2VkYofObxzBa6kHGkjoi7Uf5d64qIhQvDVIRwlh0YEkta0CPtkepDyr1M8cH1xM+tdnF/CWyqkZUOllf2ocfcK+b6MCUsLFD8q8Qlfl9ax17Im8J5LR5I49qBehxvYvIJ5XWr32G+/KtJmW9baOSxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097465; 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=VwqL+RGq+hFNR5LKcItZK6P97VIqtguuwPKFrYGwNfY=; b=nXjHz7L7hEt43B9qbd2ZBCscM+okxspQ2kAIG7uN9o4Ikkkdhklpq9/09SOU1S9kUtKkJgkboZ9+pMttdh4zn9lLnx2gsq0hREGlZmtDSXrXtRmo05a3UQ8R3BCZzTr46bDiZZZDEKH6F+mZhH1cbgHhOKxOuhyr19BAqpbSO/A= 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 1709097465233758.1011531061004; Tue, 27 Feb 2024 21:17:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJU-0001SU-R6; Wed, 28 Feb 2024 00:17: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 1rfCIO-0000hV-K9 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCIJ-0006wN-Uf for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:15:56 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-272-EVs-krNhPGWUvG2oj19gJA-1; Wed, 28 Feb 2024 00:15:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5BC038212C6; Wed, 28 Feb 2024 05:15:46 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D07911C06532; Wed, 28 Feb 2024 05:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097350; h=from:from:reply-to:subject:subject: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=VwqL+RGq+hFNR5LKcItZK6P97VIqtguuwPKFrYGwNfY=; b=bG155ei5ygtQ+czgntt9jP4rcBwddW7KVZREt7wwvn5bYg73lAIOIgmZzqzIV7ud89lug3 Y/CDoj5WCgbrsNaKiejAvqXyn0BPcHjeDBkm7aDp1SSuUQeyGOtrtdJ1jqHOmAjUsS4ZNq ZLPaXLGCJAcIK+OBandZdCdeUDAK4No= X-MC-Unique: EVs-krNhPGWUvG2oj19gJA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 15/25] migration: remove postcopy_after_devices Date: Wed, 28 Feb 2024 13:13:05 +0800 Message-ID: <20240228051315.400759-16-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097465806100011 Content-Type: text/plain; charset="utf-8" From: Steve Sistare postcopy_after_devices and migration_in_postcopy_after_devices are no longer used, so delete them. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/1708622920-68779-6-git-send-email-steven.si= stare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 - migration/migration.h | 2 -- migration/migration.c | 7 ------- 3 files changed, 10 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 9e4abae97f..e6150009e0 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -89,7 +89,6 @@ bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); /* ...and after the device transmission */ -bool migration_in_postcopy_after_devices(MigrationState *); /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ bool migration_in_incoming_postcopy(void); /* True if incoming migration entered POSTCOPY_INCOMING_ADVISE */ diff --git a/migration/migration.h b/migration/migration.h index f2c8b8f286..aef8afbe1f 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -348,8 +348,6 @@ struct MigrationState { =20 /* Flag set once the migration has been asked to enter postcopy */ bool start_postcopy; - /* Flag set after postcopy has sent the device state */ - bool postcopy_after_devices; =20 /* Flag set once the migration thread is running (and needs joining) */ bool migration_thread_running; diff --git a/migration/migration.c b/migration/migration.c index 4650c21f67..8f7f2d92f4 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1527,11 +1527,6 @@ bool migration_postcopy_is_alive(int state) } } =20 -bool migration_in_postcopy_after_devices(MigrationState *s) -{ - return migration_in_postcopy() && s->postcopy_after_devices; -} - bool migration_in_incoming_postcopy(void) { PostcopyState ps =3D postcopy_state_get(); @@ -1613,7 +1608,6 @@ int migrate_init(MigrationState *s, Error **errp) s->expected_downtime =3D 0; s->setup_time =3D 0; s->start_postcopy =3D false; - s->postcopy_after_devices =3D false; s->migration_thread_running =3D false; error_free(s->error); s->error =3D NULL; @@ -2543,7 +2537,6 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * at the transition to postcopy and after the device state; in partic= ular * spice needs to trigger a transition now */ - ms->postcopy_after_devices =3D true; migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE); =20 migration_downtime_end(ms); --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097693; cv=none; d=zohomail.com; s=zohoarc; b=d1gy7sZeq9szi/rgK7ppXKeXfQRXIX8McFWQcfc2iKruwFXyDtINucEYn/cG7VITC/IQPZIISnF297GnNVBGEdOaVlvNygpeGY6UjogTLa+fGye+EMedCN0lNcRgkEs4lVCVkswr5iACfRo+penZpEBX5EVYAN2D8ID95oj8hHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097693; 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=Qd8Z/jutVJfb9LaI81oSmXF2ibdrxNCl4dXH9s/tEq8=; b=XoCWta0gnWlkjfIm/yfu7dTsBDjPCSKuVStG8mXQjQAV+5TtnfstNcb6Zqy91JRngJqO07c7h7228nXWc5PVebwR+wngzngHwNgZyfiht0MeUOSsi0NqD7H9S596JfIssR82PtXVmT9vGhbJhhc7zXa5h07gJ4Z+K0QnZomh4ls= 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 1709097693013669.0598786809945; Tue, 27 Feb 2024 21:21:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCKA-0003re-Jl; Wed, 28 Feb 2024 00:17: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 1rfCIX-0000pr-4l for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCIS-0006xM-OQ for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:04 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-Nras3mU-OSSHnKAEGHjgyw-1; Wed, 28 Feb 2024 00:15:56 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B40E185A781; Wed, 28 Feb 2024 05:15:56 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 753B31C06532; Wed, 28 Feb 2024 05:15:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097360; h=from:from:reply-to:subject:subject: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=Qd8Z/jutVJfb9LaI81oSmXF2ibdrxNCl4dXH9s/tEq8=; b=EUrwedcCkOMk1jL/0nNbB0B7QBF/YzR5YmA9vD2ayIFLhC02ghPeJ0XeYD32CrPl/rOjBK TSABUzLKaFLdWRpTcZF9gZ+tUBTtcchXrTLGQLv0URYzstJoyiNQSHg1oFJJrCQIt7Lvl4 6pLyNY7dG/5dAUfz0pmwNx+D8Z9K9SQ= X-MC-Unique: Nras3mU-OSSHnKAEGHjgyw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 16/25] migration: MigrationNotifyFunc Date: Wed, 28 Feb 2024 13:13:06 +0800 Message-ID: <20240228051315.400759-17-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097694436100003 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Define MigrationNotifyFunc to improve type safety and simplify migration notifiers. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/1708622920-68779-7-git-send-email-steven.si= stare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 5 ++++- hw/net/virtio-net.c | 4 +--- hw/vfio/migration.c | 3 +-- migration/migration.c | 4 ++-- net/vhost-vdpa.c | 6 ++---- ui/spice-core.c | 4 +--- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index e6150009e0..e36a1f3ec4 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -72,6 +72,9 @@ typedef struct MigrationEvent { MigrationEventType type; } MigrationEvent; =20 +typedef int (*MigrationNotifyFunc)(NotifierWithReturn *notify, + MigrationEvent *e, Error **errp); + /* * Register the notifier @notify to be called when a migration event occurs * for MIG_MODE_NORMAL, as specified by the MigrationEvent passed to @func. @@ -81,7 +84,7 @@ typedef struct MigrationEvent { * - MIG_EVENT_PRECOPY_FAILED */ void migration_add_notifier(NotifierWithReturn *notify, - NotifierWithReturnFunc func); + MigrationNotifyFunc func); =20 void migration_remove_notifier(NotifierWithReturn *notify); void migration_call_notifiers(MigrationState *s, MigrationEventType type); diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index e803f98c3a..a3c711b56d 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -3535,10 +3535,8 @@ static void virtio_net_handle_migration_primary(Virt= IONet *n, MigrationEvent *e) } =20 static int virtio_net_migration_state_notifier(NotifierWithReturn *notifie= r, - void *data, Error **errp) + MigrationEvent *e, Error **= errp) { - MigrationEvent *e =3D data; - VirtIONet *n =3D container_of(notifier, VirtIONet, migration_state); virtio_net_handle_migration_primary(n, e); return 0; diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 869d8417d6..50140eda87 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -755,9 +755,8 @@ static void vfio_vmstate_change(void *opaque, bool runn= ing, RunState state) } =20 static int vfio_migration_state_notifier(NotifierWithReturn *notifier, - void *data, Error **errp) + MigrationEvent *e, Error **errp) { - MigrationEvent *e =3D data; VFIOMigration *migration =3D container_of(notifier, VFIOMigration, migration_state); VFIODevice *vbasedev =3D migration->vbasedev; diff --git a/migration/migration.c b/migration/migration.c index 8f7f2d92f4..33149c462c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1464,9 +1464,9 @@ static void migrate_fd_cancel(MigrationState *s) } =20 void migration_add_notifier(NotifierWithReturn *notify, - NotifierWithReturnFunc func) + MigrationNotifyFunc func) { - notify->notify =3D func; + notify->notify =3D (NotifierWithReturnFunc)func; notifier_with_return_list_add(&migration_state_notifiers, notify); } =20 diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index a29d18a9ef..e6bdb4562d 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -323,11 +323,9 @@ static void vhost_vdpa_net_log_global_enable(VhostVDPA= State *s, bool enable) } =20 static int vdpa_net_migration_state_notifier(NotifierWithReturn *notifier, - void *data, Error **errp) + MigrationEvent *e, Error **er= rp) { - MigrationEvent *e =3D data; - VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, - migration_state); + VhostVDPAState *s =3D container_of(notifier, VhostVDPAState, migration= _state); =20 if (e->type =3D=3D MIG_EVENT_PRECOPY_SETUP) { vhost_vdpa_net_log_global_enable(s, true); diff --git a/ui/spice-core.c b/ui/spice-core.c index 0a59876da2..15be640286 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -569,10 +569,8 @@ static SpiceInfo *qmp_query_spice_real(Error **errp) } =20 static int migration_state_notifier(NotifierWithReturn *notifier, - void *data, Error **errp) + MigrationEvent *e, Error **errp) { - MigrationEvent *e =3D data; - if (!spice_have_target_host) { return 0; } --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097744; cv=none; d=zohomail.com; s=zohoarc; b=S9lmUWjGMUWYLqzDAne+N1GVYkX7WKQztmlhq1HouyZ5oYi3SRxTPS0om423iCPMK/KOknqhX4NwOo/mDH34S1WUxnZG/WpAUZ1g4BrTJ24g/2UzJ0bIuMTZroB0UUCLyQId6W4TuS+Mwxr3uDZ/H4Prqf2GV7q36sunPwiN3RI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097744; 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=7NsovfeF8cfD7pP93qcBb8PC0+ZjoQaPnIIVHkuGSPY=; b=WxLpxXsI2eqfW2Y3v86EaNcPbGYSn5f5/mIMARYv2dKvXoAG34fIkjwVpOc1VhFYdrm5vopaV4g9QkzMgv1hnJwaLxQVgL8vpIWbg2pEpf4AEgLwmF68D4BiMTNLJDV1tyQ3PuPwqOl4dFfddwU+eJIQOZLj2GUgXhUIAQRe0+E= 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 1709097744123826.5419906161488; Tue, 27 Feb 2024 21:22:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJm-0001yi-4b; Wed, 28 Feb 2024 00:17:22 -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 1rfCIv-0001Ay-Nq for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:35 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCIr-0007EB-QW for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:29 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-551-SeGDnQN8Mmq_0OI9E0p8PA-1; Wed, 28 Feb 2024 00:16:22 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20DA23C11CC4; Wed, 28 Feb 2024 05:16:06 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0430B1C060B1; Wed, 28 Feb 2024 05:15:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097384; h=from:from:reply-to:subject:subject: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=7NsovfeF8cfD7pP93qcBb8PC0+ZjoQaPnIIVHkuGSPY=; b=XAqbjspupbjCup1UvEJDqfSYAaEj9uq8vmd4RqrazQi7z7VohXvMPLWoiSBSq+QOOZF/je 2TF173PcNnsxAbxhWTrfOptoYR643VfVSRs/wpOz8r53kpHjpqTrIf7fsOTC3d5ahghQLZ 7Go899G/yf1Uxdv5niMzMPERD1ToUd0= X-MC-Unique: SeGDnQN8Mmq_0OI9E0p8PA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 17/25] migration: per-mode notifiers Date: Wed, 28 Feb 2024 13:13:07 +0800 Message-ID: <20240228051315.400759-18-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097744519100009 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Keep a separate list of migration notifiers for each migration mode. Suggested-by: Peter Xu Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/1708622920-68779-8-git-send-email-steven.si= stare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 6 ++++++ migration/migration.c | 22 +++++++++++++++++----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index e36a1f3ec4..4dc06a92b7 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -86,6 +86,12 @@ typedef int (*MigrationNotifyFunc)(NotifierWithReturn *n= otify, void migration_add_notifier(NotifierWithReturn *notify, MigrationNotifyFunc func); =20 +/* + * Same as migration_add_notifier, but applies to be specified @mode. + */ +void migration_add_notifier_mode(NotifierWithReturn *notify, + MigrationNotifyFunc func, MigMode mode); + void migration_remove_notifier(NotifierWithReturn *notify); void migration_call_notifiers(MigrationState *s, MigrationEventType type); bool migration_in_setup(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 33149c462c..925103b61a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -69,8 +69,13 @@ #include "qemu/sockets.h" #include "sysemu/kvm.h" =20 -static NotifierWithReturnList migration_state_notifiers =3D - NOTIFIER_WITH_RETURN_LIST_INITIALIZER(migration_state_notifiers); +#define NOTIFIER_ELEM_INIT(array, elem) \ + [elem] =3D NOTIFIER_WITH_RETURN_LIST_INITIALIZER((array)[elem]) + +static NotifierWithReturnList migration_state_notifiers[] =3D { + NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_NORMAL), + NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_CPR_REBOOT), +}; =20 /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { @@ -1463,11 +1468,17 @@ static void migrate_fd_cancel(MigrationState *s) } } =20 +void migration_add_notifier_mode(NotifierWithReturn *notify, + MigrationNotifyFunc func, MigMode mode) +{ + notify->notify =3D (NotifierWithReturnFunc)func; + notifier_with_return_list_add(&migration_state_notifiers[mode], notify= ); +} + void migration_add_notifier(NotifierWithReturn *notify, MigrationNotifyFunc func) { - notify->notify =3D (NotifierWithReturnFunc)func; - notifier_with_return_list_add(&migration_state_notifiers, notify); + migration_add_notifier_mode(notify, func, MIG_MODE_NORMAL); } =20 void migration_remove_notifier(NotifierWithReturn *notify) @@ -1480,10 +1491,11 @@ void migration_remove_notifier(NotifierWithReturn *= notify) =20 void migration_call_notifiers(MigrationState *s, MigrationEventType type) { + MigMode mode =3D s->parameters.mode; MigrationEvent e; =20 e.type =3D type; - notifier_with_return_list_notify(&migration_state_notifiers, &e, 0); + notifier_with_return_list_notify(&migration_state_notifiers[mode], &e,= 0); } =20 bool migration_in_setup(MigrationState *s) --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097741; cv=none; d=zohomail.com; s=zohoarc; b=gh2He9fIXMcQ12tiBSoQcFnzWJ3YeQrpNYATznVUKOQUHuODLrwoeJj0eH3KwfDUcVaWrIOL/31/YAm0YZLDDlo8cmCo5VXSdmY8BnFBTt5rzWlWW5O2R7jJtfVJd7NGPbCz7CtM+nZnEoOrtWs0ahWw4iyQXw2jWzD4yE241ZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097741; 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=976ofXCQ+ZURBsxTTe6MQFPpvlilgxPR1g+V7wD4ViY=; b=EnqHl0ZIdy4QC7CnkUrItp8JiSsjxUkGXopY/faho3yh1+yQ7IUgnxhNz3pwaM2z3IF9Y7obmnDkoKlj95vgOEMFd40qz0yuwUE5+LzcCfbbXkBSAJJWnmhs7Gz0Gc/oFuLj6/7Vd0L4Qh0DDlRyKxsnm9tV2I+TNHvQwqzUPpk= 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 1709097741855608.7074148323665; Tue, 27 Feb 2024 21:22:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJm-000239-HJ; Wed, 28 Feb 2024 00:17:22 -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 1rfCIs-0001A9-8Y for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCIn-0007CH-CS for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:25 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-608-XIxHTxGqM6Ke01mbWY99jA-1; Wed, 28 Feb 2024 00:16:16 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A068B85A599; Wed, 28 Feb 2024 05:16:15 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4C9A1C06710; Wed, 28 Feb 2024 05:16:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097379; h=from:from:reply-to:subject:subject: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=976ofXCQ+ZURBsxTTe6MQFPpvlilgxPR1g+V7wD4ViY=; b=UCRX1mKuaKP8hzLoDXRsMfu/fE0BoY0zp9zr+3D7kOu1IK/EaHTLhyNYJ9Xp+vbmc+MwEZ OPMlvh1d22OaTz6fNCboqOHRUTeZE755F80W6Hp5si3kwx59UL0+evTEns/n3+z8oU33cA gAaoWxBD2S5CNDZQgNyqX2a8V8gssrA= X-MC-Unique: XIxHTxGqM6Ke01mbWY99jA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 18/25] migration: refactor migrate_fd_connect failures Date: Wed, 28 Feb 2024 13:13:08 +0800 Message-ID: <20240228051315.400759-19-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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 @redhat.com) X-ZM-MESSAGEID: 1709097742563100002 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Move common code for the error path in migrate_fd_connect to a shared fail label. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Reviewed-by: David Hildenbrand Link: https://lore.kernel.org/r/1708622920-68779-9-git-send-email-steven.si= stare@oracle.com Signed-off-by: Peter Xu --- migration/migration.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 925103b61a..6a115d28b8 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3627,11 +3627,7 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) if (migrate_postcopy_ram() || migrate_return_path()) { if (open_return_path_on_source(s)) { error_setg(&local_err, "Unable to open return-path for postcop= y"); - migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED= ); - migrate_set_error(s, local_err); - error_report_err(local_err); - migrate_fd_cleanup(s); - return; + goto fail; } } =20 @@ -3660,6 +3656,13 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) migration_thread, s, QEMU_THREAD_JOINABLE); } s->migration_thread_running =3D true; + return; + +fail: + migrate_set_error(s, local_err); + migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); + error_report_err(local_err); + migrate_fd_cleanup(s); } =20 static void migration_class_init(ObjectClass *klass, void *data) --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097465; cv=none; d=zohomail.com; s=zohoarc; b=Y2MmYB/dVIwtbISKfRmjPkILGNzdG1mzraJVcO161PyR0umfRZmFKH6SJfCcG28ckTFg/a7T3NXE3fPBR2H6itPpOcrUP8sxlswlKhFgxROt1rtXgVUbVdjiUFzxLxTR7x+Sa4VQYfTaZ9Dz9XxYQBRU0VMU03Cs1uqh0azcD1s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097465; 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=Dg1ggDXCGJYUq+p4wWurYdu97dbcucxaIdvVX4P1Egk=; b=cXCoWmBCr1LTyfup/oOilSs3Sq1hEco1KcsVZ6Bnvv0ev3z7jzDG8c/pcxIH+q9xac67CdO6REmhuHkdvZItRBNSPYI7bdox+bSsRWgJe+yh166/ucKHq+LdL0WbB3btb0TMRga/tP9ctwafE7bSrB1aOqngxH+d7yOdfhq6HR4= 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 1709097465798622.8398712174843; Tue, 27 Feb 2024 21:17:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJv-0002Kg-23; Wed, 28 Feb 2024 00:17:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCJ7-0001Kb-EY for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCIv-0007Gs-M9 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:39 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-575-NvQZgMmEP4qfaw3A-vC7Vw-1; Wed, 28 Feb 2024 00:16:25 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76E643C11CC3; Wed, 28 Feb 2024 05:16:25 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7093F1C060B1; Wed, 28 Feb 2024 05:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097389; h=from:from:reply-to:subject:subject: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=Dg1ggDXCGJYUq+p4wWurYdu97dbcucxaIdvVX4P1Egk=; b=gUa1sEkQ6J+3aVYoXPbZOR8zKdJKbgx5oS0SB2kcmPlIBTvF+9ys6Sw1l/fnGWiveyNeS/ iZQrL161kms9nHpQ4t9XIMYm6qNKKKOKhdkFVA5NpHrIJTzr842WKcE+ZhE2daNjvhzAHW za5Z2/t34mm/kAfZPKcTFGPg3oGdeZg= X-MC-Unique: NvQZgMmEP4qfaw3A-vC7Vw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 19/25] migration: notifier error checking Date: Wed, 28 Feb 2024 13:13:09 +0800 Message-ID: <20240228051315.400759-20-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097467820100017 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Check the status returned by migration notifiers for event type MIG_EVENT_PRECOPY_SETUP, and report errors. None of the notifiers return an error status at this time. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/1708622920-68779-10-git-send-email-steven.s= istare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 8 +++++++- migration/migration.c | 25 ++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index 4dc06a92b7..e4933b815b 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -72,6 +72,11 @@ typedef struct MigrationEvent { MigrationEventType type; } MigrationEvent; =20 +/* + * A MigrationNotifyFunc may return an error code and an Error object, + * but only when @e->type is MIG_EVENT_PRECOPY_SETUP. The code is an int + * to allow for different failure modes and recovery actions. + */ typedef int (*MigrationNotifyFunc)(NotifierWithReturn *notify, MigrationEvent *e, Error **errp); =20 @@ -93,7 +98,8 @@ void migration_add_notifier_mode(NotifierWithReturn *noti= fy, MigrationNotifyFunc func, MigMode mode); =20 void migration_remove_notifier(NotifierWithReturn *notify); -void migration_call_notifiers(MigrationState *s, MigrationEventType type); +int migration_call_notifiers(MigrationState *s, MigrationEventType type, + Error **errp); bool migration_in_setup(MigrationState *); bool migration_has_finished(MigrationState *); bool migration_has_failed(MigrationState *); diff --git a/migration/migration.c b/migration/migration.c index 6a115d28b8..37c836b0b0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1376,7 +1376,7 @@ static void migrate_fd_cleanup(MigrationState *s) } type =3D migration_has_failed(s) ? MIG_EVENT_PRECOPY_FAILED : MIG_EVENT_PRECOPY_DONE; - migration_call_notifiers(s, type); + migration_call_notifiers(s, type, NULL); block_cleanup_parameters(); yank_unregister_instance(MIGRATION_YANK_INSTANCE); } @@ -1489,13 +1489,18 @@ void migration_remove_notifier(NotifierWithReturn *= notify) } } =20 -void migration_call_notifiers(MigrationState *s, MigrationEventType type) +int migration_call_notifiers(MigrationState *s, MigrationEventType type, + Error **errp) { MigMode mode =3D s->parameters.mode; MigrationEvent e; + int ret; =20 e.type =3D type; - notifier_with_return_list_notify(&migration_state_notifiers[mode], &e,= 0); + ret =3D notifier_with_return_list_notify(&migration_state_notifiers[mo= de], + &e, errp); + assert(!ret || type =3D=3D MIG_EVENT_PRECOPY_SETUP); + return ret; } =20 bool migration_in_setup(MigrationState *s) @@ -2549,7 +2554,7 @@ static int postcopy_start(MigrationState *ms, Error *= *errp) * at the transition to postcopy and after the device state; in partic= ular * spice needs to trigger a transition now */ - migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE); + migration_call_notifiers(ms, MIG_EVENT_PRECOPY_DONE, NULL); =20 migration_downtime_end(ms); =20 @@ -2569,11 +2574,10 @@ static int postcopy_start(MigrationState *ms, Error= **errp) =20 ret =3D qemu_file_get_error(ms->to_dst_file); if (ret) { - error_setg(errp, "postcopy_start: Migration stream errored"); - migrate_set_state(&ms->state, MIGRATION_STATUS_POSTCOPY_ACTIVE, - MIGRATION_STATUS_FAILED); + error_setg_errno(errp, -ret, "postcopy_start: Migration stream err= or"); + bql_lock(); + goto fail; } - trace_postcopy_preempt_enabled(migrate_postcopy_preempt()); =20 return ret; @@ -2594,6 +2598,7 @@ fail: error_report_err(local_err); } } + migration_call_notifiers(ms, MIG_EVENT_PRECOPY_FAILED, NULL); bql_unlock(); return -1; } @@ -3613,7 +3618,9 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) rate_limit =3D migrate_max_bandwidth(); =20 /* Notify before starting migration thread */ - migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP); + if (migration_call_notifiers(s, MIG_EVENT_PRECOPY_SETUP, &local_er= r)) { + goto fail; + } } =20 migration_rate_set(rate_limit); --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097574; cv=none; d=zohomail.com; s=zohoarc; b=KFhGw8+xtqDme0IkOSNjEEnKwlu+WSGgQw4Q4zZZ7NJrGVuy8+JCL+C4z4DitZoZNet9IYg02nmYBvw32ihhXt+D1+dKrIW5BvJNkoQkolG9BAuwzIkcr4AUCr9jEpBIe6R3ZX1ceXbFEDLWhlU5TthKL0AQHDsdOR7RVOpQxXM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097574; 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=LlFwz6O3mZ2LTaLrgZ+vg13FsQPgmVBoBxanF/BPCd4=; b=lqb1BV96AL/duVPi4dMt4pVjmmtBu80NTz8k6PB/i+rm2wL873uuP3fe4sb/hWVectKuuXbIBf2tjQLQp3sDOW7stnvZWk2ikNU/KstwBq3p19BfuRH8hg5aV73RpNNgTe8HfU/35sek3hgxILsM8PD5mPc1rvCAKBNbOIo3YOA= 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 1709097574931837.853127892893; Tue, 27 Feb 2024 21:19:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJx-0002Qc-DM; Wed, 28 Feb 2024 00:17:33 -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 1rfCJK-0001Og-0W for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCJ5-0007Hu-Er for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:52 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-631-NuewWbeGNMimO56PS6ym3w-1; Wed, 28 Feb 2024 00:16:35 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37A8438212C0; Wed, 28 Feb 2024 05:16:35 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 470661C060AF; Wed, 28 Feb 2024 05:16:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097397; h=from:from:reply-to:subject:subject: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=LlFwz6O3mZ2LTaLrgZ+vg13FsQPgmVBoBxanF/BPCd4=; b=Bm9XiLx8L0JGpZASBUj3rhdY+3cmkqo0HECNHW38IxzzaNn1BoLfkLkDJFG7qpvnDXv1/m +yEXrrplMmmqPkSUlZELITBmZ6m0+Yui+XV074GvWiFXvTkUUu/8SEduNYasJjIFqCmXK9 w+P3VOxHgdCPlB4Ym+YnR++FhLTM23o= X-MC-Unique: NuewWbeGNMimO56PS6ym3w-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 20/25] migration: stop vm for cpr Date: Wed, 28 Feb 2024 13:13:10 +0800 Message-ID: <20240228051315.400759-21-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097576186100008 Content-Type: text/plain; charset="utf-8" From: Steve Sistare When migration for cpr is initiated, stop the vm and set state RUN_STATE_FINISH_MIGRATE before ram is saved. This eliminates the possibility of ram and device state being out of sync, and guarantees that a guest in the suspended state remains suspended, because qmp_cont rejects a cont command in the RUN_STATE_FINISH_MIGRATE state. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/1708622920-68779-11-git-send-email-steven.s= istare@oracle.com Signed-off-by: Peter Xu --- include/migration/misc.h | 1 + migration/migration.h | 2 -- migration/migration.c | 51 ++++++++++++++++++++++++---------------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index e4933b815b..5d1aa593ed 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -60,6 +60,7 @@ void migration_object_init(void); void migration_shutdown(void); bool migration_is_idle(void); bool migration_is_active(MigrationState *); +bool migrate_mode_is_cpr(MigrationState *); =20 typedef enum MigrationEventType { MIG_EVENT_PRECOPY_SETUP, diff --git a/migration/migration.h b/migration/migration.h index aef8afbe1f..65c0b61cbd 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -541,6 +541,4 @@ int migration_rp_wait(MigrationState *s); */ void migration_rp_kick(MigrationState *s); =20 -int migration_stop_vm(RunState state); - #endif diff --git a/migration/migration.c b/migration/migration.c index 37c836b0b0..90a90947fb 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -167,11 +167,19 @@ static gint page_request_addr_cmp(gconstpointer ap, g= constpointer bp) return (a > b) - (a < b); } =20 -int migration_stop_vm(RunState state) +static int migration_stop_vm(MigrationState *s, RunState state) { - int ret =3D vm_stop_force_state(state); + int ret; + + migration_downtime_start(s); + + s->vm_old_state =3D runstate_get(); + global_state_store(); + + ret =3D vm_stop_force_state(state); =20 trace_vmstate_downtime_checkpoint("src-vm-stopped"); + trace_migration_completion_vm_stop(ret); =20 return ret; } @@ -1602,6 +1610,11 @@ bool migration_is_active(MigrationState *s) s->state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE); } =20 +bool migrate_mode_is_cpr(MigrationState *s) +{ + return s->parameters.mode =3D=3D MIG_MODE_CPR_REBOOT; +} + int migrate_init(MigrationState *s, Error **errp) { int ret; @@ -2454,10 +2467,7 @@ static int postcopy_start(MigrationState *ms, Error = **errp) bql_lock(); trace_postcopy_start_set_run(); =20 - migration_downtime_start(ms); - - global_state_store(); - ret =3D migration_stop_vm(RUN_STATE_FINISH_MIGRATE); + ret =3D migration_stop_vm(ms, RUN_STATE_FINISH_MIGRATE); if (ret < 0) { goto fail; } @@ -2652,15 +2662,12 @@ static int migration_completion_precopy(MigrationSt= ate *s, int ret; =20 bql_lock(); - migration_downtime_start(s); - - s->vm_old_state =3D runstate_get(); - global_state_store(); =20 - ret =3D migration_stop_vm(RUN_STATE_FINISH_MIGRATE); - trace_migration_completion_vm_stop(ret); - if (ret < 0) { - goto out_unlock; + if (!migrate_mode_is_cpr(s)) { + ret =3D migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE); + if (ret < 0) { + goto out_unlock; + } } =20 ret =3D migration_maybe_pause(s, current_active_state, @@ -3500,15 +3507,10 @@ static void *bg_migration_thread(void *opaque) s->setup_time =3D qemu_clock_get_ms(QEMU_CLOCK_HOST) - setup_start; =20 trace_migration_thread_setup_complete(); - migration_downtime_start(s); =20 bql_lock(); =20 - s->vm_old_state =3D runstate_get(); - - global_state_store(); - /* Forcibly stop VM before saving state of vCPUs and devices */ - if (migration_stop_vm(RUN_STATE_PAUSED)) { + if (migration_stop_vm(s, RUN_STATE_PAUSED)) { goto fail; } /* @@ -3584,6 +3586,7 @@ void migrate_fd_connect(MigrationState *s, Error *err= or_in) Error *local_err =3D NULL; uint64_t rate_limit; bool resume =3D s->state =3D=3D MIGRATION_STATUS_POSTCOPY_PAUSED; + int ret; =20 /* * If there's a previous error, free it and prepare for another one. @@ -3655,6 +3658,14 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) return; } =20 + if (migrate_mode_is_cpr(s)) { + ret =3D migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE); + if (ret < 0) { + error_setg(&local_err, "migration_stop_vm failed, error %d", -= ret); + goto fail; + } + } + if (migrate_background_snapshot()) { qemu_thread_create(&s->thread, "bg_snapshot", bg_migration_thread, s, QEMU_THREAD_JOINABLE); --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097574; cv=none; d=zohomail.com; s=zohoarc; b=SqDORv2HwcfrHRr9Xhc49rDYcP52pv4Q8Lb7Gez/xSfR8SOR0BqdTBSx4RU0jCWv3QxTE53fbtM3Vh51ogaTH0bSBBAAardC3bGcTtwrhAGDzJxWWj0k9vXtsyBR1v/q3/+gufzSHHnaQAJyzHrhKJrt4xG29mYVXx8Wx3kaYbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097574; 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=SP3OexboYkgrsNQ0WmIkQllrjA/g1P+GKoEKbQpmMiw=; b=hKiXJ2COX2/dSRrIa9gFosImRAgd8bPE2JucOsyB8dJAqQfdbLDLqYxv1UjdBuxoXTPwLmKatvYa3LUTQjsIu2yRY+wYA5FrUgMb4GxvemoAtwilddT4suXbxvFdhhUpZtbCFilvVe1UFNNpTp6sgnyKDW9xwj7tiRkw/zy/q8A= 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 1709097574696111.2306506877917; Tue, 27 Feb 2024 21:19:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCJz-0002iW-B0; Wed, 28 Feb 2024 00:17: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 1rfCJN-0001Os-2U for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCJF-0007W5-Rh for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:16:55 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-X9QrUcU-MAmsnq4tb49NFA-1; Wed, 28 Feb 2024 00:16:45 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 393CB185A784; Wed, 28 Feb 2024 05:16:45 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D1BD1C060AF; Wed, 28 Feb 2024 05:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097409; h=from:from:reply-to:subject:subject: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=SP3OexboYkgrsNQ0WmIkQllrjA/g1P+GKoEKbQpmMiw=; b=iBslPpQX+ZR2Oi2n0nt16ZgQ/mT+b0VpmXrLTd+8tjT+KK53ZAzvgQvlwC/Y/4ehicHCWj dv0YcSxZZ7kQ67o8Bd0PVqtVAy1zs9S95ZqajhhOk8mYx10MBCUulNbYpX0fET73mjDxMg QBHnt8gTqV8mciVwjPvTDZ7d5/k+2N8= X-MC-Unique: X9QrUcU-MAmsnq4tb49NFA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 21/25] migration: update cpr-reboot description Date: Wed, 28 Feb 2024 13:13:11 +0800 Message-ID: <20240228051315.400759-22-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097576162100006 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Clarify qapi for cpr-reboot migration mode, and add vfio support. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/1708622920-68779-14-git-send-email-steven.s= istare@oracle.com Signed-off-by: Peter Xu --- qapi/migration.json | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 7303e57e8e..bee5e71fe3 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -636,19 +636,28 @@ # # @normal: the original form of migration. (since 8.2) # -# @cpr-reboot: The migrate command saves state to a file, allowing one to -# quit qemu, reboot to an updated kernel, and restart an upda= ted -# version of qemu. The caller must specify a migration URI -# that writes to and reads from a file. Unlike normal mode, -# the use of certain local storage options does not block the -# migration, but the caller must not modify guest block devic= es -# between the quit and restart. To avoid saving guest RAM to= the -# file, the memory backend must be shared, and the @x-ignore-= shared -# migration capability must be set. Guest RAM must be non-vo= latile -# across reboot, such as by backing it with a dax device, but= this -# is not enforced. The restarted qemu arguments must match t= hose -# used to initially start qemu, plus the -incoming option. -# (since 8.2) +# @cpr-reboot: The migrate command stops the VM and saves state to the URI. +# After quitting qemu, the user resumes by running qemu -incoming. +# +# This mode allows the user to quit qemu, and restart an updated versi= on +# of qemu. The user may even update and reboot the OS before restarti= ng, +# as long as the URI persists across a reboot. +# +# Unlike normal mode, the use of certain local storage options does not +# block the migration, but the user must not modify guest block devices +# between the quit and restart. +# +# This mode supports vfio devices provided the user first puts the gue= st +# in the suspended runstate, such as by issuing guest-suspend-ram to t= he +# qemu guest agent. +# +# Best performance is achieved when the memory backend is shared and t= he +# @x-ignore-shared migration capability is set, but this is not requir= ed. +# Further, if the user reboots before restarting such a configuration,= the +# shared backend must be be non-volatile across reboot, such as by bac= king +# it with a dax device. +# +# (since 8.2) ## { 'enum': 'MigMode', 'data': [ 'normal', 'cpr-reboot' ] } --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097742; cv=none; d=zohomail.com; s=zohoarc; b=jXeiU49mn8njaKYacpysIMZSWaDOdHRkRj4rRuWVRQI6kzpdpUkli9qkNIbNSroK7Olrd8gyI3bCGvmcuB17KM5bpaJ7uYw/KNhT9+32qFFcv5Lnf5sMxm/L28X0AyLErVTypCBW+yfxgFWHVYqW5iEYJvucbosDWE3O1Twpt2M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097742; 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=yruyBw49zJ5tVwVlBKVbE1Lx8R7iKPKHx4phAx9r0jE=; b=QmWkv1jUOQjqJWuair32cQn6wAIIFEjMUdX+4Is5/23PmwO3lC0Zt3ulxYCkSET7KIggFZWD+6eEicz86AXeHLV8/GXxwPkXwZW1/+XkheWaHu6FHWw5ujPlhUpQXMSZovqEG2Ropkm3Z25ihvJlIr4Rnv9TjjS9FY4BQS+HL60= 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 1709097742269742.4928735083013; Tue, 27 Feb 2024 21:22:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCK0-0002pW-69; Wed, 28 Feb 2024 00:17:36 -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 1rfCJR-0001SS-7O for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCJP-0007c3-87 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:00 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-L20Dph42MiuM3VHlBC4gcw-1; Wed, 28 Feb 2024 00:16:55 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A606B38212D8; Wed, 28 Feb 2024 05:16:54 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E81C81C060B1; Wed, 28 Feb 2024 05:16:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097418; h=from:from:reply-to:subject:subject: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=yruyBw49zJ5tVwVlBKVbE1Lx8R7iKPKHx4phAx9r0jE=; b=EQqEMIZWdxwogw8PWjjGwV/fYPxVxZKiF6Jjz8nNQqil6ohsWojDSKEg/rJRuyfH30YjHG 3emTo63m/LfqamJh0YTwHVW3ZhOUtvl5iaAwbQfUz5nCC9amxzEQR40H8OyWlCehtVjA+N k7EOjyxhF/JH5UaxRUqJzP1m0M0RrlI= X-MC-Unique: L20Dph42MiuM3VHlBC4gcw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu , Steve Sistare Subject: [PULL 22/25] migration: options incompatible with cpr Date: Wed, 28 Feb 2024 13:13:12 +0800 Message-ID: <20240228051315.400759-23-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097742562100001 Content-Type: text/plain; charset="utf-8" From: Steve Sistare Fail the migration request if options are set that are incompatible with cpr. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/1708622920-68779-15-git-send-email-steven.s= istare@oracle.com Signed-off-by: Peter Xu --- qapi/migration.json | 2 ++ migration/migration.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/qapi/migration.json b/qapi/migration.json index bee5e71fe3..0b33a71ab4 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -657,6 +657,8 @@ # shared backend must be be non-volatile across reboot, such as by bac= king # it with a dax device. # +# cpr-reboot may not be used with postcopy, colo, or background-snapsh= ot. +# # (since 8.2) ## { 'enum': 'MigMode', diff --git a/migration/migration.c b/migration/migration.c index 90a90947fb..7652fd4d14 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1953,6 +1953,23 @@ static bool migrate_prepare(MigrationState *s, bool = blk, bool blk_inc, return false; } =20 + if (migrate_mode_is_cpr(s)) { + const char *conflict =3D NULL; + + if (migrate_postcopy()) { + conflict =3D "postcopy"; + } else if (migrate_background_snapshot()) { + conflict =3D "background snapshot"; + } else if (migrate_colo()) { + conflict =3D "COLO"; + } + + if (conflict) { + error_setg(errp, "Cannot use %s with CPR", conflict); + return false; + } + } + if (blk || blk_inc) { if (migrate_colo()) { error_setg(errp, "No disk migration is required in COLO mode"); --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097574; cv=none; d=zohomail.com; s=zohoarc; b=RO/PnD6wXNwaVu4dj8Z86PhSQPn5/DyveIrwjWjqNcWYnofm27E2b7FkFStLxAMXEjj8zlkfrpmrNBifNnpSgDslKLkL1nj64mKa7wrvam4xMGH8NBgF9O4wGc1ADwbLL2MSKFwDXZPSFZUFsMRCSy1Wu8AW5DwkxnBuaW3wn3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097574; 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=4SeCXWTc2LOa/udPJdH7J6CxuapLlRBF7PPJgbugBis=; b=CPbeOtKySdJCDpFveJnRG4z5XQjhvwx5G0I1hy+RaPKpZRuKQpgch0sXFLbjvu0lY4JX8+DfxBqVv6cx/bHi959/+IuC3Z3NN14okWzkvvZJrRMOtF7v19lwlhTyGuIZS5BcbKlwV5HpfqoWmoXWH36PMeUVjqDiRYB1YpiWFOE= 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 1709097574490382.34642924651905; Tue, 27 Feb 2024 21:19:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCK1-0002zn-TH; Wed, 28 Feb 2024 00:17: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 1rfCJd-0001yE-0l for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCJX-0007rf-51 for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:11 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-478-KlJ5Q3LpOBiI2y1LCimvpQ-1; Wed, 28 Feb 2024 00:17:04 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A72951071CE0; Wed, 28 Feb 2024 05:17:03 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73DF81C06710; Wed, 28 Feb 2024 05:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097426; h=from:from:reply-to:subject:subject: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=4SeCXWTc2LOa/udPJdH7J6CxuapLlRBF7PPJgbugBis=; b=DYZcu4XE7hIvpWR/qxEQWiuO1e3wKMKNhSEH51TpQLVlaYf3/2oxMo8tsRWgvyaVyXAjZW Yah4Zr2ixh3hdEU7dwTH7SSMZOmcV6qOwfh0yDYGdBgsVbYbsi39mcl9T1dFa31R2O6e0X lHpEKG9oFFXU7nPggBl5l5sV7ww/YL8= X-MC-Unique: KlJ5Q3LpOBiI2y1LCimvpQ-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 23/25] migration: Fix qmp_query_migrate mbps value Date: Wed, 28 Feb 2024 13:13:13 +0800 Message-ID: <20240228051315.400759-24-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=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 @redhat.com) X-ZM-MESSAGEID: 1709097576132100005 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas The QMP command query_migrate might see incorrect throughput numbers if it runs after we've set the migration completion status but before migration_calculate_complete() has updated s->total_time and s->mbps. The migration status would show COMPLETED, but the throughput value would be the one from the last iteration and not the one from the whole migration. This will usually be a larger value due to the time period being smaller (one iteration). Move migration_calculate_complete() earlier so that the status MIGRATION_STATUS_COMPLETED is only emitted after the final counters update. Keep everything under the BQL so the QMP thread sees the updates as atomic. Rename migration_calculate_complete to migration_completion_end to reflect its new purpose of also updating s->state. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240226143335.14282-1-farosas@suse.de Signed-off-by: Peter Xu --- migration/migration.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 7652fd4d14..ccb13fa94a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -107,6 +107,7 @@ static int migration_maybe_pause(MigrationState *s, int new_state); static void migrate_fd_cancel(MigrationState *s); static bool close_return_path_on_source(MigrationState *s); +static void migration_completion_end(MigrationState *s); =20 static void migration_downtime_start(MigrationState *s) { @@ -2787,8 +2788,7 @@ static void migration_completion(MigrationState *s) migrate_set_state(&s->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COLO); } else { - migrate_set_state(&s->state, current_active_state, - MIGRATION_STATUS_COMPLETED); + migration_completion_end(s); } =20 return; @@ -2825,8 +2825,7 @@ static void bg_migration_completion(MigrationState *s) goto fail; } =20 - migrate_set_state(&s->state, current_active_state, - MIGRATION_STATUS_COMPLETED); + migration_completion_end(s); return; =20 fail: @@ -3028,18 +3027,28 @@ static MigThrError migration_detect_error(Migration= State *s) } } =20 -static void migration_calculate_complete(MigrationState *s) +static void migration_completion_end(MigrationState *s) { uint64_t bytes =3D migration_transferred_bytes(); int64_t end_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); int64_t transfer_time; =20 + /* + * Take the BQL here so that query-migrate on the QMP thread sees: + * - atomic update of s->total_time and s->mbps; + * - correct ordering of s->mbps update vs. s->state; + */ + bql_lock(); migration_downtime_end(s); s->total_time =3D end_time - s->start_time; transfer_time =3D s->total_time - s->setup_time; if (transfer_time) { s->mbps =3D ((double) bytes * 8.0) / transfer_time / 1000; } + + migrate_set_state(&s->state, s->state, + MIGRATION_STATUS_COMPLETED); + bql_unlock(); } =20 static void update_iteration_initial_status(MigrationState *s) @@ -3186,7 +3195,6 @@ static void migration_iteration_finish(MigrationState= *s) bql_lock(); switch (s->state) { case MIGRATION_STATUS_COMPLETED: - migration_calculate_complete(s); runstate_set(RUN_STATE_POSTMIGRATE); break; case MIGRATION_STATUS_COLO: @@ -3230,9 +3238,6 @@ static void bg_migration_iteration_finish(MigrationSt= ate *s) bql_lock(); switch (s->state) { case MIGRATION_STATUS_COMPLETED: - migration_calculate_complete(s); - break; - case MIGRATION_STATUS_ACTIVE: case MIGRATION_STATUS_FAILED: case MIGRATION_STATUS_CANCELLED: --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097600; cv=none; d=zohomail.com; s=zohoarc; b=CJE3GLW0pH9Mh1mi/7Ek1yLzJpDuR/wDPtEbW/wDlFnzKCl9NhoMnG7T+Yv5TEdEOg1GgM7w7VaTnfxOtxcGhCoycBvvvdTRQ4Ci72N5LgqQ+C4ZZoZWHWzvRhqN6rRlM+AQu9n8utvLNdyxcWDXkdfgo2bZB+uRmaOq2c4Fs9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097600; 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=s5XcBZWtNNgoUe5c3H0PbKnfzkeO/NiM+2qwR9WJckM=; b=BSuPV2eULqOWQyCwWGKpZUxPEDNvlTeW87J453j8dg0SgoJ38dcVKjKSkXijb98IqX5OMCP4rI65ysGUt+5uCeN6CPgRoXZxqasfwZvKAiScoWKPA/cRfiJfbSjWqqBijIohFgJq2suW/9qYdDDi2dSUdgVecrX7beab4UrtcTY= 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 1709097600709409.7598275571622; Tue, 27 Feb 2024 21:20:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCK7-0003XY-Qy; Wed, 28 Feb 2024 00:17: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 1rfCJi-00023t-7B for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCJg-0008GW-Aj for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:17 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-516-M93zfFqSOsmsCrxRnEWUYg-1; Wed, 28 Feb 2024 00:17:13 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DBAF43C02B9F; Wed, 28 Feb 2024 05:17:12 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DA7E1C060B1; Wed, 28 Feb 2024 05:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097435; h=from:from:reply-to:subject:subject: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=s5XcBZWtNNgoUe5c3H0PbKnfzkeO/NiM+2qwR9WJckM=; b=M4pcTafr6vRqC44J072c9atQSDdwKMGeLHsqa9BVLkQHpiUXqcfgjyV3WriO9rhltv6W+k zzAonBUA+s1VM/kbgNOHP+kcbqHEloZ3BdgfnKTgQ2L+kN+IXzuHKzXlRnqI36kNjLUDtT YTG0oSJEojQUAHNtwdAyVoDgGm7Lclk= X-MC-Unique: M93zfFqSOsmsCrxRnEWUYg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 24/25] migration: Join the return path thread before releasing to_dst_file Date: Wed, 28 Feb 2024 13:13:14 +0800 Message-ID: <20240228051315.400759-25-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.133.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097602202100003 From: Fabiano Rosas The return path thread might hang at a blocking system call. Before joining the thread we might need to issue a shutdown() on the socket file descriptor to release it. To determine whether the shutdown() is necessary we look at the QEMUFile error. Make sure we only clean up the QEMUFile after the return path has been waited for. This fixes a hang when qemu_savevm_state_setup() produced an error that was detected by migration_detect_error(). That skips migration_completion() so close_return_path_on_source() would get stuck waiting for the RP thread to terminate. Reported-by: C=C3=A9dric Le Goater Tested-by: C=C3=A9dric Le Goater Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240226203122.22894-2-farosas@suse.de Signed-off-by: Peter Xu --- migration/migration.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index ccb13fa94a..7ba2b60e46 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1342,6 +1342,8 @@ static void migrate_fd_cleanup(MigrationState *s) =20 qemu_savevm_state_cleanup(); =20 + close_return_path_on_source(s); + if (s->to_dst_file) { QEMUFile *tmp; =20 @@ -1366,12 +1368,6 @@ static void migrate_fd_cleanup(MigrationState *s) qemu_fclose(tmp); } =20 - /* - * We already cleaned up to_dst_file, so errors from the return - * path might be due to that, ignore them. - */ - close_return_path_on_source(s); - assert(!migration_is_active(s)); =20 if (s->state =3D=3D MIGRATION_STATUS_CANCELLING) { @@ -2914,6 +2910,13 @@ static MigThrError postcopy_pause(MigrationState *s) while (true) { QEMUFile *file; =20 + /* + * We're already pausing, so ignore any errors on the return + * path and just wait for the thread to finish. It will be + * re-created when we resume. + */ + close_return_path_on_source(s); + /* * Current channel is possibly broken. Release it. Note that this= is * guaranteed even without lock because to_dst_file should only be @@ -2933,13 +2936,6 @@ static MigThrError postcopy_pause(MigrationState *s) qemu_file_shutdown(file); qemu_fclose(file); =20 - /* - * We're already pausing, so ignore any errors on the return - * path and just wait for the thread to finish. It will be - * re-created when we resume. - */ - close_return_path_on_source(s); - migrate_set_state(&s->state, s->state, MIGRATION_STATUS_POSTCOPY_PAUSED); =20 --=20 2.43.0 From nobody Tue Nov 26 06:50:05 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709097472; cv=none; d=zohomail.com; s=zohoarc; b=CFs5A8Ywh7Pp0eGSCYk2D9VDyoUdEZGO5O8rOOqA1q7OLGpq4hidfEyvIgxSWQ7Tx34hYcc709I3HK8mxX9Fk58Ysqq7bu3/RnBWnTQGSELgIbKyQiVEhlW0S0IgkmkCPUxGpBGNGQ//i+aQUApB/smQ6ZEDtim2utOdVZUaNGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709097472; 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=GIq7sYU2u/VS0Fv7gb09V6xAb962itV7xL19wZRK/Ks=; b=JXQuWhSFP1Ctg3eJLz3lpyrHmXGXHB65K0ZkOS99mOqjB5U/Pf+iVUPt3xI8RTJjvFbOcRajsXuhQi3eX7G726h8Ss5MWo0t+hO5Gra61JX0qFpn8MRSJmFfPBCj/eWD9neuwQGyDZn+H1SGcVa5D+6VCKCdez3E2/mtd9hX7Xs= 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 1709097472259221.93417634494426; Tue, 27 Feb 2024 21:17:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfCK3-00035o-S7; Wed, 28 Feb 2024 00:17:40 -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 1rfCJv-0002Ny-6K for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rfCJq-0008IM-Jk for qemu-devel@nongnu.org; Wed, 28 Feb 2024 00:17:30 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-ll99i9BjMOyCOmGSyDnmAw-1; Wed, 28 Feb 2024 00:17:22 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03B0983B871; Wed, 28 Feb 2024 05:17:22 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 924681C060AF; Wed, 28 Feb 2024 05:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709097445; h=from:from:reply-to:subject:subject: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=GIq7sYU2u/VS0Fv7gb09V6xAb962itV7xL19wZRK/Ks=; b=IV0jvJt3Ja1//+xxw56rnkJVaDgE4L1IDyt/RbPPMx1CY0l8X2KB99C5TH/7jU5MqNTS+x spm4QGiLMJtpc13EvJQyXd8rR4Zworj6ClbvXq0UhEBodSapVsDIc8H/tLz8CgXYdjKXJG rND7kJaQJtTBUUSEEbbHMi3bXbdup2c= X-MC-Unique: ll99i9BjMOyCOmGSyDnmAw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: David Hildenbrand , Eric Blake , Laurent Vivier , Paolo Bonzini , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Markus Armbruster , Fabiano Rosas , "Michael S. Tsirkin" , Thomas Huth , Jason Wang , Alex Williamson , Peter Xu Subject: [PULL 25/25] migration: Use migrate_has_error() in close_return_path_on_source() Date: Wed, 28 Feb 2024 13:13:15 +0800 Message-ID: <20240228051315.400759-26-peterx@redhat.com> In-Reply-To: <20240228051315.400759-1-peterx@redhat.com> References: <20240228051315.400759-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 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=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.088, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, 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 @redhat.com) X-ZM-MESSAGEID: 1709097473803100009 From: C=C3=A9dric Le Goater close_return_path_on_source() retrieves the migration error from the the QEMUFile '->to_dst_file' to know if a shutdown is required. This shutdown is required to exit the return-path thread. Avoid relying on '->to_dst_file' and use migrate_has_error() instead. (using to_dst_file is a heuristic to infer whether rp_state.from_dst_file might be stuck on a recvmsg(). Using a generic method for detecting errors is more reliable. We also want to reduce dependency on QEMUFile::last_error) Suggested-by: Peter Xu Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Peter Xu [added some words about the motivation for this patch] Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240226203122.22894-3-farosas@suse.de Signed-off-by: Peter Xu --- migration/migration.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 7ba2b60e46..bab68bcbef 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2429,8 +2429,7 @@ static bool close_return_path_on_source(MigrationStat= e *ms) * cause it to unblock if it's stuck waiting for the destination. */ WITH_QEMU_LOCK_GUARD(&ms->qemu_file_lock) { - if (ms->to_dst_file && ms->rp_state.from_dst_file && - qemu_file_get_error(ms->to_dst_file)) { + if (migrate_has_error(ms) && ms->rp_state.from_dst_file) { qemu_file_shutdown(ms->rp_state.from_dst_file); } } --=20 2.43.0