Description of problem: In cockpit we are installing VMs with virt-install and use `--wait -1` option. If a user tries to `Shut Down` the VM from outside (virsh destroy $VM_NAME) while the installation is running then virt-install restarts the VM and the VM appears running again. z Version-Release number of selected component (if applicable): 2.2.1 How reproducible: Always Steps to Reproduce: 1: sudo virt-install \ --connect qemu:///system \ --name VmTestRestart \ --wait -1 --noautoconsole \ --memory memory=300,maxmemory=400 --disk none \ --cdrom ./Fedora-Server-netinst-x86_64-31-1.9.iso WARNING Requested memory 300 MiB is less than the recommended 1024 MiB for OS fedora31 Starting install... Domain installation still in progress. Waiting for installation to complete. ^C Domain has shutdown. Continuing. Domain creation completed. Restarting guest. Actual results: While the installation is going on shut off the VM, with `virsh destroy VmTestRestart` and note that virt-install is restarting the guest. Expected results: When DESTROY signal was received virt-install should not try to restart the guest. In other words virt-install should start listening to signals, as well as waiting for the console to exit, so it can judge if the guest requires a restart.
Thanks for the report. We have similar behavior in virt-manager for when user invokes destroy from there. Wiring up in virt-install is a good thing to do but will definitely take a bit of work to teach virt-install about the event loop, but it's useful to do that anyways. A simpler solution could be to check the VM shutdown reason after noticing the state change, and if it was a user invoked destroy (probably anything besides a graceful VM shutdown) then don't do the reboot.
Upstream now: commit 26e6d3b76cebf1902d8c0a9f1568835b4e4f53c6 Author: Cole Robinson <crobinso> Date: Fri Sep 11 08:57:08 2020 -0400 virt-install: Don't reboot VM is user manually stopped it