Bug 1467245
| Summary: | nvram file will not be deleted if use virsh to undefine a running uefi guest with --nvram option | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | mxie <mxie> |
| Component: | libvirt | Assignee: | Michal Privoznik <mprivozn> |
| Status: | CLOSED ERRATA | QA Contact: | lijuan men <lmen> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.4 | CC: | juzhou, kuwei, mzhan, rbalakri, tzheng, xiaodwan, xuzhang, yafu |
| Target Milestone: | rc | Keywords: | Upstream |
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | libvirt-3.7.0-1.el7 | Doc Type: | If docs needed, set a value |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2018-04-10 10:50:46 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: | |||
This is not specific just to NVRAM, e.g. snapshot metadata is also left behind. I wonder if we can remove those files and rely on qemu having them opened. (In reply to Michal Privoznik from comment #2) > This is not specific just to NVRAM, e.g. snapshot metadata is also left > behind. I wonder if we can remove those files and rely on qemu having them > opened. Ah, my bad. snapshot metadata are removed in different parts of the code. Anyway, patches proposed here: https://www.redhat.com/archives/libvir-list/2017-August/msg00221.html I've just pushed the patch upstream:
commit e488ebb31d523c68b0342ea62cd2e174644d66e3
Author: Michal Privoznik <mprivozn>
AuthorDate: Mon Aug 7 13:18:23 2017 +0200
Commit: Michal Privoznik <mprivozn>
CommitDate: Thu Aug 10 09:30:15 2017 +0200
qemuDomainUndefineFlags: unlink nvram file regardless of domain state
https://bugzilla.redhat.com/show_bug.cgi?id=1467245
Currently, there's a bug when undefining a domain with NVRAM
store. Basically, the unlink() of the NVRAM store file happens
during the undefine procedure iff domain is inactive. So, if
domain is running and undefine is called the file is left behind.
It won't be removed in the domain cleanup process either
(qemuProcessStop). One of the solutions is to remove if
regardless of the domain state and rely on qemu having the file
opened. This still has a downside that if the domain is defined
back the NVRAM store file is going to be new, any changes to the
current one are lost (just like with any other file that is
deleted while a process has it opened). But is it really a
downside?
Signed-off-by: Michal Privoznik <mprivozn>
v3.6.0-64-ge488ebb31
verify the bug:
version:
libvirt-3.7.0-2.el7.x86_64
qemu-kvm-rhev-2.9.0-16.el7_4.8.x86_64
OVMF-20170228-5.gitc325e41585e3.el7.noarch
steps:
1.prepare a OVMF guest with the xml:
<os>
<type arch='x86_64' machine='pc-q35-rhel7.4.0'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.secboot.fd</loader>
<nvram>/var/lib/libvirt/qemu/nvram/uefi_VARS.fd</nvram>
<boot dev='hd'/>
</os>
2.start the guest
[root@lmen1 ~]# virsh start uefi
Domain uefi started
3.check the vnram file
[root@lmen1 ~]# ls /var/lib/libvirt/qemu/nvram/uefi_VARS.fd
/var/lib/libvirt/qemu/nvram/uefi_VARS.fd
4.undefine the running guest
[root@lmen1 ~]# virsh undefine uefi --nvram
Domain uefi has been undefined
5.check the nvram file again
[root@lmen1 ~]# ls /var/lib/libvirt/qemu/nvram/uefi_VARS.fd
ls: cannot access /var/lib/libvirt/qemu/nvram/uefi_VARS.fd: No such file or directory
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, 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/RHEA-2018:0704 |
Description of problem: nvram file will not be deleted if use virsh to undefine a running uefi guest with --nvram option Version-Release number of selected component (if applicable): libvirt-3.2.0-14.el7.x86_64 qemu-kvm-rhev-2.9.0-14.el7.x86_64 OVMF-20170228-5.gitc325e41585e3.el7.noarch How reproducible: 100% Steps to Reproduce: 1.Check --nvram option in virsh man page #man virsh --nvram and --keep-nvram specify accordingly to delete or keep nvram (/domain/os/nvram/) file. If the domain has an nvram file and the flags are omitted, the undefine will fail. Result: nvram file should be deleted when undefine a guest with --nvram option by virsh 2.Prepare a uefi guest # virsh dumpxml win2012r2-efi <domain type='kvm'> <name>win2012r2-efi</name> <uuid>05b35b4f-ea2a-4d47-8dd5-83fe77b2d1d1</uuid> <memory unit='KiB'>4194304</memory> <currentMemory unit='KiB'>4194304</currentMemory> <vcpu placement='static'>1</vcpu> <os> <type arch='x86_64' machine='pc-q35-rhel7.4.0'>hvm</type> <loader readonly='yes' secure='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.secboot.fd</loader> <nvram template='/usr/share/OVMF/OVMF_VARS.fd'>/var/lib/libvirt/qemu/nvram/win2012r2-efi_VARS.fd</nvram> .... 3.Power on a guest # virsh start win2012r2-efi Domain win2012r2-efi started 4.Use virsh to undefine the running uefi guest with --nvram option # virsh undefine win2012r2-efi --nvram Domain win2012r2-efi has been undefined 5.The guest's nvram file is not deleted # ls /var/lib/libvirt/qemu/nvram/ ... win2012r2-efi_VARS.fd 6.# virsh destroy Auto-esx6.0-win7-efi Domain Auto-esx6.0-win7-efi destroyed 7.# virsh list --all there is no win2012r2-efi guest 8.The guest's nvram file still exists # ls /var/lib/libvirt/qemu/nvram/ .... win2012r2-efi_VARS.fd Actual results: As above description Expected results: nvram file will be deleted if use virsh to undefine a running uefi guest with --nvram option Additional info: 1.nvram file could be deleted if use virsh to undefine a shutdown uefi guest with --nvram option