Chapter 6. Shutting down virtual machines
To shut down or restart a virtual machine on a RHEL 9 host, you can use the command line or the web console GUI.
6.1. Shutting down a virtual machine by using the command line Copy linkLink copied to clipboard!
To shut down a virtual machine (VM), you can use the virsh shutdown command. If the VM is unresponsive, you can force the shutdown by using the virsh destroy command.
Prerequisites
- You have a running VM on your host.
Procedure
To shut down a responsive VM, do one of the following:
If you are connected to the guest, use a shutdown command or a GUI element appropriate to the guest operating system.
NoteIn some environments, such as in Linux guests that use the GNOME Desktop, using the GUI power button for suspending or hibernating the guest might instead shut down the VM.
Alternatively, use the
virsh shutdowncommand on the host:If the VM is on a local host:
# virsh shutdown <demo-guest1>Successful output:
Domain 'demo-guest1' is being shutdownIf the VM is on a remote host (in this example 192.0.2.1):
# virsh -c qemu+ssh://root@192.0.2.1/system shutdown <demo-guest1>Successful output:
root@192.0.2.1's password: Domain 'demo-guest1' is being shutdown
If the VM is not responding, you can force it to shut down. To do this, use the
virsh destroycommand on the host:# virsh destroy <demo-guest1>Successful output:
Domain 'demo-guest1' destroyedImportantThe
virsh destroycommand does not actually delete or remove the VM configuration or disk images. It only terminates the running instance of the VM, similarly to pulling the power cord from a physical machine.However, in rare cases,
virsh destroymight cause corruption of the VM’s file system, so use this command only if all other shutdown methods have failed.
Verification
On the host, display the list of your VMs to see their status.
# virsh list --allSuccessful output:
Id Name State ------------------------------------------ 1 demo-guest1 shut off
6.2. Shutting down and restarting virtual machines by using the web console Copy linkLink copied to clipboard!
Using the RHEL 9 web console, you can shut down or restart running virtual machines. You can also send a non-maskable interrupt to an unresponsive virtual machine.
6.2.1. Shutting down virtual machines in the web console Copy linkLink copied to clipboard!
To shut down a running virtual machine (VM), you can use the interface in the RHEL 9 web console.
Prerequisites
- You have installed the RHEL 9 web console.
- You have enabled the cockpit service.
Your user account is allowed to log in to the web console.
For instructions, see Installing and enabling the web console.
- The web console VM plug-in is installed on your system.
Procedure
- In the interface, find the row of the VM you want to shut down.
On the right side of the row, click .
The VM shuts down.
Troubleshooting
- If the VM does not shut down, click the Menu button next to the button and select .
- To shut down an unresponsive VM, you can also send a non-maskable interrupt.
6.2.2. Restarting virtual machines by using the web console Copy linkLink copied to clipboard!
To restart a running virtual machine (VM), you can use the Virtual Machines interface in the RHEL 9 web console.
Prerequisites
- You have installed the RHEL 9 web console.
- You have enabled the cockpit service.
Your user account is allowed to log in to the web console.
For instructions, see Installing and enabling the web console.
- The web console VM plug-in is installed on your system.
Procedure
- In the interface, find the row of the VM you want to restart.
On the right side of the row, click the Menu button .
A drop-down menu of actions appears.
In the drop-down menu, click .
The VM shuts down and restarts.
Troubleshooting
- If the VM does not restart, click the Menu button next to the button and select .
- To shut down an unresponsive VM, you can also send a non-maskable interrupt.
6.2.3. Sending non-maskable interrupts to VMs by using the web console Copy linkLink copied to clipboard!
Sending a non-maskable interrupt (NMI) may cause an unresponsive running virtual machine (VM) to respond or shut down. For example, you can send the Ctrl+Alt+Del NMI to a VM that is not responding to standard input.
Prerequisites
- You have installed the RHEL 9 web console.
- You have enabled the cockpit service.
Your user account is allowed to log in to the web console.
For instructions, see Installing and enabling the web console.
- The web console VM plug-in is installed on your system.
Procedure
- Log in to the RHEL 9 web console.
- In the interface, find the row of the VM to which you want to send an NMI.
On the right side of the row, click the Menu button .
A drop-down menu of actions appears.
In the drop-down menu, click .
An NMI is sent to the VM.