On Fri, Mar 13, 2026 at 09:06:58AM +0100, Peter Krempa via Devel wrote:
On Fri, Mar 13, 2026 at 07:46:30 -0000, Roy Orbitson via Devel wrote:
So, to clarify, the best way to power-cycle a (persistent) VM and minimise downtime is:
virsh set-lifecycle-action $DOM poweroff destroy --live && virsh await $DOM --condition domain-inactive && virsh start $DOM
'virsh set-lifecycle-action' just changes the setting of <on_poweroff>. You still need to initiate the shutdown via virsh shutdown.
I still think this would be nicer:
virsh reboot $DOM --cold
Compounding too many operations into one is brittle and may cause that some assumptions are baked in which may not make sense in other scenarios.
E.g. the above case could wait an unbounded amount of time if the guest os ignores graceful shutdown. What to do when such thing happens is a policy decision, as in some cases you might not want to just 'virsh destroy' the VM and potentialy lose data.
'virsh await' has --timeout but what to do when the timeout is reached isn't IMO for us to decide. Same would apply if we were to compound everything into what you propose.
I would highly recommend not trying todo this in shell using virsh. This is far better suited to writing a short python script using the libvirt-python API, where thereis much more flexibility and easier control to get the behaviour desired. With regards, Daniel -- |: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|