Changes

Managing and Monitoring CentOS based KVM Guest Systems

6,122 bytes added, 14:29, 14 July 2010
New page: In the previous chapters we covered the steps necessary to configure the CentOS operating system to act as a KVM host system and created, installed and ran a KVM guest system. In this ch...
In the previous chapters we covered the steps necessary to configure the CentOS operating system to act as a KVM host system and created, installed and ran a KVM guest system.

In this chapter we will explore the use of the virt-manager tool to manage the KVM guest operating systems.

== Starting and Stopping CentOS based KVM Guest Systems ==

When a KVM virtual guest system has been configured it will appear in the list of systems when the virt-manager is loaded. The virt-manager tool is launched either by selecting ''Applications -> System Tools -> Virtual Machine Manager'' or from the command-line by running ''virt-manager''. If virt-manager shows the host system as being disconnected, connect to it either by double clicking on the host in the list or right clicking on it and selecting ''Connect'' from the resulting menu.

The following screenshot shows the virt-manager tool running on a CentOS system. It lists one connected host system (named centos5), and one guest virtual system named Windows7 which is currently running:


[[Image:centos_kvm_virt_manager_vm_running.jpg|The CentOS virt-manager listing one virtual machine as running]]


To launch a guest virtual OS, either double click on the virtual machine in the list or select the machine and click on the Open button to display the virtual machine console. Once the virtual machine console appears, click on the Run button located in the toolbar.

To stop a virtual machine running a guest OS it is not sufficient to simply close the Virtual Machine Console and Virtual Machine Manager windows. Doing so only closes the manager and console, leaving the guest operating system running in the background. In fact, if you try closing these windows and then restart the virt-manager tool you will see the guest OS is still listed as running, and double clicking on it will display the guest OS exactly as it was before you closed the console window.

To shutdown a guest OS, either shut it down using the operating system's own shut down mechanism, select an option from the Virtual Machine Console Shutdown toolbar button menu, or right click on the guest OS from the list in the virt-manager main screen and select ''Shutdown'' followed by the type of shutdown you want to perform.

== Pausing a KVM Guest Operating System ==

KVM provides the ability to pause and resume a running guest operating system. To pause a running system, either select ''Pause'' in the Virtual Machine Console toolbar, or right click the operating system in the virt-manager main screen and select ''Pause''.

A paused guest OS may then be resumed either by clicking again on the Pause toolbar option in the Virtual Machine Console, or right clicking the operating system in the virt-manager main screen and selecting Resume.

Note that a paused guest system will not survive the reboot of the host operating system and continues to use system memory in the paused state. In the event that the host operating system is rebooted, the guest operating system will need to be restarted and cannot be resumed from its paused state.

== Changing KVM Virtual Guest System Settings ==

During the initial configuration of the guest OS in virt-manager a number of resources such as memory allocation and CPU usage were defined. It is common to discover after the guest OS starts running that these settings need to be changed. Fortunately, virt-manager makes it easy to change these settings, though it is important to note that some settings (such as the number virtual CPUs and current memory allocation) can only be changed when the corresponding virtual machine is shut down.

Settings are changed from within the ''Hardware'' screen of the Virtual Machine Console window. Once the hardware tab has been selected, the screen should appear as illustrated in the following figure:


[[Image:centos_kvm_virtual_machine_hardware_settings.jpg|Configuring CentOS KVm Vm hardware settings]]


The hardware screen consists of a list of categories on the left hand side and the settings corresponding to the currently selected category in the main panel. The panel on the left allows the currently displayed category to be changed. For example, to change the memory assigned to the guest system, select the Memory option and change the settings as required, clicking the Apply button to commit the new settings:


[[Image:centos_kvm_configure_memory.jpg|Configuring the memory allocated to a Centos/KVM based virtual machine]]


Additional disks and other devices may be added by clicking on the Add Hardware button at the bottom of the hardware category list, selecting Storage from the Hardware type menu and clicking on Forward. Specify either a disk partition, or a file location to act as the new disk.

== Monitoring Virtual Machine Performance ==

The virt-manager tool provides information on CPU and memory usage together with disk and network I/O activity for each guest operating system. Monitoring of Disk and Network I/O are disabled by default. To enabling monitoring of these statistics, select ''Edit -> Preferences'' from the main virt-manager window and enable the checkboxes next to ''Disk I/O'' and ''Network I/O'':


[[Image:centos_kvm_enable_disk_and_network_monitoring.jpg|Enabling Disk and Network I/O monitoring on a virt-manager]]


To view the performance graphs, display the virtual machine console window (double click on the guest in the virt-manager window) and select the Overview tab. The performance screen will display real-time graphs showing the performance statistics for the selected guest:


[[Image:centos_kvm_vm_usage_monitoring.jpg|Monitoring the performance of a KVm virtual machine]]


In addition, the virt-manager main window displays smaller CPU graph scale next to each guest OS.

== Monitoring Host Performance ==

The overall performance statistics of the host operating system may similarly be viewed by selecting the host item in virt-manager and selecting the ''Edit -> Host Details'' menu option:


[[Image:centos_kvm_host_performance.jpg|Monitoring the performance of a KVM host system running on CentOS]]