Terminate a running, paused, or crashed virtual server with or without
saving its system image.
About this task
Refer to Virtual server life cycle to
see the effect of the virsh commands to terminate a virtual server depending on its
state.
Procedure
Description |
Command |
Comments |
To properly terminate a virtual server: |
shutdown |
|
To save a system image and terminate a virtual server properly: |
managedsave |
|
To terminate a virtual server
immediately: |
destroy |
Use the --graceful option to try to properly terminate the virtual server before terminating it forcefully. |
-
In most cases, you use the virsh shutdown command to properly terminate a
virtual server.
If the virtual server does not respond, it is not
terminated.
While the virtual server is shutting down,
it traverses the state in shutdown
and finally enters the shutdown shut off
state.
# virsh shutdown <VS>
Example:
To properly shut down
virtual server vserv1,
issue:
# virsh shutdown vserv1
Domain vserv1 is being shutdown
-
Save the system image of a running or a paused virtual server and terminate it thereafter with the virsh
managedsave command.
Example:
To save the system image of
virtual server vserv2 and
properly shut it down,
issue:
# virsh managedsave vserv2
Domain vserv2 state saved by libvirt
The system image of the virtual server is resumed at the
time of the next start. Then, the state of the virtual server
is either running or paused, depending on the last state of the virtual server and the managedsave command
options.
Note: The managedsave operation will save the virtual server
state in a file in the host filesystem. This file
has at least the size of the virtual server memory. Make sure
the host filesystem has enough space to hold the virtual server state.
-
When a virtual server is not responding, you can terminate it
immediately with the virsh destroy command.
The
virtual server enters the
destroyed shut
off
state. This command might cause a loss of
data.
# virsh destroy <VS>
The --graceful option
tries to properly terminate the virtual server, and only if it
is not responding in a reasonable amount of time, it is forcefully
terminated:# virsh destroy <VS> --graceful
Example:
To force a shutdown of
virtual server vserv3,
issue:
# virsh destroy vserv3
Domain vserv3 destroyed
- <VS>
- Is the name of the virtual server as specified in its domain configuration-XML file.