From nobody Sat Nov 15 11:11:23 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=1753097854; cv=none; d=zohomail.com; s=zohoarc; b=Ln49FyH4VgSK/ja3NaPNYUm45vOuJV/GGIecbtySw4IaNoNBZTH9PkKrS9PqqGZV3I4Rhb14oM8ipYJoE1EMI/XQYxngu9aBhlLwePrH7ul5LQlN5zCrh8ZVXAB2qO84FuMjB/miZWmy9A5sdgzgziMXDMbotrDGyNvIryE9ZK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753097854; 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=JKqN1L12LAwvLMjtKMNxSR7OTCvLy+JRJATb+NmV8Sk=; b=SHJ8OFhsOeF1lUKsGXzIUtg3WyvdqGJvzOR6G0tW3YrOx1v9ZabfiCYJaS2uUv1pXTdgortcWXxrlTzTrDR97A9Va3n4A2hCEvyYcYHxFDBSvYopboJmraWuOwWVXK004XuoHTktPmbA5m2fZ/FGclrmRt9KcCgBYjl8Lb05HHw= 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 1753097854659141.47937413229454; Mon, 21 Jul 2025 04:37:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1udopG-0007V0-5L; Mon, 21 Jul 2025 07:36: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 1udolX-0005FA-6w for qemu-devel@nongnu.org; Mon, 21 Jul 2025 07:33:08 -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 1udolQ-0001FW-9H for qemu-devel@nongnu.org; Mon, 21 Jul 2025 07:33:06 -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-311-tcrA8jA-MnSAwDuedWPw6w-1; Mon, 21 Jul 2025 07:32:56 -0400 Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-b31ca4b6a8eso2870645a12.1 for ; Mon, 21 Jul 2025 04:32:56 -0700 (PDT) Received: from armenon-kvm.bengluru.csb ([49.36.101.21]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23e3b5e3c89sm56150465ad.18.2025.07.21.04.32.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jul 2025 04:32:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1753097577; 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=JKqN1L12LAwvLMjtKMNxSR7OTCvLy+JRJATb+NmV8Sk=; b=SVtM6kgVdkiFQ7gwIFMMNmfpaSBX20DX4AYLr8dBNGhXjimaejosFCpD5L1G/Gg+gX+TDR ROVJQF/N/whtaqiXr3qltSPtTZxyuXdngiF7lzTGMmJgwMkzX/lW4rhdKscqRQz2ux0tHc aEqATgjU7e0iCsARgqQkv3ow40LC3yk= X-MC-Unique: tcrA8jA-MnSAwDuedWPw6w-1 X-Mimecast-MFC-AGG-ID: tcrA8jA-MnSAwDuedWPw6w_1753097576 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753097575; x=1753702375; 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=JKqN1L12LAwvLMjtKMNxSR7OTCvLy+JRJATb+NmV8Sk=; b=Nd/67YVVIdLopq+5RjSmXLmLBbOFOK7BTnVUtk7BAj3vorQPG1ThXvnLtEPB6TmuLo HsSXA8GJOGyBzvf26Ig2B8He1mlzDUEkJeuKHniBjJ8NTMrBPpLB0z7YGKrhn8OXSS0M T0wFconVErsKM/yD2Jh/1Zm2kQB/fgZwZ9RTu2ZNVEq0CK4V79AlDprW68oWB5NCnywe m65f8ISUvzPXffSirPQL85m7hgFzcttywgtJAODtdl9pLW58Eih1zZDZCuTuJat4nbyJ vCyxNfijpv7fxPHrmJ1A7bDD8CuoqYVGjbD/LNAcN4Ysrd3kx0DqYtn/dvaambU+i7Z7 1g0g== X-Gm-Message-State: AOJu0YzXHVcDA+7HgeEA3h7MkcN9lxnGWyyiQmE4+TRm0Y34gnay04Hq GS+FJ0fTjKgMPGPGhcbReyiG5WL9od4IpfXBFTpaKZF54VTLt2stC4ylefoXLIWvb91H+Y/Vmuo tyssfLOhx7Yke6LqJaRNb5tesAJfGrhVcjDBQMzZST+OWBXV/PIbfqbrQ X-Gm-Gg: ASbGncvD6EMz2yT5ojsm6y716SCwDOd8I+N0u/Cc/cYyBQXRuOAyD6DNlq1lOlFTiG4 KZD+wy6IfnJDRnIv8vx5Vg+1GBafHQOHrMrv9ShyrsrvBbPE50R0kW8TE/XElMq13ojn1X1sW5i B9vCVucAuzA6YjMqwdbkSkTXPWcwHbV+VjfEi3GJBN5yUqWrp1EsRyh+wGVlOcLS1t05OEykdK7 2+l9grx84HKr2pINA18O63U8Lka8wCYK5OmqtsmM0MT1bHQm0FTs1Pq1KSl8txt7Y+WyWILOK3d 9tb3p4R3SK8HOGeuKRdL/DtnL1qgzwWEjwFDlfnnJTCPe2yRbAV8 X-Received: by 2002:a17:903:84c:b0:23e:3c33:6be8 with SMTP id d9443c01a7336-23e3c336f4bmr118762505ad.8.1753097575467; Mon, 21 Jul 2025 04:32:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbfcVzkuh97j6K4G+F+JYn3x8FxbBl/npQfCdEJ1D7+ERjT8M9jlTe8kVvxHVmtfNuOeF5Bg== X-Received: by 2002:a17:903:84c:b0:23e:3c33:6be8 with SMTP id d9443c01a7336-23e3c336f4bmr118762025ad.8.1753097574996; Mon, 21 Jul 2025 04:32:54 -0700 (PDT) From: Arun Menon Date: Mon, 21 Jul 2025 16:59:29 +0530 Subject: [PATCH v6 24/24] 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: <20250721-propagate_tpm_error-v6-24-fef740e15e17@redhat.com> References: <20250721-propagate_tpm_error-v6-0-fef740e15e17@redhat.com> In-Reply-To: <20250721-propagate_tpm_error-v6-0-fef740e15e17@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 , Paolo Bonzini , Fam Zheng , Nicholas Piggin , Daniel Henrique Barboza , Harsh Prateek Bora , 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?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Alex_Benn=C3=A9e?= , Akihiko Odaki , Dmitry Osipenko , Matthew Rosato , Arun Menon , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Stefan Berger X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=6670; i=armenon@redhat.com; h=from:subject:message-id; bh=Rn6IArfRb4G/LsYJZqQjGjrf7FvxqQakb6I/9s6ac6U=; b=owGbwMvMwCWWVaVqcZPfqI/xtFoSQ0adyuTjbclbljwp/mzUOyM3PCNKTvKVY1rPFVO19dfnf 7jmIBjXUcrCIMbFICumyNLwNUC2KaAwItL25XWYOaxMIEMYuDgFYCI3bzL8z7adVpeadmF381Le xugo9km3559bf0kzR/aowJE3+f0eexj+Bx7uKHU937m/4tUWK2V/BfFdySItr17m3pF5X3uFSZC FEQA= 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: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.926, 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_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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1753097855152116600 - When migration of a VM with encrypted vTPM fails on the destination host, (e.g., due to a mismatch in secret values), the error message displayed on the source host is generic and unhelpful. - For example, a typical error looks like this: "operation failed: job 'migration out' failed: Sibling indicated error 1. operation failed: job 'migration in' failed: load of migration failed: Input/output error" - Such generic errors are logged using error_report(), which prints to the console/monitor but does not make the detailed error accessible via the QMP query-migrate command. - This change, along with the set of changes of passing errp Error object to the VM state loading functions, help in addressing the issue. We use the post_load_errp hook of VMStateDescription to propagate errors by setting Error **errp objects in case of failure in the TPM backend. - It can then be retrieved using QMP command: {"execute" : "query-migrate"} Buglink: https://issues.redhat.com/browse/RHEL-82826 Reviewed-by: Stefan Berger Reviewed-by: Daniel P. Berrang=C3=A9 Signed-off-by: Arun Menon --- backends/tpm/tpm_emulator.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index 4a234ab2c0b19b2604bf0dd8cb5f4540c72a9438..9bf5927e8e1542cf2e4f2275783= d32853d5f1473 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_errp =3D tpm_emulator_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINT32(state_blobs.permanent_flags, TPMEmulator), VMSTATE_UINT32(state_blobs.permanent.size, TPMEmulator), --=20 2.50.0