RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2084046 - active_pcr_banks are removed from guest xml if tpm version not specified
Summary: active_pcr_banks are removed from guest xml if tpm version not specified
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.1
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Yanqiu Zhang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-05-11 09:28 UTC by Yanqiu Zhang
Modified: 2023-05-09 08:07 UTC (History)
7 users (show)

Fixed In Version: libvirt-8.7.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-09 07:26:11 UTC
Type: Bug
Target Upstream Version: 8.7.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker LIBVIRTAT-13618 0 None None None 2022-10-24 05:03:52 UTC
Red Hat Issue Tracker LIBVIRTAT-13619 0 None None None 2022-10-24 05:03:52 UTC
Red Hat Issue Tracker RHELPLAN-121692 0 None None None 2022-05-11 09:32:32 UTC
Red Hat Product Errata RHBA-2023:2171 0 None None None 2023-05-09 07:26:51 UTC

Description Yanqiu Zhang 2022-05-11 09:28:43 UTC
Description of problem:
As we know, if edit vm xml with a tpm device without version specified, it automatically changes to '2.0' on the latest product. But, when add active_pcr_banks to the tpm, they will disappear if tpm version is not specified.

Version-Release number of selected component (if applicable):
libvirt-8.3.0-1.el9.x86_64
qemu-kvm-7.0.0-2.el9.x86_64

How reproducible:
100%

Steps to Reproduce:
1. Edit vm with following tpm:
  <tpm model='tpm-crb'>
    <backend type='emulator' version='2.0'>
      <active_pcr_banks>
          <sha256/>
      </active_pcr_banks>
    </backend>
  </tpm>
Xml saved successfully and keep consistent with above.

2. Edit vm again to remove tpm version:
    <tpm model='tpm-crb'>
      <backend type='emulator'>
        <active_pcr_banks>
          <sha256/>
        </active_pcr_banks>
      </backend>
    </tpm>

Xml saved.

3. Check vm xml again, version is auto added to the default 2.0, but active_pcr_banks disappear.
    <tpm model='tpm-crb'>
      <backend type='emulator' version='2.0'/>
    </tpm>


Actual results:
As in step3.

Expected results:
Since default version can be auto added to '2.0', active_pcr_banks is sure be supported, so should not be removed.
And if there is a new version (say 3.0) that no longer supports <active_pcr_banks/>, reporting an error is better than dropping a piece of information that user provided.

Additional info:

Comment 1 Michal Privoznik 2022-07-18 09:31:29 UTC
Patches posted on the list:

https://listman.redhat.com/archives/libvir-list/2022-July/232872.html

Comment 2 Michal Privoznik 2022-08-01 15:39:32 UTC
Merged upstream as:

bdd8ce02c4 conf: Don't lose <active_pcr_banks/> when no TPM version is provided
99e2b670fa qemu: Move TPMs validation out of PostParse
2b3e8ddd9d qemu_domain: Move TPM post parse code into qemuDomainTPMDefPostParse()
e31fc5bb2a conf: Use virXMLPropEnum more when parsing TPM
c8992f6d97 conf: Move _virDomainTPMDef::version into _virDomainTPMDef::data::emulator
598ffbdd41 conf: Drop needless setting of VIR_DOMAIN_TPM_VERSION_DEFAULT
d5712c54a6 conf: Report error when default TPM version is provided
3f7c63bba5 conf: Report an error when default TPM model is provided

v8.6.0-16-gbdd8ce02c4

Comment 3 Yanqiu Zhang 2022-09-16 12:13:22 UTC
Tested with:
libvirt-8.7.0-1.el9.x86_64
qemu-kvm-7.1.0-1.el9.x86_64

Steps:
Edit vm xml as:
    <tpm model='tpm-crb'>
      <backend type='emulator'>
        <active_pcr_banks>
          <sha256/>
        </active_pcr_banks>
      </backend>
    </tpm>

Saved.

Check xml again:
# virsh dumpxml avocado-vt-vm1 |grep /tpm -B6
    <tpm model='tpm-crb'>
      <backend type='emulator' version='2.0'>
        <active_pcr_banks>
          <sha256/>
        </active_pcr_banks>
      </backend>
    </tpm>

Version of default '2.0' is auto-added, and active_pcr_banks still exist.

Comment 6 Yanqiu Zhang 2022-10-21 11:56:08 UTC
Reproduce some issues:
libvirt-8.0.0-10.module+el8.7.0+16689+53d59bc2.x86_64
qemu-kvm-6.2.0-20.module+el8.7.0+16689+53d59bc2.1.x86_64

Steps:
1.value ’default’ previously can be accepted:
(1)"default" model.
# cat update-avocado.xml |grep /tpm -B2
    <tpm model='default'>
      <backend type='emulator' version='2.0'/>
    </tpm>
# virsh define update-avocado.xml 
Domain 'avocado-vt-vm1' defined from update-avocado.xml
# virsh dumpxml avocado-vt-vm1|grep /tpm -B2
    <tpm model='tpm-tis'>
      <backend type='emulator' version='2.0'/>
    </tpm>
(2)"default" version.
# cat update-avocado.xml |grep /tpm -B2
    <tpm model='tpm-crb'>
      <backend type='emulator' version='default'/>
    </tpm>
# virsh define update-avocado.xml 
Domain 'avocado-vt-vm1' defined from update-avocado.xml
# virsh dumpxml avocado-vt-vm1|grep /tpm -B2
    <tpm model='tpm-crb'>
      <backend type='emulator' version='2.0'/>
    </tpm>

2. Previous specific error report:
(1)
error: Failed to define domain from update-avocado.xml
error: unsupported configuration: Unknown TPM frontend model '0'
(2)
error: Failed to define domain from update-avocado.xml
error: XML error: missing TPM device backend type
(3)
error: Failed to define domain from update-avocado.xml
error: unsupported configuration: Unknown TPM backend type '0'
(4)
error: Failed to define domain from update-avocado.xml
error: unsupported configuration: Unsupported TPM version '2'


—------------------------
Verify with:
libvirt-8.8.0-1.el9.x86_64
qemu-kvm-7.1.0-3.el9.x86_64

Steps:
1. Report error for value ‘default’:
(1)# cat avocado-vt-vm1.xml|grep /tpm -B2
    <tpm model='default'>
      <backend type='emulator' version='2.0'/>
    </tpm>
# virsh define avocado-vt-vm1.xml
error: Failed to define domain from avocado-vt-vm1.xml
error: XML error: Invalid value for attribute 'model' in element 'tpm': 'default'.
(2)# cat avocado-vt-vm1.xml|grep /tpm -B2
    <tpm model='tpm-crb'>
      <backend type='emulator' version='default'/>
    </tpm>
# virsh define avocado-vt-vm1.xml
error: Failed to define domain from avocado-vt-vm1.xml
error: XML error: Invalid value for attribute 'version' in element 'backend': 'default'.

2. Current unified error report:
For unknown model(1) and unsupported version(4), same as verification steps 1(1)(2);
(2)error: Failed to define domain from avocado-vt-vm1.xml
error: XML error: Missing required attribute 'type' in element 'backend'
(3)error: Failed to define domain from avocado-vt-vm1.xml
error: XML error: Invalid value for attribute 'type' in element 'backend': '0'.


3.retest the bug issue and got same result with comment3:
Edit vm xml as:
    <tpm model='tpm-crb'>
      <backend type='emulator'>
        <active_pcr_banks>
          <sha256/>
        </active_pcr_banks>
      </backend>
    </tpm>
Saved.
# virsh dumpxml avocado-vt-vm1 |grep /tpm -B6
    <tpm model='tpm-crb'>
      <backend type='emulator' version='2.0'>
        <active_pcr_banks>
          <sha256/>
        </active_pcr_banks>
      </backend>
    </tpm>

Also get the same result if edit a xml file and define from it.

Comment 8 errata-xmlrpc 2023-05-09 07:26:11 UTC
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 (libvirt 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-2023:2171


Note You need to log in before you can comment on or make changes to this bug.