On 3/12/26 01:51, roy-orbitson--- via Devel wrote: > When libvirt components get updated on a hypervisor, VMs continue > running with obsolete files. Programs like "needrestart" alert one to > this condition with messages like: > > VM guests are running outdated hypervisor (qemu) binaries on this host: > 'bazquux' with pid 1234 > > Normal restarting of a VM (from within or with `virsh reboot ...`) does > not resolve it because it's 'warm'; VMs must be completely shut down > then started again to utilise the updates. Afaik, to do so reliably, in > a way that minimises downtime, requires scripts like this: > > (d=bazquux; virsh shutdown --domain "$d" && until LC_ALL=C LANG=C virsh > domstate --domain "$d" | grep -Fi 'shut off' &> /dev/null; do echo ...; sleep > 1; done && virsh start --domain "$d") > > Adding a timeout complicates that further. Options for this logic to > be performed by virsh would be beneficial, as a single operation: > > virsh reboot --domain bazquux --cold > > And by allowing poweroff to wait: > > (d=bazquux; virsh shutdown --domain "$d" --synchronous && virsh start > --domain "$d")
There is an inherent problem with bundling two or more operations under a single command (and you point it out at the end): what to do when one operation in sequence fails? And specifically for powering off/rebooting a VM - that requires guest cooperation. What to do, when guest (silently) refuses poweroff/reboot request (e.g. acpid is not running)? The moment virsh introduces a timeout there's going to be a user for whom the timeout is short. > > The latter would also assist with scripting changes to a VM that can > only be performed whilst it is not running (shutdown -> alter -> start). > Ideally, these would accept `--timeout n` so that if the shutdown > portion was not completed quickly enough, they would fail and exit with > a non-zero status, and the former would not start the VM again. > > I'm not sure of a good way to handle this where `on_poweroff` is set to > something that doesn't result in the machine being shut off. > Michal
