Managing KVM Deployments with Virt-Manager
Before diving into creating virtual machines, it's important to take a look at the related tools and files. Virtual Machine Manager is actually a suite of tools for working with virtual machines:
virt-install: command-line tool used to install software into a VM image.
virt-clone: command-line tool used to clone a VM image.
virt-manager: GUI for starting, stopping and using VM images.
virt-image: command-line tool used to create a VM-based on an XML description.
The first three of these will be used to create, clone and use virtual machines. The latter is useful for advanced users but is beyond the scope of this article.
The virt-manager tools are Python programs that depend on the libvirt library to manage virtual machines and QEMU to run the virtual machines. Both libvirt and QEMU offer sophisticated features for a wide variety of tasks. Fortunately, you don't need to know anything about QEMU to get started using a VM, and you need to know only very basic information about libvirt.
The virt-manager application uses VNC to connect to remote libvirt dæmons and view remote virtual machines on a local display. This means you can launch virt-manager on your system and connect to a VM running on another system across the network. Such connections will require password authentication in most cases, depending on how libvirt is configured. This article takes the simple (and highly insecure) path of using root SSH access to access remote hosts. This works for my company, because the virtual machines are on an insulated networks. This also works if you're behind a well-configured firewall at home, but to be safe, consider further research into the secure (TLS) transport options of libvirt.
Note that virt-manager provides a wizard for creating new virtual machines on the localhost using local or remote media installations (Figure 1). However, this article focuses on the underlying tools virt-install and virt-clone. These tools offer far more power and flexibility when creating virtual machines.
With the software installed and the host network configured, it's time to create a base image. The base image is an installation of an operating system into a VM image file. These files can take multiple formats, but the recommended format is qcow2:
sudo virt-install --connect qemu:///system \
-n <vm-name> \
-r 512 \
--vcpus=1 \
-f ~/<vm-name>.qcow2 \
-s 12 \
-c <distro-install-image>.iso \
--vnc \
--noautoconsole \
--accelerate \
--os-type linux \
--os-variant generic26 \
--network=bridge:br0
Replace <vm-name> with a symbolic name for the virtual machine. At work, we use the distribution name, version and CPU size, such as “fedora11-64”. The <distro-install-image> is the name of the ISO image file used to install a Linux distribution.
The man page for virt-install covers the available options in detail. This particular command attaches to the local hypervisor as root (--connect) and sets up a guest virtual machine with 512MB of memory and the maximum number of CPUs it can use (-r, --vcpus). It will create a virtual machine image in the file ~/<vm-name>.qcow2 that is 12GB (-f, -s) and boot the installation media <distro-install-image>.iso. virt-install will start a VNC console on the guest and make it available for use via the host (--vnc), but no connection to it is started by default (--noautoconsole). A connection to it will be made later using virt-manager. The guest machine will run using kernel acceleration if available (--accelerate).
The guest will be created using optimized ACPI, APIC, mouse and other hardware configurations (--os-type, --os-variant) and use the bridged network device (--network). Note that the os_type has specific valid values. Check the man page for details.
This command will exit immediately while it starts up the VM in the background. To interact with the operating system installation, start the virt-manager application. This program will recognize VNC servers on the local network and list them (Figure 2). Double-clicking on one will open a connection to that host and list the available guest systems. Double-clicking on a guest will open a window to the guest (Figure 3).

Figure 2. The virt-manager window shows hosts with VNC servers. Connecting to the localhost is automatic.

Figure 3. Each OS will set the default size of the console. The console window can be scaled up, but not down, using the View→Scale Display menu.
With the VNC window open, the installation proceeds just as it would when installing on bare metal. Click inside the VM window to activate the guest VM mouse, then hold down Ctrl-Alt at the same time to return the mouse to the host desktop. In many cases, you won't need to capture the mouse pointer this way. Instead, just type with the host mouse pointer over the VM console window and keystrokes are passed to the guest VM.
Once the installation completes, a reboot typically is required. A reboot of the VM, that is—a reboot in this VM instance shuts down only the virtual machine, not the host. You must use the Run button in the menu bar of the VNC window to start the VM again manually. After rebooting, be sure to install any updates for the Linux distribution.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- RSS Feeds
- A Topic for Discussion - Open Source Feature-Richness?
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Readers' Choice Awards
- The Secret Password Is...
- All the articles you talked
1 hour 17 min ago - All the articles you talked
1 hour 20 min ago - All the articles you talked
1 hour 22 min ago - myip
5 hours 47 min ago - Keeping track of IP address
7 hours 38 min ago - Roll your own dynamic dns
12 hours 51 min ago - Please correct the URL for Salt Stack's web site
16 hours 2 min ago - Android is Linux -- why no better inter-operation
18 hours 18 min ago - Connecting Android device to desktop Linux via USB
18 hours 46 min ago - Find new cell phone and tablet pc
19 hours 44 min ago





Comments
Configuring the host for DHCP address assignment
I'm confused by the paragraph describing configuration of the host for DHCP network access. The lines listed are to be left "out"? Out of which file - ifcfg-br0 or ifcfg-eth0? My first guess would be that ifcfg-eth0 should contain the same contents as for a statically addressed host, and that the lines listed should appear in ifcfg-br0. Please clarify.
Thanks.