Contents
Basic management tasks such as starting or stopping a VM Guest, can either be done using the graphical application Virtual Machine Manager or on the command line using virsh. Connecting to the graphical console via VNC is only possible from a graphical user interface.
In order to be able to list VM Guests, you need to connect to a VM Host Server first. If you start the management tool on the VM Host Server itself, you are automatically connected. When operating from remote, refer to Section 7.3, “Connecting to a VM Host Server” for instructions.
The main Window of the Virtual Machine Manager shows a list of all VM Guests for each VM Host Server it is connected to. Each VM Guest entry contains the machine's name, its status (
, , or ) displayed as icon and literal, and a CPU usage bar.
Use the command virsh list
to get a
list of VM Guests:
# list running guests on localhost virsh -c qemu:///system list # list running + inactive guests on mercury over TLS connection virsh -c qemu+tls://mercury.example.com/system list --all # list running + inactive guests on mercury over SSH connection virsh -c qemu+ssh://tux@mercury.example.com/system list --inactive
Opening a Graphical Console to a VM Guest lets you interact with the machine like a physical host via a VNC connection. If accessing the VNC server requires authentication, you are prompted to enter a user name (if applicable) and a password.
Once you click into the VNC console, the cursor is “grabbed” and cannot be used outside the console anymore. To release it, press +.
Absolute Cursor Movement | |
---|---|
In order to prevent the console from grabbing the cursor and to enable absolute (seamless) cursor movement, add a tablet input device to the VM Guest. |
Certain key combinations such as ++ are interpreted by the host system and are not passed to the VM Guest.
To pass such key combinations to a VM Guest, open the
menu from the VNC window and choose the desired key combination entry.Supported VNC Viewer | |
---|---|
Principally all VNC viewers are able to connect to the console of a
VM Guest. However, if you are using SASL authentication and/or TLS/SSL
connection to access the guest, the options become limited. Common VNC
viewers such as |
In the Virtual Machine Manager, right-click on a VM Guest entry.
Choose
from the pop-up menu.virt-viewer is a simple VNC viewer with added functionality for displaying VM Guest consoles. It can, for example, be started in “wait” mode, where it waits for a VM Guest to start before it connects. It also supports automatically reconnecting to a VM Guest that is rebooted.
virt-viewer addresses VM Guests by name, by ID or by
UUID. Use virsh list --all
to get
this data.
To connect to a guest that is running or paused, either use the ID, UUID, or name. VM Guests that are shut off do not have an ID—you can only connect by UUID or name.
# local connect to guest with ID 8 virt-viewer -c qemu:///system 8 # local connect to the inactive guest sles11; will connect once # the guest starts virt-viewer --wait sles11 virt-viewer -c qemu:///system --wait sles11 # remote connect via ssh viewer -c qemu+ssh://tux@mercury.example.com/system 8 # remote connect via ssh wait / reconnect mode: virt-viewer -c qemu+ssh://root@mercury.example.com/system -w sles11
For more information, see virt-viewer
--help
or man 1
virt-viewer.
Starting, stopping or pausing a VM Guest can either be done with Virtual Machine Manager or virsh. You can also configure a VM Guest to be automatically started when booting the VM Host Server.
When shutting down a VM Guest, you may either shut it down gracefully, or force the shutdown. The latter is equivalent to pulling the power plug on a physical host and is only recommended if there are no alternatives. Forcing a shutdown may cause file system corruption and loss of data on the VM Guest.
Graceful Shutdown | |||
---|---|---|---|
In order to be able to perform a graceful shutdown, the VM Guest must be configured to support ACPI. If you have created the guest with vm-install or with Virtual Machine Manager, ACPI should be available. Use the following procedure in Virtual Machine Manager to check: Double-click the VM Guest entry in Virtual Machine Manager. Choose + and then + . should be checked.Depending on the guest operating system, enabling ACPI may not be sufficient. It is strongly recommended to test shutting down and rebooting a guest before releasing it to production. openSUSE or SUSE Linux Enterprise Desktop, for example, may require PolicyKit authorization for shutdown and reboot. Make sure this policy is turned off on all VM Guests. If ACPI was enabled during a Windows XP/Server 2003 guest installation, turning it on in the VM Guest configuration alone is not sufficient. See the following articles for more information:
A graceful shutdown is of course always possible from within the guest operating system, regardless of the VM Guest's configuration. |
Changing a VM Guest's state can either be done from Virtual Machine Manager's main window, or from a VNC window.
Procedure 6.1. State Change from the Virtual Machine Manager Window
Right-click on a VM Guest entry.
Choose
, , or one of the from the pop-up menu.Procedure 6.2. State change from the VNC Window
Open a VNC Window as described in Section 6.2.1, “Opening a Graphical Console with Virtual Machine Manager”.
Choose
, , or one of the options either from the toolbar or from the menu.Automatically starting a guest when the VM Host Server boots is not enabled by default. This feature needs to be turned on for each VM Guest individually. There is no way to activate it globally.
Double-click the VM Guest entry in Virtual Machine Manager to open its console.
Choose
+ to open the VM Guest configuration window.Choose
and check .Save the new configuration with
.In the following examples the state of a VM Guest named “sles11” is changed. All commands are run directly on the VM Host Server.
virsh -c qemu:///system start sles11 # start virsh -c qemu:///system suspend sles11 # pause virsh -c qemu:///system reboot sles11 # reboot virsh -c qemu:///system shutdown sles11 # graceful shutdown virsh -c qemu:///system destroy sles11 # force shutdown virsh -c qemu:///system autostart sles11 # turn on autostart virsh -c qemu:///system autostart --disable sles11 # turn off autostart
Saving a VM Guest preserves the exact state of the guest’s memory. The operation is slightly similar to hibernating a computer. A saved VM Guest can be quickly restored to its previously saved running condition.
When saved, the VM Guest is paused, its current memory state saved to disk, and then the guest is stopped. The operation does not make a copy of any portion of the VM Guest’s virtual disk. The amount of time to save the virtual machine depends on the amount of memory allocated. When saved, a VM Guest’s memory is returned to the pool of memory available on the VM Host Server.
The restore operation loads a VM Guest’s previously saved memory state file and starts it. The guest is not booted but rather resumes at the point where it was previously saved. The operation is slightly similar to coming out of hibernation.
The VM Guest is saved to a state file. Make sure there is enough space on the partition you are going to save to. Issue the following command on the guest to get a rough estimation of the file size in megabytes to be expected:
free -m | awk '/^Mem:/ {print $3}'
After using the save operation, do not boot, start, or run the saved VM Guest. Doing so would cause the machine's virtual disk and the saved memory state getting out of sync and can result in critical errors when restoring the guest. |
Save a running VM Guest with the command virsh
save
:
# save the guest named opensuse11 virsh save opensuse11 /virtual/saves/opensuse11.vmsave # save the guest with Id 37 virsh save 37 /virtual/saves/opensuse11.vmsave
To restore it, use virsh restore
:
virsh restore /virtual/saves/opensuse11.vmsave
Deleting a VM Guest removes its XML configuration by default. Since the attached storage is not deleted, you will be able to use it with another VM Guest. With Virtual Machine Manager you may also delete a guest's storage files as well—this will completely erase the guest.
In order to delete a VM Guest, it has to be shut down first (refer to Section 6.3, “Changing a VM Guest's State: Start, Stop, Pause” for instructions). It is not possible to delete a running guest.
In the Virtual Machine Manager, right-click on a VM Guest entry.
Choose
from the pop-up menu.A confirmation window opens. Clicking
will permanently erase the VM Guest. The deletion is not recoverable.You may also choose to permanently delete the guest's virtual disk by ticking
. The deletion is not recoverable either.
To delete a VM Guest with virsh run virsh
undefine
VM_NAME
.
There is no option to automatically delete the attached storage files.