Bug 2035731
| Summary: | Failed to restore vm after saving a booting vm with vtpm device | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 9 | Reporter: | Fangge Jin <fjin> | |
| Component: | libtpms | Assignee: | Marc-Andre Lureau <marcandre.lureau> | |
| Status: | CLOSED ERRATA | QA Contact: | Qinghua Cheng <qcheng> | |
| Severity: | medium | Docs Contact: | ||
| Priority: | medium | |||
| Version: | 9.0 | CC: | coli, jinzhao, marcandre.lureau, qcheng, stefanb, virt-maint, xiaohli, yanqzhan, yfu | |
| Target Milestone: | rc | Keywords: | AutomationTriaged, Triaged | |
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
|
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | libtpms-0.9.1-2.20211126git1ff6fe1f43.el9 | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 2111433 (view as bug list) | Environment: | ||
| Last Closed: | 2022-11-15 10:26:42 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 2111433 | |||
We don't reproduce it with Win11 and Win2022 guests Environment: libtpms-0.9.1-0.20211126git1ff6fe1f43.el9.x86_64 swtpm-0.7.0-1.20211109gitb79fd91.el9.x86_64 qemu-kvm-6.2.0-1.el9.x86_64 libvirt-7.10.0-1.el9.x86_64 edk2-ovmf-20210527gite1999b264f1f-7.el9.noarch The fix for this is in a PR here now: https://github.com/stefanberger/libtpms/pull/287 Hi there, We i test migration with Win11 + tpm device, if src and dst vm use same tpm daemon by mistake, can hit the same error info: 18:23:27 INFO | [qemu output] qemu-kvm: tpm-emulator: Setting the stateblob (type 2) failed with a TPM error 0x84 18:23:27 INFO | [qemu output] qemu-kvm: error while loading state for instance 0x0 of device 'tpm-emulator' 18:23:27 INFO | [qemu output] qemu-kvm: load of migration failed: Input/output error 18:23:27 INFO | [qemu output] (Process terminated with status 1) Just for a reference, thanks! (In reply to Yanan Fu from comment #5) > Hi there, > > We i test migration with Win11 + tpm device, if src and dst vm use same tpm > daemon by mistake, can hit the same error info: What is 'same tpm daemon by mistake'? > > 18:23:27 INFO | [qemu output] qemu-kvm: tpm-emulator: Setting the stateblob > (type 2) failed with a TPM error 0x84 > 18:23:27 INFO | [qemu output] qemu-kvm: error while loading state for > instance 0x0 of device 'tpm-emulator' > 18:23:27 INFO | [qemu output] qemu-kvm: load of migration failed: > Input/output error > 18:23:27 INFO | [qemu output] (Process terminated with status 1) > > > Just for a reference, thanks! Is this with the fix applied to libptms on both machines or without? (In reply to Stefan Berger from comment #6) > (In reply to Yanan Fu from comment #5) > > Hi there, > > > > We i test migration with Win11 + tpm device, if src and dst vm use same tpm > > daemon by mistake, can hit the same error info: > > What is 'same tpm daemon by mistake'? It is for local migration test: 1. src vm, qemu cli: -chardev socket,id=char_vtpm_tpm0,path=/tmp/avocado_5l5j2ys4/avocado-vt-vm1_tpm0_swtpm.sock \ <--- here -tpmdev emulator,chardev=char_vtpm_tpm0,id=emulator_vtpm_tpm0 \ -device tpm-crb,id=tpm-crb_vtpm_tpm0,tpmdev=emulator_vtpm_tpm0 \ 2. dst vm qemu cli: -chardev socket,id=char_vtpm_tpm0,path=/tmp/avocado_5l5j2ys4/avocado-vt-vm1_tpm0_swtpm.sock \ <--- here -tpmdev emulator,chardev=char_vtpm_tpm0,id=emulator_vtpm_tpm0 \ -device tpm-crb,id=tpm-crb_vtpm_tpm0,tpmdev=emulator_vtpm_tpm0 \ I hit the same error when use same 'path' for both src and dst vm. This is incorrect usage, so i say 'by mistake'. The correct usage is using unique path for each one, in this way, it works normally. > > > > > 18:23:27 INFO | [qemu output] qemu-kvm: tpm-emulator: Setting the stateblob > > (type 2) failed with a TPM error 0x84 > > 18:23:27 INFO | [qemu output] qemu-kvm: error while loading state for > > instance 0x0 of device 'tpm-emulator' > > 18:23:27 INFO | [qemu output] qemu-kvm: load of migration failed: > > Input/output error > > 18:23:27 INFO | [qemu output] (Process terminated with status 1) > > > > > > Just for a reference, thanks! > > Is this with the fix applied to libptms on both machines or without? Without any fix. Anyway, thanks for finding the bug! QE bot(pre verify): Set 'Verified:Tested,SanityOnly' as gating/tier1 test pass. Verified for on rhel 9.1 kernel: 5.14.0-114.el9.x86_64 qemu: qemu-kvm-7.0.0-6.el9.x86_64 libtpms-0.9.1-2.20211126git1ff6fe1f43.el9.x86_64 swtpm-0.7.0-3.20211109gitb79fd91.el9.x86_64 edk2-ovmf-20220526git16779ede2d36-1.el9.noarch guest: win11 Looped the actions virsh start <vm> (save it immediately) virsh managedsave <vm> virsh start <vm> 40 times, guest vm works normally. Set bug status to verified. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (libtpms bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2022:8141 |
Description of problem: Start a vm with vtpm device, then save the vm immediately. Restoring vm will fail. Version-Release number of selected component (if applicable): # rpm -q libvirt qemu-kvm libtpms swtpm libvirt-7.10.0-1.el9.x86_64 qemu-kvm-6.2.0-1.el9.x86_64 libtpms-0.9.1-0.20211126git1ff6fe1f43.el9.x86_64 swtpm-0.7.0-1.20211109gitb79fd91.el9.x86_64 How reproducible: 100% Steps to Reproduce: 1.Start a vm with vtpm device, and save it immediately # virsh start vm1; virsh managedsave vm1 <tpm model='tpm-crb'> <backend type='emulator' version='2.0'/> </tpm> 2. Restore the vm: # virsh start vm1 error: Failed to start domain 'vm1' error: internal error: qemu unexpectedly closed the monitor: 2021-12-27T08:52:14.261131Z qemu-kvm: tpm-emulator: Setting the stateblob (type 2) failed with a TPM error 0x3 a parameter is bad 2021-12-27T08:52:14.261145Z qemu-kvm: error while loading state for instance 0x0 of device 'tpm-emulator' 2021-12-27T08:52:14.261235Z qemu-kvm: load of migration failed: Input/output error 3. Remove state file, try to restore vm again: # rm /var/lib/libvirt/swtpm/505ee98d-e9af-4597-9eff-168e66f5f6ce/tpm2/tpm2-00.permall rm: remove regular file '/var/lib/libvirt/swtpm/505ee98d-e9af-4597-9eff-168e66f5f6ce/tpm2/tpm2-00.permall'? y # virsh start vm1 error: Failed to start domain 'vm1' error: internal error: qemu unexpectedly closed the monitor: 2021-12-27T09:05:28.928729Z qemu-kvm: tpm-emulator: Setting the stateblob (type 2) failed with a TPM error 0x3 a parameter is bad 2021-12-27T09:05:28.928743Z qemu-kvm: error while loading state for instance 0x0 of device 'tpm-emulator' 2021-12-27T09:05:28.928832Z qemu-kvm: load of migration failed: Input/output error Actual results: Failed to restore vm Expected results: Restore vm successfully Additional info: 1. Can't reproduce if save vm after vm is fully booted up. 2. swtpm log: # cat /var/log/swtpm/libvirt/qemu/vm1-swtpm.log libtpms/tpm2: STATE_RESET_DATA: s_ContextSlotMask has bad value: 0x0000 Data client disconnected libtpms/tpm2: STATE_RESET_DATA: s_ContextSlotMask has bad value: 0x0000 Data client disconnected