Bug 1857069

Summary: Firmware shows BIOS in virt-manager if add 'firmware=efi' to uefi guest xml
Product: Red Hat Enterprise Linux 8 Reporter: mxie <mxie>
Component: virt-managerAssignee: Pavel Hrdina <phrdina>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.3CC: crobinso, jsuchane, juzhou, kanderso, mzhan, tyan, tzheng, virt-maint, xiaodwan, zili
Target Milestone: rcKeywords: Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-manager-2.2.1-4.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 15:47:03 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:
Attachments:
Description Flags
firmware-efi-virt-manager.png none

Description mxie@redhat.com 2020-07-15 04:56:17 UTC
Created attachment 1701146 [details]
firmware-efi-virt-manager.png

Description of problem:
Firmware shows BIOS in virt-manager if add 'firmware=efi' to uefi guest xml


Version-Release number of selected component (if applicable):
virt-manager-2.2.1-3.el8.noarch
libvirt-6.0.0-25.module+el8.3.0+7176+57f10f42.x86_64
qemu-kvm-4.2.0-30.module+el8.3.0+7298+c26a06b8.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a uefi guest with below xml and firmware shows 'UEFI x86_64: /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd' in virt-manager
# virsh dumpxml rhel8.3-efi
....
 <os>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/rhel8.3-efi_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
....

2.Power off guest and add "firmware='efi'" to uefi guest xml, check guest in virt-mangaer but find firmware shows BIOS, pls refer to screenshot "firmware-efi-virt-manager"

# virsh dumpxml rhel8.3-efi |grep firmware -A 5
  <os firmware='efi'>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <loader secure='yes'/>
    <nvram>/var/lib/libvirt/qemu/nvram/rhel8.3-efi_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>


3.Power on guest, found firmware is changed from 'BIOS' to 'UEFI x86_64: /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd' in virt-manager, and found os attribute of guest xml is different if check xml in different ways

Check guest xml in virt-manger: 
....
<os firmware="efi">
    <type arch="x86_64" machine="pc-q35-rhel8.2.0">hvm</type>
    <loader secure="yes"/>
    <nvram>/var/lib/libvirt/qemu/nvram/rhel8.3-efi_VARS.fd</nvram>
    <boot dev="hd"/>
  </os>
......

Check guest xml by virsh edit:
.....
 <os firmware='efi'>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <loader secure='yes'/>
    <nvram>/var/lib/libvirt/qemu/nvram/rhel8.3-efi_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
.....

Check guest xml by virsh dumpxml:
....
  <os>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/rhel8.3-efi_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
....



Actual results:
As above description

Expected results:
Should show guest firmware correctly in virt-manager if uefi guest has 'firmware=efi' element in libvirtxml

Additional info:
Can reproduce the problem on rhel8.3 fast stream:
virt-manager-2.2.1-3.el8.noarch
libvirt-6.5.0-1.module+el8.3.0+7323+d54bb644.x86_64
qemu-kvm-5.0.0-0.module+el8.3.0+7323+d54bb644.wrb200701.x86_64

Comment 1 zhoujunqin 2020-07-15 06:27:59 UTC
Additional info, I also find that I fail to delete VM (under Comment 0 configuration) on virt-manager.

VM's xml configuration:
...
 <os firmware="efi">
    <type arch="x86_64" machine="pc-q35-rhel8.3.0">hvm</type>
    <boot dev="hd"/>
  </os>
...

When guest in shutoff status, then try to delete it:

Error deleting virtual machine 'rhel8.2-juzhou': Requested operation is not valid: cannot undefine domain with nvram

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1303, in delete
    self._backend.undefineFlags(flags)
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 2925, in undefineFlags
    if ret == -1: raise libvirtError ('virDomainUndefineFlags() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: cannot undefine domain with nvram

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/delete.py", line 191, in _async_delete
    vm.delete()
  File "/usr/share/virt-manager/virtManager/object/libvirtobject.py", line 66, in newfn
    ret = fn(self, *args, **kwargs)
  File "/usr/share/virt-manager/virtManager/object/domain.py", line 1307, in delete
    self._backend.undefine()
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 2889, in undefine
    if ret == -1: raise libvirtError ('virDomainUndefine() failed', dom=self)
libvirt.libvirtError: Requested operation is not valid: cannot undefine domain with nvram


Additionally, there were errors removing certain storage devices: 


-------------------------------------------
The VM can be deleted by # virsh undefine $vm --nvram command, so please fix it together, thanks.

Comment 2 Jaroslav Suchanek 2020-07-15 14:18:52 UTC
As for the issue from comment 0, this should be fixed upstream already by commit:

commit 15a9502b7b7a263c4d66ff2b3f31c209f58fe0b4
Author:     Lin Ma <lma>
AuthorDate: Wed Jan 15 10:34:12 2020 +0800
Commit:     Cole Robinson <crobinso>
CommitDate: Wed Jan 15 10:21:46 2020 -0500

    details: Fix showing the firmware type in case of firmware auto selection
    
    For a shutoff VM, If user select uefi firmware auto selection, e.g.
    <os firmware='efi'>
    ...
    </os>
    
    Its firmware information is set to 'BIOS' in details, This is incorrect.
    This fixes it.
    
    Reviewed-by: Cole Robinson <crobinso>
    Signed-off-by: Lin Ma <lma>

v2.2.1-157-g15a9502b

Comment 3 Pavel Hrdina 2020-08-13 14:47:00 UTC
For the issue from Comment 0 there is additional patch required from upstream:

commit e8bf16b983558010cc9645e09eb36117e9e4fba4
Author: Pavel Hrdina <phrdina>
Date:   Tue Jul 21 12:33:56 2020 +0200

    details: fix detection of firmware auto-selection

Comment 4 Pavel Hrdina 2020-08-13 14:48:29 UTC
For the issue from Comment 1 please create a new BZ. Both issues are related to firmware autoselection but they are different issues.

Comment 6 zhoujunqin 2020-08-17 03:55:24 UTC
(In reply to Pavel Hrdina from comment #4)
> For the issue from Comment 1 please create a new BZ. Both issues are related
> to firmware autoselection but they are different issues.

Thanks Pavel.
I have filed Bug 1869135 to track Comment 1 issue, thanks very much.

Comment 17 zhoujunqin 2020-11-26 12:01:16 UTC
I can reproduce this issue with package:
virt-install-2.2.1-3.el8.noarch
virt-manager-common-2.2.1-3.el8.noarch

Steps as Comment 0.

Then try to verify this bug with new build:
virt-manager-common-2.2.1-4.el8.noarch
virt-install-2.2.1-4.el8.noarch
libvirt-6.0.0-30.module+el8.4.0+8705+34397d87.x86_64
qemu-kvm-4.2.0-37.module+el8.4.0+8837+c89bcfe6.x86_64
kernel-4.18.0-249.el8.x86_64

Steps:
1. Prepare a uefi vm with below xml and firmware shows 'UEFI x86_64: /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd' in virt-manager
# virsh dumpxml rhel8.3
....
  <os>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <loader readonly='yes' secure='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/rhel8.3_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
....

2. Power off vm and add "firmware='efi'" to vm's xml, then check the firmware type via virt-manager.
 

Hypervisor Details
Hypervisor: KVM
Architecture: x86_64
Chipset: Q35
Firmware: UEFI

Result: Firmware shows UEFI correctly.

3. Power on vm to ensure the vm can boot up successfully.
Result: vm can start successfully

3.1 Check guest xml in virt-manger: 
...
  <os firmware="efi">
    <type arch="x86_64" machine="pc-q35-rhel8.2.0">hvm</type>
    <boot dev="hd"/>
  </os>
...

3.2 Check guest xml by virsh edit:
...
  <os firmware='efi'>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <boot dev='hd'/>
  </os>

...

3.3 Check guest xml by virsh dumpxml:
...
  <os>
    <type arch='x86_64' machine='pc-q35-rhel8.2.0'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd</loader>
    <nvram template='/usr/share/edk2/ovmf/OVMF_VARS.secboot.fd'>/var/lib/libvirt/qemu/nvram/rhel8.3_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
...

4. Navigate to "Show virtual hardware details" page, then check the information of Overview tab.

Hypervisor Details
Hypervisor: KVM
Architecture: x86_64
Chipset: Q35
Firmware: /usr/share/edk2/ovmf/OVMF_CODE.secboot.fd

Result: Firmware changes to "/usr/share/edk2/ovmf/OVMF_CODE.secboot.fd" correctly in virt-manager.


So I move this bug from ON_QA to VERIFIED status based on above testing.

Comment 19 errata-xmlrpc 2021-05-18 15:47:03 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 (virt-manager 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-2021:1843