I’ve always been in love with opensource for a long time. Thanks to the M.D of our company for introducing me to this beautiful world. I’ve learnt alot from this world and I desperately wanted to share what I have. Today, I’m gonna share my experience in dealing with KVM using libvirt virtualization API, and few other stuff if I find some more time. Now, managing KVM on a host machine is really touch, particularly if you have couple of hosts running with migration testing switched on. I really had touch time dealing with those machines.
Any ways, if you are new to KVM and stuff, then here is how you install KVM on a debian lenny. This is one of those the best tutorial I found on the internet. Of-course, its the first result for the Google Search “Installing kvm in debian lenny”.
Here are some virsh basic terminal commands that will get u started with KVM. You can always use “Virt-manager” to control the VM’s but I love using it from a command line prompt. Here is how you can use it.
virsh -c qemu:///system list –all
virsh list Id Name State
0 Domain-0 running
1 lenny running
2 fedora paused
The above command connects (-c) to qemu and lists out all (both active and inactive) VM’s available. l
You can alternatively do this to do the same.
virsh -c qemu:///system
virsh# list –all
Here is how u can see inactive virtual machines.
virsh -c qemu:///system list –inactive
Any approach is right!! Now, here is how you can look at your host configuration of your KVM machine. This generally gives you information about your CPU and memory available.
virsh -c qemu:///system nodeinfo
Here is how you can edit the configuration file of a particular VM. Make sure to edit the machine after turning it off. Also note that “lenny” in the following command is the name of the virtual machine. I will use this through out the rest of the document.
virsh -c qemu:///system edit lenny
Check this out, to find the xml format of the document. That’s the best document you can possibly find to edit your VM.
Here is how you can shutdown your VM.
virsh -c qemu:///system shutdown lenny
If your machine is not down, you should possibly bring it down from the VM console.
Here is how you can start your VM.
virsh -c qemu:///system start lenny
Viewing your Virtual Machine console is straight if you have virt-manager installed. You can alternately use virt-viewer to view your machine. Here is how you can do it. Make sure your xterm display is set. Here is how you can check it.
Debian:~# echo $DISPLAY
If you see nothing, then your display is not set. The display is generally set to the user with which you logged in. You can generally forward the display settings to the root from user account by doing this.
user@Debian:~$ ssh -X root@your-host-name
And now your display should be enabled.
Now, do this to view your virtual machine.
Debian:~# virt-viewer lenny
user@Debian:~$ sudo virt-viewer lenny
That’s how it ends for now. I will be back with few more other tutorials later on. Let me know if u have some questions. Shall reply you in my free time.
If you like this article, then please consider sharing it. Sharing really inspires us to do things much better!!