From nobody Sat May 18 10:57:27 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=1698136894; cv=none; d=zohomail.com; s=zohoarc; b=e9gt1qr4MUR+CpIrkkw2fgbsbzV2kGdXsInCXEyV17Y5t0ZTW2XVSFY96h4CGm+lcvlOCvqq7lSuEnhd5uqnmz9mVDdUnTH8oIb/sJBAtbdLxrRfp3jorPXPfhdKPWsRUjQjLdLtRRPk6CEWocG6BJ2f9PZ5zDS2+OjBWlVi45A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136894; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HFJfX2UbdUONwAiwbnWDg/Z2Ma5pzUtKmwKBZ6J1/3g=; b=NhhCtkPya8XHpD8i3NlOzlpZ/Fzr3mBR5tUlyfLp1MPPP+W5mPX2gIRcTV66cfVvyk5xNwUYwcT78dLqzKw3FeV69caOgrw803kyJNfBUtOcaHzSxXJy+wZRQayYkfAEi5abJNgS48Q3TwOu8qmtT9r0UrQ+aKGRRQE/XgxhToU= 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 1698136894483789.5327026481258; Tue, 24 Oct 2023 01:41:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCy9-0003b9-VI; Tue, 24 Oct 2023 04:40:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCy8-0003PY-0o for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:40:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCy6-0003Fs-DJ for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:40:55 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-9pUllD1KPXCPUZhde0NC8Q-1; Tue, 24 Oct 2023 04:40:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8314857A85; Tue, 24 Oct 2023 08:40:51 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id B74F58C0B; Tue, 24 Oct 2023 08:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136853; 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=HFJfX2UbdUONwAiwbnWDg/Z2Ma5pzUtKmwKBZ6J1/3g=; b=OOXrqhqm/gXTWr0jC4G2+3baLXdRNDGMFfQeebRdT4ZWiKS9P9AUZij4JvHWhnS5iAKqDV hcEyLFZh1VWGA+jbiiM9dMcwY4nPZlEF0n+jDUk6NkT5s8Xdf7Z0XblJNfr6ZSDPPCUvIx 7MCAh9DokDr9pkf7TRL6zRTadsMD1zY= X-MC-Unique: 9pUllD1KPXCPUZhde0NC8Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 1/9] block/fdc: 'phase' is not needed on load Date: Tue, 24 Oct 2023 12:40:35 +0400 Message-ID: <20231024084043.2926316-2-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136896473100003 From: Marc-Andr=C3=A9 Lureau It is reconstructed during fdc_post_load() Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/block/fdc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index d7cc4d3ec1..fc71660ba0 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -1005,6 +1005,11 @@ static bool fdc_phase_needed(void *opaque) { FDCtrl *fdctrl =3D opaque; =20 + /* not needed on load */ + if (fdctrl->phase =3D=3D FD_PHASE_RECONSTRUCT) { + return false; + } + return reconstruct_phase(fdctrl) !=3D fdctrl->phase; } =20 --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136915; cv=none; d=zohomail.com; s=zohoarc; b=APcUdXno35FAUlMfqtJW8+aYsBa1QANtP2KjtnnsODIT/8CSZPHjz+P6Vesf8Ar0PcSI2tMFnTvgRiMjwf7+/EyJ4cIS6UEyFbwRKI9bC0L2bDBbkYXq8fsC29v107EkWUkfRxAQd4oIAuZo7cqDIs/TzIHhPc4w+G87k0hig4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136915; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=b0sIoyOFAtdBEQyNjp7wD5mrhmgIJhKoQXB/TDbxuWQ=; b=CceMEcJZEocGBY7nRtPZIibMNpdHinainCmZukQp0YFOhoVd1/2XMur41ZnR6AZcws2OZc3DVPnyghNxTqeTK9j1Z+rJGfFBsJUlUrEuTwcyxKKclb+gYNeyFvB3lclkTUPlNwls868c2al/kidWdqpkrg2ci7BKeY6WpCv2A+c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698136915959647.1880150963433; Tue, 24 Oct 2023 01:41:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCyF-0003oZ-MX; Tue, 24 Oct 2023 04:41:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyE-0003n8-3i for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyC-0003Je-LF for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:01 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-226-CyuS3CWENJewInKyUoSbaQ-1; Tue, 24 Oct 2023 04:40:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EB0D2185A7BC; Tue, 24 Oct 2023 08:40:55 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 213831121318; Tue, 24 Oct 2023 08:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136860; 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=b0sIoyOFAtdBEQyNjp7wD5mrhmgIJhKoQXB/TDbxuWQ=; b=e4FTV+oRWoBQgs6DpFCOKa7viI7hxksaLM0nVaEZW+L39i9MoeE+8yv20Sv5Yyfu4zUiQb 2g5mvD6Tx7pw50RIE9gEQPxVi9FA1F+vYYxEayOjLmukfYePe8p51HHWve1Bl0EeabPY7i eOalvH8dQYRpFsZTHf4gR0KpRWUB3OA= X-MC-Unique: CyuS3CWENJewInKyUoSbaQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 2/9] virtio: make endian_needed() work during loading Date: Tue, 24 Oct 2023 12:40:36 +0400 Message-ID: <20231024084043.2926316-3-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136916457100001 From: Marc-Andr=C3=A9 Lureau There is no simple way to distinguish when the callback is used for load or save, AFAICT. Signed-off-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/virtio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 6facd64fbc..8baf9f7ca8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2502,7 +2502,11 @@ static bool virtio_device_endian_needed(void *opaque) { VirtIODevice *vdev =3D opaque; =20 - assert(vdev->device_endian !=3D VIRTIO_DEVICE_ENDIAN_UNKNOWN); + /* On load, endian is UNKNOWN. The section might be loaded as required= . */ + if (vdev->device_endian =3D=3D VIRTIO_DEVICE_ENDIAN_UNKNOWN) { + return false; + } + if (!virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { return vdev->device_endian !=3D virtio_default_endian(); } --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136946; cv=none; d=zohomail.com; s=zohoarc; b=E73+kPD2KEMmHt4CDgR64m27YCXjXkYR0U0fRA+eOxfEz/O3Vj9GHhlfI/qzs/n5QgszE5Zo7wyMkqmDAA7hcfGrhMmGw4JSvfMo9GqMT9GmziWijBzgQbRvMQRH2QtpcKZjRpnB7ZAwKOJJGJD7w67qnlkMQA/fY+sM/geuvxk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136946; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BS4K4hPt4nte3fTZb5lBi+CHvfoDZl40p9U7Y5fbyOg=; b=Mec/55B8TxAWJKU4mEfln3OvZtzwgXZkHnUj9NfoSfa+LrsXIq/ou0VsBM8KX0DTQqUZ7BVMvYPoISdyEtuooXzIRjxgJ8Re4/bQ5QIPd+gYvEIi33SwzUnFxkShOFBOVjaW201Okvasb567owVL/hfRpLJOCUtbV62nA2ikFko= 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 1698136946799280.0575971814786; Tue, 24 Oct 2023 01:42:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCyU-00041D-Ej; Tue, 24 Oct 2023 04:41:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyR-0003yk-Cq for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyP-0003LO-QA for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:15 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-75-VvVOjqkeNrq82tOb4k6P1g-1; Tue, 24 Oct 2023 04:41:01 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DA96B1019C99; Tue, 24 Oct 2023 08:41:00 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF25CC15BB8; Tue, 24 Oct 2023 08:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136872; 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=BS4K4hPt4nte3fTZb5lBi+CHvfoDZl40p9U7Y5fbyOg=; b=YV+Q8DEdhHhlD7ShwS5EvxwMzQWFo6j211o4JbRIkIKkH60z9aTixX8CL10XwbrORy2DJR MpS+yForWSVEBMMn/0Kq3Z40DVy2En2ZGQlyrSSJjlHaMREcNuKFUB6bgN/6BhRE+0l6yf d337dgDSuvS1Xh1+0VloZbhsgjWYXrE= X-MC-Unique: VvVOjqkeNrq82tOb4k6P1g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 3/9] net/slirp: use different IDs for each instance Date: Tue, 24 Oct 2023 12:40:37 +0400 Message-ID: <20231024084043.2926316-4-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 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=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136948523100007 From: Marc-Andr=C3=A9 Lureau Using always 0, QEMU will end up loading the same instance, even if multiple have been saved. Signed-off-by: Marc-Andr=C3=A9 Lureau --- net/slirp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/slirp.c b/net/slirp.c index c33b3e02e7..af1451b60f 100644 --- a/net/slirp.c +++ b/net/slirp.c @@ -47,6 +47,7 @@ #include "util.h" #include "migration/register.h" #include "migration/qemu-file-types.h" +#include "migration/vmstate.h" =20 static int get_str_sep(char *buf, int buf_size, const char **pp, int sep) { @@ -659,7 +660,7 @@ static int net_slirp_init(NetClientState *peer, const c= har *model, * specific version? */ g_assert(slirp_state_version() =3D=3D 4); - register_savevm_live("slirp", 0, slirp_state_version(), + register_savevm_live("slirp", VMSTATE_INSTANCE_ID_ANY, slirp_state_ver= sion(), &savevm_slirp_state, s->slirp); =20 s->poll_notifier.notify =3D net_slirp_poll_notify; --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136972; cv=none; d=zohomail.com; s=zohoarc; b=gk9ppHGg35vxoMqSrnSG/KvDsX37mbgZ9E2ZgD4JJq4jYB8KdFZag59FM+webhihMgQqtssCoJ1oXpj0sd3FVuGN92EEthaWCnsoFOam3wCWFgt2SqwuVcuRQByA84lxNm1QAoJMwi7S6ADzvB+EdNqWIO9eEO2ycGSF+iSghpw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136972; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0T1ckZ/Ff7y9NC51JPbCpyeyBtZPrNqFVintRXVUvls=; b=SordSsIv7mlshAKUJXCTRXzcS04mH2mFWHHvd/LogL9c06EYnAe0k8a/T7uJFSJLOe7OHpCZvPQ0pHykAQCwrXkZJB/idqYpkaHRP/nz3lQL6AAONAlQ9aU7YmdqfzxroJAP6VaWPgPxWHxVMEurYU7Mpl9XKCx9bacXxlD0OGA= 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 1698136972567461.35990693256656; Tue, 24 Oct 2023 01:42:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCyO-0003tH-Vw; Tue, 24 Oct 2023 04:41:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyM-0003qd-Q1 for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyL-0003Ku-AX for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:10 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-94-Y8-wSi-tMEytXCJy3K4Y2w-1; Tue, 24 Oct 2023 04:41:05 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC73D3811F33; Tue, 24 Oct 2023 08:41:04 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5DEB1C060AE; Tue, 24 Oct 2023 08:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136868; 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=0T1ckZ/Ff7y9NC51JPbCpyeyBtZPrNqFVintRXVUvls=; b=Rcxt6PZnHoAGCtCSRpJLYsGy0e150AbI+RNNXyZ3QGm7KWNAt0PSyaYAmEEeVzbmiyIWxp tQL73Jt3n8ztmNkvL2CpW1ceo6rd1umf7hyXrtI66UTiLC+knXJ6O+7TSgSwMj6XunwTfN TfexqozI6vzw6wub97cU4mckQQWGROo= X-MC-Unique: Y8-wSi-tMEytXCJy3K4Y2w-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 4/9] migration: rename vmstate_save_needed->vmstate_section_needed Date: Tue, 24 Oct 2023 12:40:38 +0400 Message-ID: <20231024084043.2926316-5-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136974557100003 From: Marc-Andr=C3=A9 Lureau The function is used on save at this point. The following commits will use it on load. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela --- include/migration/vmstate.h | 2 +- migration/savevm.c | 2 +- migration/vmstate.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 1a31fb7293..1af181877c 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1202,7 +1202,7 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, void *opaque, JSONWriter *vmdesc, int version_id, Error **errp); =20 -bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque); +bool vmstate_section_needed(const VMStateDescription *vmsd, void *opaque); =20 #define VMSTATE_INSTANCE_ID_ANY -1 =20 diff --git a/migration/savevm.c b/migration/savevm.c index 8622f229e5..ca5c7cebe0 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -985,7 +985,7 @@ static int vmstate_save(QEMUFile *f, SaveStateEntry *se= , JSONWriter *vmdesc) if ((!se->ops || !se->ops->save_state) && !se->vmsd) { return 0; } - if (se->vmsd && !vmstate_save_needed(se->vmsd, se->opaque)) { + if (se->vmsd && !vmstate_section_needed(se->vmsd, se->opaque)) { trace_savevm_section_skip(se->idstr, se->section_id); return 0; } diff --git a/migration/vmstate.c b/migration/vmstate.c index 1cf9e45b85..16e33a5d34 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -324,7 +324,7 @@ static void vmsd_desc_field_end(const VMStateDescriptio= n *vmsd, } =20 =20 -bool vmstate_save_needed(const VMStateDescription *vmsd, void *opaque) +bool vmstate_section_needed(const VMStateDescription *vmsd, void *opaque) { if (vmsd->needed && !vmsd->needed(opaque)) { /* optional section not needed */ @@ -522,7 +522,7 @@ static int vmstate_subsection_save(QEMUFile *f, const V= MStateDescription *vmsd, =20 trace_vmstate_subsection_save_top(vmsd->name); while (sub && *sub) { - if (vmstate_save_needed(*sub, opaque)) { + if (vmstate_section_needed(*sub, opaque)) { const VMStateDescription *vmsdsub =3D *sub; uint8_t len; =20 --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136946; cv=none; d=zohomail.com; s=zohoarc; b=j3tTdtgq1UKNXL48K309Mh+L9Z/pPh6ITtXkY+BIaehHVA/SPA33r1u9SYKshsxpYwY9icbVue2y+gQl7fbcQuyVWKNwts/ppi7YvkoGI92V8hw0zndHfAy0IcP1qGajj/h4Q9lQoETLwXyGC4xX7m1ZuoW4nqKnN7dMkNBDrjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136946; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LnsG5NWQMp6ppcb6O/Y0IH9dMdUd6gQTyemwrekuS08=; b=Z3RAVUzD26fDEUkr+T7x/SgI119PWpJOUgR0keWkFfPL6f+KwarbX/f1VN4LhuxMmS+bDAf/7lFWWxIQ6+THwzI7liwA8uCD95lc5XgTGc4bHF2IGtZmnJvnxY1/B80FOcfK/LeXFt8YqJcyvn7QhvWJxPa9P3STZpRQbTneoWA= 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 1698136946495191.79523055591767; Tue, 24 Oct 2023 01:42:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCyq-0004Cc-SZ; Tue, 24 Oct 2023 04:41:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyS-0003yl-Fr for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyP-0003LT-QN for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:15 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-1RGbMSjsMmCVGt_lZbA9OQ-1; Tue, 24 Oct 2023 04:41:09 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A25C1C051A1; Tue, 24 Oct 2023 08:41:09 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CE44492BD9; Tue, 24 Oct 2023 08:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136873; 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=LnsG5NWQMp6ppcb6O/Y0IH9dMdUd6gQTyemwrekuS08=; b=PWTockgSkXoVd5oKEn/OxwHbfOCtGtO9ZupfksWL3uR9X2znYWB0+9Ndyb31EzpC1yhHD8 s4vgjt0defySlf0IO5ZsZ6hpixwv7DoaQzxVWY59rFpnvcoAuJoAExRoAWBkrEergXrraN 8Mrsyf7vlPQz5tKxYFox2d9LzyS5dM0= X-MC-Unique: 1RGbMSjsMmCVGt_lZbA9OQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 5/9] migration: check required subsections are loaded, once Date: Tue, 24 Oct 2023 12:40:39 +0400 Message-ID: <20231024084043.2926316-6-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136948524100008 From: Marc-Andr=C3=A9 Lureau Check that required subsections have been loaded. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela --- migration/vmstate.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/migration/vmstate.c b/migration/vmstate.c index 16e33a5d34..d6fe38a5e1 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -451,22 +451,51 @@ int vmstate_save_state_v(QEMUFile *f, const VMStateDe= scription *vmsd, } =20 static const VMStateDescription * -vmstate_get_subsection(const VMStateDescription **sub, char *idstr) +vmstate_get_subsection(const VMStateDescription **sub, char *idstr, bool *= visited) { + size_t i =3D 0; + while (sub && *sub) { if (strcmp(idstr, (*sub)->name) =3D=3D 0) { + if (visited[i]) { + return NULL; + } + visited[i] =3D true; return *sub; } + i++; sub++; } return NULL; } =20 +static size_t +vmstate_get_n_subsections(const VMStateDescription **sub) +{ + size_t n =3D 0; + + if (!sub) { + return 0; + } + + while (sub[n]) { + n++; + } + + return n; +} + static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, void *opaque) { + size_t i, n; + g_autofree bool *visited =3D NULL; + trace_vmstate_subsection_load(vmsd->name); =20 + n =3D vmstate_get_n_subsections(vmsd->subsections); + visited =3D g_new0(bool, n); + while (qemu_peek_byte(f, 0) =3D=3D QEMU_VM_SUBSECTION) { char idstr[256], *idstr_ret; int ret; @@ -492,7 +521,7 @@ static int vmstate_subsection_load(QEMUFile *f, const V= MStateDescription *vmsd, /* it doesn't have a valid subsection name */ return 0; } - sub_vmsd =3D vmstate_get_subsection(vmsd->subsections, idstr); + sub_vmsd =3D vmstate_get_subsection(vmsd->subsections, idstr, visi= ted); if (sub_vmsd =3D=3D NULL) { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(lookup)= "); return -ENOENT; @@ -509,6 +538,13 @@ static int vmstate_subsection_load(QEMUFile *f, const = VMStateDescription *vmsd, } } =20 + for (i =3D 0; i < n; i++) { + if (!visited[i] && vmstate_section_needed(vmsd->subsections[i], op= aque)) { + trace_vmstate_subsection_load_bad(vmsd->name, vmsd->subsection= s[i]->name, "(not visited)"); + return -ENOENT; + } + } + trace_vmstate_subsection_load_good(vmsd->name); return 0; } --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136966; cv=none; d=zohomail.com; s=zohoarc; b=GmHAuGmgTuziJ5XEnmCX162KyEU9GNdnlqHQgBdKOovYxsNJd1QtFx2rgwbxb6Adr6viXVUona4nfJa2asaDj+Fr+vGm1JJiy+64KXBfG7litOkQ1MjWReR5eR+lA8XfELal7NmeaJfoY7uACNvK/l4gSfKClk5/JcktfFb12oU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136966; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JcTpCgZ35LfhC+wFH9xrmV5omvGtiL8P6lxVbihLf/E=; b=co1gaKYG1T6PNB+zRlHICVKUdm5Ez5i6oPIM/ciNoGe+YfK8+qhMEbO6+1iLhhjGzKP3EOOYUSbOPPdMx7q+/DO9q32C0ou00xPkIuDeZzGi9KeDRu60aFKoMRPH7q8yqlBhanAGa1wpGCC+DTMr32ZW69+mU+RVRF0KZKhB4mk= 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 1698136966934761.4558173341486; Tue, 24 Oct 2023 01:42:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCyW-00045z-3O; Tue, 24 Oct 2023 04:41:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyU-00041U-Jx for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyS-0003M1-Pr for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:18 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-JJYg65rzNbaQWhiovTqt7g-1; Tue, 24 Oct 2023 04:41:14 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DB87A811E97; Tue, 24 Oct 2023 08:41:13 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B5C825C0; Tue, 24 Oct 2023 08:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136875; 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=JcTpCgZ35LfhC+wFH9xrmV5omvGtiL8P6lxVbihLf/E=; b=X2NW7S6xXdS/NPvr0xyfgKK/PCK881BxkmF1VGBl932Xwopq5VNb+gOxivkINrIiwHf/Ga qDKVy+SnNODwW28OfAEAKbM5bt70omvu3M/FHKfU4Lg7grKQGFOJeCq5DSey/TZk+yArUc +foFT6xqfaJ7blTeAVVR4RBxe5Wv85k= X-MC-Unique: JJYg65rzNbaQWhiovTqt7g-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 6/9] migration: check required entries are loaded, once Date: Tue, 24 Oct 2023 12:40:40 +0400 Message-ID: <20231024084043.2926316-7-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136968539100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela --- migration/savevm.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index ca5c7cebe0..66c9c3095b 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -217,6 +217,7 @@ typedef struct SaveStateEntry { void *opaque; CompatEntry *compat; int is_ram; + bool visited; } SaveStateEntry; =20 typedef struct SaveState { @@ -1739,6 +1740,36 @@ int qemu_save_device_state(QEMUFile *f) return qemu_file_get_error(f); } =20 +static void savevm_reset_visited(void) +{ + SaveStateEntry *se; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + se->visited =3D false; + } +} + +static bool loadvm_check_visited(Error **errp) +{ + SaveStateEntry *se; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (se->ops && se->ops->is_active && !se->ops->is_active(se->opaqu= e)) { + continue; + } + if (se->vmsd && !vmstate_section_needed(se->vmsd, se->opaque)) { + continue; + } + if (!se->visited) { + error_setg(errp, "Missing entry '%s' while loading VM", se->id= str); + return false; + } + } + + return true; +} + + static SaveStateEntry *find_se(const char *idstr, uint32_t instance_id) { SaveStateEntry *se; @@ -2541,6 +2572,11 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migratio= nIncomingState *mis) idstr, instance_id); return -EINVAL; } + if (se->visited) { + error_report("error while loading state for instance 0x%"PRIx32" o= f" + " device '%s'", instance_id, idstr); + return -EINVAL; + } =20 /* Validate version */ if (version_id > se->version_id) { @@ -2567,6 +2603,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, Migration= IncomingState *mis) return -EINVAL; } =20 + se->visited =3D true; + return 0; } =20 @@ -2874,7 +2912,12 @@ int qemu_loadvm_state(QEMUFile *f) =20 cpu_synchronize_all_pre_loadvm(); =20 + savevm_reset_visited(); ret =3D qemu_loadvm_state_main(f, mis); + if (!loadvm_check_visited(&local_err)) { + error_report_err(local_err); + return -EINVAL; + } qemu_event_set(&mis->main_thread_load_event); =20 trace_qemu_loadvm_state_post_main(ret); --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136935; cv=none; d=zohomail.com; s=zohoarc; b=IqwhCaa5CowZ7TzeVgRNoM7xkDw6Dy0fua7+sMWPYlUL4j7DccB2vz6pf+vgM4S0NJiQ0CAikPFy4AaHN+ncXyayKNnywLxZo3jAXLj322mZuIqgYIQgTzvjxI4js66J8cLWieRCp+Ut544HJO6hZPpvyg3A1Xxvp32bj4zRWv4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136935; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QMfsu1D3Em5HyaSgl6VAZL8RSeHOmIYpXte1yU4sBcs=; b=QwOu87x23HOxHbBJiOxpwtecx9THxoucQPxIbdTa4j42HAvbuNi1h2StxBwWY8R289BsRwpVSB/f2jMzpdK/mGkWEhJyqq8bh09NG+wnlTg9Xz+JH+9Hs01s3GqjNKBV5FKQq+1hfnIeEQkG1a+kzrMcDGMK20ncwx/8Z5Cjq/Q= 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 1698136935014153.766480175634; Tue, 24 Oct 2023 01:42:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCys-0004Fw-NF; Tue, 24 Oct 2023 04:41:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCya-00048e-8z for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyY-0003OX-Oq for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:24 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-621-JNJFnvLTNSmafGL3_WoVPw-1; Tue, 24 Oct 2023 04:41:18 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2C45F1C05AD7; Tue, 24 Oct 2023 08:41:18 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 70BCE492BD9; Tue, 24 Oct 2023 08:41:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136881; 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=QMfsu1D3Em5HyaSgl6VAZL8RSeHOmIYpXte1yU4sBcs=; b=ToT6vPiVFFR9MJbsUtgYuMeKTp7LpAHPSsbLxmrCAEbNMSu3oMhe+rwQ5N3+eaoJBoFJAd gWMIErjMp22bC9Mf606VqJxxQfjhZvmLsDBY47auIAHUd/ND1us6NjYwyE/R9nECAah1A7 5XJ4lkPLuSjvl57m8R0dUAI4zmmcpso= X-MC-Unique: JNJFnvLTNSmafGL3_WoVPw-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 7/9] migration: set file error on subsection loading Date: Tue, 24 Oct 2023 12:40:41 +0400 Message-ID: <20231024084043.2926316-8-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136936378100003 From: Marc-Andr=C3=A9 Lureau commit 13cde50889237 ("vmstate: Return error in case of error") sets QemuFile error to stop reading from it and report to the caller (checked by unit tests). We should do the same on subsection loading error. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela --- migration/vmstate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/vmstate.c b/migration/vmstate.c index d6fe38a5e1..be2193158f 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -179,6 +179,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, assert(field->flags =3D=3D VMS_END); ret =3D vmstate_subsection_load(f, vmsd, opaque); if (ret !=3D 0) { + qemu_file_set_error(f, ret); return ret; } if (vmsd->post_load) { --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136947; cv=none; d=zohomail.com; s=zohoarc; b=AcPBwkE+NA/57H78AmPgvSzwxwda8kObJNwW+PYeTjxhFlzyhQdqQ3mm1qc0n6Z/GwuPM7rLMiTTQOVsa9pIs1cPles+96MWhb/Wsc6RwVJqsmnDx6EdCY2T3shi5f+cpWZSjDrCOnRklrPwgvNpKC9XZ6b4xQiT43NvaHFq9FE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136947; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wR2TWmu2nXFe+Yt2dn6KOypBMftWecdiJd9iSWtUhzo=; b=lFoTzgOUskVwL/+wfWD6JP2MrZQEqpzpNaUpGzXaK2Npjq7sRotLdJrrN/l/lKNrzJCGhlmmooOFkhWno03ZV2LbZ+ORC/A02HtNiezgwRsC8fEaGhvJLmCxI8vVPQQqIFyUvRqo8B50SbQPzJY9s7zTnn6BqahRi0wfptcFa74= 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 1698136947245565.0130975739131; Tue, 24 Oct 2023 01:42:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCyu-0004HT-LD; Tue, 24 Oct 2023 04:41:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyn-0004Cz-HR for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyl-0003QU-Sz for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-328-dXfmySJwOzSOH4-oIxml0Q-1; Tue, 24 Oct 2023 04:41:23 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DC3D1185AD13; Tue, 24 Oct 2023 08:41:22 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 194438C0B; Tue, 24 Oct 2023 08:41:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136895; 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=wR2TWmu2nXFe+Yt2dn6KOypBMftWecdiJd9iSWtUhzo=; b=g132gfw0srvt9BLFoI2NkpMFNLf5M5M7jQYp05pPLxXAyYmD3F+ddygqeV5W2c/1SiFs96 nZ6POTbrMdVPEpUKNetkdBeBifhfW4+fSpJdXjRuzzcngDUzGzaETuFI7mdXfo6ZSJmxZe 6hee3b//UINfnzB1UGqEiXlLbNxRrsE= X-MC-Unique: dXfmySJwOzSOH4-oIxml0Q-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 8/9] test-vmstate: add some subsection tests Date: Tue, 24 Oct 2023 12:40:42 +0400 Message-ID: <20231024084043.2926316-9-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136948537100009 From: Marc-Andr=C3=A9 Lureau Check subsection support, and optional handling. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela --- tests/unit/test-vmstate.c | 116 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 0b7d5ecd68..7f4a02b4c0 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -1479,6 +1479,118 @@ static void test_tmp_struct(void) g_assert_cmpint(obj.f, =3D=3D, 8); /* From the child->parent */ } =20 +static bool sub_optional_needed =3D true; + +static bool sub_optional_needed_cb(void *opaque) +{ + return sub_optional_needed; +} + +static const VMStateDescription vmstate_sub_optional_a =3D { + .name =3D "sub/optional/a", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D sub_optional_needed_cb, + .fields =3D (VMStateField[]) { + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_sub_optional =3D { + .name =3D "sub/optional", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_END_OF_LIST() + }, + .subsections =3D (const VMStateDescription * []) { + &vmstate_sub_optional_a, + } +}; + +static uint8_t wire_sub_optional[] =3D { + QEMU_VM_SUBSECTION, + 14, + 's', 'u', 'b', '/', 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l', '/', 'a', + 0x0, 0x0, 0x0, 1, + QEMU_VM_EOF, +}; + +static uint8_t wire_sub_optional_missing[] =3D { + QEMU_VM_EOF, +}; + +static void test_sub_optional_needed(void) +{ + sub_optional_needed =3D true; + save_vmstate(&vmstate_sub_optional, NULL); + + compare_vmstate(wire_sub_optional, sizeof(wire_sub_optional)); + + SUCCESS(load_vmstate_one(&vmstate_sub_optional, NULL, + 1, wire_sub_optional, + sizeof(wire_sub_optional))); + + FAILURE(load_vmstate_one(&vmstate_sub_optional, NULL, + 1, wire_sub_optional_missing, + sizeof(wire_sub_optional_missing))); + +} + +static void test_sub_optional_missing(void) +{ + sub_optional_needed =3D false; + save_vmstate(&vmstate_sub_optional, NULL); + + compare_vmstate(wire_sub_optional_missing, sizeof(wire_sub_optional_mi= ssing)); + + SUCCESS(load_vmstate_one(&vmstate_sub_optional, NULL, + 1, wire_sub_optional, + sizeof(wire_sub_optional))); + + SUCCESS(load_vmstate_one(&vmstate_sub_optional, NULL, + 1, wire_sub_optional_missing, + sizeof(wire_sub_optional_missing))); +} + +static uint8_t wire_sub_dup[] =3D { + QEMU_VM_SUBSECTION, + 14, + 's', 'u', 'b', '/', 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l', '/', 'a', + 0x0, 0x0, 0x0, 1, + QEMU_VM_SUBSECTION, + 14, + 's', 'u', 'b', '/', 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l', '/', 'a', + 0x0, 0x0, 0x0, 1, + QEMU_VM_EOF, +}; + +static void test_sub_optional_dup(void) +{ + sub_optional_needed =3D false; + + FAILURE(load_vmstate_one(&vmstate_sub_optional, NULL, + 1, wire_sub_dup, + sizeof(wire_sub_dup))); +} + +static uint8_t wire_sub_unknown[] =3D { + QEMU_VM_SUBSECTION, + 14, + 's', 'u', 'b', '/', 'o', 'p', 't', 'i', 'o', 'n', 'a', 'l', '/', 'b', + 0x0, 0x0, 0x0, 1, + QEMU_VM_EOF, +}; + +static void test_sub_optional_unknown(void) +{ + sub_optional_needed =3D false; + + FAILURE(load_vmstate_one(&vmstate_sub_optional, NULL, + 1, wire_sub_unknown, + sizeof(wire_sub_unknown))); +} + int main(int argc, char **argv) { g_autofree char *temp_file =3D g_strdup_printf("%s/vmst.test.XXXXXX", @@ -1519,6 +1631,10 @@ int main(int argc, char **argv) g_test_add_func("/vmstate/qlist/save/saveqlist", test_save_qlist); g_test_add_func("/vmstate/qlist/load/loadqlist", test_load_qlist); g_test_add_func("/vmstate/tmp_struct", test_tmp_struct); + g_test_add_func("/vmstate/subsection/needed", test_sub_optional_needed= ); + g_test_add_func("/vmstate/subsection/missing", test_sub_optional_missi= ng); + g_test_add_func("/vmstate/subsection/dup", test_sub_optional_dup); + g_test_add_func("/vmstate/subsection/unknown", test_sub_optional_unkno= wn); g_test_run(); =20 close(temp_fd); --=20 2.41.0 From nobody Sat May 18 10:57:27 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=1698136955; cv=none; d=zohomail.com; s=zohoarc; b=i1YPPV4KkCWUVYj0QBBMf7HKhw9vPLvDIjiXr7JrvCm/lbswk4+B/3r3JAgnmYsLRL/8wZ6kCNMo0shlyiz8l1Ul+j77FHNEpdGAX1GFiTIbiakmX/SFg5XW/Yp4JB8FjGEwDjmGyLORBPIEAEAPIgv5evgshlL56I1zebNgXVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698136955; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LCp3AYBhBG3mDrqT6tO9NXD2VXeACBOwSKm4rlSu9xk=; b=awkVPXABr4eAl/YUU+QaWqxolIKFHnCOdlzbHKKnd3OFwAz7PTndeY0Sn7efa2ip3FRghGVyE8SCkcnL7Nl/HUxi/QmU4d2ZQkVqziz2jlxT0DrF5FAKkgtjpDpO/bs+tzDKZi9O5KRGddiUgjtofLiBKaa+jORTfOYvyXkdtuw= 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 1698136955657820.1666420263628; Tue, 24 Oct 2023 01:42:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvCz2-0004RA-IN; Tue, 24 Oct 2023 04:41:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyz-0004KW-KG for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvCyx-0003Sy-UU for qemu-devel@nongnu.org; Tue, 24 Oct 2023 04:41:49 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-Y-ZUxls1MVmdDlquaqdkUQ-1; Tue, 24 Oct 2023 04:41:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D272185AD06; Tue, 24 Oct 2023 08:41:27 +0000 (UTC) Received: from localhost (unknown [10.39.208.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A2892166B26; Tue, 24 Oct 2023 08:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698136907; 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=LCp3AYBhBG3mDrqT6tO9NXD2VXeACBOwSKm4rlSu9xk=; b=jQ2ztbBMoxRDaij/j7HehfdzZEPExYFrhOxkGj7dGXfDe+hu4jYNTIEf91XMxr80etg3jy 83OFTTimWtDORiKMxwISVgXHvIApH7/tucn+C2S0gPfUS33BGo7hQvVjeu1JScaM0DetYF 4tk1wY0x1nXWms/MnOJbYRHa3xiQVMI= X-MC-Unique: Y-ZUxls1MVmdDlquaqdkUQ-1 From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Cc: Kevin Wolf , "Michael S. Tsirkin" , Fabiano Rosas , John Snow , Hanna Reitz , Leonardo Bras , Samuel Thibault , qemu-block@nongnu.org, Peter Xu , Jason Wang , Juan Quintela , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH v2 9/9] docs/migration: reflect the changes about needed subsections Date: Tue, 24 Oct 2023 12:40:43 +0400 Message-ID: <20231024084043.2926316-10-marcandre.lureau@redhat.com> In-Reply-To: <20231024084043.2926316-1-marcandre.lureau@redhat.com> References: <20231024084043.2926316-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 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=marcandre.lureau@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1698136956508100003 From: Marc-Andr=C3=A9 Lureau Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela --- docs/devel/migration.rst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index c3e1400c0c..50f313f178 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -240,17 +240,16 @@ a newer form of device, or adding that state that you= previously forgot to migrate. This is best solved using a subsection. =20 A subsection is "like" a device vmstate, but with a particularity, it -has a Boolean function that tells if that values are needed to be sent -or not. If this functions returns false, the subsection is not sent. -Subsections have a unique name, that is looked for on the receiving -side. +has a Boolean function that tells if that values are needed or not. If +this functions returns false, the subsection is not sent. Subsections +have a unique name, that is looked for on the receiving side. =20 On the receiving side, if we found a subsection for a device that we -don't understand, we just fail the migration. If we understand all -the subsections, then we load the state with success. There's no check -that a subsection is loaded, so a newer QEMU that knows about a subsection -can (with care) load a stream from an older QEMU that didn't send -the subsection. +don't understand, we just fail the migration. If we understand all the +subsections, then we load the state with success. There's no check +that an optional subsection is loaded, so a newer QEMU that knows +about a subsection can (with care) load a stream from an older QEMU +that didn't send the subsection. =20 If the new data is only needed in a rare case, then the subsection can be made conditional on that case and the migration will still --=20 2.41.0