Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1759753

Summary: Add firmware(UEFI) limitation for vtpm from qemu when guest starts
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: Yanqiu Zhang <yanqzhan>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
qemu-kvm sub component: General QA Contact: Qinghua Cheng <qcheng>
Status: CLOSED WONTFIX Docs Contact:
Severity: unspecified    
Priority: low CC: areis, berrange, chhu, coli, ddepaula, dyuan, dzheng, jferlan, jinzhao, juzhang, knoel, marcandre.lureau, virt-maint, yanqzhan
Version: 8.1Keywords: Triaged
Target Milestone: rcFlags: knoel: mirror+
Target Release: 8.2   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1787444 (view as bug list) Environment:
Last Closed: 2020-09-17 21:48:45 UTC Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
comment10_libvirt_qemu_logs none

Description Yanqiu Zhang 2019-10-09 02:35:52 UTC
Description of problem:
Since only uefi firmware is supported for vtpm device per bz1519013, there should be a limitation when guest starts

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:

An example for this concern when user uses seabios+vtpm by accident:
    Normal usage of vtpm in guest and general migration work well, user doesn't feel difference, but when do postcopy migration, encounters this issue:
# virsh migrate avocado-vt-vm1  --live qemu+ssh://10.*.*.*/system --verbose --postcopy
error: internal error: qemu unexpectedly closed the monitor: qemu_madvise: Invalid argument
madvise doesn't support MADV_DONTDUMP, but dump_guest_core=off specified
2019-08-27T11:49:25.683996Z qemu-kvm: ram_block_discard_range: Unaligned start address: 0x563a855e3430
2019-08-27T11:49:25.684224Z qemu-kvm: load of migration failed: Operation not permitted
    (not reproduce for an uefi guest)
    Then user maybe start debugging, time is costed, finally find that he/she should redefine a guest to use uefi instead. 

So this can be a reason why an early limitation from qemu when guest starts is needed. It can avoid any further potential issues users may meet. And an earlier limitation by qemu is more close to the supporting status and more controllable as I think.

There are parameters in qemu cmdline can be used to judge whether it's an uefi guest. An error to prompt when try to start a guest with vtpm without ovmf would be welcome.
    -global driver=cfi.pflash01,property=secure,value=on -drive file=/usr/share/OVMF/OVMF_CODE.secboot.fd,if=pflash,format=raw,unit=0,readonly=on -drive file=/var/lib/libvirt/qemu/nvram/rhel8.1-ovmf_VARS.fd,if=pflash,format=raw,unit=1


Actual results:


Expected results:


Additional info:

Comment 1 John Ferlan 2019-10-10 20:33:53 UTC
Seems this is a follow-up to https://bugzilla.redhat.com/show_bug.cgi?id=1519013#c63.

I've switched this from qemu-kvm to libvirt, since any way to limit the startup should be added to the libvirt code and documentation. I also removed FutureFeature as this is more of ensuring a limitation of the existing vTPM startup/execution code.

Probably would have helped to have a better description of the defined guest environment from the source host and of course the target environment (otherwise assumptions are made determining what role migration is playing).

My assumption is qemuDomainDeviceDefValidateTPM needs to be modified so that the code can learn what to do for the _EMULATOR switch based on TPM version value. Whether TPM 1.2 will ever support PFLASH is something from bz1758153, but certainly for emulator and tpm==2.0, the def->os.loader && def->os.loader->type == VIR_DOMAIN_LOADER_TYPE_PFLASH must be true.

The https://libvirt.org/formatdomain.html#elementsTpm also should be adjusted to indicate that using TPM v2.0 emulator would require configuring/starting w/ UEFI. Add an XML example in the docs too.

Comment 2 Yanqiu Zhang 2019-10-11 02:43:58 UTC
I have a concern that "tpm 2.0 & uefi & CRB device" supporting status was introduced from qemu bug bz1519013. What if qemu makes changes later that it supporting more scenarios after adding limitation in libvirt or other uplayer components? Or does qemu have some API that telling libvirt which kind of vtpm is supported?
That's why I think "an earlier limitation by qemu is more close to the supporting status and more controllable".

Comment 3 Marc-Andre Lureau 2019-10-14 17:06:09 UTC
It's not simple to limit qemu/libvirt to the "vtpm 2.0 & uefi & CRB device" combo.

It would probably be a nastly RH-specific patches to limit libvirt or qemu, and a customer could probably find work arounds the check.

However what you reported here seems like an upstream qemu bug. Imho, we should close this RH bug as WONTFIX, since the configuration isn't supported, and open an upstream bug instead.

Comment 4 Yanqiu Zhang 2019-10-15 02:49:23 UTC
(In reply to Marc-Andre Lureau from comment #3)

Hi Marc-Andre,

Thanks for your explanation. From what you said, is RH-specific patches a downstream only fix? You mean upstream has no statement that it doesn't support seabios+vtpm, right?
Then even the method of comment1 can be implemented, content in formatdomain.xml should not be changed since it's an upstream doc.

My bug intention is to have a limit to libvirt or qemu when guest starts. I would like to keep this bug open. Even a RH-specific patches is helpful for our customer to use vtpm as supported and avoid unnecessary wasting time.   

For the postcopy migration failure, the bug can only be filed if upstream supports seabios+vtpm. Otherwise I don't want to file a rfe bug to ask upstream to support this configuration.

Thanks.

Comment 5 Marc-Andre Lureau 2019-10-16 13:19:03 UTC
I sent "[RHEL-AV-8.1.0 qemu-kvm PATCH] RHEL-only: limit vTPM 2.0 usage" patch for discussion/review

Comment 6 Marc-Andre Lureau 2019-11-22 07:58:52 UTC
Feedback of the downstream-only qemu RFC patch is that it should be upstream.

But I can't justify changes in qemu upstream that aren't necessary, and would result in dead-code there.

Since it's a higher-level and rhel-only limitation, based on a particular configuration combination, I think we should revisit the idea of having this check in libvirt.

Daniel, what do you think?

Comment 7 Daniel Berrangé 2019-12-02 10:29:59 UTC
(In reply to Marc-Andre Lureau from comment #6)
> Feedback of the downstream-only qemu RFC patch is that it should be upstream.
> 
> But I can't justify changes in qemu upstream that aren't necessary, and
> would result in dead-code there.

I don't read that comment as a blocker - it was just a suggestion to make it easier when we rebase in future.

> Since it's a higher-level and rhel-only limitation, based on a particular
> configuration combination, I think we should revisit the idea of having this
> check in libvirt.

Any libvirt check would be downstream only too which has the same downsides as QEMU, so this doesn't improve the situation, it just makes it someone else's problem.

The only better solution would be to not put any downstream code hacks in at all and treat the support situation as a documentation task.

Comment 9 Danilo de Paula 2019-12-10 14:14:55 UTC
The patch regarding this BZ was dropped from the queue.

Comment 10 Yanqiu Zhang 2019-12-26 11:10:36 UTC
Issue also reproduces for uefi guest on latest:
qemu-kvm-4.1.0-20.module+el8.1.1+5309+6d656f05.x86_64
swtpm-0.2.0-1.20191018git9227cf4.module+el8.1.1+5309+6d656f05.x86_64
libvirt-daemon-5.6.0-10.module+el8.1.1+5309+6d656f05.x86_64

#  virsh migrate rhel8.1-ovmf --live qemu+ssh://10.66.85.249/system --verbose --postcopy --postcopy-after-precopy 
error: internal error: qemu unexpectedly closed the monitor: qemu_madvise: Invalid argument
madvise doesn't support MADV_DONTDUMP, but dump_guest_core=off specified
2019-12-26T10:22:44.714644Z qemu-kvm: ram_block_discard_range: Unaligned start address: 0x559d2afae9a0
2019-12-26T10:22:44.714892Z qemu-kvm: load of migration failed: Operation not permitted

Eventhough enable "dump_guest_core=1" in target's qemu.conf, still meet error:
#  virsh migrate rhel8.1-ovmf --live qemu+ssh://10.66.85.249/system --verbose --postcopy 
error: internal error: qemu unexpectedly closed the monitor: 2019-12-26T10:58:04.179006Z qemu-kvm: ram_block_discard_range: Unaligned start address: 0x5597964ef410
2019-12-26T10:58:04.179230Z qemu-kvm: load of migration failed: Operation not permitted


Hi John and Marc-Andre, 

Could you help confirm and move this bug from RFE to normal to fix on qemu-kvm please? 

Thank you!

Comment 11 Yanqiu Zhang 2019-12-26 11:19:09 UTC
Created attachment 1647741 [details]
comment10_libvirt_qemu_logs

Comment 12 Marc-Andre Lureau 2019-12-28 12:43:43 UTC
Hi

(In reply to yanqzhan from comment #10)
> Issue also reproduces for uefi guest on latest:
> Eventhough enable "dump_guest_core=1" in target's qemu.conf, still meet
> error:
> #  virsh migrate rhel8.1-ovmf --live qemu+ssh://10.66.85.249/system
> --verbose --postcopy 
> error: internal error: qemu unexpectedly closed the monitor:
> 2019-12-26T10:58:04.179006Z qemu-kvm: ram_block_discard_range: Unaligned
> start address: 0x5597964ef410
> 2019-12-26T10:58:04.179230Z qemu-kvm: load of migration failed: Operation
> not permitted
> 
> Could you help confirm and move this bug from RFE to normal to fix on
> qemu-kvm please? 

This is a different bug. Can you confirm the same error happens without a TPM device?

Comment 13 Yanqiu Zhang 2020-01-02 02:51:37 UTC
(In reply to Marc-Andre Lureau from comment #12)

> This is a different bug. Can you confirm the same error happens without a
> TPM device?

Not reproduces when guest without tpm, or general migration.

Comment 15 John Ferlan 2020-09-17 21:48:45 UTC
Closing as WONTFIX based on Comment 6 and Comment 7. There is not a clear way to fix this.