Bug 1818089 - virt-install: don't perform post-install VM boot if user 'virsh destroy'd the VM
Summary: virt-install: don't perform post-install VM boot if user 'virsh destroy'd the VM
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: virt-manager
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Cole Robinson
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-03-27 16:16 UTC by Katerina Koukiou
Modified: 2021-05-20 10:41 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2020-09-11 13:38:54 UTC
Embargoed:


Attachments (Terms of Use)

Description Katerina Koukiou 2020-03-27 16:16:08 UTC
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.

Comment 1 Cole Robinson 2020-03-27 18:47:22 UTC
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.

Comment 2 Cole Robinson 2020-09-11 13:38:54 UTC
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


Note You need to log in before you can comment on or make changes to this bug.