Up and Running with KVM Ubuntu Style: Part Two

Last week, you tested your Ubuntu system for KVM compatibility, installed KVM on your host server and installed a guest operating system into a virtual machine. This week you’ll learn some KVM-oriented terminology and will continue your dive into KVM Ubuntu style by working with virtual machines via the virsh command.

Terminology Basics

Every technology, and sub-technology, has its own jargon and virtualization falls in line with this jargonized culture. You need to learn the KVM’s language so that you can understand the documentation and discuss KVM with other users in a meaningful way.

Most of your command line interaction with KVM will occur through virsh, the management user interface as it’s called. It’s really the KVM virtualization shell used to interact with your virtual machines (VMs). Virsh works interactively, as a shell, or in single non-interactive command mode, which makes it easier to include in other scripts so that you can create automated applications.

Before beginning this discussion, some assumptions have to be made. One is that you have your fully functioning KVM host system running as described in Part One of this series. And, you have one or more “disposable” VMs with which you can work without any fear of data loss or destruction of valuable computing resources.

Turn your focus now to a VM that is in a shut off or powered down state so that you can start using a few basic virshcommands. Virsh has the general syntax of:

sudo virsh <command> <domain> [OPTIONS]

To start a VM, issue the following command. Replace “Ubuntu_10.04″ with the name of your target VM. This command will power on and boot your VM. Note that you won’t see the console when you use this command.

You may gracefully shutdown a running VM with the shutdown command. This is the appropriate method for shutting down a VM. The other acceptable option is to issue the sudo halt -p command when logged into the VM.

If your systems never shutdown or don’t respond to the shutdown command, login to the VM and install the acpid package. That will solve the problem. The next command is the destroy command. Destroy powers off the system as if you unplugged it from its power source. A power loss like that isn’t good for a physical system or a virtual one. Reserve it for when you must kill a system quickly and without regard for data corruption. Destroy does not remove the VM’s definition file or disk file(s).

To clone a VM, you’ll have to abandon virsh for the virt-clone tool. Minimally, you have to supply the VM name that you’re cloning, which is called the source or original. You have to provide the new VM name and the disk filename(s) that you want to clone.

Undefine the domain. This means that you’re removing the domain definition from KVM.

$ sudo virsh undefine Ubuntu_10.04_2

Now, you can remove the VM’s directory and disk file(s). Neither destroy nor undefine removes the domain’s directory or disk file(s). You have to explicitly remove them from your filesystem.

$ sudo rm -rf /VM/Ubuntu_10.04_2

The Ubuntu_10.04_2 VM is now removed from your system. If you decide that you want it back, you’ll have to restore from backup. When you perform a backup, save the XML descriptor file under /etc/libvirt/qemu that bears the same name as your VM and the associated disk file(s) for your VM.

Virsh gives you a powerful interface with which you can use to manage your VMs. You can use virsh commands in scripts or call them from other programming languages to help you develop automated or web-based virtualization services. You may access help at any time by using the virsh help command for the entire list of commands. If you’re using libvirtd version < 0.6.3, upgrade to a newer version to enjoy a more functional list of virsh commands.

Next time, you’ll enjoy the third and final article in this Ubuntu-flavored KVM series where you’ll learn, finally, how to manage your VMs with the graphical application virt-manager and gather a few troubleshooting tips to boot.

?lectrlu? offers some off the best microwave ovens which ensire niform cooking,
pre?erving nuutrition and enhancing taste. Thhe Deluyxe by? P?estige
is ??afted f?om strong virgin aluminum. Hunting for a?pliaces can be a very
daunting task.

Hi! This is my first visit to your blog! We are a team of volunteers and starting a new project in a community in the same niche.
Your blog provided us useful information to work on. You have done a marvellous job!

Howdy! This article could not be written any better!
Looking through this post reminds me of my previous roommate!
He continually kept talking about this. I’ll forward this post to him.
Pretty sure he’s going to have a good read. Thanks for sharing!

Hey! I know this is kinda off topic however I’d
figured I’d ask. Would you be interested in exchanging links
or maybe guest authoring a blog article or vice-versa?
My blog discusses a lot of the same subjects as
yours and I feel we could greatly benefit from each other.

If you happen to be interested feel free to send me an
email. I look forward to hearing from you! Superb blog by the way!

of course like your web-site however you need to check the spelling on
several of your posts. A number of them are rife with spelling issues and I find it very bothersome
to inform the reality however I will definitely come again again.

It is perfect time to make some plans for the longer term and it’s time to be happy.
I have read this put up and if I may just I wish to suggest you few
fascinating issues or tips. Maybe you can write subsequent
articles regarding this article. I want to learn more issues approximately it!

Great post. I was checking constantly this weblog and I
am impressed! Very helpful info specially the remaining section :) I deal with such info a lot.
I used to be seeking this certain info for a
long time. Thanks and best of luck.

I carry on listening to the news update speak about receiving free online grant applications so I have been looking around for the top site to get one. Could you tell me please, where could i acquire some?

hi!,I really like your writing so a lot! percentage we keep up a correspondence more approximately your post on AOL? I require an expert on this area to unravel my problem. Maybe that’s you! Having a look ahead to peer you.

In previous garage then, the track alignment will
not enable the smooth Turing of the door this
may increasingly cause your door to not work at all.
Calling Portland door restore will repair it better, you may be convinced as if there was no downside on the door.

Hi! This post could not be written any better! Reading
through this post reminds me of my previous room mate!
He always kept talking about this. I will forward this article to him.
Pretty sure he will have a good read. Thank
you for sharing!