In case swtpm was to return a control channel message with an error code it would only return 4 bytes. However, some of the commands expect a response with more bytes and QEMU would get stuck in qemu_chr_fe_read_all() waiting for bytes following the error code. Therefore, read the response in 2 passes stopping if an error code is received in the first 4 bytes to avoid getting stuck.
Stefan Stefan Berger (2): tpm: Use new ptm_cap_n structure for PTM_GET_CAPABILITY tpm_emulator: Read control channel response in 2 passes backends/tpm/tpm_emulator.c | 39 +++++++++++++++++++++++++++++-------- backends/tpm/tpm_ioctl.h | 13 ++++++++++++- backends/tpm/trace-events | 2 +- 3 files changed, 44 insertions(+), 10 deletions(-) -- 2.46.2