From nobody Fri May 17 03:01:02 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=1646245974; cv=none; d=zohomail.com; s=zohoarc; b=Or0VNlE7Kv3LD/fBq3hhKllz1yCcJxf+Umfg5ni9L6P833fr0zsOkqs5xEPvL4P3d8+QvkCSwhPz4b0yXsnNgYUBiOWGE9cpOyaLLdVV0hX5rEeoitRht5+EJXSpEz06xSyrDP71B8TV+yuIcZvSFVhR36B+3M3wlz9LnCCYTbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646245974; 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=FUeohVwMXEu92BpzCEiijkV/baBocA1U7rFGsPiR+KY=; b=Xd9+NAB5Rtlpt7MNbD2tOZTuzUCNEO1HXRI5FvA3DIdtOkA0X4+bDPlzYnMKR/i/uRSeGUM2UNFiLyJdEWHBVdEH2/I5fSrWKfhIXH78SWv79WlwYkW9ePpDT0Xz8CeMm0wWI6aV9958xZW4g3PoPkqzw84TKBlkWkvmkR7JXbs= 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 1646245974157293.4760157387376; Wed, 2 Mar 2022 10:32:54 -0800 (PST) Received: from localhost ([::1]:40540 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTmP-0003kZ-8g for importer@patchew.org; Wed, 02 Mar 2022 13:32:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkG-0000r4-7q for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:53359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkD-0000Ev-Ol for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-393-j3jaezzPNIGC0GvV__cS5g-1; Wed, 02 Mar 2022 13:30:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 864D81018745; Wed, 2 Mar 2022 18:30:31 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E51F91059172; Wed, 2 Mar 2022 18:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245837; 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=FUeohVwMXEu92BpzCEiijkV/baBocA1U7rFGsPiR+KY=; b=gXgat6teetXRgkmo3mIULxP4AMwJpSD4fdb4DfAJTuKm25WXgtN3VnGVuMU6ftA3PBPS6T XjOk76SiULfW5oTtShsGTKNGEA9vBR2978mH7t9QVebOBwDMl/xi//FsHfb+1g5rYiUEU+ 1nEpbcEU3J7bsVVaWkDct/AEvliIc+o= X-MC-Unique: j3jaezzPNIGC0GvV__cS5g-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 01/18] clock-vmstate: Add missing END_OF_LIST Date: Wed, 2 Mar 2022 18:29:19 +0000 Message-Id: <20220302182936.227719-2-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646245974950100001 From: "Dr. David Alan Gilbert" Add the missing VMSTATE_END_OF_LIST to vmstate_muldiv Fixes: 99abcbc7600 ("clock: Provide builtin multiplier/divider") Signed-off-by: Dr. David Alan Gilbert Message-Id: <20220111101934.115028-1-dgilbert@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Luc Michel Cc: qemu-stable@nongnu.org Signed-off-by: Dr. David Alan Gilbert --- hw/core/clock-vmstate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/core/clock-vmstate.c b/hw/core/clock-vmstate.c index 9d9174ffbd..7eccb6d4ea 100644 --- a/hw/core/clock-vmstate.c +++ b/hw/core/clock-vmstate.c @@ -44,6 +44,7 @@ const VMStateDescription vmstate_muldiv =3D { .fields =3D (VMStateField[]) { VMSTATE_UINT32(multiplier, Clock), VMSTATE_UINT32(divider, Clock), + VMSTATE_END_OF_LIST() }, }; =20 --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247394; cv=none; d=zohomail.com; s=zohoarc; b=iNYRKRXFatppSB+eRQTrVgFgfLFj54+5+ClbJw7sMKnHcwvs6znQpvOeYnKQo1eW6OOU8zjUSkQ0l0F4qF8zRkA6uXuxIUZyP58JvIo0zj6xIrqNL+avlv42OQTbWOPShOQzR+LcCxBPc2/e8WTmbF8UQqyqP1K+zGWrMFkmDb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247394; 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=+Y5T8Fwf9mR7p5wzLcO8Ej6uZejLheoOnrA75Npxe5A=; b=ErWrOiq8xcV6vG5hz8V1JUYtCkGr5nvI602YFgnu3Jy+vz9XJUKgYxmwCwt1JGh+m8+JSt39RLEvL8nCL1wW0zj9GIhNhZVQG/Yl40/9n5c4jy/GvYNWMQ8yaGJvJGYuFq6Q1jYSImIlo5B2baYSDJ2O24f8rXDqUgdGWem3WDQ= 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 1646247394860247.79676166748027; Wed, 2 Mar 2022 10:56:34 -0800 (PST) Received: from localhost ([::1]:36968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU9K-0005uW-6K for importer@patchew.org; Wed, 02 Mar 2022 13:56:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkP-00019w-Bs for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:23158) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkK-0000GY-Hj for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-287-vNSbX2hwPou_IwTPN3EPRA-1; Wed, 02 Mar 2022 13:30:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B0D11091DAB; Wed, 2 Mar 2022 18:30:33 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id D07A5105917E; Wed, 2 Mar 2022 18:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245844; 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=+Y5T8Fwf9mR7p5wzLcO8Ej6uZejLheoOnrA75Npxe5A=; b=hS/IS468OHGrKlgtsvnDS743LSuXFKTwStef+yrWwlmPnQRGf4bPY+cvDdo5DsfiPyUS4u 0IQdA01TZ4ICTIoISeHDMJbsOhszD7Zy2VbRQ/7tONmPELHM6m9cUgie8Ou+qtI5Tv93XK fdDP8z0JwWnwzsdY7xpj+9tgcCGOKRk= X-MC-Unique: vNSbX2hwPou_IwTPN3EPRA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 02/18] virtiofsd: Let meson check for statx.stx_mnt_id Date: Wed, 2 Mar 2022 18:29:20 +0000 Message-Id: <20220302182936.227719-3-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247396497100003 Content-Type: text/plain; charset="utf-8" From: Hanna Reitz In virtiofsd, we assume that the presence of the STATX_MNT_ID macro implies existence of the statx.stx_mnt_id field. Unfortunately, that is not necessarily the case: glibc has introduced the macro in its commit 88a2cf6c4bab6e94a65e9c0db8813709372e9180, but the statx.stx_mnt_id field is still missing from its own headers. Let meson.build actually chek for both STATX_MNT_ID and statx.stx_mnt_id, and set CONFIG_STATX_MNT_ID if both are present. Then, use this config macro in virtiofsd. Closes: https://gitlab.com/qemu-project/qemu/-/issues/882 Signed-off-by: Hanna Reitz Message-Id: <20220223092340.9043-1-hreitz@redhat.com> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- meson.build | 13 +++++++++++++ tools/virtiofsd/passthrough_ll.c | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 8df40bfac4..a5b63e62cd 100644 --- a/meson.build +++ b/meson.build @@ -1306,6 +1306,18 @@ statx_test =3D gnu_source_prefix + ''' =20 has_statx =3D cc.links(statx_test) =20 +# Check whether statx() provides mount ID information + +statx_mnt_id_test =3D gnu_source_prefix + ''' + #include + int main(void) { + struct statx statxbuf; + statx(0, "", 0, STATX_BASIC_STATS | STATX_MNT_ID, &statxbuf); + return statxbuf.stx_mnt_id; + }''' + +has_statx_mnt_id =3D cc.links(statx_mnt_id_test) + have_vhost_user_blk_server =3D get_option('vhost_user_blk_server') \ .require(targetos =3D=3D 'linux', error_message: 'vhost_user_blk_server requires linux') \ @@ -1553,6 +1565,7 @@ config_host_data.set('CONFIG_NETTLE', nettle.found()) config_host_data.set('CONFIG_QEMU_PRIVATE_XTS', xts =3D=3D 'private') config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim) config_host_data.set('CONFIG_STATX', has_statx) +config_host_data.set('CONFIG_STATX_MNT_ID', has_statx_mnt_id) config_host_data.set('CONFIG_ZSTD', zstd.found()) config_host_data.set('CONFIG_FUSE', fuse.found()) config_host_data.set('CONFIG_FUSE_LSEEK', fuse_lseek.found()) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index dfa2fc250d..028dacdd8f 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -1039,7 +1039,7 @@ static int do_statx(struct lo_data *lo, int dirfd, co= nst char *pathname, { int res; =20 -#if defined(CONFIG_STATX) && defined(STATX_MNT_ID) +#if defined(CONFIG_STATX) && defined(CONFIG_STATX_MNT_ID) if (lo->use_statx) { struct statx statxbuf; =20 --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246933; cv=none; d=zohomail.com; s=zohoarc; b=TMQmPBP6yosANHE3IZjIhVQAGZ/9UGmhhThDR2mxArxNLzr37BLri6H2N08RwhV3ii/jwyWnfRSxzNqomR3+7jihVONHzLhKyfcw30ds0kiirib/dNes7e9dkz63O+gqkP7bQ207AhCBWmkkAN9ZuUDbiZg+TsjbIsrWQ/RvpVg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246933; 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=MNNzTCJ3sfh4FYEl4UDc8P7LoIeeXaET9qa+h0rnd9s=; b=EpvREgZS6cm1/fRjzocknmCekz6J62BKX5YvMCZ33kM5OH24HicW2CjNzm7D7LpYs3DLsgmw/uiI7NtR3F5N/j1fkLU5chc8BdCKHunqimW4kdpFbYkzlSca9yeBJjBWFU6rgYvbzKyTclUkoRngAjQcGc1Y9uy4SPoG7wEwVdo= 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 1646246933208659.0555727724857; Wed, 2 Mar 2022 10:48:53 -0800 (PST) Received: from localhost ([::1]:44096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU1s-0008Bj-1h for importer@patchew.org; Wed, 02 Mar 2022 13:48:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkI-00012J-Iz for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkG-0000Fb-Jt for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:42 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-658-aCHn19NWOvCVhY18waJ1SQ-1; Wed, 02 Mar 2022 13:30:36 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56C7083DC07; Wed, 2 Mar 2022 18:30:35 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7255105B1FD; Wed, 2 Mar 2022 18:30:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245839; 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=MNNzTCJ3sfh4FYEl4UDc8P7LoIeeXaET9qa+h0rnd9s=; b=Xfp/S+9tQyqynfiV0XJ+iZigf3B2rDErFH7hH/R45+frodovgZZ1xVE5QniiubkUq0Azpw 7IN4JmuVu/mUYXlrgkRYSK+BC6zhIkX4U34aIYc8LOYnPrCD7RI6OxJL2fOTgEy7D1Ym2B qgJpHuRrK0zEOiR95eTNBkK1Ptdliko= X-MC-Unique: aCHn19NWOvCVhY18waJ1SQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 03/18] monitor/hmp: add support for flag argument with value Date: Wed, 2 Mar 2022 18:29:21 +0000 Message-Id: <20220302182936.227719-4-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246934569100001 Content-Type: text/plain; charset="utf-8" From: Stefan Reiter Adds support for the "-xs" parameter type, where "-x" denotes a flag name and the "s" suffix indicates that this flag is supposed to take an arbitrary string parameter. These parameters are always optional, the entry in the qdict will be omitted if the flag is not given. Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Eric Blake Signed-off-by: Stefan Reiter [FE: fixed typo pointed out by Eric Blake use s instead of V to indicate string parameter] Signed-off-by: Fabian Ebner Message-Id: <20220225084949.35746-2-f.ebner@proxmox.com> Signed-off-by: Dr. David Alan Gilbert --- monitor/hmp.c | 19 ++++++++++++++++++- monitor/monitor-internal.h | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/monitor/hmp.c b/monitor/hmp.c index b20737e63c..569066036d 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -981,6 +981,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, { const char *tmp =3D p; int skip_key =3D 0; + int ret; /* option */ =20 c =3D *typestr++; @@ -1003,11 +1004,27 @@ static QDict *monitor_parse_arguments(Monitor *mon, } if (skip_key) { p =3D tmp; + } else if (*typestr =3D=3D 's') { + /* has option with string value */ + typestr++; + tmp =3D p++; + while (qemu_isspace(*p)) { + p++; + } + ret =3D get_str(buf, sizeof(buf), &p); + if (ret < 0) { + monitor_printf(mon, "%s: value expected for -%= c\n", + cmd->name, *tmp); + goto fail; + } + qdict_put_str(qdict, key, buf); } else { - /* has option */ + /* has boolean option */ p++; qdict_put_bool(qdict, key, true); } + } else if (*typestr =3D=3D 's') { + typestr++; } } break; diff --git a/monitor/monitor-internal.h b/monitor/monitor-internal.h index 3da3f86c6a..caa2e90ef2 100644 --- a/monitor/monitor-internal.h +++ b/monitor/monitor-internal.h @@ -63,7 +63,8 @@ * '.' other form of optional type (for 'i' and 'l') * 'b' boolean * user mode accepts "on" or "off" - * '-' optional parameter (eg. '-f') + * '-' optional parameter (eg. '-f'); if followed by a 's', it + * specifies an optional string param (e.g. '-fs' allows '-f = foo') * */ =20 --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247130; cv=none; d=zohomail.com; s=zohoarc; b=cvqPuFcjMCJWmcXgL3pgPBLoPG5mF9LeKsDB/wXFjvKZfpz6XpNtxg8280b6ba3ixTE5v9xSfsms4mbmIZVuXcAW1QFHc23AY3MLk2XYflTdnnjbq2koVTUSSUQpWwo74NI/bQxK79pz33mQSHM48Q18pyjZwlAGtFkMmrzOabI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247130; 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=0cEFJjINxdRihmqDNTllYNJqdgNUBUUbrBA92lP+Afg=; b=XvZGwfTbEQ8w9yRzs4FG1nn8FuG/WHpgOKVzzQ4I7rxTkAS/U+H9OOJ9ejUI0JxWsu6NkqiSPMGa4EC3Uit4uzNJNatX8AhWWFOXvRBgZbBAh2b3lcrE7mm6KzUpeIlSAjBARhXEG1rO0mc8tMUGXIhWR34iUtpvLb8zGuCUrb4= 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 1646247130453393.1212735926995; Wed, 2 Mar 2022 10:52:10 -0800 (PST) Received: from localhost ([::1]:51246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU53-0004aN-De for importer@patchew.org; Wed, 02 Mar 2022 13:52:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkK-000188-Cv for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:44 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32446) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkI-0000Fy-DZ for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:44 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-r7PfhVHiMpyhtylDc9P0yw-1; Wed, 02 Mar 2022 13:30:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4748518C43E7; Wed, 2 Mar 2022 18:30:37 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E0D31059172; Wed, 2 Mar 2022 18:30:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245841; 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=0cEFJjINxdRihmqDNTllYNJqdgNUBUUbrBA92lP+Afg=; b=LmOEu6zTNJ2pB0RK2ospakTHCjRDhKSCLfPjnBitmYXaGkisgE5ZjCkB69F2jAJh961YdB pGQeemMJF/G/IVZf0idpqH9rsBssiYN0/a7rAmf2NjljrRE/NShxj1TNqjApIAynYnqCw5 G/QDy+IwzoclEt9Dr12w4SakFsWqomI= X-MC-Unique: r7PfhVHiMpyhtylDc9P0yw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 04/18] qapi/monitor: refactor set/expire_password with enums Date: Wed, 2 Mar 2022 18:29:22 +0000 Message-Id: <20220302182936.227719-5-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247131883100001 Content-Type: text/plain; charset="utf-8" From: Stefan Reiter 'protocol' and 'connected' are better suited as enums than as strings, make use of that. No functional change intended. Suggested-by: Markus Armbruster Reviewed-by: Markus Armbruster Signed-off-by: Stefan Reiter [FE: update "Since: " from 6.2 to 7.0 put 'keep' first in enum to ease use as a default] Signed-off-by: Fabian Ebner Message-Id: <20220225084949.35746-3-f.ebner@proxmox.com> Signed-off-by: Dr. David Alan Gilbert --- monitor/hmp-cmds.c | 29 +++++++++++++++++++++++++++-- monitor/qmp-cmds.c | 37 ++++++++++++------------------------- qapi/ui.json | 36 ++++++++++++++++++++++++++++++++++-- 3 files changed, 73 insertions(+), 29 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8c384dc1b2..ff78741b75 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1398,8 +1398,24 @@ void hmp_set_password(Monitor *mon, const QDict *qdi= ct) const char *password =3D qdict_get_str(qdict, "password"); const char *connected =3D qdict_get_try_str(qdict, "connected"); Error *err =3D NULL; + DisplayProtocol proto; + SetPasswordAction conn; =20 - qmp_set_password(protocol, password, !!connected, connected, &err); + proto =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, + DISPLAY_PROTOCOL_VNC, &err); + if (err) { + goto out; + } + + conn =3D qapi_enum_parse(&SetPasswordAction_lookup, connected, + SET_PASSWORD_ACTION_KEEP, &err); + if (err) { + goto out; + } + + qmp_set_password(proto, password, !!connected, conn, &err); + +out: hmp_handle_error(mon, err); } =20 @@ -1408,8 +1424,17 @@ void hmp_expire_password(Monitor *mon, const QDict *= qdict) const char *protocol =3D qdict_get_str(qdict, "protocol"); const char *whenstr =3D qdict_get_str(qdict, "time"); Error *err =3D NULL; + DisplayProtocol proto; + + proto =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, + DISPLAY_PROTOCOL_VNC, &err); + if (err) { + goto out; + } =20 - qmp_expire_password(protocol, whenstr, &err); + qmp_expire_password(proto, whenstr, &err); + +out: hmp_handle_error(mon, err); } =20 diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index db4d186448..b6e8b57fcc 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -168,33 +168,27 @@ void qmp_system_wakeup(Error **errp) qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp); } =20 -void qmp_set_password(const char *protocol, const char *password, - bool has_connected, const char *connected, Error **e= rrp) +void qmp_set_password(DisplayProtocol protocol, const char *password, + bool has_connected, SetPasswordAction connected, + Error **errp) { int disconnect_if_connected =3D 0; int fail_if_connected =3D 0; int rc; =20 if (has_connected) { - if (strcmp(connected, "fail") =3D=3D 0) { - fail_if_connected =3D 1; - } else if (strcmp(connected, "disconnect") =3D=3D 0) { - disconnect_if_connected =3D 1; - } else if (strcmp(connected, "keep") =3D=3D 0) { - /* nothing */ - } else { - error_setg(errp, QERR_INVALID_PARAMETER, "connected"); - return; - } + fail_if_connected =3D connected =3D=3D SET_PASSWORD_ACTION_FAIL; + disconnect_if_connected =3D connected =3D=3D SET_PASSWORD_ACTION_D= ISCONNECT; } =20 - if (strcmp(protocol, "spice") =3D=3D 0) { + if (protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { if (!qemu_using_spice(errp)) { return; } rc =3D qemu_spice.set_passwd(password, fail_if_connected, disconnect_if_connected); - } else if (strcmp(protocol, "vnc") =3D=3D 0) { + } else { + assert(protocol =3D=3D DISPLAY_PROTOCOL_VNC); if (fail_if_connected || disconnect_if_connected) { /* vnc supports "connected=3Dkeep" only */ error_setg(errp, QERR_INVALID_PARAMETER, "connected"); @@ -203,10 +197,6 @@ void qmp_set_password(const char *protocol, const char= *password, /* Note that setting an empty password will not disable login thro= ugh * this interface. */ rc =3D vnc_display_password(NULL, password); - } else { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", - "'vnc' or 'spice'"); - return; } =20 if (rc !=3D 0) { @@ -214,7 +204,7 @@ void qmp_set_password(const char *protocol, const char = *password, } } =20 -void qmp_expire_password(const char *protocol, const char *whenstr, +void qmp_expire_password(DisplayProtocol protocol, const char *whenstr, Error **errp) { time_t when; @@ -230,17 +220,14 @@ void qmp_expire_password(const char *protocol, const = char *whenstr, when =3D strtoull(whenstr, NULL, 10); } =20 - if (strcmp(protocol, "spice") =3D=3D 0) { + if (protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { if (!qemu_using_spice(errp)) { return; } rc =3D qemu_spice.set_pw_expire(when); - } else if (strcmp(protocol, "vnc") =3D=3D 0) { - rc =3D vnc_display_pw_expire(NULL, when); } else { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "protocol", - "'vnc' or 'spice'"); - return; + assert(protocol =3D=3D DISPLAY_PROTOCOL_VNC); + rc =3D vnc_display_pw_expire(NULL, when); } =20 if (rc !=3D 0) { diff --git a/qapi/ui.json b/qapi/ui.json index 9354f4c467..e112409211 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -9,6 +9,34 @@ { 'include': 'common.json' } { 'include': 'sockets.json' } =20 +## +# @DisplayProtocol: +# +# Display protocols which support changing password options. +# +# Since: 7.0 +# +## +{ 'enum': 'DisplayProtocol', + 'data': [ 'vnc', 'spice' ] } + +## +# @SetPasswordAction: +# +# An action to take on changing a password on a connection with active cli= ents. +# +# @keep: maintain existing clients +# +# @fail: fail the command if clients are connected +# +# @disconnect: disconnect existing clients +# +# Since: 7.0 +# +## +{ 'enum': 'SetPasswordAction', + 'data': [ 'keep', 'fail', 'disconnect' ] } + ## # @set_password: # @@ -38,7 +66,9 @@ # ## { 'command': 'set_password', - 'data': {'protocol': 'str', 'password': 'str', '*connected': 'str'} } + 'data': { 'protocol': 'DisplayProtocol', + 'password': 'str', + '*connected': 'SetPasswordAction' } } =20 ## # @expire_password: @@ -71,7 +101,9 @@ # <- { "return": {} } # ## -{ 'command': 'expire_password', 'data': {'protocol': 'str', 'time': 'str'}= } +{ 'command': 'expire_password', + 'data': { 'protocol': 'DisplayProtocol', + 'time': 'str' } } =20 ## # @screendump: --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646245979; cv=none; d=zohomail.com; s=zohoarc; b=bYInL7XPuzKZJyrFDgVRc1VbpMu//OO6ytmZtceMAXTtMcW5bwxTdHm4oIZVfKXa9aaeKJYWHEAFZ1FS8yYuhx6Y3g/8vmOy3Yt+pfxPZBa7+qKNG11HC9dp3A+rQmWyC9vtGnkvjZB/6kJZJ2wH/XXth/cSzwy+aPDeAIpG41Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646245979; 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=V5OS6X28CJYt0aRJnlUsLOmQ3BCdps6eCIxXg9FrfNs=; b=aXnPEmROZXlBzpOBLlbeMDYAomtfAGK++Ly7g1riyP9xPZo9dhnoWy1QatLET+rs1ECvJRGkpnrLrBVS68dDTIvum4/DG6reZkqIC8XVhgGtZaMBDrJRWdF2+7qUP+2qEkkTqt5X8UQogctm/04Y3h+du4TQaZsId/78x2ei0iw= 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 1646245979494193.1777757311413; Wed, 2 Mar 2022 10:32:59 -0800 (PST) Received: from localhost ([::1]:41008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTmU-00040g-MI for importer@patchew.org; Wed, 02 Mar 2022 13:32:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkM-00019v-4I for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57503) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkJ-0000GG-Te for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:45 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-111-VznV6WlAPXCKXt4sYC-G0g-1; Wed, 02 Mar 2022 13:30:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 356351091DAE; Wed, 2 Mar 2022 18:30:39 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 93AE61059172; Wed, 2 Mar 2022 18:30:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245843; 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=V5OS6X28CJYt0aRJnlUsLOmQ3BCdps6eCIxXg9FrfNs=; b=beowldBdMfpCqWPDWwkEvtmsuV4gGyvqmyHZUwoQcN2sXcIk0TkcKvPIbnOOSuMdxHfzyZ P4pC4pQX4+60G/sh8NqF1IF25NLWcDI11jJvMJC9Mo8a3O6qOmCT7GKEd9SuYkKiqEMrRk mgXYKStQYJXncv8B2CcSDF6XxVlbo5A= X-MC-Unique: VznV6WlAPXCKXt4sYC-G0g-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 05/18] qapi/monitor: allow VNC display id in set/expire_password Date: Wed, 2 Mar 2022 18:29:23 +0000 Message-Id: <20220302182936.227719-6-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646245982896100001 From: Stefan Reiter It is possible to specify more than one VNC server on the command line, either with an explicit ID or the auto-generated ones =C3=A0 la "default", "vnc2", "vnc3", ... It is not possible to change the password on one of these extra VNC displays though. Fix this by adding a "display" parameter to the "set_password" and "expire_password" QMP and HMP commands. For HMP, the display is specified using the "-d" value flag. For QMP, the schema is updated to explicitly express the supported variants of the commands with protocol-discriminated unions. Signed-off-by: Stefan Reiter [FE: update "Since: " from 6.2 to 7.0 make @connected a common member of @SetPasswordOptions] Signed-off-by: Fabian Ebner Message-Id: <20220225084949.35746-4-f.ebner@proxmox.com> Acked-by: Markus Armbruster Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- hmp-commands.hx | 24 ++++++------ monitor/hmp-cmds.c | 40 +++++++++++++------ monitor/qmp-cmds.c | 34 +++++++--------- qapi/ui.json | 96 +++++++++++++++++++++++++++++++++++----------- 4 files changed, 129 insertions(+), 65 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 70a9136ac2..8476277aa9 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1514,33 +1514,35 @@ ERST =20 { .name =3D "set_password", - .args_type =3D "protocol:s,password:s,connected:s?", - .params =3D "protocol password action-if-connected", + .args_type =3D "protocol:s,password:s,display:-ds,connected:s?", + .params =3D "protocol password [-d display] [action-if-connect= ed]", .help =3D "set spice/vnc password", .cmd =3D hmp_set_password, }, =20 SRST -``set_password [ vnc | spice ] password [ action-if-connected ]`` - Change spice/vnc password. *action-if-connected* specifies what - should happen in case a connection is established: *fail* makes the - password change fail. *disconnect* changes the password and +``set_password [ vnc | spice ] password [ -d display ] [ action-if-connect= ed ]`` + Change spice/vnc password. *display* can be used with 'vnc' to specify + which display to set the password on. *action-if-connected* specifies + what should happen in case a connection is established: *fail* makes + the password change fail. *disconnect* changes the password and disconnects the client. *keep* changes the password and keeps the connection up. *keep* is the default. ERST =20 { .name =3D "expire_password", - .args_type =3D "protocol:s,time:s", - .params =3D "protocol time", + .args_type =3D "protocol:s,time:s,display:-ds", + .params =3D "protocol time [-d display]", .help =3D "set spice/vnc password expire-time", .cmd =3D hmp_expire_password, }, =20 SRST -``expire_password [ vnc | spice ]`` *expire-time* - Specify when a password for spice/vnc becomes - invalid. *expire-time* accepts: +``expire_password [ vnc | spice ] expire-time [ -d display ]`` + Specify when a password for spice/vnc becomes invalid. + *display* behaves the same as in ``set_password``. + *expire-time* accepts: =20 ``now`` Invalidate password instantly. diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index ff78741b75..634968498b 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1396,24 +1396,33 @@ void hmp_set_password(Monitor *mon, const QDict *qd= ict) { const char *protocol =3D qdict_get_str(qdict, "protocol"); const char *password =3D qdict_get_str(qdict, "password"); + const char *display =3D qdict_get_try_str(qdict, "display"); const char *connected =3D qdict_get_try_str(qdict, "connected"); Error *err =3D NULL; - DisplayProtocol proto; - SetPasswordAction conn; =20 - proto =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, - DISPLAY_PROTOCOL_VNC, &err); + SetPasswordOptions opts =3D { + .password =3D (char *)password, + .has_connected =3D !!connected, + }; + + opts.connected =3D qapi_enum_parse(&SetPasswordAction_lookup, connecte= d, + SET_PASSWORD_ACTION_KEEP, &err); if (err) { goto out; } =20 - conn =3D qapi_enum_parse(&SetPasswordAction_lookup, connected, - SET_PASSWORD_ACTION_KEEP, &err); + opts.protocol =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, + DISPLAY_PROTOCOL_VNC, &err); if (err) { goto out; } =20 - qmp_set_password(proto, password, !!connected, conn, &err); + if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { + opts.u.vnc.has_display =3D !!display; + opts.u.vnc.display =3D (char *)display; + } + + qmp_set_password(&opts, &err); =20 out: hmp_handle_error(mon, err); @@ -1423,16 +1432,25 @@ void hmp_expire_password(Monitor *mon, const QDict = *qdict) { const char *protocol =3D qdict_get_str(qdict, "protocol"); const char *whenstr =3D qdict_get_str(qdict, "time"); + const char *display =3D qdict_get_try_str(qdict, "display"); Error *err =3D NULL; - DisplayProtocol proto; =20 - proto =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, - DISPLAY_PROTOCOL_VNC, &err); + ExpirePasswordOptions opts =3D { + .time =3D (char *)whenstr, + }; + + opts.protocol =3D qapi_enum_parse(&DisplayProtocol_lookup, protocol, + DISPLAY_PROTOCOL_VNC, &err); if (err) { goto out; } =20 - qmp_expire_password(proto, whenstr, &err); + if (opts.protocol =3D=3D DISPLAY_PROTOCOL_VNC) { + opts.u.vnc.has_display =3D !!display; + opts.u.vnc.display =3D (char *)display; + } + + qmp_expire_password(&opts, &err); =20 out: hmp_handle_error(mon, err); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index b6e8b57fcc..df97582dd4 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -168,35 +168,27 @@ void qmp_system_wakeup(Error **errp) qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, errp); } =20 -void qmp_set_password(DisplayProtocol protocol, const char *password, - bool has_connected, SetPasswordAction connected, - Error **errp) +void qmp_set_password(SetPasswordOptions *opts, Error **errp) { - int disconnect_if_connected =3D 0; - int fail_if_connected =3D 0; int rc; =20 - if (has_connected) { - fail_if_connected =3D connected =3D=3D SET_PASSWORD_ACTION_FAIL; - disconnect_if_connected =3D connected =3D=3D SET_PASSWORD_ACTION_D= ISCONNECT; - } - - if (protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { + if (opts->protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { if (!qemu_using_spice(errp)) { return; } - rc =3D qemu_spice.set_passwd(password, fail_if_connected, - disconnect_if_connected); + rc =3D qemu_spice.set_passwd(opts->password, + opts->connected =3D=3D SET_PASSWORD_ACTION_FAIL, + opts->connected =3D=3D SET_PASSWORD_ACTION_DISCONNECT); } else { - assert(protocol =3D=3D DISPLAY_PROTOCOL_VNC); - if (fail_if_connected || disconnect_if_connected) { + assert(opts->protocol =3D=3D DISPLAY_PROTOCOL_VNC); + if (opts->connected !=3D SET_PASSWORD_ACTION_KEEP) { /* vnc supports "connected=3Dkeep" only */ error_setg(errp, QERR_INVALID_PARAMETER, "connected"); return; } /* Note that setting an empty password will not disable login thro= ugh * this interface. */ - rc =3D vnc_display_password(NULL, password); + rc =3D vnc_display_password(opts->u.vnc.display, opts->password); } =20 if (rc !=3D 0) { @@ -204,11 +196,11 @@ void qmp_set_password(DisplayProtocol protocol, const= char *password, } } =20 -void qmp_expire_password(DisplayProtocol protocol, const char *whenstr, - Error **errp) +void qmp_expire_password(ExpirePasswordOptions *opts, Error **errp) { time_t when; int rc; + const char *whenstr =3D opts->time; =20 if (strcmp(whenstr, "now") =3D=3D 0) { when =3D 0; @@ -220,14 +212,14 @@ void qmp_expire_password(DisplayProtocol protocol, co= nst char *whenstr, when =3D strtoull(whenstr, NULL, 10); } =20 - if (protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { + if (opts->protocol =3D=3D DISPLAY_PROTOCOL_SPICE) { if (!qemu_using_spice(errp)) { return; } rc =3D qemu_spice.set_pw_expire(when); } else { - assert(protocol =3D=3D DISPLAY_PROTOCOL_VNC); - rc =3D vnc_display_pw_expire(NULL, when); + assert(opts->protocol =3D=3D DISPLAY_PROTOCOL_VNC); + rc =3D vnc_display_pw_expire(opts->u.vnc.display, when); } =20 if (rc !=3D 0) { diff --git a/qapi/ui.json b/qapi/ui.json index e112409211..4a13f883a3 100644 --- a/qapi/ui.json +++ b/qapi/ui.json @@ -38,20 +38,47 @@ 'data': [ 'keep', 'fail', 'disconnect' ] } =20 ## -# @set_password: +# @SetPasswordOptions: # -# Sets the password of a remote display session. +# Options for set_password. # # @protocol: - 'vnc' to modify the VNC server password # - 'spice' to modify the Spice server password # # @password: the new password # -# @connected: how to handle existing clients when changing the -# password. If nothing is specified, defaults to 'keep' -# 'fail' to fail the command if clients are connected -# 'disconnect' to disconnect existing clients -# 'keep' to maintain existing clients +# @connected: How to handle existing clients when changing the +# password. If nothing is specified, defaults to 'keep'. +# For VNC, only 'keep' is currently implemented. +# +# Since: 7.0 +# +## +{ 'union': 'SetPasswordOptions', + 'base': { 'protocol': 'DisplayProtocol', + 'password': 'str', + '*connected': 'SetPasswordAction' }, + 'discriminator': 'protocol', + 'data': { 'vnc': 'SetPasswordOptionsVnc' } } + +## +# @SetPasswordOptionsVnc: +# +# Options for set_password specific to the VNC procotol. +# +# @display: The id of the display where the password should be changed. +# Defaults to the first. +# +# Since: 7.0 +# +## +{ 'struct': 'SetPasswordOptionsVnc', + 'data': { '*display': 'str' } } + +## +# @set_password: +# +# Set the password of a remote display server. # # Returns: - Nothing on success # - If Spice is not enabled, DeviceNotFound @@ -65,17 +92,15 @@ # <- { "return": {} } # ## -{ 'command': 'set_password', - 'data': { 'protocol': 'DisplayProtocol', - 'password': 'str', - '*connected': 'SetPasswordAction' } } +{ 'command': 'set_password', 'boxed': true, 'data': 'SetPasswordOptions' } =20 ## -# @expire_password: +# @ExpirePasswordOptions: # -# Expire the password of a remote display server. +# General options for expire_password. # -# @protocol: the name of the remote display protocol 'vnc' or 'spice' +# @protocol: - 'vnc' to modify the VNC server expiration +# - 'spice' to modify the Spice server expiration # # @time: when to expire the password. # @@ -84,16 +109,45 @@ # - '+INT' where INT is the number of seconds from now (integer) # - 'INT' where INT is the absolute time in seconds # -# Returns: - Nothing on success -# - If @protocol is 'spice' and Spice is not active, DeviceNotFou= nd -# -# Since: 0.14 -# # Notes: Time is relative to the server and currently there is no way to # coordinate server time with client time. It is not recommended to # use the absolute time version of the @time parameter unless you're # sure you are on the same machine as the QEMU instance. # +# Since: 7.0 +# +## +{ 'union': 'ExpirePasswordOptions', + 'base': { 'protocol': 'DisplayProtocol', + 'time': 'str' }, + 'discriminator': 'protocol', + 'data': { 'vnc': 'ExpirePasswordOptionsVnc' } } + +## +# @ExpirePasswordOptionsVnc: +# +# Options for expire_password specific to the VNC procotol. +# +# @display: The id of the display where the expiration should be changed. +# Defaults to the first. +# +# Since: 7.0 +# +## + +{ 'struct': 'ExpirePasswordOptionsVnc', + 'data': { '*display': 'str' } } + +## +# @expire_password: +# +# Expire the password of a remote display server. +# +# Returns: - Nothing on success +# - If @protocol is 'spice' and Spice is not active, DeviceNotFou= nd +# +# Since: 0.14 +# # Example: # # -> { "execute": "expire_password", "arguments": { "protocol": "vnc", @@ -101,9 +155,7 @@ # <- { "return": {} } # ## -{ 'command': 'expire_password', - 'data': { 'protocol': 'DisplayProtocol', - 'time': 'str' } } +{ 'command': 'expire_password', 'boxed': true, 'data': 'ExpirePasswordOpti= ons' } =20 ## # @screendump: --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246098; cv=none; d=zohomail.com; s=zohoarc; b=AHRkMWc3R3q0X/brEZ6xACf0k5g72LUJ3Ejf87gdHjmSDSYdsWKjWGmZ9UCrwn1vuF0iF4alhM2miNZAGOV8yoh0mIhcGUoh8R9jRpXPuGGkFmaZ6dEicfSHZtr9md40J7TFlsW1K3DzxcMO/hxkXXyiD+8GGJx6UqP+zOEFow4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246098; 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=Tc4udTrpSuesJc2oRGnDMPkB/bGr2BLtznUnOJNu+lc=; b=bgNQxsoLZbsyMGgyoAS4V3lH/PlGn+cxgSbtqx9x8NuRk6yvbdvoYE6wz/bMfojO75t1iEdK8WLpswIYwpikYH/TB82Ys5XZZORQYce0d9NRaKjuc1bca8iekgd0jwIZ0Y6JvBYSfjozHc2+Esa2HbC2D3H6htKlGuKKeMHRxCU= 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 1646246098197882.6110682035201; Wed, 2 Mar 2022 10:34:58 -0800 (PST) Received: from localhost ([::1]:48940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPToO-0000HL-PO for importer@patchew.org; Wed, 02 Mar 2022 13:34:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkN-0001A0-P0 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47250) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkL-0000H1-T8 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-345-cStrEprUOO2iKlzSH2J1ng-1; Wed, 02 Mar 2022 13:30:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1D15684A5F7; Wed, 2 Mar 2022 18:30:41 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F0491059166; Wed, 2 Mar 2022 18:30:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245845; 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=Tc4udTrpSuesJc2oRGnDMPkB/bGr2BLtznUnOJNu+lc=; b=eQ/LSTxGgX/WQ1zhe07cYuYWX3JkCI6IRz5QFBacRGzBiVqD4F9dEehpSDFm7s4C3UvUjg LswGv8xWD9Jhy0ZeGgQTKhlkPmb+NO3B2oI8qspXd95XAi1+XPSDSZfkD4OdMVW4lGfGid xXupCAyI8Oa+YaYQ72x0gT2te0s8/8U= X-MC-Unique: cStrEprUOO2iKlzSH2J1ng-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 06/18] migration/rdma: set the REUSEADDR option for destination Date: Wed, 2 Mar 2022 18:29:24 +0000 Message-Id: <20220302182936.227719-7-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246099415100001 Content-Type: text/plain; charset="utf-8" From: Jack Wang We hit following error during testing RDMA transport: in case of migration error, mgmt daemon pick one migration port, incoming rdma:[::]:8089: RDMA ERROR: Error: could not rdma_bind_addr Then try another -incoming rdma:[::]:8103, sometime it worked, sometimes need another try with other ports number. Set the REUSEADDR option for destination, This allow address could be reused to avoid rdma_bind_addr error out. Signed-off-by: Jack Wang Message-Id: <20220208085640.19702-1-jinpu.wang@ionos.com> Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Pankaj Gupta Signed-off-by: Dr. David Alan Gilbert dgilbert: Fixed up some tabs --- migration/rdma.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index c7c7a38487..ef1e65ec36 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2705,6 +2705,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) char ip[40] =3D "unknown"; struct rdma_addrinfo *res, *e; char port_str[16]; + int reuse =3D 1; =20 for (idx =3D 0; idx < RDMA_WRID_MAX; idx++) { rdma->wr_data[idx].control_len =3D 0; @@ -2740,6 +2741,12 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Er= ror **errp) goto err_dest_init_bind_addr; } =20 + ret =3D rdma_set_option(listen_id, RDMA_OPTION_ID, RDMA_OPTION_ID_REUS= EADDR, + &reuse, sizeof reuse); + if (ret) { + ERROR(errp, "Error: could not set REUSEADDR option"); + goto err_dest_init_bind_addr; + } for (e =3D res; e !=3D NULL; e =3D e->ai_next) { inet_ntop(e->ai_family, &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof= ip); --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247260; cv=none; d=zohomail.com; s=zohoarc; b=lNpcy4MFOaEF32kJxKiIyL/BfTXMnVLljDsIDYzf5CGCpt2Vf5jArbr4vz7N081X3U4SmIBUsTl8gbGnVz8QcYv6gK7B5muHOeyV1b5tY/bRD8n1MgagwX6cFMxcqVI/z0Mo4JdQHGEBi886WmqfzJ8/RrxwS7vCXVlfLkZoaMg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247260; 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=z07z8CGNUIIYlCG7E922xqz5XbqR2PM+pls6kG+eRsU=; b=JZbczJQ3NCCE5quOvnoJ6xzASwnW0MRtSsKN4tqEkmmV3969scZbtHOwHprWksoGQcVEbh4mXVSFvAztb/Bfv/OAknyI5KZwXkPZuUKUzKwQwRAjfTN/5r74pvxPTu34E6gh+r5Vch0h9Tn6QGDlo3J8ZfLQgB32w5BOkpB9a2g= 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 1646247260068701.6376270982765; Wed, 2 Mar 2022 10:54:20 -0800 (PST) Received: from localhost ([::1]:58294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU78-0000zx-JQ for importer@patchew.org; Wed, 02 Mar 2022 13:54:18 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36552) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkN-00019z-9O for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48755) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkL-0000Gy-SL for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:47 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636-iUgNLhxVNo-pblI0l2vGag-1; Wed, 02 Mar 2022 13:30:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 051A618D6A22; Wed, 2 Mar 2022 18:30:43 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66A651059166; Wed, 2 Mar 2022 18:30:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245845; 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=z07z8CGNUIIYlCG7E922xqz5XbqR2PM+pls6kG+eRsU=; b=LaNzHB0GGaun4EsF+gCp6dFlNPMdtNsvyZY65ipwvgfXbQx44X5eF/Sn2KJ37CSnNyQxLT 1hFL6lEI621X5OZbmIK2jeYxNHPse7M+NMoWW4kVY7oP2cca6h7FYT6Q2tXrF5pCkDUzDd juK2fkyRiWEFyYK60qBr5GwR816R6rs= X-MC-Unique: iUgNLhxVNo-pblI0l2vGag-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 07/18] migration: Dump sub-cmd name in loadvm_process_command tp Date: Wed, 2 Mar 2022 18:29:25 +0000 Message-Id: <20220302182936.227719-8-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247261441100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu It'll be easier to read the name rather than index of sub-cmd when debuggin= g. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-2-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/savevm.c | 3 ++- migration/trace-events | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 1599b02fbc..7bb65e1d61 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2273,12 +2273,13 @@ static int loadvm_process_command(QEMUFile *f) return qemu_file_get_error(f); } =20 - trace_loadvm_process_command(cmd, len); if (cmd >=3D MIG_CMD_MAX || cmd =3D=3D MIG_CMD_INVALID) { error_report("MIG_CMD 0x%x unknown (len 0x%x)", cmd, len); return -EINVAL; } =20 + trace_loadvm_process_command(mig_cmd_args[cmd].name, len); + if (mig_cmd_args[cmd].len !=3D -1 && mig_cmd_args[cmd].len !=3D len) { error_report("%s received with bad length - expecting %zu, got %d", mig_cmd_args[cmd].name, diff --git a/migration/trace-events b/migration/trace-events index 48aa7b10ee..123cfe79d7 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -22,7 +22,7 @@ loadvm_postcopy_handle_resume(void) "" loadvm_postcopy_ram_handle_discard(void) "" loadvm_postcopy_ram_handle_discard_end(void) "" loadvm_postcopy_ram_handle_discard_header(const char *ramid, uint16_t len)= "%s: %ud" -loadvm_process_command(uint16_t com, uint16_t len) "com=3D0x%x len=3D%d" +loadvm_process_command(const char *s, uint16_t len) "com=3D%s len=3D%d" loadvm_process_command_ping(uint32_t val) "0x%x" postcopy_ram_listen_thread_exit(void) "" postcopy_ram_listen_thread_start(void) "" --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246697; cv=none; d=zohomail.com; s=zohoarc; b=nzY9TDmaU2I7Yrw30XCLTkrYqcQP2ZtAzExoBR8gaTHTbE3O6WGXp7KXux9obwn2mD8ouaVu62kbz3aiPq7leYrMixonYeGWV6hzJZh9kS3AQIiKf2w93eXZd3YvYz2OTGOxYtAto5nDB93qjh0mxof9mtdBi6sINUvp4kTLIbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246697; 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=JQEpxXYDKo25qii7TXS62u3K8NDhEgNMVxi0JvIKVTw=; b=SQpgWYs90H8C0+0FSGTHM1sHxMsk/uYiHvZ2LPVIXF0ywfQ8qdB93cE2rWFuEl1iVfQNiuWWDGXRmTDCW/haYBisc0LbkF1YPNUAojsg3rCBCF2dBrEI40KlKcBuH+kh6HKDyhFECtZDFphvxIPuSZSMnOpPEaWpl36aH83TEeo= 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 1646246697215963.7231101245512; Wed, 2 Mar 2022 10:44:57 -0800 (PST) Received: from localhost ([::1]:38942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTy3-0004VG-K6 for importer@patchew.org; Wed, 02 Mar 2022 13:44:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36584) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkP-0001Aq-Fe for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57533) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkN-0000HU-Qh for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:49 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-372-Nt8cHhzOM26m8IxKqpesJQ-1; Wed, 02 Mar 2022 13:30:46 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E88E184A5F2; Wed, 2 Mar 2022 18:30:44 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4FB761059166; Wed, 2 Mar 2022 18:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245847; 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=JQEpxXYDKo25qii7TXS62u3K8NDhEgNMVxi0JvIKVTw=; b=FuIVX6CxKKi+uq31Q+27fm6m2aTh5IFMAHqZ4uavc6lqMYruv2H/+QUtyp3TMMtuFbblL1 OyCCtanCs5ngKMU/IZaFPXRaN55/Ra597t7NkBqYPtNXrhH1zHOP33vLjiOXqiCwul88fO o7HzTA6j0n2rBrAbOCWuVhRsc0OSQU0= X-MC-Unique: Nt8cHhzOM26m8IxKqpesJQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 08/18] migration: Finer grained tracepoints for POSTCOPY_LISTEN Date: Wed, 2 Mar 2022 18:29:26 +0000 Message-Id: <20220302182936.227719-9-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246699249100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu The enablement of postcopy listening has a few steps, add a few tracepoints= to be there ready for some basic measurements for them. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-3-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/savevm.c | 9 ++++++++- migration/trace-events | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 7bb65e1d61..190cc5fc42 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1948,9 +1948,10 @@ static void *postcopy_ram_listen_thread(void *opaque) static int loadvm_postcopy_handle_listen(MigrationIncomingState *mis) { PostcopyState ps =3D postcopy_state_set(POSTCOPY_INCOMING_LISTENING); - trace_loadvm_postcopy_handle_listen(); Error *local_err =3D NULL; =20 + trace_loadvm_postcopy_handle_listen("enter"); + if (ps !=3D POSTCOPY_INCOMING_ADVISE && ps !=3D POSTCOPY_INCOMING_DISC= ARD) { error_report("CMD_POSTCOPY_LISTEN in wrong postcopy state (%d)", p= s); return -1; @@ -1965,6 +1966,8 @@ static int loadvm_postcopy_handle_listen(MigrationInc= omingState *mis) } } =20 + trace_loadvm_postcopy_handle_listen("after discard"); + /* * Sensitise RAM - can now generate requests for blocks that don't exi= st * However, at this point the CPU shouldn't be running, and the IO @@ -1977,6 +1980,8 @@ static int loadvm_postcopy_handle_listen(MigrationInc= omingState *mis) } } =20 + trace_loadvm_postcopy_handle_listen("after uffd"); + if (postcopy_notify(POSTCOPY_NOTIFY_INBOUND_LISTEN, &local_err)) { error_report_err(local_err); return -1; @@ -1991,6 +1996,8 @@ static int loadvm_postcopy_handle_listen(MigrationInc= omingState *mis) qemu_sem_wait(&mis->listen_thread_sem); qemu_sem_destroy(&mis->listen_thread_sem); =20 + trace_loadvm_postcopy_handle_listen("return"); + return 0; } =20 diff --git a/migration/trace-events b/migration/trace-events index 123cfe79d7..92596c00d8 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -14,7 +14,7 @@ loadvm_handle_cmd_packaged_main(int ret) "%d" loadvm_handle_cmd_packaged_received(int ret) "%d" loadvm_handle_recv_bitmap(char *s) "%s" loadvm_postcopy_handle_advise(void) "" -loadvm_postcopy_handle_listen(void) "" +loadvm_postcopy_handle_listen(const char *str) "%s" loadvm_postcopy_handle_run(void) "" loadvm_postcopy_handle_run_cpu_sync(void) "" loadvm_postcopy_handle_run_vmstart(void) "" --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247510; cv=none; d=zohomail.com; s=zohoarc; b=AKNKxqxxfIW6MAz4I29Q8C8hS1X6bO+Ou4SCTXwoL1l19YoN1tMmTdy0sXdqmIYVlIsJ7S7kBnjTIRM1zqQwt5BmcxSgi9t3ukvw7mx+8iZus01yDxminUckQ7wSjzhuHvsy6l9FnSy95iNorRGbA/NIVtkgUj/L2jbDIDVJf6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247510; 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=QMuijoeyhdD7ZAKSpw+7FmSCKswDHGvkCzCaIxtCAhA=; b=dAL+pXu2wqiQAP/I6i8eIzbGp5DPq/zAxBpT8pv5JB8SPuP18XWvgQeAn/tA/sqJwVXWo1/x+HzVL9wCXqRYQVpdyuaDbTBPlQJlsTxdpARXCu9RnR1t63CxHz1VTJ5IGZufSpeihluyBE8J4O6PfpNxsBkAcTQ+sFEIaSGv2DI= 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 1646247510507667.2180279591967; Wed, 2 Mar 2022 10:58:30 -0800 (PST) Received: from localhost ([::1]:42740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPUBB-0001sh-V1 for importer@patchew.org; Wed, 02 Mar 2022 13:58:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkR-0001G8-J7 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkQ-0000Hj-0U for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:51 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-3f2A1pQyO1y7YfzTABoOOw-1; Wed, 02 Mar 2022 13:30:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 07A4284A5F1; Wed, 2 Mar 2022 18:30:47 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A95B105916E; Wed, 2 Mar 2022 18:30:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245849; 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=QMuijoeyhdD7ZAKSpw+7FmSCKswDHGvkCzCaIxtCAhA=; b=S2sOEvVObKQAweL7tlIo8H3KjI0fZ6eomDs2cWqg1eyqSYmWEdYJ2WbJVsJ9g6msoQkAAS kMLa6bJuym1eRqMPM6qOvDZYdGmSqopmzkf7OrPYtiKqyjgWlvX6uDgsufmel40zJ/PDNu iw6JF3oZ0bfWWk0QwPTl3ob1YvklcR4= X-MC-Unique: 3f2A1pQyO1y7YfzTABoOOw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 09/18] migration: Tracepoint change in postcopy-run bottom half Date: Wed, 2 Mar 2022 18:29:27 +0000 Message-Id: <20220302182936.227719-10-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247513197100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Remove the old two tracepoints and they're even near each other: trace_loadvm_postcopy_handle_run_cpu_sync() trace_loadvm_postcopy_handle_run_vmstart() Add trace_loadvm_postcopy_handle_run_bh() with a finer granule trace. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-4-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/savevm.c | 12 +++++++++--- migration/trace-events | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 190cc5fc42..41e3238798 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2006,13 +2006,19 @@ static void loadvm_postcopy_handle_run_bh(void *opa= que) Error *local_err =3D NULL; MigrationIncomingState *mis =3D opaque; =20 + trace_loadvm_postcopy_handle_run_bh("enter"); + /* TODO we should move all of this lot into postcopy_ram.c or a shared= code * in migration.c */ cpu_synchronize_all_post_init(); =20 + trace_loadvm_postcopy_handle_run_bh("after cpu sync"); + qemu_announce_self(&mis->announce_timer, migrate_announce_params()); =20 + trace_loadvm_postcopy_handle_run_bh("after announce"); + /* Make sure all file formats flush their mutable metadata. * If we get an error here, just don't restart the VM yet. */ bdrv_invalidate_cache_all(&local_err); @@ -2022,9 +2028,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaqu= e) autostart =3D false; } =20 - trace_loadvm_postcopy_handle_run_cpu_sync(); - - trace_loadvm_postcopy_handle_run_vmstart(); + trace_loadvm_postcopy_handle_run_bh("after invalidate cache"); =20 dirty_bitmap_mig_before_vm_start(); =20 @@ -2037,6 +2041,8 @@ static void loadvm_postcopy_handle_run_bh(void *opaqu= e) } =20 qemu_bh_delete(mis->bh); + + trace_loadvm_postcopy_handle_run_bh("return"); } =20 /* After all discards we can start running and asking for pages */ diff --git a/migration/trace-events b/migration/trace-events index 92596c00d8..1aec580e92 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -16,8 +16,7 @@ loadvm_handle_recv_bitmap(char *s) "%s" loadvm_postcopy_handle_advise(void) "" loadvm_postcopy_handle_listen(const char *str) "%s" loadvm_postcopy_handle_run(void) "" -loadvm_postcopy_handle_run_cpu_sync(void) "" -loadvm_postcopy_handle_run_vmstart(void) "" +loadvm_postcopy_handle_run_bh(const char *str) "%s" loadvm_postcopy_handle_resume(void) "" loadvm_postcopy_ram_handle_discard(void) "" loadvm_postcopy_ram_handle_discard_end(void) "" --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246137; cv=none; d=zohomail.com; s=zohoarc; b=UMW4tMfl2yVsx9t+JGBobNoDG4AJ2dEfXTkV6jjR7Wo6QhRs/FQstLHFbgOXoJ3E8dcemWKWGuypQJ0PnNciZPULUX1vcIANjyu88VeTfGrf0E9lh6fQvW5ls8SOs3HVesL6j8gtUMvqgH86FyfLvX06OczkQHLV/BPM2Lx0Mgw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246137; 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=/rRrpb1sDuxZy+FQkUbEtE26orkvvdoajPiaObxe81k=; b=hk58wDUAi64Zv+PiW6D9roEwkXwI0O2TNis+iFuRL6NQVBO9dH/JRGr1Af5LH3KNtjF2oPOYERhnMdY9KQZVidV/y0nFEgfppkx6vPOSycudwsoesKCKJm2M4Hh6/ddUwxINWRhuvT82nH6Jp0Wmv35ODVAlNBJyMTH6FM1fxhY= 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 1646246137051530.7676809236301; Wed, 2 Mar 2022 10:35:37 -0800 (PST) Received: from localhost ([::1]:50866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTp2-0001YM-0X for importer@patchew.org; Wed, 02 Mar 2022 13:35:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkX-0001KD-CQ for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39301) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkU-0000IL-Tz for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:57 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-578-VmzQ4yl3NT-hN-ioYuQYYQ-1; Wed, 02 Mar 2022 13:30:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF34F801DDB; Wed, 2 Mar 2022 18:30:48 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 254C01059166; Wed, 2 Mar 2022 18:30:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245853; 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=/rRrpb1sDuxZy+FQkUbEtE26orkvvdoajPiaObxe81k=; b=IA7/fM1I2YKEeUDlwUgzjx889fOHmHaANI+Sf/WNeXGNOWNCGkqLykr4MvrB1tFvNHlz6S kyeaUimpc+fMPgHAwRikf+h0ZrrOaCQqIbtX095J1ogPKE3A4L+ry1ZK1ScCCrsJSeU7UI /LHFE8yi3q+qI+CFBchZuyuANKGwqAc= X-MC-Unique: VmzQ4yl3NT-hN-ioYuQYYQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 10/18] migration: Introduce postcopy channels on dest node Date: Wed, 2 Mar 2022 18:29:28 +0000 Message-Id: <20220302182936.227719-11-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246137751100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Postcopy handles huge pages in a special way that currently we can only have one "channel" to transfer the page. It's because when we install pages using UFFDIO_COPY, we need to have the w= hole huge page ready, it also means we need to have a temp huge page when trying= to receive the whole content of the page. Currently all maintainance around this tmp page is global: firstly we'll allocate a temp huge page, then we maintain its status mostly within ram_load_postcopy(). To enable multiple channels for postcopy, the first thing we need to do is = to prepare N temp huge pages as caching, one for each channel. Meanwhile we need to maintain the tmp huge page status per-channel too. To give some example, some local variables maintained in ram_load_postcopy() are listed; they are responsible for maintaining temp huge page status: - all_zero: this keeps whether this huge page contains all zeros - target_pages: this counts how many target pages have been copied - host_page: this keeps the host ptr for the page to install Move all these fields to be together with the temp huge pages to form a new structure called PostcopyTmpPage. Then for each (future) postcopy channel,= we need one structure to keep the state around. For vanilla postcopy, obviously there's only one channel. It contains both precopy and postcopy pages. This patch teaches the dest migration node to start realize the possible nu= mber of postcopy channels by introducing the "postcopy_channels" variable. Its value is calculated when setup postcopy on dest node (during POSTCOPY_LISTEN phase). Vanilla postcopy will have channels=3D1, but when postcopy-preempt capabili= ty is enabled (in the future), we will boost it to 2 because even during partial sending of a precopy huge page we still want to preempt it and start sending the postcopy requested page right away (so we start to keep two temp huge pages; more if we want to enable multifd). In this patch there's a TODO ma= rked for that; so far the channels is always set to 1. We need to send one "host huge page" on one channel only and we cannot split them, because otherwise the data upon the same huge page can locate on more than one channel so we need more complicated logic to manage. One temp host huge page for each channel will be enough for us for now. Postcopy will still always use the index=3D0 huge page even after this patc= h. However it prepares for the latter patches where it can start to use multip= le channels (which needs src intervention, because only src knows which channe= l we should use). Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-5-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert dgilbert: Fixed up long line --- migration/migration.h | 36 +++++++++++++++++++++++- migration/postcopy-ram.c | 60 ++++++++++++++++++++++++++++++---------- migration/ram.c | 45 ++++++++++++++---------------- migration/savevm.c | 12 ++++++++ 4 files changed, 114 insertions(+), 39 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 8130b703eb..42c7395094 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -45,6 +45,24 @@ struct PostcopyBlocktimeContext; */ #define CLEAR_BITMAP_SHIFT_MAX 31 =20 +/* This is an abstraction of a "temp huge page" for postcopy's purpose */ +typedef struct { + /* + * This points to a temporary huge page as a buffer for UFFDIO_COPY. = It's + * mmap()ed and needs to be freed when cleanup. + */ + void *tmp_huge_page; + /* + * This points to the host page we're going to install for this temp p= age. + * It tells us after we've received the whole page, where we should pu= t it. + */ + void *host_addr; + /* Number of small pages copied (in size of TARGET_PAGE_SIZE) */ + unsigned int target_pages; + /* Whether this page contains all zeros */ + bool all_zero; +} PostcopyTmpPage; + /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; @@ -81,7 +99,22 @@ struct MigrationIncomingState { QemuMutex rp_mutex; /* We send replies from multiple threads */ /* RAMBlock of last request sent to source */ RAMBlock *last_rb; - void *postcopy_tmp_page; + /* + * Number of postcopy channels including the default precopy channel, = so + * vanilla postcopy will only contain one channel which contain both + * precopy and postcopy streams. + * + * This is calculated when the src requests to enable postcopy but bef= ore + * it starts. Its value can depend on e.g. whether postcopy preemptio= n is + * enabled. + */ + unsigned int postcopy_channels; + /* + * An array of temp host huge pages to be used, one for each postcopy + * channel. + */ + PostcopyTmpPage *postcopy_tmp_pages; + /* This is shared for all postcopy channels */ void *postcopy_tmp_zero_page; /* PostCopyFD's for external userfaultfds & handlers of shared memory = */ GArray *postcopy_remote_fds; @@ -391,5 +424,6 @@ bool migration_rate_limit(void); void migration_cancel(const Error *error); =20 void populate_vfio_info(MigrationInfo *info); +void postcopy_temp_page_reset(PostcopyTmpPage *tmp_page); =20 #endif diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 2a2cc5faf8..30c3508f44 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -526,9 +526,18 @@ int postcopy_ram_incoming_init(MigrationIncomingState = *mis) =20 static void postcopy_temp_pages_cleanup(MigrationIncomingState *mis) { - if (mis->postcopy_tmp_page) { - munmap(mis->postcopy_tmp_page, mis->largest_page_size); - mis->postcopy_tmp_page =3D NULL; + int i; + + if (mis->postcopy_tmp_pages) { + for (i =3D 0; i < mis->postcopy_channels; i++) { + if (mis->postcopy_tmp_pages[i].tmp_huge_page) { + munmap(mis->postcopy_tmp_pages[i].tmp_huge_page, + mis->largest_page_size); + mis->postcopy_tmp_pages[i].tmp_huge_page =3D NULL; + } + } + g_free(mis->postcopy_tmp_pages); + mis->postcopy_tmp_pages =3D NULL; } =20 if (mis->postcopy_tmp_zero_page) { @@ -1092,17 +1101,30 @@ retry: =20 static int postcopy_temp_pages_setup(MigrationIncomingState *mis) { - int err; - - mis->postcopy_tmp_page =3D mmap(NULL, mis->largest_page_size, - PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - if (mis->postcopy_tmp_page =3D=3D MAP_FAILED) { - err =3D errno; - mis->postcopy_tmp_page =3D NULL; - error_report("%s: Failed to map postcopy_tmp_page %s", - __func__, strerror(err)); - return -err; + PostcopyTmpPage *tmp_page; + int err, i, channels; + void *temp_page; + + /* TODO: will be boosted when enable postcopy preemption */ + mis->postcopy_channels =3D 1; + + channels =3D mis->postcopy_channels; + mis->postcopy_tmp_pages =3D g_malloc0_n(sizeof(PostcopyTmpPage), chann= els); + + for (i =3D 0; i < channels; i++) { + tmp_page =3D &mis->postcopy_tmp_pages[i]; + temp_page =3D mmap(NULL, mis->largest_page_size, PROT_READ | PROT_= WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (temp_page =3D=3D MAP_FAILED) { + err =3D errno; + error_report("%s: Failed to map postcopy_tmp_pages[%d]: %s", + __func__, i, strerror(err)); + /* Clean up will be done later */ + return -err; + } + tmp_page->tmp_huge_page =3D temp_page; + /* Initialize default states for each tmp page */ + postcopy_temp_page_reset(tmp_page); } =20 /* @@ -1352,6 +1374,16 @@ int postcopy_wake_shared(struct PostCopyFD *pcfd, #endif =20 /* -----------------------------------------------------------------------= -- */ +void postcopy_temp_page_reset(PostcopyTmpPage *tmp_page) +{ + tmp_page->target_pages =3D 0; + tmp_page->host_addr =3D NULL; + /* + * This is set to true when reset, and cleared as long as we received = any + * of the non-zero small page within this huge page. + */ + tmp_page->all_zero =3D true; +} =20 void postcopy_fault_thread_notify(MigrationIncomingState *mis) { diff --git a/migration/ram.c b/migration/ram.c index 781f0745dc..fe3de84856 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3641,11 +3641,8 @@ static int ram_load_postcopy(QEMUFile *f) bool place_needed =3D false; bool matches_target_page_size =3D false; MigrationIncomingState *mis =3D migration_incoming_get_current(); - /* Temporary page that is later 'placed' */ - void *postcopy_host_page =3D mis->postcopy_tmp_page; - void *host_page =3D NULL; - bool all_zero =3D true; - int target_pages =3D 0; + /* Currently we only use channel 0. TODO: use all the channels */ + PostcopyTmpPage *tmp_page =3D &mis->postcopy_tmp_pages[0]; =20 while (!ret && !(flags & RAM_SAVE_FLAG_EOS)) { ram_addr_t addr; @@ -3689,7 +3686,7 @@ static int ram_load_postcopy(QEMUFile *f) ret =3D -EINVAL; break; } - target_pages++; + tmp_page->target_pages++; matches_target_page_size =3D block->page_size =3D=3D TARGET_PA= GE_SIZE; /* * Postcopy requires that we place whole host pages atomically; @@ -3701,15 +3698,16 @@ static int ram_load_postcopy(QEMUFile *f) * however the source ensures it always sends all the componen= ts * of a host page in one chunk. */ - page_buffer =3D postcopy_host_page + + page_buffer =3D tmp_page->tmp_huge_page + host_page_offset_from_ram_block_offset(block, ad= dr); /* If all TP are zero then we can optimise the place */ - if (target_pages =3D=3D 1) { - host_page =3D host_page_from_ram_block_offset(block, addr); - } else if (host_page !=3D host_page_from_ram_block_offset(bloc= k, - addr))= { + if (tmp_page->target_pages =3D=3D 1) { + tmp_page->host_addr =3D + host_page_from_ram_block_offset(block, addr); + } else if (tmp_page->host_addr !=3D + host_page_from_ram_block_offset(block, addr)) { /* not the 1st TP within the HP */ - error_report("Non-same host page %p/%p", host_page, + error_report("Non-same host page %p/%p", tmp_page->host_ad= dr, host_page_from_ram_block_offset(block, addr)); ret =3D -EINVAL; break; @@ -3719,10 +3717,11 @@ static int ram_load_postcopy(QEMUFile *f) * If it's the last part of a host page then we place the host * page */ - if (target_pages =3D=3D (block->page_size / TARGET_PAGE_SIZE))= { + if (tmp_page->target_pages =3D=3D + (block->page_size / TARGET_PAGE_SIZE)) { place_needed =3D true; } - place_source =3D postcopy_host_page; + place_source =3D tmp_page->tmp_huge_page; } =20 switch (flags & ~RAM_SAVE_FLAG_CONTINUE) { @@ -3736,12 +3735,12 @@ static int ram_load_postcopy(QEMUFile *f) memset(page_buffer, ch, TARGET_PAGE_SIZE); } if (ch) { - all_zero =3D false; + tmp_page->all_zero =3D false; } break; =20 case RAM_SAVE_FLAG_PAGE: - all_zero =3D false; + tmp_page->all_zero =3D false; if (!matches_target_page_size) { /* For huge pages, we always use temporary buffer */ qemu_get_buffer(f, page_buffer, TARGET_PAGE_SIZE); @@ -3759,7 +3758,7 @@ static int ram_load_postcopy(QEMUFile *f) } break; case RAM_SAVE_FLAG_COMPRESS_PAGE: - all_zero =3D false; + tmp_page->all_zero =3D false; len =3D qemu_get_be32(f); if (len < 0 || len > compressBound(TARGET_PAGE_SIZE)) { error_report("Invalid compressed data length: %d", len); @@ -3791,16 +3790,14 @@ static int ram_load_postcopy(QEMUFile *f) } =20 if (!ret && place_needed) { - if (all_zero) { - ret =3D postcopy_place_page_zero(mis, host_page, block); + if (tmp_page->all_zero) { + ret =3D postcopy_place_page_zero(mis, tmp_page->host_addr,= block); } else { - ret =3D postcopy_place_page(mis, host_page, place_source, - block); + ret =3D postcopy_place_page(mis, tmp_page->host_addr, + place_source, block); } place_needed =3D false; - target_pages =3D 0; - /* Assume we have a zero page until we detect something differ= ent */ - all_zero =3D true; + postcopy_temp_page_reset(tmp_page); } } =20 diff --git a/migration/savevm.c b/migration/savevm.c index 41e3238798..0ccd7e5e3f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2579,6 +2579,18 @@ void qemu_loadvm_state_cleanup(void) /* Return true if we should continue the migration, or false. */ static bool postcopy_pause_incoming(MigrationIncomingState *mis) { + int i; + + /* + * If network is interrupted, any temp page we received will be useless + * because we didn't mark them as "received" in receivedmap. After a + * proper recovery later (which will sync src dirty bitmap with receiv= edmap + * on dest) these cached small pages will be resent again. + */ + for (i =3D 0; i < mis->postcopy_channels; i++) { + postcopy_temp_page_reset(&mis->postcopy_tmp_pages[i]); + } + trace_postcopy_pause_incoming(); =20 assert(migrate_postcopy_ram()); --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246230; cv=none; d=zohomail.com; s=zohoarc; b=JsVYIf/uqdNNBPkIU21rCcs+Wwc1rG+BiMzzMUiQrGyvvEfbllARAr29RW1jV2iQhpLunPhOX94B6DEW68zgPUR3AAUPHJmlIuVpSRBDQHB5tBPTMj2lzhzjM+/CAeNLqMxajwokrVcsOXN1Jr0aaRdcbrWys+LFgXSWqj2ynR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246230; 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=l/tUAUHrfKEnNVvUml1ZoiqMP8LRb/CPtkxhJDhvYh0=; b=luhmCOhqNszXHHYFudReOU5J7/UVhO5QsPEa/h0XpWuVIJ0ggKs7sAQrOWmJinynRwX1fvoTaSaTufSbyp4DfpF2R5Ft8s6vvSIz5vbLXU4K6UAFKWhB/GozWNZQkyekcECwpGKy1vg0iKBZEn/0Ehkl48hu0Xrc2k4Gqddb9eQ= 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 1646246230451563.5244029610355; Wed, 2 Mar 2022 10:37:10 -0800 (PST) Received: from localhost ([::1]:57486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTqX-000642-CQ for importer@patchew.org; Wed, 02 Mar 2022 13:37:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36668) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkW-0001KC-Oo for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:00 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35905) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkT-0000IJ-LN for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:30:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-299-KJINpXWcNJ2cpTEmX-0O9A-1; Wed, 02 Mar 2022 13:30:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB3D3801DDB; Wed, 2 Mar 2022 18:30:50 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 34C691059170; Wed, 2 Mar 2022 18:30:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245853; 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=l/tUAUHrfKEnNVvUml1ZoiqMP8LRb/CPtkxhJDhvYh0=; b=YZOkSOYbEg7N6cdXdZUaLxqBgSYPmsBIu2jC5fcsVq70g6e+WQLy2UWvQGJJfEU++whSzp yxEeV/pyooZ0Znsi1PPkXedoY3rKe0Y3jnWC5DxvScBi5n8Vv++ZjNUtyEM5M1TU62wY78 jDuOOYuVTSY4K16KlEJPrkjs3cv7E4Y= X-MC-Unique: KJINpXWcNJ2cpTEmX-0O9A-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 11/18] migration: Dump ramblock and offset too when non-same-page detected Date: Wed, 2 Mar 2022 18:29:29 +0000 Message-Id: <20220302182936.227719-12-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246231571100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu In ram_load_postcopy() we'll try to detect non-same-page case and dump erro= r. This error is very helpful for debugging. Adding ramblock & offset into the error log too. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-6-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert dgilbert: Fix up long line --- migration/ram.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index fe3de84856..a9d0d100bd 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3707,8 +3707,12 @@ static int ram_load_postcopy(QEMUFile *f) } else if (tmp_page->host_addr !=3D host_page_from_ram_block_offset(block, addr)) { /* not the 1st TP within the HP */ - error_report("Non-same host page %p/%p", tmp_page->host_ad= dr, - host_page_from_ram_block_offset(block, addr)); + error_report("Non-same host page detected. " + "Target host page %p, received host page %p " + "(rb %s offset 0x"RAM_ADDR_FMT" target_pages = %d)", + tmp_page->host_addr, + host_page_from_ram_block_offset(block, addr), + block->idstr, addr, tmp_page->target_pages); ret =3D -EINVAL; break; } --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247057; cv=none; d=zohomail.com; s=zohoarc; b=LTgk7AgZCJskxn3a2agppXnDlJeReiI6fUKa5m6aMxNfYsZRFmzmjSl0yta3P1RMrjfPfQOHOOXqoiUdBPGEo+X+3jdNFEdgWViyI9qka8M4waxPzsQJ29Fu6MoeYZRMHjYsXJOuY4ssN0f88nWXY9DdrMTuWGkiyDHVJqF7B68= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247057; 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=0PbF8YIadBK+ZkjWWRQZ0TnFmDA+2sgn4LnHgGUaaEg=; b=iI/NF5LdLFTOASnhnvinWqr7hn/OTo8dcuD0EztAsgRHHIaA+zTouiRsCyazx1ALFWFHxpJAYFBYpSHV0o1a/aeJs2KkKrqqDowtPnKvJRTRVtNGqzm1PwuIX9Q91mRKaWfYS/Tp/L2qerIrWBxZYZsBB4BQrTJ6XwGH8MO4KCs= 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 1646247057587138.77853556505272; Wed, 2 Mar 2022 10:50:57 -0800 (PST) Received: from localhost ([::1]:46998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU3s-0001k3-3t for importer@patchew.org; Wed, 02 Mar 2022 13:50:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkd-0001UR-Ku for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkb-0000KA-GN for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-577-lO5QZGZEO6yRlioD319XxQ-1; Wed, 02 Mar 2022 13:30:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6BBC19251C0; Wed, 2 Mar 2022 18:30:52 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2157A1059170; Wed, 2 Mar 2022 18:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245860; 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=0PbF8YIadBK+ZkjWWRQZ0TnFmDA+2sgn4LnHgGUaaEg=; b=MyRp3XQq7XmKAXW2ebFI//aG36CIdX14wxPr67WAey+u3+CUhsLYOb6JpwETbuRd+l8a3j J9X3XhtikWsrn6FLX2Uv8rkMZeCm4eITuPL8mbQZusBwzKQpU7nrMKMQyBnxp+KsrwnDEL wSsFO2FrAlG+cJ6WJoOBi55eaI6PEQs= X-MC-Unique: lO5QZGZEO6yRlioD319XxQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 12/18] migration: Add postcopy_thread_create() Date: Wed, 2 Mar 2022 18:29:30 +0000 Message-Id: <20220302182936.227719-13-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247059635100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Postcopy create threads. A common manner is we init a sem and use it to sync with the thread. Namely, we have fault_thread_sem and listen_thread_sem and they're only used for this. Make it a shared infrastructure so it's easier to create yet another thread. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-7-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.h | 8 +++++--- migration/postcopy-ram.c | 23 +++++++++++++++++------ migration/postcopy-ram.h | 4 ++++ migration/savevm.c | 12 +++--------- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 42c7395094..8445e1d14a 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -70,7 +70,11 @@ struct MigrationIncomingState { /* A hook to allow cleanup at the end of incoming migration */ void *transport_data; void (*transport_cleanup)(void *data); - + /* + * Used to sync thread creations. Note that we can't create threads in + * parallel with this sem. + */ + QemuSemaphore thread_sync_sem; /* * Free at the start of the main state load, set as the main thread fi= nishes * loading state. @@ -83,13 +87,11 @@ struct MigrationIncomingState { size_t largest_page_size; bool have_fault_thread; QemuThread fault_thread; - QemuSemaphore fault_thread_sem; /* Set this when we want the fault thread to quit */ bool fault_thread_quit; =20 bool have_listen_thread; QemuThread listen_thread; - QemuSemaphore listen_thread_sem; =20 /* For the kernel to send us notifications */ int userfault_fd; diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 30c3508f44..d08d396c63 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -78,6 +78,20 @@ int postcopy_notify(enum PostcopyNotifyReason reason, Er= ror **errp) &pnd); } =20 +/* + * NOTE: this routine is not thread safe, we can't call it concurrently. B= ut it + * should be good enough for migration's purposes. + */ +void postcopy_thread_create(MigrationIncomingState *mis, + QemuThread *thread, const char *name, + void *(*fn)(void *), int joinable) +{ + qemu_sem_init(&mis->thread_sync_sem, 0); + qemu_thread_create(thread, name, fn, mis, joinable); + qemu_sem_wait(&mis->thread_sync_sem); + qemu_sem_destroy(&mis->thread_sync_sem); +} + /* Postcopy needs to detect accesses to pages that haven't yet been copied * across, and efficiently map new pages in, the techniques for doing this * are target OS specific. @@ -902,7 +916,7 @@ static void *postcopy_ram_fault_thread(void *opaque) trace_postcopy_ram_fault_thread_entry(); rcu_register_thread(); mis->last_rb =3D NULL; /* last RAMBlock we sent part of */ - qemu_sem_post(&mis->fault_thread_sem); + qemu_sem_post(&mis->thread_sync_sem); =20 struct pollfd *pfd; size_t pfd_len =3D 2 + mis->postcopy_remote_fds->len; @@ -1173,11 +1187,8 @@ int postcopy_ram_incoming_setup(MigrationIncomingSta= te *mis) return -1; } =20 - qemu_sem_init(&mis->fault_thread_sem, 0); - qemu_thread_create(&mis->fault_thread, "postcopy/fault", - postcopy_ram_fault_thread, mis, QEMU_THREAD_JOINABL= E); - qemu_sem_wait(&mis->fault_thread_sem); - qemu_sem_destroy(&mis->fault_thread_sem); + postcopy_thread_create(mis, &mis->fault_thread, "postcopy/fault", + postcopy_ram_fault_thread, QEMU_THREAD_JOINABLE= ); mis->have_fault_thread =3D true; =20 /* Mark so that we get notified of accesses to unwritten areas */ diff --git a/migration/postcopy-ram.h b/migration/postcopy-ram.h index 6d2b3cf124..07684c0e1d 100644 --- a/migration/postcopy-ram.h +++ b/migration/postcopy-ram.h @@ -135,6 +135,10 @@ void postcopy_remove_notifier(NotifierWithReturn *n); /* Call the notifier list set by postcopy_add_start_notifier */ int postcopy_notify(enum PostcopyNotifyReason reason, Error **errp); =20 +void postcopy_thread_create(MigrationIncomingState *mis, + QemuThread *thread, const char *name, + void *(*fn)(void *), int joinable); + struct PostCopyFD; =20 /* ufd is a pointer to the struct uffd_msg *TODO: more Portable! */ diff --git a/migration/savevm.c b/migration/savevm.c index 0ccd7e5e3f..967ff80547 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1863,7 +1863,7 @@ static void *postcopy_ram_listen_thread(void *opaque) =20 migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_POSTCOPY_ACTIVE); - qemu_sem_post(&mis->listen_thread_sem); + qemu_sem_post(&mis->thread_sync_sem); trace_postcopy_ram_listen_thread_start(); =20 rcu_register_thread(); @@ -1988,14 +1988,8 @@ static int loadvm_postcopy_handle_listen(MigrationIn= comingState *mis) } =20 mis->have_listen_thread =3D true; - /* Start up the listening thread and wait for it to signal ready */ - qemu_sem_init(&mis->listen_thread_sem, 0); - qemu_thread_create(&mis->listen_thread, "postcopy/listen", - postcopy_ram_listen_thread, NULL, - QEMU_THREAD_DETACHED); - qemu_sem_wait(&mis->listen_thread_sem); - qemu_sem_destroy(&mis->listen_thread_sem); - + postcopy_thread_create(mis, &mis->listen_thread, "postcopy/listen", + postcopy_ram_listen_thread, QEMU_THREAD_DETACHE= D); trace_loadvm_postcopy_handle_listen("return"); =20 return 0; --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246675; cv=none; d=zohomail.com; s=zohoarc; b=C2aZhW+tt9Pl9NoTc411CRQa2Jaj1qa6fA2IAsyI4s0JW0rzUioMDr0RLRJgUvC4ltSMxcoQVF1AL36FBIX2IZUWMX1KyLnIJBVcJB6LuGpsOHry6f8jjwECl2DrpNprYt/a9JP03T/kd1eSji0dZ823bpf76GsUqHBeLSYWE+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246675; 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=aXjz+2MNLnroPE3ihHyOxtiNfZ6IF9g6NN6aDSYvBR8=; b=KmR0sZxH/1fFxL8gHEHjlLUBKZyDR/Xj/aI+UtOQnVUB6C+syhNEUR9o06GlKvGI8bKahASm0iAsJoR6y4l3elr4zROdlDjMym4rDTq2gFATvPo/pLPhbIAzFfMNHqGPYyTypdP1ccWvgVImSxyxw2MXjoJy05PxKamPFiOzEOY= 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 1646246675334219.1989665440475; Wed, 2 Mar 2022 10:44:35 -0800 (PST) Received: from localhost ([::1]:38028 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTxi-0003q2-MW for importer@patchew.org; Wed, 02 Mar 2022 13:44:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36718) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkb-0001Pm-Uf for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:02 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTka-0000Jc-6v for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:01 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-90-rlFvXiEFOLKhDb4lWD_6dg-1; Wed, 02 Mar 2022 13:30:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A10C01019982; Wed, 2 Mar 2022 18:30:54 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D5531059170; Wed, 2 Mar 2022 18:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245859; 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=aXjz+2MNLnroPE3ihHyOxtiNfZ6IF9g6NN6aDSYvBR8=; b=BbmIe/80m8mgjpvt6/LicZChwTnrrGGkcrt2ZPArApUvm9FM2Xjx5u98bKjKm48eemKl1x z3KlmpojvvCRR+KJSDcW8tKFI66VFicM//cyXxLFW47EZ/PGsYDSfosK7N54QoQgvgnwN+ khcj7KDC4C2iTBwyvuYO2ZuLGXy/G58= X-MC-Unique: rlFvXiEFOLKhDb4lWD_6dg-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 13/18] migration: Move static var in ram_block_from_stream() into global Date: Wed, 2 Mar 2022 18:29:31 +0000 Message-Id: <20220302182936.227719-14-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246699250100002 Content-Type: text/plain; charset="utf-8" From: Peter Xu Static variable is very unfriendly to threading of ram_block_from_stream(). Move it into MigrationIncomingState. Make the incoming state pointer to be passed over to ram_block_from_stream(= ) on both caller sites. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-8-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.h | 3 ++- migration/ram.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 8445e1d14a..d8b9850eae 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -66,7 +66,8 @@ typedef struct { /* State for the incoming migration */ struct MigrationIncomingState { QEMUFile *from_src_file; - + /* Previously received RAM's RAMBlock pointer */ + RAMBlock *last_recv_block; /* A hook to allow cleanup at the end of incoming migration */ void *transport_data; void (*transport_cleanup)(void *data); diff --git a/migration/ram.c b/migration/ram.c index a9d0d100bd..170e522a1f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3185,12 +3185,14 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr= , void *host) * * Returns a pointer from within the RCU-protected ram_list. * + * @mis: the migration incoming state pointer * @f: QEMUFile where to read the data from * @flags: Page flags (mostly to see if it's a continuation of previous bl= ock) */ -static inline RAMBlock *ram_block_from_stream(QEMUFile *f, int flags) +static inline RAMBlock *ram_block_from_stream(MigrationIncomingState *mis, + QEMUFile *f, int flags) { - static RAMBlock *block; + RAMBlock *block =3D mis->last_recv_block; char id[256]; uint8_t len; =20 @@ -3217,6 +3219,8 @@ static inline RAMBlock *ram_block_from_stream(QEMUFil= e *f, int flags) return NULL; } =20 + mis->last_recv_block =3D block; + return block; } =20 @@ -3669,7 +3673,7 @@ static int ram_load_postcopy(QEMUFile *f) trace_ram_load_postcopy_loop((uint64_t)addr, flags); if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | RAM_SAVE_FLAG_COMPRESS_PAGE)) { - block =3D ram_block_from_stream(f, flags); + block =3D ram_block_from_stream(mis, f, flags); if (!block) { ret =3D -EINVAL; break; @@ -3881,6 +3885,7 @@ void colo_flush_ram_cache(void) */ static int ram_load_precopy(QEMUFile *f) { + MigrationIncomingState *mis =3D migration_incoming_get_current(); int flags =3D 0, ret =3D 0, invalid_flags =3D 0, len =3D 0, i =3D 0; /* ADVISE is earlier, it shows the source has the postcopy capability = on */ bool postcopy_advised =3D postcopy_is_advised(); @@ -3919,7 +3924,7 @@ static int ram_load_precopy(QEMUFile *f) =20 if (flags & (RAM_SAVE_FLAG_ZERO | RAM_SAVE_FLAG_PAGE | RAM_SAVE_FLAG_COMPRESS_PAGE | RAM_SAVE_FLAG_XBZRLE)) { - RAMBlock *block =3D ram_block_from_stream(f, flags); + RAMBlock *block =3D ram_block_from_stream(mis, f, flags); =20 host =3D host_from_ram_block_offset(block, addr); /* --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246252; cv=none; d=zohomail.com; s=zohoarc; b=h82NswviIEBoBUw+0J35OYJVNvkxy1O1QAqL4z3aIXOCwAcs1pCGSR68vj6/aYT1DVvADxg42h8OUeByV6jiH5e1FBZidunD3yIHYp/FIZmRZaD4z9JlacXL4FOQ4B2IPWIItGH3aQbHxWnSUvFBCRWeN7emjL5eQT13cMCFkdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246252; 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=a8gHke2pCSAMiwh/6LHB8vvYNMwQN7z8KlGxyLEWOVA=; b=dh1YEt9Qj0n+YX14jq37a5r6/3LlSZ+moK478hJDYkoSJAJtwabuaf+FAqVP/mD4cWLj39ZlcNyjNqWhKgk3gvPpulyQ52yRqkLfdVoOipNGGdyEqohK0ZW2UALFjUM3ADJCcHiY+hCHreSCi4oaq9CmmhytLcaXylK3DrapOXw= 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 1646246252322640.1107980592094; Wed, 2 Mar 2022 10:37:32 -0800 (PST) Received: from localhost ([::1]:59440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTqt-0007LF-13 for importer@patchew.org; Wed, 02 Mar 2022 13:37:31 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkd-0001Th-D0 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39105) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkb-0000KD-LD for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:03 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-609-5RVStdfBNoqyOClMsgLmQQ-1; Wed, 02 Mar 2022 13:30:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2DF384A5F3; Wed, 2 Mar 2022 18:30:56 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC6A0105916D; Wed, 2 Mar 2022 18:30:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245861; 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=a8gHke2pCSAMiwh/6LHB8vvYNMwQN7z8KlGxyLEWOVA=; b=PGZ0TAh9Sktfni6jzz/afo1yiaN9MYJto0/w7cnq8fS37iVXNE/mQPx0dqmG0DpRoa2D9x rzL7HWqmL2OOoYYm1VeEHpwVUBMeZw8f97kfV/O3KVv4wqPF5caGDb+TECDrGVWuJTMF+1 7c1up7pYeHRzaua4GT2xOKQcQVCMNFc= X-MC-Unique: 5RVStdfBNoqyOClMsgLmQQ-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 14/18] migration: Enlarge postcopy recovery to capture !-EIO too Date: Wed, 2 Mar 2022 18:29:32 +0000 Message-Id: <20220302182936.227719-15-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246253585100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu We used to have quite a few places making sure -EIO happened and that's the only way to trigger postcopy recovery. That's based on the assumption that we'll only return -EIO for channel issues. It'll work in 99.99% cases but logically that won't cover some corner cases. One example is e.g. ram_block_from_stream() could fail with an interrupted network, then -EINVAL will be returned instead of -EIO. I remembered Dave Gilbert pointed that out before, but somehow this is overlooked. Neither did I encounter anything outside the -EIO error. However we'd better touch that up before it triggers a rare VM data loss du= ring live migrating. To cover as much those cases as possible, remove the -EIO restriction on triggering the postcopy recovery, because even if it's not a channel failur= e, we can't do anything better than halting QEMU anyway - the corpse of the process may even be used by a good hand to dig out useful memory regions, or the admin could simply kill the process later on. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-11-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 4 ++-- migration/postcopy-ram.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index bcc385b94b..306e2ac60e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2865,7 +2865,7 @@ retry: out: res =3D qemu_file_get_error(rp); if (res) { - if (res =3D=3D -EIO && migration_in_postcopy()) { + if (res && migration_in_postcopy()) { /* * Maybe there is something we can do: it looks like a * network down issue, and we pause for a recovery. @@ -3466,7 +3466,7 @@ static MigThrError migration_detect_error(MigrationSt= ate *s) error_free(local_error); } =20 - if (state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE && ret =3D=3D -EIO) { + if (state =3D=3D MIGRATION_STATUS_POSTCOPY_ACTIVE && ret) { /* * For postcopy, we allow the network to be down for a * while. After that, it can be continued by a diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index d08d396c63..b0d12d5053 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -1039,7 +1039,7 @@ retry: msg.arg.pagefault.address); if (ret) { /* May be network failure, try to wait for recovery */ - if (ret =3D=3D -EIO && postcopy_pause_fault_thread(mis)) { + if (postcopy_pause_fault_thread(mis)) { /* We got reconnected somehow, try to continue */ goto retry; } else { --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247081; cv=none; d=zohomail.com; s=zohoarc; b=KjRm0iKhfzAE9Nr2J3Wt6+cpXBmTRh7NJJD277mmOa59UH8mT3R5MWKPfhHXklNinUrOzrgv6hb86O2VFL58MowStip43/nEfHlHXvRyg6dgd6pWQJwuSLmRVFLCViWc1Gn60XcIfzi6B42HB3nQtpwoesxs9DEBVvxgsZBmVH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247081; 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=5B4Qg3Si6icwzLYk2MSPnDdZkFQ4h4oO6akMfjLnkGc=; b=fWZVqwpjR2q8qh6GXTyd9ezaFGhqvAKScV99BRTu8I2SVMqqWBCoEySvFBsw9YPjeuX2KTgtICzWSDs0LEP5VMBxYknP3Q8jF0LLSwIouLmGOoyRYqz5gyAspJfjEyHIdrkI69y8TELs2lIqIERlaaG2uaQ+2uhDaElCF+Ux2j4= 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 1646247081589811.1098904043866; Wed, 2 Mar 2022 10:51:21 -0800 (PST) Received: from localhost ([::1]:48306 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU4G-0002dn-CJ for importer@patchew.org; Wed, 02 Mar 2022 13:51:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkf-0001ZO-0G for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:05 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:29520) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkd-0000Ku-Cu for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:04 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-140-Hh3CdOwGO9uPGRV5dKXvFA-1; Wed, 02 Mar 2022 13:30:59 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 934731091DA0; Wed, 2 Mar 2022 18:30:58 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id F03241059166; Wed, 2 Mar 2022 18:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245862; 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=5B4Qg3Si6icwzLYk2MSPnDdZkFQ4h4oO6akMfjLnkGc=; b=NUCHp3mjjkWVQ9AQBtf8+fiP7RINHRD5Ul4s6PxYsc8ftt9Cq/NFYyzR7UrdvRZ0nnyXsH afvfPtNj/ldW0IuCWCuMvt03V00VfgODq3QmimdUxI6lS7gHDReXL0ZP1LdYbZmqMeZ3sv SQh1KHLZHfLwBBMYaZpc5f0uInbo9ig= X-MC-Unique: Hh3CdOwGO9uPGRV5dKXvFA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 15/18] migration: postcopy_pause_fault_thread() never fails Date: Wed, 2 Mar 2022 18:29:33 +0000 Message-Id: <20220302182936.227719-16-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247083500100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Per the title, remove the return code and simplify the callers as the errors will never be triggered. No functional change intended. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-12-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/postcopy-ram.c | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index b0d12d5053..32c52f4b1d 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -891,15 +891,11 @@ static void mark_postcopy_blocktime_end(uintptr_t add= r) affected_cpu); } =20 -static bool postcopy_pause_fault_thread(MigrationIncomingState *mis) +static void postcopy_pause_fault_thread(MigrationIncomingState *mis) { trace_postcopy_pause_fault_thread(); - qemu_sem_wait(&mis->postcopy_pause_sem_fault); - trace_postcopy_pause_fault_thread_continued(); - - return true; } =20 /* @@ -959,13 +955,7 @@ static void *postcopy_ram_fault_thread(void *opaque) * broken already using the event. We should hold until * the channel is rebuilt. */ - if (postcopy_pause_fault_thread(mis)) { - /* Continue to read the userfaultfd */ - } else { - error_report("%s: paused but don't allow to continue", - __func__); - break; - } + postcopy_pause_fault_thread(mis); } =20 if (pfd[1].revents) { @@ -1039,15 +1029,8 @@ retry: msg.arg.pagefault.address); if (ret) { /* May be network failure, try to wait for recovery */ - if (postcopy_pause_fault_thread(mis)) { - /* We got reconnected somehow, try to continue */ - goto retry; - } else { - /* This is a unavoidable fault */ - error_report("%s: postcopy_request_page() get %d", - __func__, ret); - break; - } + postcopy_pause_fault_thread(mis); + goto retry; } } =20 --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646246773; cv=none; d=zohomail.com; s=zohoarc; b=Xbjep57Yi9HD3sy8p5p0x75yfWgboF+cUbAhJBFtRNlCcOR1T/O8EFUtHFq+WbFQywz3yACoDYsZyjsXQzrQEIl+/zUb3ErMWZ9AFkYAghWagO7YvPAGQcv4I/rrDXpmOnsjR+4ytV97EKeBQJb8PDfYjNJxpmBIxAoYu3D3uxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646246773; 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=fP/tSqp5T3DCO/o7BYpMflxukfHmEcrKyYEABxnV1NI=; b=NBEomuBwSm5AY3YpzvXMRJsrBIkeM9M0efjAlj/7huYmSyPv/6K060JHNnByKQZuS2c+1ML+JYYGN+dlEWOiPNSeJyOc7OBcwOuCPe+d7JgB56uqUPIqtgfMmqR8ZGcmLuNkCbl8tgKV93YVVHC95DqlAH2eXkwkguHv5Uh71tE= 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 1646246773025908.7666552788063; Wed, 2 Mar 2022 10:46:13 -0800 (PST) Received: from localhost ([::1]:40266 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPTzH-0005PG-ND for importer@patchew.org; Wed, 02 Mar 2022 13:46:11 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkh-0001hM-6U for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28143) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkf-0000Lf-G9 for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:06 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-500-csPTRpmnPUO9UR5bsWQgWw-1; Wed, 02 Mar 2022 13:31:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 800D084A5F0; Wed, 2 Mar 2022 18:31:00 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E1B43105916D; Wed, 2 Mar 2022 18:30:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245864; 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=fP/tSqp5T3DCO/o7BYpMflxukfHmEcrKyYEABxnV1NI=; b=FHzEwVVM41Xc9bzNVARpne9IOgdnYi6m7REM+c4yDtHwWz9a2x+3i9Ba4eDNiAiHuhN5jK p2L1ocLA0DOgLRLELyyBFb1sWdHtmXMuYNHGEbtUNP+oZKk6v2bgTDyi3EgtyBtLhv7v3X SELM+qPrFLeTCAim+e3F22tT6IwsX3I= X-MC-Unique: csPTRpmnPUO9UR5bsWQgWw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 16/18] migration: Add migration_incoming_transport_cleanup() Date: Wed, 2 Mar 2022 18:29:34 +0000 Message-Id: <20220302182936.227719-17-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646246774664100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu Add a helper to cleanup the transport listener. When do it, we should also null-ify the cleanup hook and the data, then it's even safe to call it multiple times. Move the socket_address_list cleanup altogether, because that's a mirror of= the listener channels and only for the purpose of query-migrate. Hence when someone wants to cleanup the listener transport, it should also want to cle= anup the socket list too, always. No functional change intended. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-15-peterx@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- migration/migration.c | 22 ++++++++++++++-------- migration/migration.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 306e2ac60e..9cc344514b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -267,6 +267,19 @@ MigrationIncomingState *migration_incoming_get_current= (void) return current_incoming; } =20 +void migration_incoming_transport_cleanup(MigrationIncomingState *mis) +{ + if (mis->socket_address_list) { + qapi_free_SocketAddressList(mis->socket_address_list); + mis->socket_address_list =3D NULL; + } + + if (mis->transport_cleanup) { + mis->transport_cleanup(mis->transport_data); + mis->transport_data =3D mis->transport_cleanup =3D NULL; + } +} + void migration_incoming_state_destroy(void) { struct MigrationIncomingState *mis =3D migration_incoming_get_current(= ); @@ -287,10 +300,8 @@ void migration_incoming_state_destroy(void) g_array_free(mis->postcopy_remote_fds, TRUE); mis->postcopy_remote_fds =3D NULL; } - if (mis->transport_cleanup) { - mis->transport_cleanup(mis->transport_data); - } =20 + migration_incoming_transport_cleanup(mis); qemu_event_reset(&mis->main_thread_load_event); =20 if (mis->page_requested) { @@ -298,11 +309,6 @@ void migration_incoming_state_destroy(void) mis->page_requested =3D NULL; } =20 - if (mis->socket_address_list) { - qapi_free_SocketAddressList(mis->socket_address_list); - mis->socket_address_list =3D NULL; - } - yank_unregister_instance(MIGRATION_YANK_INSTANCE); } =20 diff --git a/migration/migration.h b/migration/migration.h index d8b9850eae..2de861df01 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -166,6 +166,7 @@ struct MigrationIncomingState { =20 MigrationIncomingState *migration_incoming_get_current(void); void migration_incoming_state_destroy(void); +void migration_incoming_transport_cleanup(MigrationIncomingState *mis); /* * Functions to work with blocktime context */ --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247202; cv=none; d=zohomail.com; s=zohoarc; b=Wou3BUJRYMjhuqieUxvw0bdOmfmmbQoYfYlnXG+H4f/z/KWtNuHodfUI3QsuMy3VlZ3HezsjThHU+c0aceZpLO03sLvCXWstWZogHk0kwtSgwDaFXe15luVZBcxDQJ5dDzZp7WL+PRsGzQTlNKNB/yJOtPpkGYDUKOr+m9+6QAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247202; 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=dBgJE1JRhE6X1SUaBOG+Vqgs+NvOCCVxq25oeP48n54=; b=KZiIgrxPH/RmFTCkY7NlBZN0Pr8KnL1tnWZ8YKK8jmG9OR54pdTj7YaH8nnBCz5vLt6wiWAB9t+ZOiALmSRRtUklmdGqK+miL1JdrqFYvDCCGHmCF1G8XXg8KuIt+1gtr2s1oOXOx9MLtNmv3d0IqQKIiebDgC0v1xSUBqjEG60= 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 1646247202273354.6451887698729; Wed, 2 Mar 2022 10:53:22 -0800 (PST) Received: from localhost ([::1]:55436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU6D-0007SM-12 for importer@patchew.org; Wed, 02 Mar 2022 13:53:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkm-0001n5-Jr for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52006) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkh-0000Lt-Bv for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:08 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-582-fLSuthr9PqGyFrh4O7hR8A-1; Wed, 02 Mar 2022 13:31:03 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A4601019983; Wed, 2 Mar 2022 18:31:02 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB541105916D; Wed, 2 Mar 2022 18:31:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245866; 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=dBgJE1JRhE6X1SUaBOG+Vqgs+NvOCCVxq25oeP48n54=; b=O7Fah5i8fNUNm2sUyiOrEfVwzbAfb8F/E42DeyaveVfoSAPPF52IsG7iZ86zkRt1YjSHuT 63C4bsTukPnhvJGquAQhGIyHpwOkv6apYhp06ND/dNlEQWPXyn4Bz3o73jrUbxz2PnPc7O pJRVprBTYn71SDMv45FJ95aqHrj3ULg= X-MC-Unique: fLSuthr9PqGyFrh4O7hR8A-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 17/18] tests: Pass in MigrateStart** into test_migrate_start() Date: Wed, 2 Mar 2022 18:29:35 +0000 Message-Id: <20220302182936.227719-18-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247204304100001 Content-Type: text/plain; charset="utf-8" From: Peter Xu test_migrate_start() will release the MigrateStart structure that passed in, however that's not super clear to the caller because after the call returned the pointer can still be referenced by the callers. It can easily be a source of use-after-free. Let's pass in a double pointer of that, then we can safely clear the pointer for the caller after the struct is released. Signed-off-by: Peter Xu Message-Id: <20220301083925.33483-26-peterx@redhat.com> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert dgilbert: Fixup apply since I didn't take 24/25 --- tests/qtest/migration-test.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 7b42f6fd90..0870656d82 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -495,7 +495,7 @@ static void migrate_start_destroy(MigrateStart *args) } =20 static int test_migrate_start(QTestState **from, QTestState **to, - const char *uri, MigrateStart *args) + const char *uri, MigrateStart **pargs) { g_autofree gchar *arch_source =3D NULL; g_autofree gchar *arch_target =3D NULL; @@ -507,6 +507,7 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, g_autofree char *shmem_path =3D NULL; const char *arch =3D qtest_get_arch(); const char *machine_opts =3D NULL; + MigrateStart *args =3D *pargs; const char *memory_size; int ret =3D 0; =20 @@ -621,6 +622,8 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, =20 out: migrate_start_destroy(args); + /* This tells the caller that this structure is gone */ + *pargs =3D NULL; return ret; } =20 @@ -665,7 +668,7 @@ static int migrate_postcopy_prepare(QTestState **from_p= tr, g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, uri, args)) { + if (test_migrate_start(&from, &to, uri, &args)) { return -1; } =20 @@ -788,7 +791,7 @@ static void test_baddest(void) =20 args->hide_stderr =3D true; =20 - if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", args)) { + if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", &args)) { return; } migrate_qmp(from, "tcp:127.0.0.1:0", "{}"); @@ -804,7 +807,7 @@ static void test_precopy_unix_common(bool dirty_ring) =20 args->use_dirty_ring =3D dirty_ring; =20 - if (test_migrate_start(&from, &to, uri, args)) { + if (test_migrate_start(&from, &to, uri, &args)) { return; } =20 @@ -892,7 +895,7 @@ static void test_xbzrle(const char *uri) MigrateStart *args =3D migrate_start_new(); QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, uri, args)) { + if (test_migrate_start(&from, &to, uri, &args)) { return; } =20 @@ -946,7 +949,7 @@ static void test_precopy_tcp(void) g_autofree char *uri =3D NULL; QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", args)) { + if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", &args)) { return; } =20 @@ -991,7 +994,7 @@ static void test_migrate_fd_proto(void) QDict *rsp; const char *error_desc; =20 - if (test_migrate_start(&from, &to, "defer", args)) { + if (test_migrate_start(&from, &to, "defer", &args)) { return; } =20 @@ -1071,7 +1074,7 @@ static void do_test_validate_uuid(MigrateStart *args,= bool should_fail) g_autofree char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, uri, args)) { + if (test_migrate_start(&from, &to, uri, &args)) { return; } =20 @@ -1163,7 +1166,7 @@ static void test_migrate_auto_converge(void) */ const int64_t expected_threshold =3D max_bandwidth * downtime_limit / = 1000; =20 - if (test_migrate_start(&from, &to, uri, args)) { + if (test_migrate_start(&from, &to, uri, &args)) { return; } =20 @@ -1232,7 +1235,7 @@ static void test_multifd_tcp(const char *method) QDict *rsp; g_autofree char *uri =3D NULL; =20 - if (test_migrate_start(&from, &to, "defer", args)) { + if (test_migrate_start(&from, &to, "defer", &args)) { return; } =20 @@ -1318,7 +1321,7 @@ static void test_multifd_tcp_cancel(void) =20 args->hide_stderr =3D true; =20 - if (test_migrate_start(&from, &to, "defer", args)) { + if (test_migrate_start(&from, &to, "defer", &args)) { return; } =20 @@ -1357,7 +1360,7 @@ static void test_multifd_tcp_cancel(void) args =3D migrate_start_new(); args->only_target =3D true; =20 - if (test_migrate_start(&from, &to2, "defer", args)) { + if (test_migrate_start(&from, &to2, "defer", &args)) { return; } =20 --=20 2.35.1 From nobody Fri May 17 03:01:02 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=1646247173; cv=none; d=zohomail.com; s=zohoarc; b=JV4ozpY1THeCuDakFrPtYgcJGN0dJMuizqjRxgquEgqTSmyBdpkwLoPrVcr5QslZG7sWidZl4mGSLWfHQQfag2UqSPUnqGJBSk5u19aUsCOdxUejvoZsJUyhWrOvswqrHbWJ+kl4f3wbN5lV2417LL18eauY9QOHpXC4NyRQS1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646247173; 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=K8u2T++Crfcmx6tmHawN9ZEPoosKW24Svo58S7Rae5g=; b=lm+VI+L251O8wD8ZJ42QmT8UqTK6h36IOU6JOJ9fWatMdRX95F5pwEm6A4Q2vUKDYiuoiciSOQYYz0G75Ds3evsEGEjRoetz/WvNKwu7MiTr+af1HYXCNuPtYDxYRXxbe2JINFL7lbVIWN1CJ2PEfhRidtlnWybU+V0OM22+dYE= 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 1646247173637932.8452673315986; Wed, 2 Mar 2022 10:52:53 -0800 (PST) Received: from localhost ([::1]:53696 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nPU5k-0006IC-Ie for importer@patchew.org; Wed, 02 Mar 2022 13:52:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:36876) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTko-0001th-1E for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36229) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nPTkm-0000MI-9R for qemu-devel@nongnu.org; Wed, 02 Mar 2022 13:31:13 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-267-m_s0mPO3NniHOwTMistPHw-1; Wed, 02 Mar 2022 13:31:05 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5344B19251BD; Wed, 2 Mar 2022 18:31:04 +0000 (UTC) Received: from dgilbert-t580.localhost (unknown [10.33.36.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B46911059170; Wed, 2 Mar 2022 18:31:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646245868; 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=K8u2T++Crfcmx6tmHawN9ZEPoosKW24Svo58S7Rae5g=; b=f2XehK2Gx93mlH+O7Ok95apwm3XWsqLtds1STwxMOTk0dreilNGNOkM+7m1Z7B0TPefB6Q XUmugt8a9Z6JG6cQDInCmWNsmju+N5Msn49kmpdcS2U36fN7Abj2r7h90F+710fL/btP/h kupA/kFj9qvDhbcAj/wpziAWF4HrxMA= X-MC-Unique: m_s0mPO3NniHOwTMistPHw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, f.ebner@proxmox.com, hreitz@redhat.com, jinpu.wang@ionos.com, peter.maydell@linaro.org, peterx@redhat.com, s.reiter@proxmox.com Subject: [PULL 18/18] migration: Remove load_state_old and minimum_version_id_old Date: Wed, 2 Mar 2022 18:29:36 +0000 Message-Id: <20220302182936.227719-19-dgilbert@redhat.com> In-Reply-To: <20220302182936.227719-1-dgilbert@redhat.com> References: <20220302182936.227719-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=dgilbert@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: quintela@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646247174121100001 Content-Type: text/plain; charset="utf-8" From: Peter Maydell There are no longer any VMStateDescription structs in the tree which use the load_state_old support for custom handling of incoming migration from very old QEMU. Remove the mechanism entirely. This includes removing one stray useless setting of minimum_version_id_old in a VMStateDescription with no load_state_old function, which crept in after the global weeding-out of them in commit 17e313406126. Signed-off-by: Peter Maydell Message-Id: <20220215175705.3846411-1-peter.maydell@linaro.org> Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Francisco Iglesias Reviewed-by: Alistair Francis Signed-off-by: Dr. David Alan Gilbert --- docs/devel/migration.rst | 12 +++--------- hw/ssi/xlnx-versal-ospi.c | 1 - include/migration/vmstate.h | 2 -- migration/vmstate.c | 6 ------ 4 files changed, 3 insertions(+), 18 deletions(-) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index 2401253482..3e9656d8e0 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -389,19 +389,13 @@ Each version is associated with a series of fields sa= ved. The ``save_state`` al the state as the newer version. But ``load_state`` sometimes is able to load state from an older version. =20 -You can see that there are several version fields: +You can see that there are two version fields: =20 - ``version_id``: the maximum version_id supported by VMState for that dev= ice. - ``minimum_version_id``: the minimum version_id that VMState is able to u= nderstand for that device. -- ``minimum_version_id_old``: For devices that were not able to port to vm= state, we can - assign a function that knows how to read this old state. This field is - ignored if there is no ``load_state_old`` handler. - -VMState is able to read versions from minimum_version_id to -version_id. And the function ``load_state_old()`` (if present) is able to -load state from minimum_version_id_old to minimum_version_id. This -function is deprecated and will be removed when no more users are left. + +VMState is able to read versions from minimum_version_id to version_id. =20 There are *_V* forms of many ``VMSTATE_`` macros to load fields for versio= n dependent fields, e.g. diff --git a/hw/ssi/xlnx-versal-ospi.c b/hw/ssi/xlnx-versal-ospi.c index 7ecd148fdf..c762e0b367 100644 --- a/hw/ssi/xlnx-versal-ospi.c +++ b/hw/ssi/xlnx-versal-ospi.c @@ -1800,7 +1800,6 @@ static const VMStateDescription vmstate_xlnx_versal_o= spi =3D { .name =3D TYPE_XILINX_VERSAL_OSPI, .version_id =3D 1, .minimum_version_id =3D 1, - .minimum_version_id_old =3D 1, .fields =3D (VMStateField[]) { VMSTATE_FIFO8(rx_fifo, XlnxVersalOspi), VMSTATE_FIFO8(tx_fifo, XlnxVersalOspi), diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 017c03675c..ad24aa1934 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -181,9 +181,7 @@ struct VMStateDescription { int unmigratable; int version_id; int minimum_version_id; - int minimum_version_id_old; MigrationPriority priority; - LoadStateHandler *load_state_old; int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); int (*pre_save)(void *opaque); diff --git a/migration/vmstate.c b/migration/vmstate.c index 05f87cdddc..36ae8b9e19 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -90,12 +90,6 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescrip= tion *vmsd, return -EINVAL; } if (version_id < vmsd->minimum_version_id) { - if (vmsd->load_state_old && - version_id >=3D vmsd->minimum_version_id_old) { - ret =3D vmsd->load_state_old(f, opaque, version_id); - trace_vmstate_load_state_end(vmsd->name, "old path", ret); - return ret; - } error_report("%s: incoming version_id %d is too old " "for local minimum version_id %d", vmsd->name, version_id, vmsd->minimum_version_id); --=20 2.35.1