
On 07/30/2017 03:08 AM, Sam Varshavchik wrote:
Using virsh edit, I made the following change to the domain XML file:
<on_reboot>destroy</on_reboot>
But this appears to do nothing. The VM guest is Windows 10, and when directing it to reboot, it still reboots, instead of shutting off the VM.
I was trying to work around some kind of a bug, somewhere, that started happening after updating to Fedora 26 and qemu 2.9, where a reboot throws my Windows 10 guests into some kind of a bizarre automatic recovery mode, which then claims that the hard drive is hosed. It's not, and a forced shutdown followed by a cold start boots everything back up like nothing has happened (which I didn't figure out until reinstalling one of the guests, sigh...), and everything is peachy once again.
So, anyway, I was trying to figure out a way around it, and <on_reboot>destroy</on-reboot> seemed to be exactly what I was looking for.
Perusing qemu's man page, it seems that this option should result in a -no-reboot option getting added to qemu's command line. But, looking at the actual command line, after starting the VM, it's nowhere to be seen.
A bit more Google-fu found this:
http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html
And I manually added a -no-reboot option to the domain XML file that way.
And you know what? After doing that, telling Windows 10 to reboot simply shuts off the VM. Wonderful.
Libvirt doesn't append -no-reboot because of this commit: libvirt.org/git/?p=libvirt.git;a=commitdiff;h=0e034efaf9 Having said that, I believe libvirt puts -no-shutdown on your command line. Then, libvirt has a handler for various guest events - e.g. when the guest reboots (well, when it calls 'reset'). But when looking at its implementation it looks like there is something missing: http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_process.c;h=a11... Compare it to say SHUTDOWN event: http://libvirt.org/git/?p=libvirt.git;a=blob;f=src/qemu/qemu_process.c;h=a11... Therefore I think this is a bug. Let me see if I can propose a fix for it. Meanwhile - you can report a bug if you want. Michal