From nobody Sat Nov 15 14:51:56 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750768011; cv=none; d=zohomail.com; s=zohoarc; b=jolnVQ2sUC3z3Oju4f8C9Jy9TNKXJ4jhryzrkiSZ6jqZhuxIPLXo3flK6ZfpVmL7ZlBkh9kPNNSR7gNsbyUa2SkHPuWyQTjY4uD5RukNs0HnInPQECyESx26bwUcIbGuOGr9Yqb4sYclonwC8/e1WxsXDdUXNIdXrRPhPgo3Yg8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750768011; 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=lhdFWiErjT9r4AqqPDxcy25amxPoQ0fte4AlUvRNOgo=; b=k1ep4isjgAGX1g2mEOm4aGgob2+uZZmmEarSDv0O5QsC9TYqsJbtzlO/aQbKlwlWNXvcCw5J8sEa5aNWvs+zdv+iWyLffaZ0jQH26fATSSonX5PhnonZtEtCXE8XBOJonYsin2JA3bM/WEonWHJw4hmRZXn1dreJqk3Vr6bJJy0= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750768011027381.5396974720113; Tue, 24 Jun 2025 05:26:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uU2iE-0001EJ-Gh; Tue, 24 Jun 2025 08:25: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 1uU2iA-0001DP-5H for qemu-devel@nongnu.org; Tue, 24 Jun 2025 08:25:14 -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 1uU2i0-0001sy-Nb for qemu-devel@nongnu.org; Tue, 24 Jun 2025 08:25:13 -0400 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-296-lYhaMSRyPp6G5FxlLrtRRw-1; Tue, 24 Jun 2025 08:23:43 -0400 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-74858256d38so4374348b3a.2 for ; Tue, 24 Jun 2025 05:23:43 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.103.251]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-749c882cc5fsm1772091b3a.73.2025.06.24.05.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jun 2025 05:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750767902; 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=lhdFWiErjT9r4AqqPDxcy25amxPoQ0fte4AlUvRNOgo=; b=Vc/dx8zAzMyYvSTuP1FS1lrmh/HDsp9TMuO2a98gDhTlRGk2pyTFxmAWKEhcfm7S6gg1fA K9CkP8QxNabODK04vJzI0wKSdZ7zN6zpmjzw6TbhynXD8ND2zubdoM5raC/gQ3IIRYeGFL 6Yo/btT6FoUKuRuoHRuF4BWwBDe0rTA= X-MC-Unique: lYhaMSRyPp6G5FxlLrtRRw-1 X-Mimecast-MFC-AGG-ID: lYhaMSRyPp6G5FxlLrtRRw_1750767822 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750767822; x=1751372622; 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=lhdFWiErjT9r4AqqPDxcy25amxPoQ0fte4AlUvRNOgo=; b=pWQMBmIuc1IUIgW3OpQ9LN2xnrztRRojsTFIeWpsdAVWJ2GjTIEW1by0uEf/Zt3VAh cAkXtG3WC4YBrwWzCd8dg2fpU7qE9zDEUSteofjlIs9wHCp+B3tzc69LYIurNx36qrPc 5xSzJDgzKNZx/kMBkNlE3Uc/rSR2nPdEI/bxnxFa9vgItavWm+r6LJrWG69cZjcPMfgI KF0G7L+YBpsA6BM0o8GR1R7P3Fueq4cD1Dr2OVRQZ5s2HJOjpsDyQCK/0jZQkAdonRn5 dc+X974MjJOq64LuTRLgxr2hkHTfBhfPeQ5hZW4LOgnv0fFvun/c6pdQya4j+iOQ5kUy 5vEg== X-Gm-Message-State: AOJu0YwCsq3Hme4230VyjeEA+soTXK/S+w67DGZNTNdim6yTCQIaQzw6 dJ0KqnQmmCjS9zW5a8mGUK7mHdDiX+gzM/dkALqZ4Sw2kmoFl+XNvDMZbOX0Zv+3Y9Yq4RHAmYF U0f9QbJaWOdLGbGG89nGZvP//SjCCFcBYAqgMUHli45FWa1/VcmXnX0QK X-Gm-Gg: ASbGncsgM2MT87MPwpAXAmIf0XFTDjeana02aUcgxk5aUdZPz0zGzyVfVAuo0TN0rpw 9e+2BMbHEr0gIXCfMi/dSibzuIlDfPPniHrliYtbH+7+r2RTJRDDJt9wVt0uoIBUYg1AhavFXbA I5ezAPWurmztG5rlO4kPjSOiE3csFhoTJj0tzJhJ/TA3dTSB5USJTWnlKIdNtzCDMaK8S0YoIk8 O/wGTUhvKR6qR2UHLW1wJlEZGk+AhexOL9F3MxuRwkfcXZBmntq6Nu+dU0JeWPM46QGUMtjwrde V1JcaHthbWAxnXTEE0LYNrPMUKm5NusYeece X-Received: by 2002:a05:6a21:6011:b0:1ee:a914:1d67 with SMTP id adf61e73a8af0-22026e6572emr23860951637.2.1750767822162; Tue, 24 Jun 2025 05:23:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJz+VxT7hrh1Mquxb3RSDDnHP3g0ET0RajX4Xhwlau2Qk0qD1P1NZzcfAveI3ZMg7KhNLT9Q== X-Received: by 2002:a05:6a21:6011:b0:1ee:a914:1d67 with SMTP id adf61e73a8af0-22026e6572emr23860880637.2.1750767821658; Tue, 24 Jun 2025 05:23:41 -0700 (PDT) From: Arun Menon Date: Tue, 24 Jun 2025 17:53:04 +0530 Subject: [PATCH 1/3] migration: Pass error object to report it to the caller MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250624-propagate_tpm_error-v1-1-2171487a593d@redhat.com> References: <20250624-propagate_tpm_error-v1-0-2171487a593d@redhat.com> In-Reply-To: <20250624-propagate_tpm_error-v1-0-2171487a593d@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Christian Borntraeger , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Paolo Bonzini , Fam Zheng , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Xu , Fabiano Rosas , Hailiang Zhang , Steve Sistare , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Stefan Berger , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=26733; i=armenon@redhat.com; h=from:subject:message-id; bh=ihadx744Sb5jKRVb8PIYHpD6YwouYDwAR/FB59WCZTY=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0bUjH0pthu/8uzL/G710Ceuk2WN5aycKbqf//31MP68N 58l8E1hRykLgxgXg6yYIkvD1wDZpoDCiEjbl9dh5rAygQxh4OIUgIl8bmNkWJt2TfO2cOnl825R KmoO85TMjyUxtrQX9S7X+H9u5yvF3Qz/QxbcWi2zval/kehK3axNWVIMByWiA9vTd+uwWfzbMvk VEwA= X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E 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=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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1750768013268116600 - This is an incremental step in converting vmstate loading code to report errors. - Minimal changes to the signature and body of the following functions are done, - vmstate_load() - vmstate_load_state() - vmstate_subsection_load() - qemu_load_device_state() - qemu_loadvm_state() - qemu_loadvm_section_start_full() - qemu_loadvm_section_part_end() - qemu_loadvm_state_header() - qemu_loadvm_state_main() Signed-off-by: Arun Menon --- hw/display/virtio-gpu.c | 2 +- hw/pci/pci.c | 2 +- hw/s390x/virtio-ccw.c | 2 +- hw/scsi/spapr_vscsi.c | 2 +- hw/vfio/pci.c | 2 +- hw/virtio/virtio-mmio.c | 2 +- hw/virtio/virtio-pci.c | 2 +- hw/virtio/virtio.c | 4 ++-- include/migration/vmstate.h | 2 +- migration/colo.c | 4 ++-- migration/cpr.c | 2 +- migration/migration.c | 2 +- migration/savevm.c | 52 +++++++++++++++++++++++------------------= ---- migration/savevm.h | 7 +++--- migration/vmstate-types.c | 10 ++++----- migration/vmstate.c | 16 ++++++++------ tests/unit/test-vmstate.c | 18 ++++++++-------- 17 files changed, 68 insertions(+), 63 deletions(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 0a1a625b0ea6cf26cb0d799171a57ed3d3ab2442..5d2ca8d8b864350133a674802d7= 316abd379591c 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -1343,7 +1343,7 @@ static int virtio_gpu_load(QEMUFile *f, void *opaque,= size_t size, } =20 /* load & apply scanout state */ - vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1); + vmstate_load_state(f, &vmstate_virtio_gpu_scanouts, g, 1, NULL); =20 return 0; } diff --git a/hw/pci/pci.c b/hw/pci/pci.c index c70b5ceebaf1f2b10768bd030526cbb518da2b8d..2ab5d30bb3c319ac1c7bfc9a2ac= f6a2b38082066 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -934,7 +934,7 @@ void pci_device_save(PCIDevice *s, QEMUFile *f) int pci_device_load(PCIDevice *s, QEMUFile *f) { int ret; - ret =3D vmstate_load_state(f, &vmstate_pci_device, s, s->version_id); + ret =3D vmstate_load_state(f, &vmstate_pci_device, s, s->version_id, N= ULL); /* Restore the interrupt status bit. */ pci_update_irq_status(s); return ret; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index d2f85b39f30f7fc82e0c600144c0a958e1269b2c..2f6feff2b0a22d7d7f6aecfd7e7= 870d8362f1a73 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1136,7 +1136,7 @@ static void virtio_ccw_save_config(DeviceState *d, QE= MUFile *f) static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) { VirtioCcwDevice *dev =3D VIRTIO_CCW_DEVICE(d); - return vmstate_load_state(f, &vmstate_virtio_ccw_dev, dev, 1); + return vmstate_load_state(f, &vmstate_virtio_ccw_dev, dev, 1, NULL); } =20 static void virtio_ccw_pre_plugged(DeviceState *d, Error **errp) diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c index 20f70fb2729de78b9636a6b8c869695dab4f8902..573fdea668536b464bca11f001e= 9e0288e781493 100644 --- a/hw/scsi/spapr_vscsi.c +++ b/hw/scsi/spapr_vscsi.c @@ -648,7 +648,7 @@ static void *vscsi_load_request(QEMUFile *f, SCSIReques= t *sreq) assert(!req->active); =20 memset(req, 0, sizeof(*req)); - rc =3D vmstate_load_state(f, &vmstate_spapr_vscsi_req, req, 1); + rc =3D vmstate_load_state(f, &vmstate_spapr_vscsi_req, req, 1, NULL); if (rc) { fprintf(stderr, "VSCSI: failed loading request tag#%u\n", sreq->ta= g); return NULL; diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index fa25bded25c51f8efb6c5ad31bd90506cd69745c..87aee0a5701087f9a68ea435bb9= 6e9d6b07b0c24 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2715,7 +2715,7 @@ static int vfio_pci_load_config(VFIODevice *vbasedev,= QEMUFile *f) old_addr[bar] =3D pdev->io_regions[bar].addr; } =20 - ret =3D vmstate_load_state(f, &vmstate_vfio_pci_config, vdev, 1); + ret =3D vmstate_load_state(f, &vmstate_vfio_pci_config, vdev, 1, NULL); if (ret) { return ret; } diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c index 532c67107ba1d2978a76cf49f9cdc1de1dea3e11..9058b1563462d4464dcba799643= a583c93fb5683 100644 --- a/hw/virtio/virtio-mmio.c +++ b/hw/virtio/virtio-mmio.c @@ -619,7 +619,7 @@ static int virtio_mmio_load_extra_state(DeviceState *op= aque, QEMUFile *f) { VirtIOMMIOProxy *proxy =3D VIRTIO_MMIO(opaque); =20 - return vmstate_load_state(f, &vmstate_virtio_mmio, proxy, 1); + return vmstate_load_state(f, &vmstate_virtio_mmio, proxy, 1, NULL); } =20 static bool virtio_mmio_has_extra_state(DeviceState *opaque) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index fba2372c93bfd648736b07e4bc83e7097baa58cb..50a1f5701754b88e8a1ee062d6e= eedfd848cb4f5 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -160,7 +160,7 @@ static int virtio_pci_load_extra_state(DeviceState *d, = QEMUFile *f) { VirtIOPCIProxy *proxy =3D to_virtio_pci_proxy(d); =20 - return vmstate_load_state(f, &vmstate_virtio_pci, proxy, 1); + return vmstate_load_state(f, &vmstate_virtio_pci, proxy, 1, NULL); } =20 static void virtio_pci_save_queue(DeviceState *d, int n, QEMUFile *f) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 82a285a31d1c0427d55f7cb73398adfc94e678fe..66d5941f68a4b9e1e5390bb0aa4= 5fc6cd34e2a1e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3317,14 +3317,14 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ve= rsion_id) } =20 if (vdc->vmsd) { - ret =3D vmstate_load_state(f, vdc->vmsd, vdev, version_id); + ret =3D vmstate_load_state(f, vdc->vmsd, vdev, version_id, NULL); if (ret) { return ret; } } =20 /* Subsections */ - ret =3D vmstate_load_state(f, &vmstate_virtio, vdev, 1); + ret =3D vmstate_load_state(f, &vmstate_virtio, vdev, 1, NULL); if (ret) { return ret; } diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 1ff7bd9ac425ba67cd5ca7ad97bcf570f9e19abe..056781b1c21e737583f081594d9= f88b32adfd674 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1196,7 +1196,7 @@ extern const VMStateInfo vmstate_info_qlist; } =20 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, int version_id); + void *opaque, int version_id, Error **errp); int vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd, void *opaque, JSONWriter *vmdesc); int vmstate_save_state_with_err(QEMUFile *f, const VMStateDescription *vms= d, diff --git a/migration/colo.c b/migration/colo.c index e0f713c837f5da25d67afbd02ceb6c54024ca3af..c7779683f0aad33cd071030ac55= 3da69d6a5e60d 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -686,7 +686,7 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, =20 bql_lock(); cpu_synchronize_all_states(); - ret =3D qemu_loadvm_state_main(mis->from_src_file, mis); + ret =3D qemu_loadvm_state_main(mis->from_src_file, mis, &local_err); bql_unlock(); =20 if (ret < 0) { @@ -729,7 +729,7 @@ static void colo_incoming_process_checkpoint(MigrationI= ncomingState *mis, bql_lock(); vmstate_loading =3D true; colo_flush_ram_cache(); - ret =3D qemu_load_device_state(fb); + ret =3D qemu_load_device_state(fb, &local_err); if (ret < 0) { error_setg(errp, "COLO: load device state failed"); vmstate_loading =3D false; diff --git a/migration/cpr.c b/migration/cpr.c index a50a57edca754b50e68fa9c294b3c89791e62ba8..0fb9fadac905c83689eed2b1193= b282da679b6ef 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -235,7 +235,7 @@ int cpr_state_load(MigrationChannel *channel, Error **e= rrp) return -ENOTSUP; } =20 - ret =3D vmstate_load_state(f, &vmstate_cpr_state, &cpr_state, 1); + ret =3D vmstate_load_state(f, &vmstate_cpr_state, &cpr_state, 1, errp); if (ret) { error_setg(errp, "vmstate_load_state error %d", ret); qemu_fclose(f); diff --git a/migration/migration.c b/migration/migration.c index 4098870bce33ffdc57b5972fc5b106d88abb237e..5cabb4e7307323159241ff35781= db7f1c665a75b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -876,7 +876,7 @@ process_incoming_migration_co(void *opaque) MIGRATION_STATUS_ACTIVE); =20 mis->loadvm_co =3D qemu_coroutine_self(); - ret =3D qemu_loadvm_state(mis->from_src_file); + ret =3D qemu_loadvm_state(mis->from_src_file, &local_err); mis->loadvm_co =3D NULL; =20 trace_vmstate_downtime_checkpoint("dst-precopy-loadvm-completed"); diff --git a/migration/savevm.c b/migration/savevm.c index bb04a4520df9a443d90cf6cb52a383a5f053aaff..9bcc0935781b73e209dc57945f9= dbb381283cad5 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -963,13 +963,14 @@ void vmstate_unregister(VMStateIf *obj, const VMState= Description *vmsd, } } =20 -static int vmstate_load(QEMUFile *f, SaveStateEntry *se) +static int vmstate_load(QEMUFile *f, SaveStateEntry *se, Error **errp) { trace_vmstate_load(se->idstr, se->vmsd ? se->vmsd->name : "(old)"); if (!se->vmsd) { /* Old style */ return se->ops->load_state(f, se->opaque, se->load_version_id); } - return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id= ); + return vmstate_load_state(f, se->vmsd, se->opaque, se->load_version_id, + errp); } =20 static void vmstate_save_old_style(QEMUFile *f, SaveStateEntry *se, @@ -2071,6 +2072,7 @@ static void *postcopy_ram_listen_thread(void *opaque) { MigrationIncomingState *mis =3D migration_incoming_get_current(); QEMUFile *f =3D mis->from_src_file; + Error *local_err =3D NULL; int load_res; MigrationState *migr =3D migrate_get_current(); =20 @@ -2089,7 +2091,7 @@ static void *postcopy_ram_listen_thread(void *opaque) qemu_file_set_blocking(f, true); =20 /* TODO: sanity check that only postcopiable data will be loaded here = */ - load_res =3D qemu_loadvm_state_main(f, mis); + load_res =3D qemu_loadvm_state_main(f, mis, &local_err); =20 /* * This is tricky, but, mis->from_src_file can change after it @@ -2394,6 +2396,7 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis) int ret; size_t length; QIOChannelBuffer *bioc; + Error *local_error; =20 length =3D qemu_get_be32(mis->from_src_file); trace_loadvm_handle_cmd_packaged(length); @@ -2440,7 +2443,7 @@ static int loadvm_handle_cmd_packaged(MigrationIncomi= ngState *mis) qemu_coroutine_yield(); } while (1); =20 - ret =3D qemu_loadvm_state_main(packf, mis); + ret =3D qemu_loadvm_state_main(packf, mis, &local_error); trace_loadvm_handle_cmd_packaged_main(ret); qemu_fclose(packf); object_unref(OBJECT(bioc)); @@ -2674,7 +2677,7 @@ static bool check_section_footer(QEMUFile *f, SaveSta= teEntry *se) } =20 static int -qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type) +qemu_loadvm_section_start_full(QEMUFile *f, uint8_t type, Error **errp) { bool trace_downtime =3D (type =3D=3D QEMU_VM_SECTION_FULL); uint32_t instance_id, version_id, section_id; @@ -2731,7 +2734,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype) start_ts =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); } =20 - ret =3D vmstate_load(f, se); + ret =3D vmstate_load(f, se, errp); if (ret < 0) { error_report("error while loading state for instance 0x%"PRIx32" o= f" " device '%s'", instance_id, idstr); @@ -2752,7 +2755,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype) } =20 static int -qemu_loadvm_section_part_end(QEMUFile *f, uint8_t type) +qemu_loadvm_section_part_end(QEMUFile *f, uint8_t type, Error **errp) { bool trace_downtime =3D (type =3D=3D QEMU_VM_SECTION_END); int64_t start_ts, end_ts; @@ -2784,7 +2787,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e) start_ts =3D qemu_clock_get_us(QEMU_CLOCK_REALTIME); } =20 - ret =3D vmstate_load(f, se); + ret =3D vmstate_load(f, se, errp); if (ret < 0) { error_report("error while loading state section id %d(%s)", section_id, se->idstr); @@ -2804,7 +2807,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e) return 0; } =20 -static int qemu_loadvm_state_header(QEMUFile *f) +static int qemu_loadvm_state_header(QEMUFile *f, Error **errp) { unsigned int v; int ret; @@ -2830,7 +2833,8 @@ static int qemu_loadvm_state_header(QEMUFile *f) error_report("Configuration section missing"); return -EINVAL; } - ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0); + ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0, + errp); =20 if (ret) { return ret; @@ -3019,7 +3023,8 @@ static bool postcopy_pause_incoming(MigrationIncoming= State *mis) return true; } =20 -int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis) +int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, + Error **errp) { uint8_t section_type; int ret =3D 0; @@ -3037,14 +3042,14 @@ retry: switch (section_type) { case QEMU_VM_SECTION_START: case QEMU_VM_SECTION_FULL: - ret =3D qemu_loadvm_section_start_full(f, section_type); + ret =3D qemu_loadvm_section_start_full(f, section_type, errp); if (ret < 0) { goto out; } break; case QEMU_VM_SECTION_PART: case QEMU_VM_SECTION_END: - ret =3D qemu_loadvm_section_part_end(f, section_type); + ret =3D qemu_loadvm_section_part_end(f, section_type, errp); if (ret < 0) { goto out; } @@ -3094,27 +3099,24 @@ out: return ret; } =20 -int qemu_loadvm_state(QEMUFile *f) +int qemu_loadvm_state(QEMUFile *f, Error **errp) { MigrationState *s =3D migrate_get_current(); MigrationIncomingState *mis =3D migration_incoming_get_current(); - Error *local_err =3D NULL; int ret; =20 - if (qemu_savevm_state_blocked(&local_err)) { - error_report_err(local_err); + if (qemu_savevm_state_blocked(errp)) { return -EINVAL; } =20 qemu_loadvm_thread_pool_create(mis); =20 - ret =3D qemu_loadvm_state_header(f); + ret =3D qemu_loadvm_state_header(f, errp); if (ret) { return ret; } =20 - if (qemu_loadvm_state_setup(f, &local_err) !=3D 0) { - error_report_err(local_err); + if (qemu_loadvm_state_setup(f, errp) !=3D 0) { return -EINVAL; } =20 @@ -3124,7 +3126,7 @@ int qemu_loadvm_state(QEMUFile *f) =20 cpu_synchronize_all_pre_loadvm(); =20 - ret =3D qemu_loadvm_state_main(f, mis); + ret =3D qemu_loadvm_state_main(f, mis, errp); qemu_event_set(&mis->main_thread_load_event); =20 trace_qemu_loadvm_state_post_main(ret); @@ -3192,13 +3194,13 @@ int qemu_loadvm_state(QEMUFile *f) return ret; } =20 -int qemu_load_device_state(QEMUFile *f) +int qemu_load_device_state(QEMUFile *f, Error **errp) { MigrationIncomingState *mis =3D migration_incoming_get_current(); int ret; =20 /* Load QEMU_VM_SECTION_FULL section */ - ret =3D qemu_loadvm_state_main(f, mis); + ret =3D qemu_loadvm_state_main(f, mis, errp); if (ret < 0) { error_report("Failed to load device state: %d", ret); return ret; @@ -3429,7 +3431,7 @@ void qmp_xen_load_devices_state(const char *filename,= Error **errp) f =3D qemu_file_new_input(QIO_CHANNEL(ioc)); object_unref(OBJECT(ioc)); =20 - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(f, errp); qemu_fclose(f); if (ret < 0) { error_setg(errp, "loading Xen device state failed"); @@ -3503,7 +3505,7 @@ bool load_snapshot(const char *name, const char *vmst= ate, ret =3D -EINVAL; goto err_drain; } - ret =3D qemu_loadvm_state(f); + ret =3D qemu_loadvm_state(f, errp); migration_incoming_state_destroy(); =20 bdrv_drain_all_end(); diff --git a/migration/savevm.h b/migration/savevm.h index 2d5e9c716686f06720325e82fe90c75335ced1de..c337e3e3d111a7f28a57b90f61e= 8f70b71803d4e 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -64,10 +64,11 @@ void qemu_savevm_send_colo_enable(QEMUFile *f); void qemu_savevm_live_state(QEMUFile *f); int qemu_save_device_state(QEMUFile *f); =20 -int qemu_loadvm_state(QEMUFile *f); +int qemu_loadvm_state(QEMUFile *f, Error **errp); void qemu_loadvm_state_cleanup(MigrationIncomingState *mis); -int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); -int qemu_load_device_state(QEMUFile *f); +int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis, + Error **errp); +int qemu_load_device_state(QEMUFile *f, Error **errp); int qemu_loadvm_approve_switchover(void); int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, bool in_postcopy); diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 741a588b7e18c6d37724b08a0101edc8bc74a0a5..1c5b76e1dd198030847971bc356= 37867c9d54fc0 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -549,7 +549,7 @@ static int get_tmp(QEMUFile *f, void *pv, size_t size, =20 /* Writes the parent field which is at the start of the tmp */ *(void **)tmp =3D pv; - ret =3D vmstate_load_state(f, vmsd, tmp, version_id); + ret =3D vmstate_load_state(f, vmsd, tmp, version_id, NULL); g_free(tmp); return ret; } @@ -649,7 +649,7 @@ static int get_qtailq(QEMUFile *f, void *pv, size_t unu= sed_size, =20 while (qemu_get_byte(f)) { elm =3D g_malloc(size); - ret =3D vmstate_load_state(f, vmsd, elm, version_id); + ret =3D vmstate_load_state(f, vmsd, elm, version_id, NULL); if (ret) { return ret; } @@ -803,7 +803,7 @@ static int get_gtree(QEMUFile *f, void *pv, size_t unus= ed_size, key =3D (void *)(uintptr_t)qemu_get_be64(f); } else { key =3D g_malloc0(key_size); - ret =3D vmstate_load_state(f, key_vmsd, key, version_id); + ret =3D vmstate_load_state(f, key_vmsd, key, version_id, NULL); if (ret) { error_report("%s : failed to load %s (%d)", field->name, key_vmsd->name, ret); @@ -811,7 +811,7 @@ static int get_gtree(QEMUFile *f, void *pv, size_t unus= ed_size, } } val =3D g_malloc0(val_size); - ret =3D vmstate_load_state(f, val_vmsd, val, version_id); + ret =3D vmstate_load_state(f, val_vmsd, val, version_id, NULL); if (ret) { error_report("%s : failed to load %s (%d)", field->name, val_vmsd->name, ret); @@ -892,7 +892,7 @@ static int get_qlist(QEMUFile *f, void *pv, size_t unus= ed_size, =20 while (qemu_get_byte(f)) { elm =3D g_malloc(size); - ret =3D vmstate_load_state(f, vmsd, elm, version_id); + ret =3D vmstate_load_state(f, vmsd, elm, version_id, NULL); if (ret) { error_report("%s: failed to load %s (%d)", field->name, vmsd->name, ret); diff --git a/migration/vmstate.c b/migration/vmstate.c index 5feaa3244d259874f03048326b2497e7db32e47c..177c563ff103ada2e494c14173f= a773d52adb800 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -25,7 +25,7 @@ static int vmstate_subsection_save(QEMUFile *f, const VMS= tateDescription *vmsd, void *opaque, JSONWriter *vmdesc, Error **errp); static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque); + void *opaque, Error **errp); =20 /* Whether this field should exist for either save or load the VM? */ static bool @@ -132,7 +132,7 @@ static void vmstate_handle_alloc(void *ptr, const VMSta= teField *field, } =20 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, - void *opaque, int version_id) + void *opaque, int version_id, Error **errp) { const VMStateField *field =3D vmsd->fields; int ret =3D 0; @@ -192,10 +192,12 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, =20 if (inner_field->flags & VMS_STRUCT) { ret =3D vmstate_load_state(f, inner_field->vmsd, curr_= elem, - inner_field->vmsd->version_id= ); + inner_field->vmsd->version_id, + errp); } else if (inner_field->flags & VMS_VSTRUCT) { ret =3D vmstate_load_state(f, inner_field->vmsd, curr_= elem, - inner_field->struct_version_i= d); + inner_field->struct_version_i= d, + errp); } else { ret =3D inner_field->info->get(f, curr_elem, size, inner_field); @@ -225,7 +227,7 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, field++; } assert(field->flags =3D=3D VMS_END); - ret =3D vmstate_subsection_load(f, vmsd, opaque); + ret =3D vmstate_subsection_load(f, vmsd, opaque, errp); if (ret !=3D 0) { qemu_file_set_error(f, ret); return ret; @@ -566,7 +568,7 @@ vmstate_get_subsection(const VMStateDescription * const= *sub, } =20 static int vmstate_subsection_load(QEMUFile *f, const VMStateDescription *= vmsd, - void *opaque) + void *opaque, Error **errp) { trace_vmstate_subsection_load(vmsd->name); =20 @@ -605,7 +607,7 @@ static int vmstate_subsection_load(QEMUFile *f, const V= MStateDescription *vmsd, qemu_file_skip(f, len); /* idstr */ version_id =3D qemu_get_be32(f); =20 - ret =3D vmstate_load_state(f, sub_vmsd, opaque, version_id); + ret =3D vmstate_load_state(f, sub_vmsd, opaque, version_id, errp); if (ret) { trace_vmstate_subsection_load_bad(vmsd->name, idstr, "(child)"= ); return ret; diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 63f28f26f45691a70936d33e7341d16477a3471f..ca5e0ba1e3e5e2bb0a1ce39143a= 292f2c6f9420a 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -114,7 +114,7 @@ static int load_vmstate_one(const VMStateDescription *d= esc, void *obj, qemu_fclose(f); =20 f =3D open_test_file(false); - ret =3D vmstate_load_state(f, desc, obj, version); + ret =3D vmstate_load_state(f, desc, obj, version, NULL); if (ret) { g_assert(qemu_file_get_error(f)); } else{ @@ -365,7 +365,7 @@ static void test_load_v1(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj =3D { .b =3D 200, .e =3D 500, .f =3D 600 }; - vmstate_load_state(loading, &vmstate_versioned, &obj, 1); + vmstate_load_state(loading, &vmstate_versioned, &obj, 1, NULL); g_assert(!qemu_file_get_error(loading)); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 200); @@ -391,7 +391,7 @@ static void test_load_v2(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj; - vmstate_load_state(loading, &vmstate_versioned, &obj, 2); + vmstate_load_state(loading, &vmstate_versioned, &obj, 2, NULL); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 20); g_assert_cmpint(obj.c, =3D=3D, 30); @@ -480,7 +480,7 @@ static void test_load_noskip(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj =3D { .skip_c_e =3D false }; - vmstate_load_state(loading, &vmstate_skipping, &obj, 2); + vmstate_load_state(loading, &vmstate_skipping, &obj, 2, NULL); g_assert(!qemu_file_get_error(loading)); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 20); @@ -504,7 +504,7 @@ static void test_load_skip(void) =20 QEMUFile *loading =3D open_test_file(false); TestStruct obj =3D { .skip_c_e =3D true, .c =3D 300, .e =3D 500 }; - vmstate_load_state(loading, &vmstate_skipping, &obj, 2); + vmstate_load_state(loading, &vmstate_skipping, &obj, 2, NULL); g_assert(!qemu_file_get_error(loading)); g_assert_cmpint(obj.a, =3D=3D, 10); g_assert_cmpint(obj.b, =3D=3D, 20); @@ -773,7 +773,7 @@ static void test_load_q(void) TestQtailq tgt; =20 QTAILQ_INIT(&tgt.q); - vmstate_load_state(fload, &vmstate_q, &tgt, 1); + vmstate_load_state(fload, &vmstate_q, &tgt, 1, NULL); char eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(tgt.i16, =3D=3D, obj_q.i16); @@ -1127,7 +1127,7 @@ static void test_gtree_load_domain(void) =20 fload =3D open_test_file(false); =20 - vmstate_load_state(fload, &vmstate_domain, dest_domain, 1); + vmstate_load_state(fload, &vmstate_domain, dest_domain, 1, NULL); eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(orig_domain->id, =3D=3D, dest_domain->id); @@ -1241,7 +1241,7 @@ static void test_gtree_load_iommu(void) qemu_fclose(fsave); =20 fload =3D open_test_file(false); - vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1); + vmstate_load_state(fload, &vmstate_iommu, dest_iommu, 1, NULL); eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(orig_iommu->id, =3D=3D, dest_iommu->id); @@ -1376,7 +1376,7 @@ static void test_load_qlist(void) qemu_fclose(fsave); =20 fload =3D open_test_file(false); - vmstate_load_state(fload, &vmstate_container, dest_container, 1); + vmstate_load_state(fload, &vmstate_container, dest_container, 1, NULL); eof =3D qemu_get_byte(fload); g_assert(!qemu_file_get_error(fload)); g_assert_cmpint(eof, =3D=3D, QEMU_VM_EOF); --=20 2.49.0 From nobody Sat Nov 15 14:51:56 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750768010; cv=none; d=zohomail.com; s=zohoarc; b=dRQKfwkewIg4MB3RJmnUUn7NZPs3QyX0SpmywKKNjKn3mcSsGXfUjoEBFsI72x3M82b5jgl9pqpt2dJLKDmkazjG4aCFdOoYvpprNbTp0LqNslRDovud4ikcXFWnvDJI+TDKZgdX5nvm0ZOxdqFJPbQB9R8MR2boJYLvASelC4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750768010; 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=L5amOI3Muxw9Bdaa//6DYAvpVb8Ztrhb/8eEIkO5kyU=; b=OWqKerUzVDvROAxT4pMhdVaNeFN2Ak1eAaR+MQ3o1cz3NL8d9lyHzQu09oTat3/6GGK0gY3gVof37vYD0TggtqR7MT5Hu2rjg4aKMVtk8uEaSXN+9ibI2M6EstR6EXf1pVBOxPZ5LOH7I66OcIwe1kxybO1C9n2853YBlgkZfmQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1750768010854896.0867803856423; Tue, 24 Jun 2025 05:26:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uU2iX-0001KL-RG; Tue, 24 Jun 2025 08:25:39 -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 1uU2iI-0001F5-BL for qemu-devel@nongnu.org; Tue, 24 Jun 2025 08:25:23 -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 1uU2i6-00025Y-Ot for qemu-devel@nongnu.org; Tue, 24 Jun 2025 08:25:22 -0400 Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-ezHct1MjNoK0swe30Y0B5g-1; Tue, 24 Jun 2025 08:23:50 -0400 Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-b2fdba7f818so6245061a12.2 for ; Tue, 24 Jun 2025 05:23:50 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.103.251]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-749c882cc5fsm1772091b3a.73.2025.06.24.05.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jun 2025 05:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750767909; 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=L5amOI3Muxw9Bdaa//6DYAvpVb8Ztrhb/8eEIkO5kyU=; b=XcOckgrK7h/EbOFTA6kVSf10ww+R7JR5XJLGP35tESRUa96TH3LhN0qPSxOiT5vsLZRW64 QAyqE7O4yW2ZfFZveY8ebhj4ncpdLGUcOixfNttKWBsIru53acvpZ644quB2OzecUZzhVm p3Vl2iJGpKx+8pQNTQfRwnK3+pFfHWQ= X-MC-Unique: ezHct1MjNoK0swe30Y0B5g-1 X-Mimecast-MFC-AGG-ID: ezHct1MjNoK0swe30Y0B5g_1750767830 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750767829; x=1751372629; 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=L5amOI3Muxw9Bdaa//6DYAvpVb8Ztrhb/8eEIkO5kyU=; b=f4NcDAJOxoLRbJGqj6slgWzdBkcPpxW5jvdMSwj5ibwfvynukqHcESmxz73mbieBoT 2DavtzDXMobQ6fauvs5JLe84nhd4Ym7EB+8TeC38CxEBQ56GE3Oy/j/9w0j+1EiCk9qx hUm/yALXLk3EkXYB3wEUZYw+1G1s8AChZO5qceJ+Ufsh52W+kv3FCHAHXotsj1rjplcy eaQAr/eMKlYEGepDI92gukvpzoS18W80i095A+jy9tPDK9zOZy1EMVu8E3erXnAMIdKw YSVGi7p8cWtXdqj1tJs9/M+CNurrdoFIy90QoiTLGEL6iEAfrZ/uz+A7Wn/Y14cb9fwT v2oQ== X-Gm-Message-State: AOJu0YzdhLudMfseagVaqsb1rSlhaxIGRIzrwAU0lfqE+McFp4SsYYo2 C9w+0t3lFRVvyumBxjLJ8y6EDFhOJT6eGt/kfyyxafY9S2yQNRvBbg7sg9v34BGH9vCNshVbkNW hOqoGARackYOoaeFgl6YPnMMQDsO24gSCvbQPSZTMsNPpCT7zleGpeOkz X-Gm-Gg: ASbGnctNsztgzU7GLD6n9RDMkVpPBf3KWKciO++kpzXnQk4PEvMCAPJcS9bPh4hxqS2 seYndUCpcKZw6r0VIJjkUj0yX7e7830zkrwSL232iJf6oYrftF99qpmdjJgkAxYMpKuVVr8DXsJ UvjvKgLWfsltddpu5c0qf3lHgHZP2J5F/06OlvVQC6bVgqLn2cSzYyOZbaKOkHt/10fz3jQkRz9 4tYUJtJH2jR2QfRPMWvpSGsqU8TWbh8YFD7Q+Zuro94pi/67ExRDHrp9vVt2yqZLIWGPBVTr/on jOItTYZuJkQ5t1/fr5+t5anWI0HMSf03jue/ X-Received: by 2002:a05:6a20:7350:b0:21f:62e7:cd2d with SMTP id adf61e73a8af0-22026ed2595mr28281786637.34.1750767829507; Tue, 24 Jun 2025 05:23:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH0qv/6EDiQ36RuMlJnajlMLohP38T43JWwblQEW5eEkg/Y9KE9bie9YbNem5eduY5FohGVEA== X-Received: by 2002:a05:6a20:7350:b0:21f:62e7:cd2d with SMTP id adf61e73a8af0-22026ed2595mr28281732637.34.1750767829133; Tue, 24 Jun 2025 05:23:49 -0700 (PDT) From: Arun Menon Date: Tue, 24 Jun 2025 17:53:05 +0530 Subject: [PATCH 2/3] migration: Use error_setg instead of error_report MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250624-propagate_tpm_error-v1-2-2171487a593d@redhat.com> References: <20250624-propagate_tpm_error-v1-0-2171487a593d@redhat.com> In-Reply-To: <20250624-propagate_tpm_error-v1-0-2171487a593d@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Christian Borntraeger , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Paolo Bonzini , Fam Zheng , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Xu , Fabiano Rosas , Hailiang Zhang , Steve Sistare , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Stefan Berger , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=9315; i=armenon@redhat.com; h=from:subject:message-id; bh=SkTmNBSbT3qZxSBqMViWO3dogsetGJdllcHBRy+niBU=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0bUjH0H3IJ6v5rs/JSyYferadJfnfcEzeZSaOL71qnNJ i17re5yRykLgxgXg6yYIkvD1wDZpoDCiEjbl9dh5rAygQxh4OIUgIkcjmL4K9Vm+WQ1W27h0elf xQLLktodck5Y+BS8DvyToWerP22qECPDH67Hld/+bJDNMvmZ0tHC1R82ff3lpeU6h2TcX8tJ67z gBAA= X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E 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=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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1750768012898116600 - This is an incremental step in converting vmstate loading code to report error via Error object. - error_report() has been replaced with error_setg(); and in places where error has been already set, error_prepend() is used to not lose information. Signed-off-by: Arun Menon --- migration/migration.c | 8 +++++++- migration/savevm.c | 56 ++++++++++++++++++++++++++++++++---------------= ---- migration/vmstate.c | 20 +++++++++--------- 3 files changed, 52 insertions(+), 32 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5cabb4e7307323159241ff35781db7f1c665a75b..86e16a284286928aedd47e65e77= 56d27e82e811c 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -903,7 +903,13 @@ process_incoming_migration_co(void *opaque) } =20 if (ret < 0) { - error_setg(&local_err, "load of migration failed: %s", strerror(-r= et)); + if (local_err) { + error_prepend(&local_err, "load of migration failed: %s: ", + strerror(-ret)); + } else { + error_setg(&local_err, "load of migration failed: %s", + strerror(-ret)); + } goto fail; } =20 diff --git a/migration/savevm.c b/migration/savevm.c index 9bcc0935781b73e209dc57945f9dbb381283cad5..dd7b722f51143eacdc621c343a1= 334e6056bb268 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2689,8 +2689,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype, Error **errp) /* Read section start */ section_id =3D 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 =3D qemu_get_be32(f); @@ -2698,8 +2698,8 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype, Error **errp) =20 ret =3D qemu_file_get_error(f); if (ret) { - error_report("%s: Failed to read instance/version ID: %d", - __func__, ret); + error_setg(errp, "%s: Failed to read instance/version ID: %d", + __func__, ret); return ret; } =20 @@ -2708,17 +2708,17 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t= type, Error **errp) /* Find savevm section */ se =3D find_se(idstr, instance_id); if (se =3D=3D 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 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); return -EINVAL; } =20 /* 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, "savevm: unsupported version %d for '%s' v%d", + version_id, idstr, se->version_id); return -EINVAL; } se->load_version_id =3D version_id; @@ -2726,7 +2726,7 @@ qemu_loadvm_section_start_full(QEMUFile *f, uint8_t t= ype, Error **errp) =20 /* 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", idst= r); return -EINVAL; } =20 @@ -2767,8 +2767,8 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e, Error **errp) =20 ret =3D qemu_file_get_error(f); if (ret) { - error_report("%s: Failed to read section ID: %d", - __func__, ret); + error_setg(errp, "%s: Failed to read section ID: %d", + __func__, ret); return ret; } =20 @@ -2779,7 +2779,7 @@ qemu_loadvm_section_part_end(QEMUFile *f, uint8_t typ= e, Error **errp) } } if (se =3D=3D NULL) { - error_report("Unknown savevm section %d", section_id); + error_setg(errp, "Unknown savevm section %d", section_id); return -EINVAL; } =20 @@ -2814,23 +2814,27 @@ static int qemu_loadvm_state_header(QEMUFile *f, Er= ror **errp) =20 v =3D qemu_get_be32(f); if (v !=3D QEMU_VM_FILE_MAGIC) { - error_report("Not a migration stream"); + error_setg(errp, "Not a migration stream magic %x !=3D %x", + v, QEMU_VM_FILE_MAGIC); return -EINVAL; } =20 v =3D qemu_get_be32(f); if (v =3D=3D QEMU_VM_FILE_VERSION_COMPAT) { - error_report("SaveVM v2 format is obsolete and don't work anymore"= ); + error_setg(errp, "SaveVM v2 format is obsolete and don't work anym= ore"); return -ENOTSUP; } if (v !=3D QEMU_VM_FILE_VERSION) { - error_report("Unsupported migration stream version"); + error_setg(errp, "Unsupported migration stream version %x !=3D %x", + v, QEMU_VM_FILE_VERSION); return -ENOTSUP; } =20 if (migrate_get_current()->send_configuration) { - if (qemu_get_byte(f) !=3D QEMU_VM_CONFIGURATION) { - error_report("Configuration section missing"); + v =3D qemu_get_byte(f); + if (v !=3D QEMU_VM_CONFIGURATION) { + error_setg(errp, "Configuration section missing, %x !=3D %x", + v, QEMU_VM_CONFIGURATION); return -EINVAL; } ret =3D vmstate_load_state(f, &vmstate_configuration, &savevm_stat= e, 0, @@ -3434,7 +3438,12 @@ void qmp_xen_load_devices_state(const char *filename= , Error **errp) ret =3D qemu_loadvm_state(f, errp); qemu_fclose(f); if (ret < 0) { - error_setg(errp, "loading Xen device state failed"); + if (*errp) { + ERRP_GUARD(); + error_prepend(errp, "loading Xen device state failed: "); + } else { + error_setg(errp, "loading Xen device state failed"); + } } migration_incoming_state_destroy(); } @@ -3511,7 +3520,12 @@ bool load_snapshot(const char *name, const char *vms= tate, bdrv_drain_all_end(); =20 if (ret < 0) { - error_setg(errp, "Error %d while loading VM state", ret); + if (*errp) { + ERRP_GUARD(); + error_prepend(errp, "Error %d while loading VM state: ", ret); + } else { + error_setg(errp, "Error %d while loading VM state", ret); + } return false; } =20 diff --git a/migration/vmstate.c b/migration/vmstate.c index 177c563ff103ada2e494c14173fa773d52adb800..3f8c3d3c1dcfe14d70bab1f43b8= 27244eb4bb385 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -139,16 +139,16 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, =20 trace_vmstate_load_state(vmsd->name, version_id); if (version_id > vmsd->version_id) { - error_report("%s: incoming version_id %d is too new " - "for local version_id %d", - vmsd->name, version_id, vmsd->version_id); + error_setg(errp, "%s: incoming version_id %d is too new " + "for local version_id %d", + vmsd->name, version_id, vmsd->version_id); trace_vmstate_load_state_end(vmsd->name, "too new", -EINVAL); return -EINVAL; } if (version_id < vmsd->minimum_version_id) { - error_report("%s: incoming version_id %d is too old " - "for local minimum version_id %d", - vmsd->name, version_id, vmsd->minimum_version_id); + error_setg(errp, "%s: incoming version_id %d is too old " + "for local minimum version_id %d", + vmsd->name, version_id, vmsd->minimum_version_id); trace_vmstate_load_state_end(vmsd->name, "too old", -EINVAL); return -EINVAL; } @@ -213,15 +213,15 @@ int vmstate_load_state(QEMUFile *f, const VMStateDesc= ription *vmsd, } if (ret < 0) { qemu_file_set_error(f, ret); - error_report("Failed to load %s:%s", vmsd->name, - field->name); + error_setg(errp, "Failed to load %s:%s", vmsd->name, + field->name); trace_vmstate_load_field_error(field->name, ret); return ret; } } } else if (field->flags & VMS_MUST_EXIST) { - error_report("Input validation failed: %s/%s", - vmsd->name, field->name); + error_setg(errp, "Input validation failed: %s/%s", + vmsd->name, field->name); return -1; } field++; --=20 2.49.0 From nobody Sat Nov 15 14:51:56 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1750768017; cv=none; d=zohomail.com; s=zohoarc; b=W5XyM/1cSReXV29nlzRZyMiQE310HW88FXYxAFeo0Pd1xHHBwVkL2aPyxGbmTljwpTgHNIxezzIMFWLqknm2Q8L+wYVjVJF3xSZWNNgY5a6yxY4yiDzQE+G5QZ4JWpJ1p69yADoLZk1vVaHHTigXnfl+S6X6LCyZiJbdJOpXMSE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750768017; 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=aoc2stLSbgQCmRzc5fPnLLeyQg1hKs3E5ePRLF2ciVs=; b=QKRqtThu3dFNSFe705j0y1cE27UEApfiqs3fFL7p2pG0ODC/7zH5YEZzJXOXKDICHYCwMFdR1QdHeQzJ9wrvvd6YPgWTfyez0vWsDC0Id1+mhmAW8IcKeT/bVpJenXk7HDLFP08VQIyzo209O18TWiVqxkY6LQ/wOiie1I8n030= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175076801759149.154997207584074; Tue, 24 Jun 2025 05:26:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uU2iN-0001Fa-Si; Tue, 24 Jun 2025 08:25:28 -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 1uU2iE-0001EV-9b for qemu-devel@nongnu.org; Tue, 24 Jun 2025 08:25: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 1uU2i4-00024j-5t for qemu-devel@nongnu.org; Tue, 24 Jun 2025 08:25:16 -0400 Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-xSZ9A43mPgyMw3a1VFddgg-1; Tue, 24 Jun 2025 08:23:57 -0400 Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-74928291bc3so368327b3a.0 for ; Tue, 24 Jun 2025 05:23:57 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.103.251]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-749c882cc5fsm1772091b3a.73.2025.06.24.05.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Jun 2025 05:23:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750767907; 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=aoc2stLSbgQCmRzc5fPnLLeyQg1hKs3E5ePRLF2ciVs=; b=eFs59hD9wo5N0XwnqpBeRNcRCI3J/c1YU+ueMaaHKIa0fDLQgY/Du8yIhE9essh49pzdff icpiiZEv2fy4GnNYwLxjncqdO1dd686KwfpRz54bR5ZhtepKPjMYakTRsm3FvoohPcBbT7 JS78mIVy/7ZZu2DtnjKdCQIRddbC+pQ= X-MC-Unique: xSZ9A43mPgyMw3a1VFddgg-1 X-Mimecast-MFC-AGG-ID: xSZ9A43mPgyMw3a1VFddgg_1750767837 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750767837; x=1751372637; 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=aoc2stLSbgQCmRzc5fPnLLeyQg1hKs3E5ePRLF2ciVs=; b=B7Yo3xlQISPisxG1Wlhs2uA3aJx6sJZZTdoxQPiOBoKVLZng0LR5iLncL0vZtZ7dLK vsl/bOuWtlPeiC8mDsqtNdvXyR2pmVlqacPg2AzeIHL4Y4tPcowLiyMXEeCXZmcxm60t kzJjw5fAD/ANAXuw+GD2nbZZwk5bAuXNxTuKNuc7HQaAMmvNCgDtgicV2ZncAc537JRa g0JjvqONwoHFJoQyiyaZt2CjUW/PFav+qCCUSx+BHGb1qC5ra88bdzQK2HGVz0/375hb 0L//BdcfB1qoAUZpkp8lENb/k86o7Lh9OxEU5qY3VMOOcdot5ZPmS7TlETjvqeNAEGho 8HiA== X-Gm-Message-State: AOJu0Ywo0Y7STBlgNaNkexxieao89eQZmLlYcp6+ke8Ie860sGTVVySl G7Y5+VHJXhBXJMQjvIWVjfqXKOSL7KGQ8d+wYNDf1Soz1YU/jDh2wOW42KJ65j8Gmut4JU/eFXE xCu09Cyi9+5qTJHQ2VHn5B+NBXzKTsPotWbJhaohJCdJH2KQwL3Kc3HQ7 X-Gm-Gg: ASbGncvebaJKJr4NngxKfNx+ZqM+QE9tZs/bnbS8FJ2uD3JMbrtnSO7XsGMYgzD4Hca SeapyeIukxbdp3ck3p/m34CwmWJ73oD/Jsf3Minb8e8i+32HwXmFzlVq4H9NSU28F1+NmP9PzPM 5x0x8zGlIAovMe7cBjP78gEh89FNLrMWpxmFFyv+WeBQ7He+69sQusU9R2S2ymcSD13RkdPka3e ts9jTSpR2JjnlNCJEcd4fa+aa0DjmuZrM4KP+5/azZC2mcTlxYyUWKNeKqBF2Newi4rcZP92rTw 0igzjsB8j4QHkhz8SqrePNaCJ9jICHatMKNE X-Received: by 2002:a05:6a00:9286:b0:736:5753:12f7 with SMTP id d2e1a72fcca58-7490d4e3682mr29561878b3a.3.1750767836611; Tue, 24 Jun 2025 05:23:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPNFHFUhpcOXLawA2l46Tc2qAXpBXE+OQ9q5ueQCGthtKIbjmIicecIxH+ovfxGqpnw920Vw== X-Received: by 2002:a05:6a00:9286:b0:736:5753:12f7 with SMTP id d2e1a72fcca58-7490d4e3682mr29561841b3a.3.1750767836236; Tue, 24 Jun 2025 05:23:56 -0700 (PDT) From: Arun Menon Date: Tue, 24 Jun 2025 17:53:06 +0530 Subject: [PATCH 3/3] backends/tpm: Propagate vTPM error on migration failure MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250624-propagate_tpm_error-v1-3-2171487a593d@redhat.com> References: <20250624-propagate_tpm_error-v1-0-2171487a593d@redhat.com> In-Reply-To: <20250624-propagate_tpm_error-v1-0-2171487a593d@redhat.com> To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , Cornelia Huck , Halil Pasic , Eric Farman , Richard Henderson , David Hildenbrand , Ilya Leoshkevich , Thomas Huth , Christian Borntraeger , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , Paolo Bonzini , Fam Zheng , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Peter Xu , Fabiano Rosas , Hailiang Zhang , Steve Sistare , qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, Stefan Berger , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Arun Menon X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7179; i=armenon@redhat.com; h=from:subject:message-id; bh=YNrXSvCavElITFnWdq5E9/4r4fGkc3Vuvin2J1tR5nc=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0bUjH3TxCPXnPQSN7/69dx+prt3HxaXbWj2CVp2LmNaW lTSptxHHaUsDGJcDLJiiiwNXwNkmwIKIyJtX16HmcPKBDKEgYtTACbSO5GR4fZcw6Q55rrv8n9a 3z++zGbvw+nOq8M3Xzh3/se6f2rCk28z/C9asbL53nK7t7cbZKOz3vVcbnfRO300YTNbr6bNikt hJzkA X-Developer-Key: i=armenon@redhat.com; a=openpgp; fpr=80F5501D82507158593DE9D76A7A2538D90F328E 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=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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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: 1750768018917116600 - Introduce a new post_load_with_error() hook that will take in the Error object as a parameter. - This error object is set if the loading of state fails. - The error can then be retrieved using QMP command {"execute" : "query-migrate"} Buglink: https://issues.redhat.com/browse/RHEL-82826 Signed-off-by: Arun Menon Reviewed-by: Stefan Berger --- backends/tpm/tpm_emulator.c | 39 ++++++++++++++++++++------------------- include/migration/vmstate.h | 1 + migration/vmstate.c | 4 +++- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index 4a234ab2c0b19b2604bf0dd8cb5f4540c72a9438..816134d7b4de00a75a3d0b928d1= 60595b17be810 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -819,7 +819,8 @@ static int tpm_emulator_get_state_blobs(TPMEmulator *tp= m_emu) static int tpm_emulator_set_state_blob(TPMEmulator *tpm_emu, uint32_t type, TPMSizedBuffer *tsb, - uint32_t flags) + uint32_t flags, + Error **errp) { ssize_t n; ptm_setstate pss; @@ -838,17 +839,17 @@ static int tpm_emulator_set_state_blob(TPMEmulator *t= pm_emu, /* write the header only */ if (tpm_emulator_ctrlcmd(tpm_emu, CMD_SET_STATEBLOB, &pss, offsetof(ptm_setstate, u.req.data), 0, 0) < 0= ) { - error_report("tpm-emulator: could not set state blob type %d : %s", - type, strerror(errno)); + error_setg(errp, "tpm-emulator: could not set state blob type %d := %s", + type, strerror(errno)); return -1; } =20 /* now the body */ n =3D qemu_chr_fe_write_all(&tpm_emu->ctrl_chr, tsb->buffer, tsb->size= ); if (n !=3D tsb->size) { - error_report("tpm-emulator: Writing the stateblob (type %d) " - "failed; could not write %u bytes, but only %zd", - type, tsb->size, n); + error_setg(errp, "tpm-emulator: Writing the stateblob (type %d) " + "failed; could not write %u bytes, but only %zd", + type, tsb->size, n); return -1; } =20 @@ -856,17 +857,17 @@ static int tpm_emulator_set_state_blob(TPMEmulator *t= pm_emu, n =3D qemu_chr_fe_read_all(&tpm_emu->ctrl_chr, (uint8_t *)&pss, sizeof(pss.u.resp)); if (n !=3D sizeof(pss.u.resp)) { - error_report("tpm-emulator: Reading response from writing stateblo= b " - "(type %d) failed; expected %zu bytes, got %zd", type, - sizeof(pss.u.resp), n); + error_setg(errp, "tpm-emulator: Reading response from writing " + "stateblob (type %d) failed; expected %zu bytes, " + "got %zd", type, sizeof(pss.u.resp), n); return -1; } =20 tpm_result =3D be32_to_cpu(pss.u.resp.tpm_result); if (tpm_result !=3D 0) { - error_report("tpm-emulator: Setting the stateblob (type %d) failed= " - "with a TPM error 0x%x %s", type, tpm_result, - tpm_emulator_strerror(tpm_result)); + error_setg(errp, "tpm-emulator: Setting the stateblob (type %d) " + "failed with a TPM error 0x%x %s", type, tpm_result, + tpm_emulator_strerror(tpm_result)); return -1; } =20 @@ -880,7 +881,7 @@ static int tpm_emulator_set_state_blob(TPMEmulator *tpm= _emu, * * Returns a negative errno code in case of error. */ -static int tpm_emulator_set_state_blobs(TPMBackend *tb) +static int tpm_emulator_set_state_blobs(TPMBackend *tb, Error **errp) { TPMEmulator *tpm_emu =3D TPM_EMULATOR(tb); TPMBlobBuffers *state_blobs =3D &tpm_emu->state_blobs; @@ -894,13 +895,13 @@ static int tpm_emulator_set_state_blobs(TPMBackend *t= b) =20 if (tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_PERMANENT, &state_blobs->permanent, - state_blobs->permanent_flags) < 0 || + state_blobs->permanent_flags, errp) < = 0 || tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_VOLATILE, &state_blobs->volatil, - state_blobs->volatil_flags) < 0 || + state_blobs->volatil_flags, errp) < 0 = || tpm_emulator_set_state_blob(tpm_emu, PTM_BLOB_TYPE_SAVESTATE, &state_blobs->savestate, - state_blobs->savestate_flags) < 0) { + state_blobs->savestate_flags, errp) < = 0) { return -EIO; } =20 @@ -948,12 +949,12 @@ static void tpm_emulator_vm_state_change(void *opaque= , bool running, * * Returns negative errno codes in case of error. */ -static int tpm_emulator_post_load(void *opaque, int version_id) +static int tpm_emulator_post_load(void *opaque, int version_id, Error **er= rp) { TPMBackend *tb =3D opaque; int ret; =20 - ret =3D tpm_emulator_set_state_blobs(tb); + ret =3D tpm_emulator_set_state_blobs(tb, errp); if (ret < 0) { return ret; } @@ -969,7 +970,7 @@ static const VMStateDescription vmstate_tpm_emulator = =3D { .name =3D "tpm-emulator", .version_id =3D 0, .pre_save =3D tpm_emulator_pre_save, - .post_load =3D tpm_emulator_post_load, + .post_load_with_error =3D tpm_emulator_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT32(state_blobs.permanent_flags, TPMEmulator), VMSTATE_UINT32(state_blobs.permanent.size, TPMEmulator), diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 056781b1c21e737583f081594d9f88b32adfd674..1c6e89c3b08a3914cde6dce3be5= 955978b6b7d0b 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -207,6 +207,7 @@ struct VMStateDescription { MigrationPriority priority; int (*pre_load)(void *opaque); int (*post_load)(void *opaque, int version_id); + int (*post_load_with_error)(void *opaque, int version_id, Error **errp= ); int (*pre_save)(void *opaque); int (*post_save)(void *opaque); bool (*needed)(void *opaque); diff --git a/migration/vmstate.c b/migration/vmstate.c index 3f8c3d3c1dcfe14d70bab1f43b827244eb4bb385..c5dfffd9bad7285e819d4769e05= 5d47157caab34 100644 --- a/migration/vmstate.c +++ b/migration/vmstate.c @@ -232,7 +232,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescri= ption *vmsd, qemu_file_set_error(f, ret); return ret; } - if (vmsd->post_load) { + if (vmsd->post_load_with_error) { + ret =3D vmsd->post_load_with_error(opaque, version_id, errp); + } else if (vmsd->post_load) { ret =3D vmsd->post_load(opaque, version_id); } trace_vmstate_load_state_end(vmsd->name, "end", ret); --=20 2.49.0