Bug 1869135

Summary: Failed to delete shutoff vm if 'firmware=efi' to uefi guest xml via virt-manager
Product: Red Hat Enterprise Linux 8 Reporter: zhoujunqin <juzhou>
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, mxie, phrdina, tyan, tzheng, virt-maint, xiaodwan, zili
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
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:

Description zhoujunqin 2020-08-17 03:54:28 UTC
Description of problem:
Failed to delete shutoff vm if  'firmware=efi' to uefi guest xml via virt-manager 

Version-Release number of selected component (if applicable):
virt-manager-2.2.1-3.el8.noarch
virt-install-2.2.1-3.el8.noarch
qemu-kvm-4.2.0-32.module+el8.3.0+7629+c86ce105.x86_64
libvirt-6.0.0-27.module+el8.3.0+7602+4b93512e.x86_64


How reproducible:
100%

Steps to Reproduce:
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.2-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.2-efi_VARS.fd</nvram>
    <boot dev="hd"/>
  </os>
....

2. Power off vm and add "firmware='efi'" to vm's xml, check vm xml file
 
# virsh dumpxml rhel8.2-efi --inactive |grep firmware -A 5

  <os firmware="efi">
    <type arch="x86_64" machine="pc-q35-rhel8.2.0">hvm</type>
    <boot dev="hd"/>
  </os>

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

4. Power off vm again and delete it via virt-manager

Error deleting virtual machine 'rhel8.2-efi': 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 2924, 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 2888, 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: 


Actual results:
As described.

Expected results:
Fix it.

Additional info:
The VM can be deleted by # virsh undefine $vm --nvram command, thanks.

Comment 1 Cole Robinson 2020-09-08 23:33:45 UTC
Fixed upstream now:

commit 38cd19b0c31788cb5e6d16cfa122d52a8c7f630d
Author: Cole Robinson <crobinso>
Date:   Tue Sep 8 15:15:14 2020 -0400

    domain: Fix VM deletion with firmare='efi'

Comment 5 zhoujunqin 2020-11-26 11:57:54 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, check vm's xml file
 
# virsh dumpxml rhel8.2-efi --inactive |grep firmware -A 5

  <os firmware="efi">
    <type arch="x86_64" machine="pc-q35-rhel8.2.0">hvm</type>
    <boot dev="hd"/>
  </os>

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

4. Power off vm again and delete it via virt-manager

Result: Vm can be deleted successfully.

5. Restart vm again and delete it via virt-manager when it's running.

Result: Vm can be deleted successfully.


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

Comment 7 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