第 8 章 Shutting down and restarting virtual machines
On RHEL 10, you can shut down or restart a virtual machine by using the command line or by using the web console GUI.
Shutting down a virtual machine (VM) requires different steps based on whether the VM is responsive.
Shutting down a responsive VM:
If you are connected to the guest, use a shutdown command or a GUI element appropriate to the guest operating system.
注意In 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 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 root@192.0.2.1's password: Domain 'demo-guest1' is being shutdown
To force a VM to shut down, for example if it has become unresponsive, use the
virsh destroycommand on the host:# virsh destroy demo-guest1 Domain 'demo-guest1' destroyed注意The
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.In rare cases,
virsh destroymay 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 --all Id Name State ------------------------------------------ 1 demo-guest1 shut off