From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4F6D0CA0EFA for ; Thu, 21 Aug 2025 08:50:59 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1up0xv-0006hw-Nw; Thu, 21 Aug 2025 04:48:12 -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 1up0wV-0003wr-1z for qemu-devel@nongnu.org; Thu, 21 Aug 2025 04:46:51 -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 1up0wK-0001BL-R0 for qemu-devel@nongnu.org; Thu, 21 Aug 2025 04:46:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1755765989; 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=OM/kWFiWAteN4H2dnQA9jukvzVu2v/XF/Qvft6AxrV4=; b=VgmcK3WEuFCHxi+lSu+Y5tKleVH53sQsLByZFS3jxnN+WDjOCsGEXWEkjAsUvGUoMoGPYE Cfg1hULh1eQk3jFlx8WT5YuQNzxeytikWUmPl8HFRJAf3LkxSZevjqy+De3MKPjpFUXRWN LywG6qSv9ILqPDcDAwMqGBxRioYcd1I= Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-316-UJIPQfpsNmiy-zXTdy85sQ-1; Thu, 21 Aug 2025 04:46:25 -0400 X-MC-Unique: UJIPQfpsNmiy-zXTdy85sQ-1 X-Mimecast-MFC-AGG-ID: UJIPQfpsNmiy-zXTdy85sQ_1755765984 Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-245fd2b644eso14290535ad.3 for ; Thu, 21 Aug 2025 01:46:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755765984; x=1756370784; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OM/kWFiWAteN4H2dnQA9jukvzVu2v/XF/Qvft6AxrV4=; b=UGLEb1Yilqs4IwdxTe24OYLGe9UlpSPpnEz34SPlosB2PPHVjKWM3m4pwF5hI0d3NJ 2MSmeBzXRGdqCsf8IFh+mY3dzJx/M7mGJBsTlcfiYKJvyCYfFeFOSd//cZPaeFgsp3H9 ucEE+xvqqHojztQogc8vf9Cu5SKW4KujuC5AJH87KKR7lXES/+VpD68f01ow051YdEu2 oL8Ldp9zfMia/wm7hQE4mHYJaYw/1MnA+inkwEx4t/qpVnbWPe+/QgytHCdHkne0CejM dzdKESsp3wK0qvtys7z6DpuHEnRwXuBHj7konokwFbsvwIv853ZIfQECKc4YYBGMVIlp n88g== X-Gm-Message-State: AOJu0YzpCZU8IIWODdEhMND6ySKSOxA0vUh6C2OrXHb/uwT3l79FEJc5 vI/j3t33FTooy92lhjkGiRhTOf6NpI3vQ7zrk0mmx4bMMgbWAeX4qqmft6S/M9pDd1oaM5iN8U/ rXlqDUN/A7g1VOwhCrHbKoC+zgSt2Er8XCxIeq9xYu8hLztDf7IxrurUI X-Gm-Gg: ASbGncsPuMwWAxkx+sn9VRnTrCT5oHOAbKLpnMQtXOYFAFi30HRzHtiCdLvPVXmlboh oxmzNHZTddCXfVM+TSJc6GGVhjuGg+6yI7KjTSD3lcUuq+5eLzGoG/zyqhxmqJWm/RD4nXyD+ax vUSdO1Ch4qBKV5QKZqfTKNacK61K4BrAkCHxDS1JmeZHAZKqyjomoCRR7mvN8c/Ac0S9Rg9Ceuo r9HrSZCi/ALDINW678UxedXH+Mv2jnsoQxU0gtfgKxrixBDUjBp619vtzsotlPrc+cRWammNMpF WMgeC+XIewVgUqaoIdLA729X7DZEzHYWPF8Es/g11e1G/gZdEI5A X-Received: by 2002:a17:902:c946:b0:244:9bcf:a8ef with SMTP id d9443c01a7336-245febecc4fmr21331925ad.18.1755765983941; Thu, 21 Aug 2025 01:46:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFyVoFhqFxrrqH4kAGaA4aG0dKVMCBrPwT+mWjIvE3tB1CKUbYkrrcGXuuH1rq4bG/X7WOGhQ== X-Received: by 2002:a17:902:c946:b0:244:9bcf:a8ef with SMTP id d9443c01a7336-245febecc4fmr21331545ad.18.1755765983532; Thu, 21 Aug 2025 01:46:23 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.47.192.65]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-245ed33e05dsm48789985ad.3.2025.08.21.01.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Aug 2025 01:46:23 -0700 (PDT) From: Arun Menon Date: Thu, 21 Aug 2025 14:14:04 +0530 Subject: [PATCH v12 10/27] migration: push Error **errp into qemu_loadvm_section_start_full() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20250821-propagate_tpm_error-v12-10-72b803e707dc@redhat.com> References: <20250821-propagate_tpm_error-v12-0-72b803e707dc@redhat.com> In-Reply-To: <20250821-propagate_tpm_error-v12-0-72b803e707dc@redhat.com> To: qemu-devel@nongnu.org Cc: Peter Xu , Fabiano Rosas , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Thomas Huth , Christian Borntraeger , Matthew Rosato , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Nicholas Piggin , Harsh Prateek Bora , Paolo Bonzini , Fam Zheng , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Steve Sistare , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Hailiang Zhang , Stefan Berger , Peter Maydell , qemu-arm@nongnu.org, Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4751; i=armenon@redhat.com; h=from:subject:message-id; bh=B27j4MbJiuGOwzuroJ8FiCe/MPorYG30oeFl9vBiziU=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ8ayO8kn383ibrunn/J0e/zJE2XKzME571SmzWpM5/x0g y3R87FqRykLgxgXg6yYIkvD1wDZpoDCiEjbl9dh5rAygQxh4OIUgImcKmH47/P2F8+9h8lb0i8e Yjx9Y/7JrqOVXnHr9qdNszQUOT1xdzcjw65DQhG1LRETtY1V7zcc29Gi8/ppo9mUeepJ5qb5Dx0 WsAAA X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E Received-SPF: pass client-ip=170.10.133.124; envelope-from=armenon@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_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This is an incremental step in converting vmstate loading code to report error via Error objects instead of directly printing it to console/monitor. It is ensured that qemu_loadvm_section_start_full() must report an error in errp, in case of failure. Reviewed-by: Marc-André Lureau Signed-off-by: Arun Menon --- migration/savevm.c | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 69222339e17a5320b64de2709504b2ad2cd584ba..b55adb7468e5356ecb636734241f1a356a42a284 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2722,21 +2722,21 @@ static bool check_section_footer(QEMUFile *f, SaveStateEntry *se) } static int -qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) +qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type, Error **errp) { + ERRP_GUARD(); bool trace_downtime = (type == QEMU_VM_SECTION_FULL); uint32_t instance_id, version_id, section_id; int64_t start_ts, end_ts; SaveStateEntry *se; char idstr[256]; int ret; - Error *local_err = NULL; /* Read section start */ section_id = qemu_get_be32(f); if (!qemu_get_counted_string(f, idstr)) { - error_report("Unable to read ID string for section %u", - section_id); + error_setg(errp, "Unable to read ID string for section %u", + section_id); return -EINVAL; } instance_id = qemu_get_be32(f); @@ -2744,8 +2744,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) ret = qemu_file_get_error(f); if (ret) { - error_report("%s: Failed to read instance/version ID: %d", - __func__, ret); + error_setg(errp, "Failed to read instance/version ID: %d", ret); return ret; } @@ -2754,17 +2753,17 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) /* Find savevm section */ se = find_se(idstr, instance_id); if (se == NULL) { - error_report("Unknown savevm section or instance '%s' %"PRIu32". " - "Make sure that your current VM setup matches your " - "saved VM setup, including any hotplugged devices", - idstr, instance_id); + error_setg(errp, "Unknown section or instance '%s' %"PRIu32". " + "Make sure that your current VM setup matches your " + "saved VM setup, including any hotplugged devices", + idstr, instance_id); return -EINVAL; } /* Validate version */ if (version_id > se->version_id) { - error_report("savevm: unsupported version %d for '%s' v%d", - version_id, idstr, se->version_id); + error_setg(errp, "unsupported version %d for '%s' v%d", + version_id, idstr, se->version_id); return -EINVAL; } se->load_version_id = version_id; @@ -2772,7 +2771,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) /* Validate if it is a device's state */ if (xen_enabled() && se->is_ram) { - error_report("loadvm: %s RAM loading not allowed on Xen", idstr); + error_setg(errp, "loadvm: %s RAM loading not allowed on Xen", idstr); return -EINVAL; } @@ -2780,11 +2779,11 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) start_ts = qemu_clock_get_us(QEMU_CLOCK_REALTIME); } - ret = vmstate_load(f, se, &local_err); + ret = vmstate_load(f, se, errp); if (ret < 0) { - error_report("error while loading state for instance 0x%"PRIx32" of" - " device '%s'", instance_id, idstr); - warn_report_err(local_err); + error_prepend(errp, + "error while loading state for instance 0x%"PRIx32" of" + " device '%s': ", instance_id, idstr); return ret; } @@ -2795,6 +2794,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) } if (!check_section_footer(f, se)) { + error_setg(errp, "Section footer error, section_id: %d", + section_id); return -EINVAL; } @@ -3102,7 +3103,7 @@ retry: switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: - ret = qemu_loadvm_section_start_full(f, section_type); + ret = qemu_loadvm_section_start_full(f, section_type, errp); if (ret < 0) { goto out; } -- 2.50.1