From nobody Sat May 4 01:28:57 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678979594; cv=none; d=zohomail.com; s=zohoarc; b=jZteN/X1O6ozBFcL8pR/Q4Cz/NDHny70l7qLHjdn0H8SB/r+TdRhit3dv3h1k2fcJg0rDx3T2EITr1kOGdp63H1qrGB4glQo2Hi7tDUbTicH4bWU2UIYtLbbqsUmQFMaVkVMlueEm9llMjuj82DxbtrRtYYjapq5anMjlmGuNsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678979594; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q+QgOHpzztQRoC5XV2gLvUVlYs/raQm+F133uw/FKVs=; b=SZpBQHUyMJtrb06MHGblYos/Hm0bFZPhWrCvedi8JHPS7qsCW/LocbJ3/5kdOsgBu+2h6CRvJj2/ovb2Vxeq/2pHF54GPgZ0sHHo6F0qi2RIpxUsYt2iNrxi9d2xEuVCfAbmu/wh1+7rbhicKnPxrIASGcq8hKGF9QRMek78tyY= 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+importer2=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 1678979594673624.8961048993947; Thu, 16 Mar 2023 08:13:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcpHb-0001Xo-So; Thu, 16 Mar 2023 11:12:48 -0400 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 1pcpHO-0001QX-U7 for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:35 -0400 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 1pcpHL-0003Hf-Ra for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:33 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-60-0ZV6UHcaM3utLVAN_Y76dw-1; Thu, 16 Mar 2023 11:12:28 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A63E2807D76; Thu, 16 Mar 2023 15:12:28 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86045492B00; Thu, 16 Mar 2023 15:12:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678979550; 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=Q+QgOHpzztQRoC5XV2gLvUVlYs/raQm+F133uw/FKVs=; b=UMD1KzAx6vfCicMkkjssTqmtPlJiefGZM7UXBr613NorW2DJ/5gnbY/owga0vGNXsb2DMT daDwQ5iDSDUZGaWlJ514abuHdh5lmuZTtjKVR//+w6ewa7w1TcDT9/xKeayhfQl6sl1mwm lEeXmSfj8kIVQYDzXf0a3TXX/M6h1XM= X-MC-Unique: 0ZV6UHcaM3utLVAN_Y76dw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , "Dr. David Alan Gilbert" , Peter Xu , Peter Maydell , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PULL 1/7] migration: Wait on preempt channel in preempt thread Date: Thu, 16 Mar 2023 16:12:19 +0100 Message-Id: <20230316151225.11362-2-quintela@redhat.com> In-Reply-To: <20230316151225.11362-1-quintela@redhat.com> References: <20230316151225.11362-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678979595892100001 From: Peter Xu QEMU main thread will wait until dest preempt channel established during processing the LISTEN command (within the whole postcopy PACKAGED data), by waiting on the semaphore postcopy_qemufile_dst_done. That's racy, because it's possible that the dest QEMU main thread hasn't yet accept()ed the new connection when processing the LISTEN event. The sem_wait() will yield the main thread without being able to run anything else including the accept() of the new socket, which can cause deadlock within the main thread. To avoid the race, move the "wait channel" from main thread to the preempt thread right at the start. Reported-by: Peter Maydell Fixes: 5655aab079 ("migration: Postpone postcopy preempt channel to be afte= r main") Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Juan Quintela Signed-off-by: Peter Xu Signed-off-by: Juan Quintela --- migration/postcopy-ram.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index f54f44d899..41c0713650 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1197,11 +1197,6 @@ int postcopy_ram_incoming_setup(MigrationIncomingSta= te *mis) } =20 if (migrate_postcopy_preempt()) { - /* - * The preempt channel is established in asynchronous way. Wait - * for its completion. - */ - qemu_sem_wait(&mis->postcopy_qemufile_dst_done); /* * This thread needs to be created after the temp pages because * it'll fetch RAM_CHANNEL_POSTCOPY PostcopyTmpPage immediately. @@ -1668,6 +1663,12 @@ void *postcopy_preempt_thread(void *opaque) =20 qemu_sem_post(&mis->thread_sync_sem); =20 + /* + * The preempt channel is established in asynchronous way. Wait + * for its completion. + */ + qemu_sem_wait(&mis->postcopy_qemufile_dst_done); + /* Sending RAM_SAVE_FLAG_EOS to terminate this thread */ qemu_mutex_lock(&mis->postcopy_prio_thread_mutex); while (1) { --=20 2.39.2 From nobody Sat May 4 01:28:57 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678979673; cv=none; d=zohomail.com; s=zohoarc; b=no/LY2g4tW/71FN/cHXaJC+dshoCW0udBVXQSFtcW7e8UPudWl0TZ0RmVmwnvbsBfaOwzvDtnBa7Al0YYlaZ4UC4AEd5/UiUJjxm3gFWub+6M1hPlrr16eUSGKnUyMXXTOLvyzH/Zp9lUIc98ZLRPFhc3Dz5Y/9m13oNSMeSkbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678979673; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KWtkZ5KFTsPGD80ZLZneVBmuZ3Uxb33J5L1+SLbAgK0=; b=CT6eFNNBDhIiHEoFr4IoPdgA5FE4qffF0Fwi07Ljh1HaWLqwq98wexFnvfDoTJQLJ91YXOMMXlLEaGJwOybGZkyAmUgxtZhjzq834RK4N0uoN85A7JmrwoJMprJY7pY12e61aR+vh8TGIn2s9oPR6nvDsoVk8+Im03E6CdG/Z4I= 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+importer2=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 1678979673813344.43067557674806; Thu, 16 Mar 2023 08:14:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcpHd-0001ax-S6; Thu, 16 Mar 2023 11:12:49 -0400 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 1pcpHO-0001QY-VF for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:35 -0400 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 1pcpHM-0003Hn-LD for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-288-f8qNwn3LO5S4iizo2R0a1A-1; Thu, 16 Mar 2023 11:12:29 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6E8A87B2A0; Thu, 16 Mar 2023 15:12:29 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC7D2492B02; Thu, 16 Mar 2023 15:12:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678979551; 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=KWtkZ5KFTsPGD80ZLZneVBmuZ3Uxb33J5L1+SLbAgK0=; b=GWjFgPYeYFlH4VF6Q2+nBSj3zs7V4TQZafDvw1pTaVEEG9vZMUTZSjUadP0wtDiypvNCUj Aln7cKrld5wkTt5iwcjxWgGIF2IQGCkTBxgFpe0vh6axvD864UMDhRSMEdXnmS8cJGFqcB BsLlf2KNgdkWk0lojXX+g2m3i9QAKB8= X-MC-Unique: f8qNwn3LO5S4iizo2R0a1A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , "Dr. David Alan Gilbert" , Li Zhijian Subject: [PULL 2/7] migration/rdma: Fix return-path case Date: Thu, 16 Mar 2023 16:12:20 +0100 Message-Id: <20230316151225.11362-3-quintela@redhat.com> In-Reply-To: <20230316151225.11362-1-quintela@redhat.com> References: <20230316151225.11362-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678979674946100003 Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" The RDMA code has return-path handling code, but it's only enabled if postcopy is enabled; if the 'return-path' migration capability is enabled, the return path is NOT setup but the core migration code still tries to use it and breaks. Enable the RDMA return path if either postcopy or the return-path capability is enabled. bz: https://bugzilla.redhat.com/show_bug.cgi?id=3D2063615 Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Reviewed-by: Li Zhijian Signed-off-by: Juan Quintela --- migration/rdma.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 288eadc2d2..9d70e9885b 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3373,7 +3373,8 @@ static int qemu_rdma_accept(RDMAContext *rdma) * initialize the RDMAContext for return path for postcopy after first * connection request reached. */ - if (migrate_postcopy() && !rdma->is_return_path) { + if ((migrate_postcopy() || migrate_use_return_path()) + && !rdma->is_return_path) { rdma_return_path =3D qemu_rdma_data_init(rdma->host_port, NULL); if (rdma_return_path =3D=3D NULL) { rdma_ack_cm_event(cm_event); @@ -3455,7 +3456,8 @@ static int qemu_rdma_accept(RDMAContext *rdma) } =20 /* Accept the second connection request for return path */ - if (migrate_postcopy() && !rdma->is_return_path) { + if ((migrate_postcopy() || migrate_use_return_path()) + && !rdma->is_return_path) { qemu_set_fd_handler(rdma->channel->fd, rdma_accept_incoming_migrat= ion, NULL, (void *)(intptr_t)rdma->return_path); @@ -4192,7 +4194,7 @@ void rdma_start_outgoing_migration(void *opaque, } =20 /* RDMA postcopy need a separate queue pair for return path */ - if (migrate_postcopy()) { + if (migrate_postcopy() || migrate_use_return_path()) { rdma_return_path =3D qemu_rdma_data_init(host_port, errp); =20 if (rdma_return_path =3D=3D NULL) { --=20 2.39.2 From nobody Sat May 4 01:28:57 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678979664; cv=none; d=zohomail.com; s=zohoarc; b=D/3W1ZHDkWzuxTexjyBxQXAZrsQc6LheZfLhM38W2QIJRZmEhpdV1PoA9r+Hz1MzP67yfaV74+fly8M9DPOWm3/iN84diEgjCAyk1XAJFimVxBhnZVoqvt1tPFsdzs5SrGo/KCQgus/E3/9lg9pAYKe8fVvd4tONLYe7D015oJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678979664; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j2ZKMZ8E9Z75S0HKJJkGW1ixZ1CA1Gl+IXoT6JvRfxQ=; b=SlfyKpsHoeWjykhFxvLs80KdXavW2BdWKpbs9JZtiN9hcVyEHNt/473sWp9cRwlD5mCA8IrFE0uZX/G6WrD6ERr2X3FVb0mZFaNWked4+iq58z1sS04wfSa7rooCqoJM/e+So9b28IGE3ZEGdWW0edbRFjWVfDeq4RKRUr7xoLg= 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+importer2=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 1678979664775588.8638241663438; Thu, 16 Mar 2023 08:14:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcpHh-0001bn-7J; Thu, 16 Mar 2023 11:12:53 -0400 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 1pcpHa-0001XX-Dx for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:46 -0400 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 1pcpHY-0003KB-CW for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:46 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-673-c30GZD26MTyec8Rg5CNr2w-1; Thu, 16 Mar 2023 11:12:33 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A924C3815F7A; Thu, 16 Mar 2023 15:12:30 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id EACF1492B02; Thu, 16 Mar 2023 15:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678979563; 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=j2ZKMZ8E9Z75S0HKJJkGW1ixZ1CA1Gl+IXoT6JvRfxQ=; b=Tpof6Ffrq2cmqpbpdUAwuwrBFVI9lYoO3RgdPX/nqcuGSNZMVxnSV12PkQP5FhRWO9FQXs 83CWJZr83oVPM0kggc05YDjc2PBBzAD/7yYSFxhlOtaqEZqIqWTGL2JCpW8XefsCnYZDP4 5TkrQBoRtYSLOaeYq1FS+52wJuRaKpQ= X-MC-Unique: c30GZD26MTyec8Rg5CNr2w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , "Dr. David Alan Gilbert" , Matheus Tavares Bernardino Subject: [PULL 3/7] migration/xbzrle: use ctz64 to avoid undefined result Date: Thu, 16 Mar 2023 16:12:21 +0100 Message-Id: <20230316151225.11362-4-quintela@redhat.com> In-Reply-To: <20230316151225.11362-1-quintela@redhat.com> References: <20230316151225.11362-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678979667048100006 Content-Type: text/plain; charset="utf-8" From: Matheus Tavares Bernardino __builtin_ctzll() produces undefined results when the argument is 0. This can be seen through test-xbzrle, which produces the following warning: ../migration/xbzrle.c:265: runtime error: passing zero to ctz(), which is n= ot a valid argument Replace __builtin_ctzll() with our ctz64() wrapper which properly handles 0. Signed-off-by: Matheus Tavares Bernardino Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/xbzrle.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/migration/xbzrle.c b/migration/xbzrle.c index 05366e86c0..21b92d4eae 100644 --- a/migration/xbzrle.c +++ b/migration/xbzrle.c @@ -12,6 +12,7 @@ */ #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/host-utils.h" #include "xbzrle.h" =20 /* @@ -233,7 +234,7 @@ int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint8= _t *new_buf, int slen, break; } never_same =3D false; - num =3D __builtin_ctzll(~comp); + num =3D ctz64(~comp); num =3D (num < bytes_to_check) ? num : bytes_to_check; zrun_len +=3D num; bytes_to_check -=3D num; @@ -262,7 +263,7 @@ int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint8= _t *new_buf, int slen, nzrun_len +=3D 64; break; } - num =3D __builtin_ctzll(comp); + num =3D ctz64(comp); num =3D (num < bytes_to_check) ? num : bytes_to_check; nzrun_len +=3D num; bytes_to_check -=3D num; --=20 2.39.2 From nobody Sat May 4 01:28:57 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678979664; cv=none; d=zohomail.com; s=zohoarc; b=lUX19v1q7v0vtIM6j90768podk6aTDkNGqChnPdbhFhNH8PUzFWeIOvzRxg8cPgWiLhNXhzNeugXiFrluOKGlh6G/U6M07FFPwyiVcgfbIbmAG7NPqZ2EnTX1gBUqjT1uE3LaQsrurvgmUiN8JZQH4yMeSLQizvyqewhYG8njL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678979664; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V8X9i5z+IA/JXYTFyPjqnkyE/RoG2BM7TUNVsDqSoo8=; b=Gk44L12qXMNysSAkJxrksoNoDCiNhbcMcB+x80BzDqU4mSpdMynQICJNXKW6DLZ9yOmYXVwuAfRFZykZf5qs3iT7D8yOhdJIq9obj4s7x7v89AL9bm75YDBdjDbP7ADuffMZd6sMJsCXtUmyEZPXSYa6ux+xVvH8l3URL2vDwOw= 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+importer2=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 1678979664906647.6678590877699; Thu, 16 Mar 2023 08:14:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcpHh-0001bp-CI; Thu, 16 Mar 2023 11:12:53 -0400 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 1pcpHQ-0001Qx-8b for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:37 -0400 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 1pcpHO-0003I3-Mt for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:35 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-117-PujK91MpMfiRTDvsnV42LA-1; Thu, 16 Mar 2023 11:12:32 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A3C482807D71; Thu, 16 Mar 2023 15:12:31 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id EA95A492B00; Thu, 16 Mar 2023 15:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678979553; 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=V8X9i5z+IA/JXYTFyPjqnkyE/RoG2BM7TUNVsDqSoo8=; b=Ed45ieRrFtEpaNrOTN4b+rstyjgqXW3l279MndcMFV0f7YIEjV00aKEypm2/qO3rv6YegE 0XEOmKSOXOM8fz/KLUkbYqzFHRW6mv7nyAtjvZl16ndr4VNHKYLdL5t9DP2x/p2b3FkDRD T22xPmLyOVLj//WfJW4UOjiQT8y5fO8= X-MC-Unique: PujK91MpMfiRTDvsnV42LA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , "Dr. David Alan Gilbert" , Matheus Tavares Bernardino Subject: [PULL 4/7] migration/xbzrle: fix out-of-bounds write with axv512 Date: Thu, 16 Mar 2023 16:12:22 +0100 Message-Id: <20230316151225.11362-5-quintela@redhat.com> In-Reply-To: <20230316151225.11362-1-quintela@redhat.com> References: <20230316151225.11362-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678979667047100005 Content-Type: text/plain; charset="utf-8" From: Matheus Tavares Bernardino xbzrle_encode_buffer_avx512() checks for overflows too scarcely in its outer loop, causing out-of-bounds writes: $ ../configure --target-list=3Daarch64-softmmu --enable-sanitizers --enable= -avx512bw $ make tests/unit/test-xbzrle && ./tests/unit/test-xbzrle =3D=3D5518=3D=3DERROR: AddressSanitizer: heap-buffer-overflow on address 0x= 62100000b100 at pc 0x561109a7714d bp 0x7ffed712a440 sp 0x7ffed712a430 WRITE of size 1 at 0x62100000b100 thread T0 #0 0x561109a7714c in uleb128_encode_small ../util/cutils.c:831 #1 0x561109b67f6a in xbzrle_encode_buffer_avx512 ../migration/xbzrle.c:= 275 #2 0x5611099a7428 in test_encode_decode_overflow ../tests/unit/test-xbz= rle.c:153 #3 0x7fb2fb65a58d (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x7a58d) #4 0x7fb2fb65a333 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x7a333) #5 0x7fb2fb65aa79 in g_test_run_suite (/lib/x86_64-linux-gnu/libglib-2.= 0.so.0+0x7aa79) #6 0x7fb2fb65aa94 in g_test_run (/lib/x86_64-linux-gnu/libglib-2.0.so.0= +0x7aa94) #7 0x5611099a3a23 in main ../tests/unit/test-xbzrle.c:218 #8 0x7fb2fa78c082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6= +0x24082) #9 0x5611099a608d in _start (/qemu/build/tests/unit/test-xbzrle+0x28408= d) 0x62100000b100 is located 0 bytes to the right of 4096-byte region [0x62100= 000a100,0x62100000b100) allocated by thread T0 here: #0 0x7fb2fb823a06 in __interceptor_calloc ../../../../src/libsanitizer/= asan/asan_malloc_linux.cc:153 #1 0x7fb2fb637ef0 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+= 0x57ef0) Fix that by performing the overflow check in the inner loop, instead. Signed-off-by: Matheus Tavares Bernardino Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/xbzrle.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/migration/xbzrle.c b/migration/xbzrle.c index 21b92d4eae..c6f8b20917 100644 --- a/migration/xbzrle.c +++ b/migration/xbzrle.c @@ -197,10 +197,6 @@ int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint= 8_t *new_buf, int slen, __m512i r =3D _mm512_set1_epi32(0); =20 while (count512s) { - if (d + 2 > dlen) { - return -1; - } - int bytes_to_check =3D 64; uint64_t mask =3D 0xffffffffffffffff; if (count512s =3D=3D 1) { @@ -216,6 +212,9 @@ int xbzrle_encode_buffer_avx512(uint8_t *old_buf, uint8= _t *new_buf, int slen, =20 bool is_same =3D (comp & 0x1); while (bytes_to_check) { + if (d + 2 > dlen) { + return -1; + } if (is_same) { if (nzrun_len) { d +=3D uleb128_encode_small(dst + d, nzrun_len); --=20 2.39.2 From nobody Sat May 4 01:28:57 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678979606; cv=none; d=zohomail.com; s=zohoarc; b=BSj8uNOJGKfpdh0o4EoQ0aN3tC2s2/PY+5Q3TZmyQW3UiMenIE7hmDZ58N89R+qMAniIMPzZZu0dV7aGXMND4MDq4Iqrdnpncg8UD2iXoP3GpxzrGUdaU14l5Dxb5z5+yRn5BO36GqH6tUwkJ99hkqfNc9YqEB59ZAWY0aC6hu8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678979606; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mWhea6iw3dwLxvuEPeKR6oDJbMOZb9wjBsr0s6KkMNE=; b=TExTaoN5G3gWOKtU3OnXYuhS/0eX0HaKslERgxHRn/R97vNZBvOOnAQlWWJ5WRcfV42u7sLFXn3+F4HjpDcBmjIvjcSw0R0NLY9MpkSKEvRkJzllILV2y0inWSiSP261uzJyMvP76E+yNKl9bR5C+LbzFkh/hqfrf410AAdOFtg= 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+importer2=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 1678979606279632.7690301201178; Thu, 16 Mar 2023 08:13:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcpHY-0001Ub-My; Thu, 16 Mar 2023 11:12:44 -0400 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 1pcpHS-0001RN-Tt for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:40 -0400 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 1pcpHR-0003Ii-FG for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:38 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-519-tam3AYlvPxeRKxQBpIy-XA-1; Thu, 16 Mar 2023 11:12:33 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9F24C811E7B; Thu, 16 Mar 2023 15:12:32 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id E724E492B00; Thu, 16 Mar 2023 15:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678979556; 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=mWhea6iw3dwLxvuEPeKR6oDJbMOZb9wjBsr0s6KkMNE=; b=f7ZSy6iSfMbinCnju732LPv+YPp8sGM2ZjKqSdB4uWQYNgcvIUBkmWTZLingJGeIbQXK7v 06cYJMWOD1tWYSp1qPg7pYL+6KBD/0ziOdPd5uD/z04ZTND3rtJcsAeDH+PUUpryq2czf4 8KsJCtLTQE3YxsPB0Lfp7AGr40Irkvg= X-MC-Unique: tam3AYlvPxeRKxQBpIy-XA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , "Dr. David Alan Gilbert" , Li Zhijian Subject: [PULL 5/7] migration/rdma: Remove deprecated variable rdma_return_path Date: Thu, 16 Mar 2023 16:12:23 +0100 Message-Id: <20230316151225.11362-6-quintela@redhat.com> In-Reply-To: <20230316151225.11362-1-quintela@redhat.com> References: <20230316151225.11362-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678979607960100001 Content-Type: text/plain; charset="utf-8" From: Li Zhijian It's no longer needed since commit 44bcfd45e98 ("migration/rdma: destination: create the return patch after th= e first accept") Signed-off-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/rdma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 9d70e9885b..df646be35e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -4111,7 +4111,7 @@ static void rdma_accept_incoming_migration(void *opaq= ue) void rdma_start_incoming_migration(const char *host_port, Error **errp) { int ret; - RDMAContext *rdma, *rdma_return_path =3D NULL; + RDMAContext *rdma; Error *local_err =3D NULL; =20 trace_rdma_start_incoming_migration(); @@ -4157,7 +4157,6 @@ err: g_free(rdma->host_port); } g_free(rdma); - g_free(rdma_return_path); } =20 void rdma_start_outgoing_migration(void *opaque, --=20 2.39.2 From nobody Sat May 4 01:28:57 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678979684; cv=none; d=zohomail.com; s=zohoarc; b=QX9e7JUvRWlsahfby7dN+yCqS8ybxIvrM4cJwQsf9RKa4LgslwehQFiac8dp6gBK9TKqDqCIN/PIzucpQDJJ5FS67fjaHPfmVWDs/pn4TEM9CFEa8/V7dljcOMLmpmTvRl0XgH49BX1MoZ85gr8SeE1TRI/BESRv5ox+1IUkNzc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678979684; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kJLO7E81w+2tfpouAoYTRxbBc1A1C7rZpQoVjfCfXsU=; b=c0+SVkwbSZj+UP1U9qdRSGBNmnnwwtbAES44adIGqKhyRX/tfLuo6OIZSwk1EnegLMUZodOhu2xh1/ulWPyNMj42JBCZe9bF63K43M/giLeN6AVxvu6eTnm48vSM7vPssg2T77pUkWf3Npy1ygWSvLAlKNHqLChhGX4YeoM7uAg= 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+importer2=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 1678979684739605.8540078249144; Thu, 16 Mar 2023 08:14:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcpHd-0001ay-TX; Thu, 16 Mar 2023 11:12:51 -0400 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 1pcpHT-0001RP-Bf for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:40 -0400 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 1pcpHR-0003Iu-TZ for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:39 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-581-yz-xIymoPIeiLy69eu7hFg-1; Thu, 16 Mar 2023 11:12:34 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 995253815F73; Thu, 16 Mar 2023 15:12:33 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id E14E1492B00; Thu, 16 Mar 2023 15:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678979557; 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=kJLO7E81w+2tfpouAoYTRxbBc1A1C7rZpQoVjfCfXsU=; b=CoCbH7Mftb2nHFJw5d3Vb5LMtJmmNlgVOP+SoMbcJxoMhC06ND1Csp3cW65l/fFzbuya7S 740dUwhjeN2iiEVuupsa0N4WFmzayLkRhdjB+gmlHfnwluVWTacjwSfMukNj80m2VCYPdh Pf50bzGIgvFweWA9L8I73IvmlEL/If0= X-MC-Unique: yz-xIymoPIeiLy69eu7hFg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , "Dr. David Alan Gilbert" , Wei Wang Subject: [PULL 6/7] migration/multifd: correct multifd_send_thread to trace the flags Date: Thu, 16 Mar 2023 16:12:24 +0100 Message-Id: <20230316151225.11362-7-quintela@redhat.com> In-Reply-To: <20230316151225.11362-1-quintela@redhat.com> References: <20230316151225.11362-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678979684977100002 Content-Type: text/plain; charset="utf-8" From: Wei Wang The p->flags could be updated via the send_prepare callback, e.g. OR-ed with MULTIFD_FLAG_ZLIB via zlib_send_prepare. Assign p->flags to the local "flags" before the send_prepare callback could only get partial of p->flags. Fix it by moving the assignment of p->flags to the local flags after the callback, so that the correct flags can be traced. Fixes: ab7cbb0b9a3b ("multifd: Make no compression operations into its own = structure") Signed-off-by: Wei Wang Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/multifd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/multifd.c b/migration/multifd.c index 5e85c3ea9b..cbc0dfe39b 100644 --- a/migration/multifd.c +++ b/migration/multifd.c @@ -677,7 +677,7 @@ static void *multifd_send_thread(void *opaque) =20 if (p->pending_job) { uint64_t packet_num =3D p->packet_num; - uint32_t flags =3D p->flags; + uint32_t flags; p->normal_num =3D 0; =20 if (use_zero_copy_send) { @@ -699,6 +699,7 @@ static void *multifd_send_thread(void *opaque) } } multifd_send_fill_packet(p); + flags =3D p->flags; p->flags =3D 0; p->num_packets++; p->total_normal_pages +=3D p->normal_num; --=20 2.39.2 From nobody Sat May 4 01:28:57 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678979638; cv=none; d=zohomail.com; s=zohoarc; b=KIndlKsl0+9JRYRHOa/EuvvKryBwIdxIFGtzQRKeupS5BeVW6xkpXgevv5KemPwNI/IDJrK+q3tZnjwUWDTpXdzioMVpJYc+Hv0Dy17TzvPXqCPZin51rRHICloQCVEMDEFx9nLiDaBP57KaA2ClqnayL2KnAKLC8JrhbFaAduM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678979638; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TgW3lNg1MAIRbI4saDOTg+xZ/0W/y13SQvKQiAkyeTQ=; b=G2+CEDLS4GQ/AUaznmfv4Sz67jaM+IC9lYuNjRgHHS6lToLZ7NHM1he9XiBO+96eYnJ+Fb7nuJu2UiUrR6gAtuaOb7VlI/SfbIs4KqRN2XVy38yXEKCDYTDQ7WeFtP+aBhW7E2/93LTF4uRrzaFWf3hP9LgdNuDWG3Grgpgemfg= 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+importer2=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 1678979638292915.574991897025; Thu, 16 Mar 2023 08:13:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcpHh-0001bl-0C; Thu, 16 Mar 2023 11:12:53 -0400 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 1pcpHZ-0001X9-7Y for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:46 -0400 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 1pcpHW-0003Jt-Ms for qemu-devel@nongnu.org; Thu, 16 Mar 2023 11:12:44 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-UOu-Ez64OBq_egdubxw1-A-1; Thu, 16 Mar 2023 11:12:35 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0755889058; Thu, 16 Mar 2023 15:12:34 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBF21492B02; Thu, 16 Mar 2023 15:12:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678979561; 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=TgW3lNg1MAIRbI4saDOTg+xZ/0W/y13SQvKQiAkyeTQ=; b=AVqcsMufdhlCj5jg/Y6rk47N3ujEXzUhdYI4EVjCU4HMoQfd8otR5V99dpzcb2qm1t9FFm cUo40Lr1dP8y1+SARAxToPa6se/VjE1AK6jOtQu8rKBHF2JBIbNsqof32Nt11faYKIS47H n5APiURszL12GpLwWg7GdZADmSNIMsk= X-MC-Unique: UOu-Ez64OBq_egdubxw1-A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , "Dr. David Alan Gilbert" , Steve Sistare , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Thomas Huth Subject: [PULL 7/7] migration: fix populate_vfio_info Date: Thu, 16 Mar 2023 16:12:25 +0100 Message-Id: <20230316151225.11362-8-quintela@redhat.com> In-Reply-To: <20230316151225.11362-1-quintela@redhat.com> References: <20230316151225.11362-1-quintela@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678979640172100001 From: Steve Sistare Include CONFIG_DEVICES so that populate_vfio_info is instantiated for CONFIG_VFIO. Without it, the 'info migrate' command never returns info about vfio. Fixes: 43bd0bf30f ("migration: Move populate_vfio_info() into a separate fi= le") Signed-off-by: Steve Sistare Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Thomas Huth Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela --- migration/target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/target.c b/migration/target.c index 907ebf0a0a..00ca007f97 100644 --- a/migration/target.c +++ b/migration/target.c @@ -8,6 +8,7 @@ #include "qemu/osdep.h" #include "qapi/qapi-types-migration.h" #include "migration.h" +#include CONFIG_DEVICES =20 #ifdef CONFIG_VFIO #include "hw/vfio/vfio-common.h" @@ -17,7 +18,6 @@ void populate_vfio_info(MigrationInfo *info) { #ifdef CONFIG_VFIO if (vfio_mig_active()) { - info->has_vfio =3D true; info->vfio =3D g_malloc0(sizeof(*info->vfio)); info->vfio->transferred =3D vfio_mig_bytes_transferred(); } --=20 2.39.2