From nobody Tue Nov 26 14:49:33 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=1706497506; cv=none; d=zohomail.com; s=zohoarc; b=mX4m3aV0RQdWeM9Ugmle8+VMW3ImQ1NFBFyAisbj9gMHiG0/wqo7xP7lLmrtMEnClRtPNfbdle6jZZq+4ftLviJ0/R8pxnwAWL5Wraf5+PyJq9FkVxadptVGcZpvq/zLvBGc6lp5yMIm0F4xkfAnNP9m1olPkhQ+E7nsW5zRgVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497506; 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=+jIxnbegQmvBVIO27FvAQrkVaPnZTYcNah9sLJ4uqLU=; b=dR4pUlh7jsOpDfTG64epyvcPIzMZqsumBDSMczV0EugJLW+OP9TZktkTyrV6L8cS6Q2mvXwOXhmXR0prp5X89Xub30c/p2awVen3/MoP73c6GKxWn9THWrci5YR8p16eHM9KJs74G72GZhs6xQg8hUfG9LS7bftv59/5J9o3rGw= 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 1706497506166315.7260499705345; Sun, 28 Jan 2024 19:05:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHwe-0003h0-RP; Sun, 28 Jan 2024 22:04:24 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUHwc-0003bi-Oa for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:23 -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 1rUHwZ-0002Zv-Cr for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:20 -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-137--Du5DmQhMgm0oRrgyCCQgg-1; Sun, 28 Jan 2024 22:04:15 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 99FFF85A589; Mon, 29 Jan 2024 03:04:14 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5246C1121306; Mon, 29 Jan 2024 03:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497458; 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=+jIxnbegQmvBVIO27FvAQrkVaPnZTYcNah9sLJ4uqLU=; b=FeYl8X5CzfMrsMqDvvcQrG9C2BWe5/8YG1zjjTlbf18WofTwpSTSL+fi5jJhFA1ALVZxFT 5JQgtxvafNTI1db5qKSeUBrYy0ISmLOQeLH5zKkZYJxQB4KGXWpk4JJZPT3YGi0K/aPxOP nrzYCVM2T54R6qGuXp31fj8wxU8ffJE= X-MC-Unique: -Du5DmQhMgm0oRrgyCCQgg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com, Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 01/14] userfaultfd: use 1ULL to build ioctl masks Date: Mon, 29 Jan 2024 11:03:52 +0800 Message-ID: <20240129030405.177100-2-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-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.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497506526100001 From: Paolo Bonzini There is no need to use the Linux-internal __u64 type, 1ULL is guaranteed to be wide enough. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daud=C3=A9 Link: https://lore.kernel.org/r/20240117160313.175609-1-pbonzini@redhat.com Signed-off-by: Peter Xu --- migration/postcopy-ram.c | 16 +++++++--------- subprojects/libvhost-user/libvhost-user.c | 2 +- tests/qtest/migration-test.c | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 5408e028c6..893ec8fa89 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -102,11 +102,9 @@ void postcopy_thread_create(MigrationIncomingState *mi= s, * are target OS specific. */ #if defined(__linux__) - #include #include #include -#include /* for __u64 */ #endif =20 #if defined(__linux__) && defined(__NR_userfaultfd) && defined(CONFIG_EVEN= TFD) @@ -272,8 +270,8 @@ static bool request_ufd_features(int ufd, uint64_t feat= ures) return false; } =20 - ioctl_mask =3D (__u64)1 << _UFFDIO_REGISTER | - (__u64)1 << _UFFDIO_UNREGISTER; + ioctl_mask =3D 1ULL << _UFFDIO_REGISTER | + 1ULL << _UFFDIO_UNREGISTER; if ((api_struct.ioctls & ioctl_mask) !=3D ioctl_mask) { error_report("Missing userfault features: %" PRIx64, (uint64_t)(~api_struct.ioctls & ioctl_mask)); @@ -462,9 +460,9 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis, Error **errp) goto out; } =20 - feature_mask =3D (__u64)1 << _UFFDIO_WAKE | - (__u64)1 << _UFFDIO_COPY | - (__u64)1 << _UFFDIO_ZEROPAGE; + feature_mask =3D 1ULL << _UFFDIO_WAKE | + 1ULL << _UFFDIO_COPY | + 1ULL << _UFFDIO_ZEROPAGE; if ((reg_struct.ioctls & feature_mask) !=3D feature_mask) { error_setg(errp, "Missing userfault map features: %" PRIx64, (uint64_t)(~reg_struct.ioctls & feature_mask)); @@ -733,11 +731,11 @@ static int ram_block_enable_notify(RAMBlock *rb, void= *opaque) error_report("%s userfault register: %s", __func__, strerror(errno= )); return -1; } - if (!(reg_struct.ioctls & ((__u64)1 << _UFFDIO_COPY))) { + if (!(reg_struct.ioctls & (1ULL << _UFFDIO_COPY))) { error_report("%s userfault: Region doesn't support COPY", __func__= ); return -1; } - if (reg_struct.ioctls & ((__u64)1 << _UFFDIO_ZEROPAGE)) { + if (reg_struct.ioctls & (1ULL << _UFFDIO_ZEROPAGE)) { qemu_ram_set_uf_zeroable(rb); } =20 diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvho= st-user/libvhost-user.c index 6684057370..a3b158c671 100644 --- a/subprojects/libvhost-user/libvhost-user.c +++ b/subprojects/libvhost-user/libvhost-user.c @@ -684,7 +684,7 @@ generate_faults(VuDev *dev) { dev->postcopy_ufd, strerror(errno)); return false; } - if (!(reg_struct.ioctls & ((__u64)1 << _UFFDIO_COPY))) { + if (!(reg_struct.ioctls & (1ULL << _UFFDIO_COPY))) { vu_panic(dev, "%s Region (%d) doesn't support COPY", __func__, i); return false; diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index d3066e119f..7675519cfa 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -104,8 +104,8 @@ static bool ufd_version_check(void) } uffd_feature_thread_id =3D api_struct.features & UFFD_FEATURE_THREAD_I= D; =20 - ioctl_mask =3D (__u64)1 << _UFFDIO_REGISTER | - (__u64)1 << _UFFDIO_UNREGISTER; + ioctl_mask =3D 1ULL << _UFFDIO_REGISTER | + 1ULL << _UFFDIO_UNREGISTER; if ((api_struct.ioctls & ioctl_mask) !=3D ioctl_mask) { g_test_message("Skipping test: Missing userfault feature"); return false; --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497497; cv=none; d=zohomail.com; s=zohoarc; b=MJqoDDsQc/iKDRa8ISeMnF0xRmXYsYKV6nQ/qQM9MSlLr+nwasBr7BtmzmHGJ1QEUcatcoJxvyFDFztjqplQmj3T062J65Za607MYhXUeeBZAoPD7WiISObjZDlYw9TN2CI3avrrHWUbCs41mWuqbczmSvm7n8WwwW2WxWMxCFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497497; 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=c4yRFXRDQBJwjoKI3Xq95tuqQOtMtlm6MhGKK9NRKlI=; b=flaIu6Wj2Bx2RaJ0Ev26z1CrDnHCXWxWuv08k7FAX/2fXk+ekcz/8vNzMFNSgQn5IyDFvc3PmzUynI8BbU54Iqspf1fGDknUOyj99def5tHiLLew0ZOZpFYqygFyX5rGgZTaVXbwN0q+rYK/unV/C3sCbHwiDIfzfIu6uhF2WRg= 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 17064974976251012.0602574974588; Sun, 28 Jan 2024 19:04:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHwj-0003rk-30; Sun, 28 Jan 2024 22:04:29 -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 1rUHwg-0003k3-A0 for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:26 -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 1rUHwe-0002aA-ID for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:26 -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-245-oDb3F0vrNOaT7in8EQUkxw-1; Sun, 28 Jan 2024 22:04:18 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 4E6C53C13A90; Mon, 29 Jan 2024 03:04:18 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 697661121306; Mon, 29 Jan 2024 03:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497462; 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=c4yRFXRDQBJwjoKI3Xq95tuqQOtMtlm6MhGKK9NRKlI=; b=dKzZfesaSNfUwkK4xEtHLc/Ct7JZd2n9ClGPPMnPn3GfS5ivLxyFzj33rAjWOZiWg0qIC8 n2UFlpsSA8lvF+DMSjNQafawYaxb1VO0OwSoRJbLhur+FlQyhKnZZMbkis9deTfuUBPRIi 24N62/szRoGj/WbTuPSOOEVrDHjw42o= X-MC-Unique: oDb3F0vrNOaT7in8EQUkxw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com, Markus Armbruster Subject: [PULL 02/14] migration: Plug memory leak on HMP migrate error path Date: Mon, 29 Jan 2024 11:03:53 +0800 Message-ID: <20240129030405.177100-3-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497498629100003 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster hmp_migrate() leaks @caps when qmp_migrate() fails. Plug the leak with g_autoptr(). Fixes: 967f2de5c9ec (migration: Implement MigrateChannelList to hmp migrati= on flow.) v8.2.0-rc0 Fixes: CID 1533125 Signed-off-by: Markus Armbruster Link: https://lore.kernel.org/r/20240117140722.3979657-1-armbru@redhat.com [peterx: fix CID number as reported by Peter Maydell] Signed-off-by: Peter Xu --- migration/migration-hmp-cmds.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 740a219aa4..99b49df5dd 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -764,7 +764,7 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) bool resume =3D qdict_get_try_bool(qdict, "resume", false); const char *uri =3D qdict_get_str(qdict, "uri"); Error *err =3D NULL; - MigrationChannelList *caps =3D NULL; + g_autoptr(MigrationChannelList) caps =3D NULL; g_autoptr(MigrationChannel) channel =3D NULL; =20 if (inc) { @@ -789,8 +789,6 @@ void hmp_migrate(Monitor *mon, const QDict *qdict) return; } =20 - qapi_free_MigrationChannelList(caps); - if (!detach) { HMPMigrationStatus *status; =20 --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497571; cv=none; d=zohomail.com; s=zohoarc; b=LGezusb5DHhO1wOXDNY2Eh2KMX5pE3OhqbFm7nzkzGW5fXIeoKgTr23jl9OrCES+RfCMBZuULZOUkhLqi8Jwtb4ZOxYh8yh6yDVvr7pRB9YQrBz6yHG4cTvbr4CEGFR9sFxGVfnrXqDR4VIAGlTVjjuxo4t2NO6Fo6GkOpl7KWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497571; 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=SPEhcTwJ0AuWD9aqtJLMzpzDrswD5mPYY/I9NmocRcc=; b=JzT1ltgMLyTmoyoZhFVCxIoXLdzQUz/TDbBjQ5v2vnzQYZvUrtFB1m+EHsUOrArpCNT0bSRegrD/SHhPyQTd8X7hji98pyypLUFFB4peKX6b/Ths5d1pL814nyK9nhQELeDHo36NhfGeCOaL19IQoTMh1rwljDp9+hlh2elxO5s= 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 1706497571844100.80305160116382; Sun, 28 Jan 2024 19:06:11 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHwj-0003yd-Rc; Sun, 28 Jan 2024 22:04:29 -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 1rUHwg-0003mE-L0 for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:26 -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 1rUHwe-0002aH-TD for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:26 -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-654-F2zb75xMOHyz8oOynID1dQ-1; Sun, 28 Jan 2024 22:04:22 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 005483C13A8C; Mon, 29 Jan 2024 03:04:22 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D4711121306; Mon, 29 Jan 2024 03:04:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497464; 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=SPEhcTwJ0AuWD9aqtJLMzpzDrswD5mPYY/I9NmocRcc=; b=Y3nPE04ln6jYJCe26DWt8LUrpXRJm8ILZzxj2XqqT05K2rDPcFmH0hLVa9f3XVDQ0HNyXJ WiIBS6cI2xz5xCkQOSV8HvUuFm9+SVk4aR2V0glJCvORhpdlqkOOIgn+wDL3UXKQkMus+c hTdFewFXmjYNq1egj7eHsv33t0L9w6o= X-MC-Unique: F2zb75xMOHyz8oOynID1dQ-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 03/14] migration: Make threshold_size an uint64_t Date: Mon, 29 Jan 2024 11:03:54 +0800 Message-ID: <20240129030405.177100-4-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-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.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497572705100009 From: Peter Xu It's always used to compare against another uint64_t. Make it always clear that it's never a negative. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240117075848.139045-2-peterx@redhat.com Signed-off-by: Peter Xu --- migration/migration.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/migration.h b/migration/migration.h index 17972dac34..a589ae8650 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -296,7 +296,7 @@ struct MigrationState { * this threshold; it's calculated from the requested downtime and * measured bandwidth, or avail-switchover-bandwidth if specified. */ - int64_t threshold_size; + uint64_t threshold_size; =20 /* params from 'migrate-set-parameters' */ MigrationParameters parameters; --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497592; cv=none; d=zohomail.com; s=zohoarc; b=UJfKUuO6w4v/vs/b4KYMHA0OsGhZhzSm0IL/d5512QRb4SLHXGNFdq1H2rl4pbeQhjo1UMHJwbVN2cP2uh23xSHHJfCDzpLIEdp9ouvBbQNCcmoM5ZTn6YqDwqTgxkaJhQnPEUeIeGuJKUG1dOWTr8BWy7DQdda047XJFUV4rvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497592; 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=yOIHVYyv54egdlVoMdUVLVFk4lzZ/xlT1WvDt+htyXc=; b=M+d0z6R5uEeHcFHHFDwWVY1pa5FyaXApMj7m4b4NkVj4mLz2EN+vphsjOWbxg6/N1H9+QTaYB9nmZxR6TU6qNjASimdfdr4u6jaVaz9XZNNbNlSWkPOUjfjDC3Mce13UGv2dHsgbNXTOZhth9THvqwaaii/7rK2NbkHO3fxciIk= 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 1706497592013225.16819002795228; Sun, 28 Jan 2024 19:06:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHwo-00043L-9M; Sun, 28 Jan 2024 22:04:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUHwm-0003zS-G4 for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:32 -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 1rUHwk-0002bo-VD for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:32 -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-447-ZTD3sIyWPJCtcTfhIz3bmg-1; Sun, 28 Jan 2024 22:04:25 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 2B2A83804507; Mon, 29 Jan 2024 03:04:25 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id C47041121306; Mon, 29 Jan 2024 03:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497470; 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=yOIHVYyv54egdlVoMdUVLVFk4lzZ/xlT1WvDt+htyXc=; b=G9W9cJcSUS7ydxnAbPhQI5P0YEFETCHCGhetaGqZxc4dBT40Sym3T1pklZnj67Q3KE175/ D23jYflk4Yf2Ij8wvtc9eHD6lcKJ8LPU3lw/AoL+ZZJ+xEoJUaSdweXkVdnZd3IDE4cZi3 eIX+Rm6wOWl9S2knNdkSAhkM63irXYU= X-MC-Unique: ZTD3sIyWPJCtcTfhIz3bmg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 04/14] migration: Drop unnecessary check in ram's pending_exact() Date: Mon, 29 Jan 2024 11:03:55 +0800 Message-ID: <20240129030405.177100-5-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497592700100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu When the migration frameworks fetches the exact pending sizes, it means this check: remaining_size < s->threshold_size Must have been done already, actually at migration_iteration_run(): if (must_precopy <=3D s->threshold_size) { qemu_savevm_state_pending_exact(&must_precopy, &can_postcopy); That should be after one round of ram_state_pending_estimate(). It makes the 2nd check meaningless and can be dropped. To say it in another way, when reaching ->state_pending_exact(), we unconditionally sync dirty bits for precopy. Then we can drop migrate_get_current() there too. Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240117075848.139045-3-peterx@redhat.com Signed-off-by: Peter Xu --- migration/ram.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index c0cdcccb75..d5b7cd5ac2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3213,21 +3213,20 @@ static void ram_state_pending_estimate(void *opaque= , uint64_t *must_precopy, static void ram_state_pending_exact(void *opaque, uint64_t *must_precopy, uint64_t *can_postcopy) { - MigrationState *s =3D migrate_get_current(); RAMState **temp =3D opaque; RAMState *rs =3D *temp; + uint64_t remaining_size; =20 - uint64_t remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SI= ZE; - - if (!migration_in_postcopy() && remaining_size < s->threshold_size) { + if (!migration_in_postcopy()) { bql_lock(); WITH_RCU_READ_LOCK_GUARD() { migration_bitmap_sync_precopy(rs, false); } bql_unlock(); - remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; } =20 + remaining_size =3D rs->migration_dirty_pages * TARGET_PAGE_SIZE; + if (migrate_postcopy_ram()) { /* We can do postcopy, and all the data is postcopiable */ *can_postcopy +=3D remaining_size; --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497581; cv=none; d=zohomail.com; s=zohoarc; b=JAABIZvcAiW871aKBo6GSXJzFJ9E9dX6D9PbrNPIPC5MrslC1t0PMTVgZ47RV6PW0Cclqi9Fp27MoUH1ECdrD2AxfJsxAALXWRYfHOpa7TDgo5aI2pK2HefZzgLZVxndoN9bEZB3LsIZ1cRIGQsI2e+JyOFFcrYubvfczqR9z6s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497581; 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=wpC3flOEeKNg7RiQbz7rs+mTBSJWZUS3FmJ01r0jr00=; b=PJCtwnz4EztiNWCnDmP9lyx2pXgsA7xW6CrA/YcjPan1UlEO2qDyvyUJmzK9hnqTR7hmdoK1Cb18zC7CvviPURcW43cM5g2yPoJ3TRIPZ5vUN34MGq6zTV/vwrUlBanfLDSn48R9fcywp6nd8qWB+hjbqviAnx0KZ2+KGjdY3/c= 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 1706497581430740.9609036062924; Sun, 28 Jan 2024 19:06:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHwo-00043K-2r; Sun, 28 Jan 2024 22:04:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUHwm-0003zO-Ac for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:32 -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 1rUHwk-0002b2-Or for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:32 -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-180-BJhTepR5ObmLnBW0whRbIw-1; Sun, 28 Jan 2024 22:04:28 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 3D78810354C2; Mon, 29 Jan 2024 03:04:28 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id D632B1121306; Mon, 29 Jan 2024 03:04:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497470; 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=wpC3flOEeKNg7RiQbz7rs+mTBSJWZUS3FmJ01r0jr00=; b=NW2QZAVIQW9E2xDrAsU6WF70u50OiLZQBjCL7zVMPnTN8swszZ2T6xpLaj/o7+T3XDdCyD nekvcWRBL2I51SYYwNGqu4Qagy/lO6GOQBHsEQLT5wtqQChB5OAXnzq1KSr2xq4Qo9K4He dyOrTbDgSyBVDUogW6YsdCKlqcUcDvI= X-MC-Unique: BJhTepR5ObmLnBW0whRbIw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 05/14] analyze-migration.py: Remove trick on parsing ramblocks Date: Mon, 29 Jan 2024 11:03:56 +0800 Message-ID: <20240129030405.177100-6-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497582676100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu RAM_SAVE_FLAG_MEM_SIZE contains the total length of ramblock idstr to know whether scanning of ramblocks is complete. Drop the trick. Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240117075848.139045-4-peterx@redhat.com Signed-off-by: Peter Xu --- scripts/analyze-migration.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/scripts/analyze-migration.py b/scripts/analyze-migration.py index a39dfb8766..8a254a5b6a 100755 --- a/scripts/analyze-migration.py +++ b/scripts/analyze-migration.py @@ -151,17 +151,12 @@ def read(self): addr &=3D ~(self.TARGET_PAGE_SIZE - 1) =20 if flags & self.RAM_SAVE_FLAG_MEM_SIZE: - while True: + total_length =3D addr + while total_length > 0: namelen =3D self.file.read8() - # We assume that no RAM chunk is big enough to ever - # hit the first byte of the address, so when we see - # a zero here we know it has to be an address, not the - # length of the next block. - if namelen =3D=3D 0: - self.file.file.seek(-1, 1) - break self.name =3D self.file.readstr(len =3D namelen) len =3D self.file.read64() + total_length -=3D len self.sizeinfo[self.name] =3D '0x%016x' % len if self.write_memory: print(self.name) --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497524; cv=none; d=zohomail.com; s=zohoarc; b=Sx94UAbXli6GyQjizApiepiS1Y3A7yosLe5aUwprYTe0ffc6Tu3/KZx1bvjzgwkMBespS/o7y7pJbMDNWCZ1jQhZd7Nu7T2a7tQKkzqKqzYRIBjDqzZuyQcnrb0AIOI5OPcsj9Sug54uIoIsO+7WklMD/Afe3y9Dg6bxG9bLc/c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497524; 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=u9E9ZiyB8lolyP1h8HTT4gHWB7P2p+lbkjksyMOxvG8=; b=d46eztB2VMY7neAN0+yIbYIoGFv7jObTkrP+sl6bARjFRq5ciKl5MV1++Eq+iPj0a8tqM1dTVmkcM5onXawbRo554pSv33rBF/RghwHHuMn5N3rkmT5NlusekSkQVxpjyNRcY1+f4mFXtwUgC5FDkoYIcsueMOaDogcMDr/nTec= 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 1706497524077989.0809807259019; Sun, 28 Jan 2024 19:05:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHwr-0004Cx-TD; Sun, 28 Jan 2024 22:04:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUHwp-00049Y-T6 for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04: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 1rUHwo-0002cV-5R for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:35 -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-5q5G6M94PzmVEF4qItCVuQ-1; Sun, 28 Jan 2024 22:04:31 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 80D8485A589; Mon, 29 Jan 2024 03:04:31 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C8521121306; Mon, 29 Jan 2024 03:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497473; 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=u9E9ZiyB8lolyP1h8HTT4gHWB7P2p+lbkjksyMOxvG8=; b=S7oZenHb+iOT2j9rI11Jpr+RjKL8TJ0Be8RzfSFlh5DxbSp0ZLu2B690m9nBcBnxmQYCel oQ2I4WkmhE9Wz6k5VFOua0Dihh+o/GN9aCTPM4dmEG6XFQTcfPH+lDpHnGsb0u3arMPwAc yH81D7RqY9Z+UqKDoH+jTohylV16Qig= X-MC-Unique: 5q5G6M94PzmVEF4qItCVuQ-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 06/14] ci: Add a migration compatibility test job Date: Mon, 29 Jan 2024 11:03:57 +0800 Message-ID: <20240129030405.177100-7-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497524534100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas The migration tests have support for being passed two QEMU binaries to test migration compatibility. Add a CI job that builds the lastest release of QEMU and another job that uses that version plus an already present build of the current version and run the migration tests with the two, both as source and destination. I.e.: old QEMU (n-1) -> current QEMU (development tree) current QEMU (development tree) -> old QEMU (n-1) The purpose of this CI job is to ensure the code we're about to merge will not cause a migration compatibility problem when migrating the next release (which will contain that code) to/from the previous release. The version of migration-test used will be the one matching the older QEMU. That way we can avoid special-casing new tests that wouldn't be compatible with the older QEMU. Note: for user forks, the version tags need to be pushed to gitlab otherwise it won't be able to checkout a different version. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240118164951.30350-3-farosas@suse.de Signed-off-by: Peter Xu --- .gitlab-ci.d/buildtest.yml | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index e1c7801598..f0b0edc634 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -167,6 +167,66 @@ build-system-centos: x86_64-softmmu rx-softmmu sh4-softmmu nios2-softmmu MAKE_CHECK_ARGS: check-build =20 +# Previous QEMU release. Used for cross-version migration tests. +build-previous-qemu: + extends: .native_build_job_template + artifacts: + when: on_success + expire_in: 2 days + paths: + - build-previous + exclude: + - build-previous/**/*.p + - build-previous/**/*.a.p + - build-previous/**/*.fa.p + - build-previous/**/*.c.o + - build-previous/**/*.c.o.d + - build-previous/**/*.fa + needs: + job: amd64-opensuse-leap-container + variables: + IMAGE: opensuse-leap + TARGETS: x86_64-softmmu aarch64-softmmu + before_script: + - export QEMU_PREV_VERSION=3D"$(sed 's/\([0-9.]*\)\.[0-9]*/v\1.0/' VER= SION)" + - git checkout $QEMU_PREV_VERSION + after_script: + - mv build build-previous + +.migration-compat-common: + extends: .common_test_job_template + needs: + - job: build-previous-qemu + - job: build-system-opensuse + # The old QEMU could have bugs unrelated to migration that are + # already fixed in the current development branch, so this test + # might fail. + allow_failure: true + variables: + IMAGE: opensuse-leap + MAKE_CHECK_ARGS: check-build + script: + # Use the migration-tests from the older QEMU tree. This avoids + # testing an old QEMU against new features/tests that it is not + # compatible with. + - cd build-previous + # old to new + - QTEST_QEMU_BINARY_SRC=3D./qemu-system-${TARGET} + QTEST_QEMU_BINARY=3D../build/qemu-system-${TARGET} ./tests/qtest= /migration-test + # new to old + - QTEST_QEMU_BINARY_DST=3D./qemu-system-${TARGET} + QTEST_QEMU_BINARY=3D../build/qemu-system-${TARGET} ./tests/qtest= /migration-test + +migration-compat-aarch64: + extends: .migration-compat-common + variables: + TARGET: aarch64 + +migration-compat-x86_64: + extends: .migration-compat-common + variables: + TARGET: x86_64 + check-system-centos: extends: .native_test_job_template needs: --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497569; cv=none; d=zohomail.com; s=zohoarc; b=bVOLxaPIaFtBLR6XAUTghI7JJ3SPA2THhAMqBzVKaXm+v4G0daI7pFtmCH/s7827bwanvGKA8GvpxB1WWahiKgAaJnFBQ9JD1ock2wt6b94O/BozYWihehwNk956n1xJIDbEfTDCEbsh88ZFmxo4a7Wu7tjsX02HMPmysAxRZbU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497569; 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=5O48hzm3gfL1t5vlHM4mhcRlYYJEH9P+E36O4VJdn9I=; b=h6a8nwGRlfPzy517Fm7bhQVkHOetgLWEbrGtkoP2D7MIUUiKPYQSrdAjV4t0ZbHWEgDmc6xQu9/zRtuKL0a4+VOvLLYc9DI6qBg0salztDmaZvbGO3DKxg/Uqg3c5BGFI/ampkZNi8ihRRsOxGjXHFImLvnVugk+ijRC8sBrNVw= 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 1706497569487576.5414681745864; Sun, 28 Jan 2024 19:06:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHww-0004En-B6; Sun, 28 Jan 2024 22:04:42 -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 1rUHwv-0004Ee-9T for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:41 -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 1rUHwt-0002cl-AP for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:41 -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-194-VFgd9EeHOjWaYj5QJAU2Eg-1; Sun, 28 Jan 2024 22:04:35 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 C3DEE185A780; Mon, 29 Jan 2024 03:04:34 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 500401121306; Mon, 29 Jan 2024 03:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497478; 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=5O48hzm3gfL1t5vlHM4mhcRlYYJEH9P+E36O4VJdn9I=; b=KkqCIJENU+KFLXCOzsBDevFK/oLvC/kgRG7JBPX4HDu4caG6+MLmcwaoEc/GuX7U9QaOWE jBlfb21IPhrQ1fLOYMWGkb/rz0GjCf6gr0IulUtJ9dtT7s8RcRft0pqJD5NuoVWRRjozxV ZwBpLBCVH/zYfAknywPl06EqrPqK2oM= X-MC-Unique: VFgd9EeHOjWaYj5QJAU2Eg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 07/14] ci: Disable migration compatibility tests for aarch64 Date: Mon, 29 Jan 2024 11:03:58 +0800 Message-ID: <20240129030405.177100-8-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497570615100005 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Until 9.0 is out, we need to keep the aarch64 job disabled because the tests always use the n-1 version of migration-test. That happens to be broken for aarch64 in 8.2. Once 9.0 is out, it will become the n-1 version and it will bring the fixed tests. We can revert this patch when 9.0 releases. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240118164951.30350-4-farosas@suse.de [peterx: use _SKIPPED rather than _OPTIONAL] Signed-off-by: Peter Xu --- .gitlab-ci.d/buildtest.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml index f0b0edc634..79bbc8585b 100644 --- a/.gitlab-ci.d/buildtest.yml +++ b/.gitlab-ci.d/buildtest.yml @@ -217,10 +217,14 @@ build-previous-qemu: - QTEST_QEMU_BINARY_DST=3D./qemu-system-${TARGET} QTEST_QEMU_BINARY=3D../build/qemu-system-${TARGET} ./tests/qtest= /migration-test =20 +# This job is disabled until we release 9.0. The existing +# migration-test in 8.2 is broken on aarch64. The fix was already +# commited, but it will only take effect once 9.0 is out. migration-compat-aarch64: extends: .migration-compat-common variables: TARGET: aarch64 + QEMU_JOB_SKIPPED: 1 =20 migration-compat-x86_64: extends: .migration-compat-common --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497567; cv=none; d=zohomail.com; s=zohoarc; b=gDgDiLD9CJWW5dcbNIxzhyzC85BCIrPgjgyI30h9sIocB74nkA2b73W58lMDE7v1+UWvQ8DUL8zBAUshCkXPB3VH1w+Z0SS0KeYuIgOF6BaWsxrMIJWI/faLi9QXQmdztxUBPvJneRqAovttAWQJmcwY3QDt/9o/P/jwCU+itAE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497567; 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=C4ER0TJ1Vqgpct/whtoJPyK9n6HJ6571tM7r0VERKjg=; b=kTJ1O4c69cWrQUh72+EY9G5cz4E6QybHbi68NyO6cEPiNzqDvqkljqyEBHLXVjNRWXSEJcHb+UutXaJs804TpXHXBKZ608Y/Vae67Z2/JqJpu6SSShwViRfQHgFTDWP/X5st4sIq4cVwpBsUfZ0HHd1mhVAB4tklpeAy4+faEpI= 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 1706497567759956.3724643268424; Sun, 28 Jan 2024 19:06:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHx1-0004GJ-KY; Sun, 28 Jan 2024 22:04:47 -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 1rUHx0-0004Fw-37 for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04: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 1rUHwy-0002d3-ET for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:45 -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-209--JgfVpHCNGGBHe8bEeDkZA-1; Sun, 28 Jan 2024 22:04:38 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 5E3E285A588; Mon, 29 Jan 2024 03:04:38 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93DA71121306; Mon, 29 Jan 2024 03:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497483; 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=C4ER0TJ1Vqgpct/whtoJPyK9n6HJ6571tM7r0VERKjg=; b=YOJq0tjQIw2j/s1wBZ2hN5xdm0ydupBCJhPlXy2SJfddBlCJUPff2SmfN9HFmswFyQ7kYw aY4rRLLgWybYQUHqcPYw9ykVbJ53p09848fRjjh/R/aG+1sWyp75IWF6tpiDwnl7sKtlmg Hc7cK/3LVgSBSRy1+hFJsUjqiFahVuE= X-MC-Unique: -JgfVpHCNGGBHe8bEeDkZA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 08/14] migration/yank: Use channel features Date: Mon, 29 Jan 2024 11:03:59 +0800 Message-ID: <20240129030405.177100-9-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-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.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497568636100001 From: Fabiano Rosas Stop using outside knowledge about the io channels when registering yank functions. Query for features instead. The yank method for all channels used with migration code currently is to call the qio_channel_shutdown() function, so query for QIO_CHANNEL_FEATURE_SHUTDOWN. We could add a separate feature in the future for indicating whether a channel supports yanking, but that seems overkill at the moment. Signed-off-by: Fabiano Rosas Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Xu Link: https://lore.kernel.org/r/20230911171320.24372-9-farosas@suse.de Signed-off-by: Peter Xu --- migration/yank_functions.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/migration/yank_functions.c b/migration/yank_functions.c index d5a710a3f2..979e60c762 100644 --- a/migration/yank_functions.c +++ b/migration/yank_functions.c @@ -8,12 +8,9 @@ */ =20 #include "qemu/osdep.h" -#include "qapi/error.h" #include "io/channel.h" #include "yank_functions.h" #include "qemu/yank.h" -#include "io/channel-socket.h" -#include "io/channel-tls.h" #include "qemu-file.h" =20 void migration_yank_iochannel(void *opaque) @@ -26,8 +23,7 @@ void migration_yank_iochannel(void *opaque) /* Return whether yank is supported on this ioc */ static bool migration_ioc_yank_supported(QIOChannel *ioc) { - return object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) || - object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS); + return qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN); } =20 void migration_ioc_register_yank(QIOChannel *ioc) --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497563; cv=none; d=zohomail.com; s=zohoarc; b=Wd+q9zSMWfO8+cCVQctXNb/6SJ+Rv7rjClWoQ1/Qn5HMh1KiVIjQfd7JyDRW75t6fp2GPz5rt2qBmAgVQUONI4F8KKIlt4Adsnn7gG9A2uSO/hUHpOOfHUUdEPd/nOpx8AB8mmLHuU8uy6+gALUP9ZtQ+Hh5HO/fsmWp4ayuFXA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497563; 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=sa2/urw2imMu6/yzcBVCu0Uejg3i9taSytYM/VmmU4A=; b=hb5ATAwlUB68viWGhXFoEWpSgmO2J8wQNERd9D4+LRf85q7HXk+R3wz1wCc4TmisCcX7zfmSsgtQInMjcJr8qiCmXTU/VWVPorBgT2ne2TyCBMENl76zencT2PI6LlyU7R37XoUJygRsxxdKgH5nrJas0vhAk7QWbbUZ2geLLD4= 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 1706497563138183.22379222916015; Sun, 28 Jan 2024 19:06:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHx2-0004Gd-QA; Sun, 28 Jan 2024 22:04:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUHx1-0004GE-Ci for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04: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 1rUHwz-0002d9-Ta for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:47 -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-679-NT2wBNpLMtWLSWNbAirSAA-1; Sun, 28 Jan 2024 22:04:41 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 572A283BA82; Mon, 29 Jan 2024 03:04:41 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 151891121306; Mon, 29 Jan 2024 03:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497485; 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=sa2/urw2imMu6/yzcBVCu0Uejg3i9taSytYM/VmmU4A=; b=YojnzWa02fTlHwxnHDUJExOzKF9REhyrhqHi8AsnN3AXo0VI7rf1PsAcPcsNsxcxfOFgFf OcK+nG9PE9A3buT3Dc+TZJBHhFbgLpcB9SP+zemGTRwipRx7sc8Ho+VolQGxZzq0wLt0UL 3UYgHXpVzD6XW0242D1zC0GFi4iqznw= X-MC-Unique: NT2wBNpLMtWLSWNbAirSAA-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 09/14] migration: Fix use-after-free of migration state object Date: Mon, 29 Jan 2024 11:04:00 +0800 Message-ID: <20240129030405.177100-10-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497564626100001 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We're currently allowing the process_incoming_migration_bh bottom-half to run without holding a reference to the 'current_migration' object, which leads to a segmentation fault if the BH is still live after migration_shutdown() has dropped the last reference to current_migration. In my system the bug manifests as migrate_multifd() returning true when it shouldn't and multifd_load_shutdown() calling multifd_recv_terminate_threads() which crashes due to an uninitialized multifd_recv_state. Fix the issue by holding a reference to the object when scheduling the BH and dropping it before returning from the BH. The same is already done for the cleanup_bh at migrate_fd_cleanup_schedule(). Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1969 Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240119233922.32588-2-farosas@suse.de Signed-off-by: Peter Xu --- migration/migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 219447dea1..cf17b68e57 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -648,6 +648,7 @@ static void process_incoming_migration_bh(void *opaque) MIGRATION_STATUS_COMPLETED); qemu_bh_delete(mis->bh); migration_incoming_state_destroy(); + object_unref(OBJECT(migrate_get_current())); } =20 static void coroutine_fn @@ -713,6 +714,7 @@ process_incoming_migration_co(void *opaque) } =20 mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); + object_ref(OBJECT(migrate_get_current())); qemu_bh_schedule(mis->bh); return; fail: --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497558; cv=none; d=zohomail.com; s=zohoarc; b=DQB+J6/bsP+rLiOo/i4z03r02sDj0Yq8eiJQ9YHZ35UrRpvQlTEyE5gSvw8O28xyjrS0xrJaM5Q04cQHdbAqI56WWEvk6AgSX8fjmhLKuLA8xZv0Sx8qe9UYbgFqvvaBskWVfu3rEVmOuSxItBO3qD2mU2zygxDkaT9WQnXuD5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497558; 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=ssSaIW3ahIip0O+ym1jhKD6aHZUz0kqQ0bfZMUBR5ng=; b=Z7854OdgJ+pi53s1b3RxFwutWyR8XS4mhgqob47VWKUsWyMaV0Svg/gaR5YhevbFM6o5bJKs466lZWewMbEtkt4MMh8+sj4ZpvDi6pXazS4QuRgY+BORgNIMUCFYhm5vEEdBu0CD0PtNJC0WBtIQmpcu6Awqvv3d/u9+8EW/HE0= 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 1706497558704239.1928494521993; Sun, 28 Jan 2024 19:05:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHx6-0004Hd-Bp; Sun, 28 Jan 2024 22:04: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 1rUHx5-0004HF-9P for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:51 -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 1rUHx3-0002dT-7A for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:50 -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-396-vL2ZL5jaNWC9-FcTEZYt4Q-1; Sun, 28 Jan 2024 22:04:45 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 9DC3785A589; Mon, 29 Jan 2024 03:04:44 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 266F01121306; Mon, 29 Jan 2024 03:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497488; 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=ssSaIW3ahIip0O+ym1jhKD6aHZUz0kqQ0bfZMUBR5ng=; b=iMwY4ygLEFgp8MZ1WsQOrJpT7fkcC+oWN9hZpCnAN7fpbVQ73gQBPyAY782n7dADai5K1D KA0A6pyDN/Qd2t32ovzRDmd1nrMuj0CZBC8Q4oZl/NV6XAVYjOf5XuiMGoFYBL0IySZNlc zSNWo3TuH1QxcQqxWey8Ly9L4BDRfJ8= X-MC-Unique: vL2ZL5jaNWC9-FcTEZYt4Q-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 10/14] migration: Take reference to migration state around bg_migration_vm_start_bh Date: Mon, 29 Jan 2024 11:04:01 +0800 Message-ID: <20240129030405.177100-11-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497560672100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We need to hold a reference to the current_migration object around async calls to avoid it been freed while still in use. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240119233922.32588-3-farosas@suse.de Signed-off-by: Peter Xu --- migration/migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index cf17b68e57..b1213b59ce 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3382,6 +3382,7 @@ static void bg_migration_vm_start_bh(void *opaque) =20 vm_resume(s->vm_old_state); migration_downtime_end(s); + object_unref(OBJECT(s)); } =20 /** @@ -3486,6 +3487,7 @@ static void *bg_migration_thread(void *opaque) * writes to virtio VQs memory which is in write-protected region. */ s->vm_start_bh =3D qemu_bh_new(bg_migration_vm_start_bh, s); + object_ref(OBJECT(s)); qemu_bh_schedule(s->vm_start_bh); =20 bql_unlock(); --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497596; cv=none; d=zohomail.com; s=zohoarc; b=FeOFkso3fVPD+7LIZJ1bl+yCLC+6Iq4HBjy50g36OjSmcUXEG2V9b+6FWW9jKTyfPgUKQGw1GAiYZdMnKW6uNh5cPj0ZUinTu5uYHVVEzIIuqwDxmrMyRr8sufh+32dFIiAWtRrGyrhS/BivjC5NpSE+4arO4TDgDO4g9803oMk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497596; 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=+Vvbftuj0OCUtZRn4vsJpQ7cASD1WEAgCGmOsdimkcI=; b=g7q1t7MEkM9opMtpBsAIqcmHJVjB+ViltRAJ50EuhPgplfQuDBpaAAsMeGoLGxCuR9rQfXUIegEac8FATQvmkq8PHDzlsFOu4pNp4nQweHXUB2m6ZFwJPxwUij9Wq8LcO3wMoo04TExSNBuXT/2cWakw9jrHGIQmjjRPTCgjszk= 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 1706497596579183.82630933258997; Sun, 28 Jan 2024 19:06:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHxA-0004PW-6A; Sun, 28 Jan 2024 22:04:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rUHx7-0004KZ-VX for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:54 -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 1rUHx6-0002dg-CH for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:53 -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-458-I0qLyhHbNmuuIgbo-_R7Gg-1; Sun, 28 Jan 2024 22:04:48 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 DE9FE8350E1; Mon, 29 Jan 2024 03:04:47 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A9521121306; Mon, 29 Jan 2024 03:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497491; 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=+Vvbftuj0OCUtZRn4vsJpQ7cASD1WEAgCGmOsdimkcI=; b=O2ug1OwHiWYLq3A1mfH7ziqS39PM7pG/1ENz23QJBYbbL+Ed4iOPCIgLmy2WqxuGzwzRm4 AdvPzRFznG0b6hq7vgFONICYvhIsJA9tVAXSrWeh4acoRPl1DCIqE+2yUldj+O40qlA0zg Y/ONDC5DAthbAm72IesLFMXBRZrnsFg= X-MC-Unique: I0qLyhHbNmuuIgbo-_R7Gg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 11/14] migration: Reference migration state around loadvm_postcopy_handle_run_bh Date: Mon, 29 Jan 2024 11:04:02 +0800 Message-ID: <20240129030405.177100-12-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497598691100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas We need to hold a reference to the current_migration object around async calls to avoid it been freed while still in use. Even on this load-side function, we might still use the MigrationState, e.g to check for capabilities. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240119233922.32588-4-farosas@suse.de Signed-off-by: Peter Xu --- migration/savevm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index 6410705ebe..93387350c7 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2174,6 +2174,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaqu= e) qemu_bh_delete(mis->bh); =20 trace_vmstate_downtime_checkpoint("dst-postcopy-bh-vm-started"); + object_unref(OBJECT(migration_get_current())); } =20 /* After all discards we can start running and asking for pages */ @@ -2189,6 +2190,7 @@ static int loadvm_postcopy_handle_run(MigrationIncomi= ngState *mis) =20 postcopy_state_set(POSTCOPY_INCOMING_RUNNING); mis->bh =3D qemu_bh_new(loadvm_postcopy_handle_run_bh, mis); + object_ref(OBJECT(migration_get_current())); qemu_bh_schedule(mis->bh); =20 /* We need to finish reading the stream from the package --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497534; cv=none; d=zohomail.com; s=zohoarc; b=Ad7VI9UiU+wKzX3FiCgluSNjO57Y9unI8Pd3avpoZh+7OMbvD6c06S3yyMXMtDE6PmQGcExpAzD1engp/pZap8F75GdlmH2jrVuUyyicp5nVegFzsko5VqIbbm2jSVsZgT8Rh+Ij59cqsfdx4jg/uPdTyxxCQdx09N/Lb8SAuCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497534; 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=nwPQaFncawh6LoHnuw9aCaruCaalCFdEX19mUZAGe+Q=; b=d4mZhb8UjjtPJOCRkKXnaWQ/OASX6H8r7iEw7YsM3Hx7jqch7qWYIfHPJQNP94DKEsOog4AD3a6Hxgu4RKE4xNW+hMOLV1g/2JIx2TK1NgFALchr4k+z4R5I/WcJ2esigPz+QkdYLdsSr8TRLxyikFmLSZv3C1MmbEj2hana2ec= 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 170649753461581.93508004997409; Sun, 28 Jan 2024 19:05:34 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHxB-0004U1-HT; Sun, 28 Jan 2024 22:04: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 1rUHxA-0004PH-2N for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04: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 1rUHx8-0002dv-C1 for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:55 -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-483-Z72gn10jMwKitbCHqErP8Q-1; Sun, 28 Jan 2024 22:04:51 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 2E4131C05AD3; Mon, 29 Jan 2024 03:04:51 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE3F81121306; Mon, 29 Jan 2024 03:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497493; 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=nwPQaFncawh6LoHnuw9aCaruCaalCFdEX19mUZAGe+Q=; b=e4mr1Jwb0MbVND5L7PgMBDc2PU+A5k1w+wxQTiYvaO28YlZQWr+b3S1vhBczUzDdqbxt+N 9idB6S5g/Qd2bUCmO+zgtgzUa1qCRKPl0vatz4mCJ0WuqIPEs6nNHHjA/nDsQQFWTOZkQk r2eu/zmlHDJZtHln0b4TMaTmj5OdpQM= X-MC-Unique: Z72gn10jMwKitbCHqErP8Q-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 12/14] migration: Add a wrapper to qemu_bh_schedule Date: Mon, 29 Jan 2024 11:04:03 +0800 Message-ID: <20240129030405.177100-13-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497536552100003 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Wrap qemu_bh_schedule() to ensure we always hold a reference to the current_migration object. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240119233922.32588-5-farosas@suse.de Signed-off-by: Peter Xu --- migration/migration.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index b1213b59ce..0e7f101d64 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -199,6 +199,16 @@ void migration_object_init(void) dirty_bitmap_mig_init(); } =20 +static void migration_bh_schedule(MigrationState *s, QEMUBH *bh) +{ + /* + * Ref the state for bh, because it may be called when + * there're already no other refs + */ + object_ref(OBJECT(s)); + qemu_bh_schedule(bh); +} + void migration_cancel(const Error *error) { if (error) { @@ -714,8 +724,7 @@ process_incoming_migration_co(void *opaque) } =20 mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); - object_ref(OBJECT(migrate_get_current())); - qemu_bh_schedule(mis->bh); + migration_bh_schedule(migrate_get_current(), mis->bh); return; fail: migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, @@ -1332,16 +1341,6 @@ static void migrate_fd_cleanup(MigrationState *s) yank_unregister_instance(MIGRATION_YANK_INSTANCE); } =20 -static void migrate_fd_cleanup_schedule(MigrationState *s) -{ - /* - * Ref the state for bh, because it may be called when - * there're already no other refs - */ - object_ref(OBJECT(s)); - qemu_bh_schedule(s->cleanup_bh); -} - static void migrate_fd_cleanup_bh(void *opaque) { MigrationState *s =3D opaque; @@ -3140,7 +3139,7 @@ static void migration_iteration_finish(MigrationState= *s) error_report("%s: Unknown ending state %d", __func__, s->state); break; } - migrate_fd_cleanup_schedule(s); + migration_bh_schedule(s, s->cleanup_bh); bql_unlock(); } =20 @@ -3171,7 +3170,7 @@ static void bg_migration_iteration_finish(MigrationSt= ate *s) break; } =20 - migrate_fd_cleanup_schedule(s); + migration_bh_schedule(s, s->cleanup_bh); bql_unlock(); } =20 @@ -3487,9 +3486,7 @@ static void *bg_migration_thread(void *opaque) * writes to virtio VQs memory which is in write-protected region. */ s->vm_start_bh =3D qemu_bh_new(bg_migration_vm_start_bh, s); - object_ref(OBJECT(s)); - qemu_bh_schedule(s->vm_start_bh); - + migration_bh_schedule(s, s->vm_start_bh); bql_unlock(); =20 while (migration_is_active(s)) { --=20 2.43.0 From nobody Tue Nov 26 14:49:33 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=1706497525; cv=none; d=zohomail.com; s=zohoarc; b=XatADhJjNZSu4zOLyHCWNlD2kQgxnpvruBECB1LpJrsqrVpSxLJPjaSvn0MX16iPP1KRBJ0orzlyX/jfNKGLi/CTBNLMSwzCuow1ekjGsn5KDbULnq9cLW2BVOe4afQg0yIfRHWthCL6eIeXrCX7f0DL8zwF3HvPnY1cdqD5OYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497525; 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=vOekGLZ5Iux9C2j66vk+K55gh9tnpRlnKIjN6UkLCzo=; b=fY5Oiv6te4J26OUVwz+4fQM80N/4RiEWh69W7YXL7DiBGeQXffY287DduAiArPYNpj9yQVE4Y42nQMBcXftxXAh2CR97HVHEpa+ZsCZ+hof7SEH49okAT6qj5XszLIqj+zyNRDMThZU3S6Pmn3y3uLQ33BL60JWTAY/GWfzv4AI= 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 1706497525389406.1552934683165; Sun, 28 Jan 2024 19:05:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHxF-0004Y2-Bu; Sun, 28 Jan 2024 22:05:01 -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 1rUHxE-0004Xi-4b for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:05:00 -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 1rUHxC-0002eS-7c for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:04:59 -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-386-JnNmj2h-OISwatzyQqMptw-1; Sun, 28 Jan 2024 22:04:54 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 D459229AC011; Mon, 29 Jan 2024 03:04:53 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id C21291121306; Mon, 29 Jan 2024 03:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497497; 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=vOekGLZ5Iux9C2j66vk+K55gh9tnpRlnKIjN6UkLCzo=; b=DGAMz5uWLk19wDT3onhiA+Sgxf/F7Pt88k6/yxZCj5EpJZ6vLiDozRqRoRUr8nVi4rXIg/ qEn8nBauNtHvMDu6Jvb7OgNhCPhIMPKcZheUEGon7Jew1KWXYHu4toGokvV9/RcD4aAv5J mMi4RTmBaoeh10y/0eazzxnHgpKLFTY= X-MC-Unique: JnNmj2h-OISwatzyQqMptw-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com Subject: [PULL 13/14] migration: Centralize BH creation and dispatch Date: Mon, 29 Jan 2024 11:04:04 +0800 Message-ID: <20240129030405.177100-14-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URG_BIZ=0.573 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1706497526588100005 Content-Type: text/plain; charset="utf-8" From: Fabiano Rosas Now that the migration state reference counting is correct, further wrap the bottom half dispatch process to avoid future issues. Move BH creation and scheduling together and wrap the dispatch with an intermediary function that will ensure we always keep the ref/unref balanced. Also move the responsibility of deleting the BH into the wrapper and remove the now unnecessary pointers. Signed-off-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240119233922.32588-6-farosas@suse.de Signed-off-by: Peter Xu --- migration/migration.h | 5 +--- migration/migration.c | 65 +++++++++++++++++++++++++------------------ migration/savevm.c | 7 +---- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index a589ae8650..f2c8b8f286 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -159,8 +159,6 @@ struct MigrationIncomingState { /* PostCopyFD's for external userfaultfds & handlers of shared memory = */ GArray *postcopy_remote_fds; =20 - QEMUBH *bh; - int state; =20 /* @@ -255,8 +253,6 @@ struct MigrationState { =20 /*< public >*/ QemuThread thread; - QEMUBH *vm_start_bh; - QEMUBH *cleanup_bh; /* Protected by qemu_file_lock */ QEMUFile *to_dst_file; /* Postcopy specific transfer channel */ @@ -528,6 +524,7 @@ int foreach_not_ignored_block(RAMBlockIterFunc func, vo= id *opaque); void migration_make_urgent_request(void); void migration_consume_urgent_request(void); bool migration_rate_limit(void); +void migration_bh_schedule(QEMUBHFunc *cb, void *opaque); void migration_cancel(const Error *error); =20 void migration_populate_vfio_info(MigrationInfo *info); diff --git a/migration/migration.c b/migration/migration.c index 0e7f101d64..d5f705ceef 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -199,8 +199,39 @@ void migration_object_init(void) dirty_bitmap_mig_init(); } =20 -static void migration_bh_schedule(MigrationState *s, QEMUBH *bh) +typedef struct { + QEMUBH *bh; + QEMUBHFunc *cb; + void *opaque; +} MigrationBH; + +static void migration_bh_dispatch_bh(void *opaque) { + MigrationState *s =3D migrate_get_current(); + MigrationBH *migbh =3D opaque; + + /* cleanup this BH */ + qemu_bh_delete(migbh->bh); + migbh->bh =3D NULL; + + /* dispatch the other one */ + migbh->cb(migbh->opaque); + object_unref(OBJECT(s)); + + g_free(migbh); +} + +void migration_bh_schedule(QEMUBHFunc *cb, void *opaque) +{ + MigrationState *s =3D migrate_get_current(); + MigrationBH *migbh =3D g_new0(MigrationBH, 1); + QEMUBH *bh =3D qemu_bh_new(migration_bh_dispatch_bh, migbh); + + /* Store these to dispatch when the BH runs */ + migbh->bh =3D bh; + migbh->cb =3D cb; + migbh->opaque =3D opaque; + /* * Ref the state for bh, because it may be called when * there're already no other refs @@ -656,9 +687,7 @@ static void process_incoming_migration_bh(void *opaque) */ migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COMPLETED); - qemu_bh_delete(mis->bh); migration_incoming_state_destroy(); - object_unref(OBJECT(migrate_get_current())); } =20 static void coroutine_fn @@ -723,8 +752,7 @@ process_incoming_migration_co(void *opaque) goto fail; } =20 - mis->bh =3D qemu_bh_new(process_incoming_migration_bh, mis); - migration_bh_schedule(migrate_get_current(), mis->bh); + migration_bh_schedule(process_incoming_migration_bh, mis); return; fail: migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, @@ -1285,9 +1313,6 @@ void migrate_set_state(int *state, int old_state, int= new_state) =20 static void migrate_fd_cleanup(MigrationState *s) { - qemu_bh_delete(s->cleanup_bh); - s->cleanup_bh =3D NULL; - g_free(s->hostname); s->hostname =3D NULL; json_writer_free(s->vmdesc); @@ -1343,9 +1368,7 @@ static void migrate_fd_cleanup(MigrationState *s) =20 static void migrate_fd_cleanup_bh(void *opaque) { - MigrationState *s =3D opaque; - migrate_fd_cleanup(s); - object_unref(OBJECT(s)); + migrate_fd_cleanup(opaque); } =20 void migrate_set_error(MigrationState *s, const Error *error) @@ -1568,8 +1591,6 @@ int migrate_init(MigrationState *s, Error **errp) * parameters/capabilities that the user set, and * locks. */ - s->cleanup_bh =3D 0; - s->vm_start_bh =3D 0; s->to_dst_file =3D NULL; s->state =3D MIGRATION_STATUS_NONE; s->rp_state.from_dst_file =3D NULL; @@ -3139,7 +3160,8 @@ static void migration_iteration_finish(MigrationState= *s) error_report("%s: Unknown ending state %d", __func__, s->state); break; } - migration_bh_schedule(s, s->cleanup_bh); + + migration_bh_schedule(migrate_fd_cleanup_bh, s); bql_unlock(); } =20 @@ -3170,7 +3192,7 @@ static void bg_migration_iteration_finish(MigrationSt= ate *s) break; } =20 - migration_bh_schedule(s, s->cleanup_bh); + migration_bh_schedule(migrate_fd_cleanup_bh, s); bql_unlock(); } =20 @@ -3376,12 +3398,8 @@ static void bg_migration_vm_start_bh(void *opaque) { MigrationState *s =3D opaque; =20 - qemu_bh_delete(s->vm_start_bh); - s->vm_start_bh =3D NULL; - vm_resume(s->vm_old_state); migration_downtime_end(s); - object_unref(OBJECT(s)); } =20 /** @@ -3485,8 +3503,7 @@ static void *bg_migration_thread(void *opaque) * calling VM state change notifiers from vm_start() would initiate * writes to virtio VQs memory which is in write-protected region. */ - s->vm_start_bh =3D qemu_bh_new(bg_migration_vm_start_bh, s); - migration_bh_schedule(s, s->vm_start_bh); + migration_bh_schedule(bg_migration_vm_start_bh, s); bql_unlock(); =20 while (migration_is_active(s)) { @@ -3542,12 +3559,6 @@ void migrate_fd_connect(MigrationState *s, Error *er= ror_in) migrate_error_free(s); =20 s->expected_downtime =3D migrate_downtime_limit(); - if (resume) { - assert(s->cleanup_bh); - } else { - assert(!s->cleanup_bh); - s->cleanup_bh =3D qemu_bh_new(migrate_fd_cleanup_bh, s); - } if (error_in) { migrate_fd_error(s, error_in); if (resume) { diff --git a/migration/savevm.c b/migration/savevm.c index 93387350c7..d612c8a902 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2171,10 +2171,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaq= ue) runstate_set(RUN_STATE_PAUSED); } =20 - qemu_bh_delete(mis->bh); - trace_vmstate_downtime_checkpoint("dst-postcopy-bh-vm-started"); - object_unref(OBJECT(migration_get_current())); } =20 /* After all discards we can start running and asking for pages */ @@ -2189,9 +2186,7 @@ static int loadvm_postcopy_handle_run(MigrationIncomi= ngState *mis) } =20 postcopy_state_set(POSTCOPY_INCOMING_RUNNING); - mis->bh =3D qemu_bh_new(loadvm_postcopy_handle_run_bh, mis); - object_ref(OBJECT(migration_get_current())); - qemu_bh_schedule(mis->bh); + migration_bh_schedule(loadvm_postcopy_handle_run_bh, mis); =20 /* We need to finish reading the stream from the package * and also stop reading anything more from the stream that loaded the --=20 2.43.0 From nobody Tue Nov 26 14:49:34 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=1706497527; cv=none; d=zohomail.com; s=zohoarc; b=GkGUiGVdWEvN+1mK0NEKGYNMb+vn3LcaQ6sb4nQPOi4l8tFmd7AZz7dPbLQdfV0M82pXUdpOAuLsq6Vd6oiQqkVC/ElLqw0hFwKNEH3mgMNaP9dxF/NHGHDHfTnFhvYximBGR/FsvICOjhMshsWKEtrH0Q+sY7axwzVNsKCmpDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1706497527; 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=+sER2eyqKnfBSeVEanQVjaVUVoCsgt1ad0+46UXYwpQ=; b=gUZRfvXRWHvq32qOAzC9Zy+g+eH0pGdNfn32Y/oecLhnT9EmGrni+N9FmB9ue4KyZPZGMdZxGqFGdCpZ2p3uP55pj5izVoWBWw+yeeMMp5MmQHb6usnzl0e0jcDZZgIM3/E7njTzgeXBtdfCtOwpl7Y0ljVDmew5hofMz/gNKvo= 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 1706497527020428.28176848313444; Sun, 28 Jan 2024 19:05:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rUHxI-0004Z6-UI; Sun, 28 Jan 2024 22:05:04 -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 1rUHxH-0004Yj-OO for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:05: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 1rUHxG-0002f3-3M for qemu-devel@nongnu.org; Sun, 28 Jan 2024 22:05:03 -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-353-1PxQWrogOxS-zDD9rb01Zg-1; Sun, 28 Jan 2024 22:04:57 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 5096A8350E1; Mon, 29 Jan 2024 03:04:57 +0000 (UTC) Received: from x1n.redhat.com (unknown [10.72.116.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74A7E1121306; Mon, 29 Jan 2024 03:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706497501; 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=+sER2eyqKnfBSeVEanQVjaVUVoCsgt1ad0+46UXYwpQ=; b=Iq3IIUhm0Vp+/wIL7qo4X/3ySbyX4k8lEPEPR71nhPhOf073Rz/tZDGQZiwYTpt/PFqNfj FqBCkh78SG/NFrgAP3H2NjnmLKV8tN9ilL0fBxoJhKNCjAOhpjzrH0I44MWCb3CxrpK4Cw RUHHWuKBA13RaZThxTyXU7aOpSqHTGE= X-MC-Unique: 1PxQWrogOxS-zDD9rb01Zg-1 From: peterx@redhat.com To: Peter Maydell , qemu-devel@nongnu.org Cc: Fabiano Rosas , peterx@redhat.com, Het Gala Subject: [PULL 14/14] Make 'uri' optional for migrate QAPI Date: Mon, 29 Jan 2024 11:04:05 +0800 Message-ID: <20240129030405.177100-15-peterx@redhat.com> In-Reply-To: <20240129030405.177100-1-peterx@redhat.com> References: <20240129030405.177100-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: -45 X-Spam_score: -4.6 X-Spam_bar: ---- X-Spam_report: (-4.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.485, 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1706497528534100009 Content-Type: text/plain; charset="utf-8" From: Het Gala 'uri' argument should be optional, as 'uri' and 'channels' arguments are mutally exclusive in nature. Fixes: 074dbce5fcce (migration: New migrate and migrate-incoming argument '= channels') Signed-off-by: Het Gala Link: https://lore.kernel.org/r/20240123064219.40514-1-het.gala@nutanix.com Signed-off-by: Peter Xu --- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index 489b591c23..d3e2b864c5 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1757,7 +1757,7 @@ # ## { 'command': 'migrate', - 'data': {'uri': 'str', + 'data': {'*uri': 'str', '*channels': [ 'MigrationChannel' ], '*blk': { 'type': 'bool', 'features': [ 'deprecated' ] }, '*inc': { 'type': 'bool', 'features': [ 'deprecated' ] }, --=20 2.43.0