-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix virt module to undefine a domain with nvram or other metadata #136
Fix virt module to undefine a domain with nvram or other metadata #136
Conversation
59c7f07
to
f93851c
Compare
This looks good, thanks @bturmann, but I need to go over it a bit carefully as I think this will change the behaviour quite a bit that people may have been relying on - for example, users may rely on the fact that nvram isn't cleaned up, or that VMs with snapshots aren't removed. I think it would be good to call this out in the changelog, not just as a bugfix, but potential behaviour change? |
f93851c
to
b10380c
Compare
if it's a behavioral change, it must be announced now (with |
Agreed. What do you think about following?
|
Sounds like a solution to me, @csmart what do you think? |
That sounds excellent! Thanks. |
5495963
to
d08b2fb
Compare
I just updated the first comment above to reflect the latest overall status. The PR got a bit larger, but I think for good reasons. With the two new options, it is now possible to Special cases, like using mutually exclusive flags or if For existing use cases, where none of the new options are provided, then the behaviour is exactly the same as before. |
d08b2fb
to
9c04800
Compare
Libvirt function undefine() is not able to delete nvram or other metadata. Therefore it is replaced with undefineFlags() which is able to handle it by using flags. All possible flags are listed in 'ENTRY_UNDEFINE_FLAGS_MAP'. Integer 23 makes undefine successful in all cases (1 + 2 + 4 + 16). Source: https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainUndefineFlags The flags nvram(4) and keep_nvram(8) are mutually exclusive. To control the metadata handling during undefine, two new options 'force' and 'flags' are introduced including documentation and examples. Compatibility / Risk: The function undefineFlags() appeared in libvirt version 0.9.4 which was release in 2011. It seems rather unlikely that somebody is still using an older unsupported libvirt version. Additionally, if none of the new module options are provided, then it behaves as before and maintains backward compatibility, means the overall risk of this commit should be rather low. Source: https://libvirt.org/hvsupport.html#virHypervisorDriver
9c04800
to
6abcda1
Compare
@bturmann this looks really great, thanks a lot for the work here! I will do some testing myself and if you're happy, then I'll merge it in. |
Tested well and looks great to me. Thanks @bturmann! |
* main: Improved domain definition handling Parse incoming XML instead of using regex to get name Refactor define command handling into separate function CI: add 2.14 tests, ignore-2.15 to avoid CI failing doc: set booleans to true/false for consistency Combine REVIEW_CHECKLIST.md and CONTRIBUTING.md and fix links CI: remove f35 from devel fix up failing pylint test, use before assignment Fix virt module to undefine a domain with nvram or other metadata (ansible-collections#136) Replace discouraged function listVolumes (ansible-collections#135) Replace functions listStoragePools and listDefinedStoragePools (ansible-collections#134) Update galaxy to next expected release (ansible-collections#133) Release 1.2.0 commit (ansible-collections#132)
# By Chris Smart (6) and others # Via Chris Smart * main: Improved domain definition handling Parse incoming XML instead of using regex to get name Refactor define command handling into separate function CI: add 2.14 tests, ignore-2.15 to avoid CI failing doc: set booleans to true/false for consistency Combine REVIEW_CHECKLIST.md and CONTRIBUTING.md and fix links CI: remove f35 from devel fix up failing pylint test, use before assignment Fix virt module to undefine a domain with nvram or other metadata (ansible-collections#136) Replace discouraged function listVolumes (ansible-collections#135) Replace functions listStoragePools and listDefinedStoragePools (ansible-collections#134) Update galaxy to next expected release (ansible-collections#133) Release 1.2.0 commit (ansible-collections#132)
# By Chris Smart (6) and others # Via Chris Smart * main: Improved domain definition handling Parse incoming XML instead of using regex to get name Refactor define command handling into separate function CI: add 2.14 tests, ignore-2.15 to avoid CI failing doc: set booleans to true/false for consistency Combine REVIEW_CHECKLIST.md and CONTRIBUTING.md and fix links CI: remove f35 from devel fix up failing pylint test, use before assignment Fix virt module to undefine a domain with nvram or other metadata (ansible-collections#136) Replace discouraged function listVolumes (ansible-collections#135) Replace functions listStoragePools and listDefinedStoragePools (ansible-collections#134) Update galaxy to next expected release (ansible-collections#133) Release 1.2.0 commit (ansible-collections#132)
* modules_virt_additions: Improved domain definition handling Parse incoming XML instead of using regex to get name Refactor define command handling into separate function CI: add 2.14 tests, ignore-2.15 to avoid CI failing doc: set booleans to true/false for consistency Combine REVIEW_CHECKLIST.md and CONTRIBUTING.md and fix links CI: remove f35 from devel fix up failing pylint test, use before assignment Fix virt module to undefine a domain with nvram or other metadata (ansible-collections#136) Replace discouraged function listVolumes (ansible-collections#135) Replace functions listStoragePools and listDefinedStoragePools (ansible-collections#134) Update galaxy to next expected release (ansible-collections#133) Release 1.2.0 commit (ansible-collections#132)
Was this fix released? I can't see the updated docs on https://docs.ansible.com/ansible/latest/collections/community/libvirt/virt_module.html and when I try with
I'm using:
Happy to create an issue if needed but thought I'd check here first. |
Indeed, the latest release tag seems to be 1.2.0. I left a comment in the Release Plan issue. |
Thanks for the bump, I will arrange a new release soon. |
@csmart thanks! Happy to help (if help is needed). |
@tomkivlin |
Many thanks 🙏 |
SUMMARY
Fixes #40
Libvirt function
undefine()
is not able to delete nvram or othermetadata. Therefore it is replaced with
undefineFlags()
which is able tohandle it by using flags.
All possible flags are listed in 'ENTRY_UNDEFINE_FLAGS_MAP'. Integer 23
makes
undefine
successful in all cases (1 + 2 + 4 + 16).Source:
https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainUndefineFlags
The flags
nvram
(4) andkeep_nvram
(8) are mutually exclusive.To control the metadata handling during
undefine
, two new optionsforce
andflags
are introduced including documentation and examples.Compatibility / Risk:
The function
undefineFlags()
appeared in libvirt version 0.9.4 which wasrelease in 2011. It seems rather unlikely that somebody is still using
an older unsupported libvirt version. Additionally, if none of the new
module options are provided, then it behaves as before and maintains
backward compatibility, means the overall risk of this commit should be
rather low.
Source:
https://libvirt.org/hvsupport.html#virHypervisorDriver
ISSUE TYPE
COMPONENT NAME
virt
ADDITIONAL INFORMATION
My tests confirm that the bugfix works as expected, like
undefine
a qemu guest with UEFI nvram or a qemu guest with BIOS. Also other commands are still working, likestart
,shutdown
ordestroy
.ansible adhoc command: