[PATCH 1/3] tpm_emulator: print error on error-ignore path

Vladimir Sementsov-Ogievskiy posted 3 patches 1 week ago
Maintainers: Stefan Berger <stefanb@linux.vnet.ibm.com>
[PATCH 1/3] tpm_emulator: print error on error-ignore path
Posted by Vladimir Sementsov-Ogievskiy 1 week ago
Commit 3469a56fa3dc985 introduced errp passthrough for many
errors in the file. But in this specific case in
tpm_emulator_get_buffer_size(), it simply used errp=NULL, so we lose
printed error. Let's bring it back

Note also, that 3469a56fa3dc985 was fixing another commit,
42e556fa3f7a "backends/tpm: Propagate vTPM error on migration failure"
and didn't mention it.

Fixes: 3469a56fa3dc985 "tmp_emulator: improve and fix use of errp"
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 backends/tpm/tpm_emulator.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
index f10b9074fb..24aa18302e 100644
--- a/backends/tpm/tpm_emulator.c
+++ b/backends/tpm/tpm_emulator.c
@@ -560,8 +560,10 @@ static TPMVersion tpm_emulator_get_tpm_version(TPMBackend *tb)
 static size_t tpm_emulator_get_buffer_size(TPMBackend *tb)
 {
     size_t actual_size;
+    Error *local_err = NULL;
 
-    if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, NULL) < 0) {
+    if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, &local_err) < 0) {
+        error_report_err(local_err);
         return 4096;
     }
 
-- 
2.48.1
Re: [PATCH 1/3] tpm_emulator: print error on error-ignore path
Posted by Stefan Berger 6 days, 19 hours ago

On 11/6/25 2:41 PM, Vladimir Sementsov-Ogievskiy wrote:
> Commit 3469a56fa3dc985 introduced errp passthrough for many
> errors in the file. But in this specific case in
> tpm_emulator_get_buffer_size(), it simply used errp=NULL, so we lose
> printed error. Let's bring it back
> 
> Note also, that 3469a56fa3dc985 was fixing another commit,
> 42e556fa3f7a "backends/tpm: Propagate vTPM error on migration failure"
> and didn't mention it.
> 
> Fixes: 3469a56fa3dc985 "tmp_emulator: improve and fix use of errp"
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>   backends/tpm/tpm_emulator.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c
> index f10b9074fb..24aa18302e 100644
> --- a/backends/tpm/tpm_emulator.c
> +++ b/backends/tpm/tpm_emulator.c
> @@ -560,8 +560,10 @@ static TPMVersion tpm_emulator_get_tpm_version(TPMBackend *tb)
>   static size_t tpm_emulator_get_buffer_size(TPMBackend *tb)
>   {
>       size_t actual_size;
> +    Error *local_err = NULL;
>   
> -    if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, NULL) < 0) {
> +    if (tpm_emulator_set_buffer_size(tb, 0, &actual_size, &local_err) < 0) {
> +        error_report_err(local_err);
>           return 4096;
>       }
>   

Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>