Showing posts with label kvm. Show all posts
Showing posts with label kvm. Show all posts

Tuesday, May 20, 2014

How do I enable nested virtualization on KVM?

Nested virtualization allows you to run virtual machines inside a virtual machine. Though this is not good for any kind of production use case because of the performance issues involved, this is usually good for testing purposes. Eg, students can be given virtual machines to test virtualization without allocating physical systems per head count.

I am only covering intel cpus in this blog post. The steps are very simple.

  • Verify that nested virtualization is not enabled already.
cat  /sys/module/kvm_intel/parameters/nested
N
  •  Add below line to /etc/modprobe.d/kvm-intel.conf
options kvm-intel nested=1
  • Reboot the host or do
modprobe -r kvm-intel
modprobe kvm-intel
  • Verify that nested virtualization is enabled.
cat  /sys/module/kvm_intel/parameters/nested
Y

Sunday, September 6, 2009

How to clone a guest over the network?

Below are the steps that I followed to clone an RHEL5 guest running under vmware ESX-3.5 to Xen environment over the network. The method that I followed can be used to clone any virtual machine (except windows?) running under any virtualization product to any other virtualization product (Correct?). I agree that there are specific tools provided by vendors for p2v and v2v conversions, but they are limited to their virtualization product. Eg, Vmware tools may not be used to convert a virtual machine running under vmware to run on Xen/KVM and vice-versa.

Pre-requisites.

- Linux based LiveCD. (Which should have coreutils and nc - netcat - packages installed).

Below are the steps that I followed:

- Downloaded the LiveCD for Fedora 10 from here (You can use whatever Linux LiveCD you want.)

- Booted the rhel5 virtual machine already available in Vmware ESX from this ISO by attaching this ISO to the guest and selecting cdrom as the first boot device. (Consult the concerned documentation for more details)

- Created a new blank guest in Xen and assigned it a hard disk with the same size of vmware disk. I just created a fully virtualized guest using virt-manager and when it started the anaconda installation, aborted the installation and shutdown the guest. Now I have a guest with a blank image.

- Then started the blank guest under Xen from the Fedora LiveCD. (If not sure how to do it, please consult xen documentation).

Now we have both Vmware guest (will be called GuestA from now onwards) and a guest with blank image in Xen (will be called GuestB from now onwards) booted of the Fedora 10 Live CD.

- On both guests flush the iptables firewall.

# iptables -F

- Networking should be enabled automatically by the LiveCD. Make sure that networking is working as expected on both guests and they can ping each other.

- Run fdisk -l on both guests and identify how the hard disk has been detected. I had them detected as "/dev/sda" on both GuestA and GuestB.

- On GuestB, run the below command:

# nc -l 7000 | dd of=/dev/sda bs=16M

- On GuestA, run the below command.

# dd if=/dev/sda bs=16M | nc ip-of-GuestB 7000

Replace ip-of-GuestB with the actual ip of GuestB and replace /dev/sda with the actual block device in both commands. 7000 is the port number, you can use other unused ports as well.

The process of copying the hard disk image will take sometime depending upon the network bandwidth and the IO bandwidth availability of storage. Please be patient and restart GuestB once the process is over from the hard disk.

- Went to bed and had a good sleep. When I was up in the morning, I had the guest cloned successfully and started off the new guest.

Saturday, June 6, 2009

How to add a sound card to a KVM guest?

I have a windows Xp virtual machine running in my laptop on top of Fedora 10 KVM. One day I accidentally deleted the sound card from virt-manager -> Hardware tab for that guest. I then understood my mistake and tried to add it via "Add Hardware" wizard. To my dismay, there was no option to add a sound card.

Then how did I add the sound card back to the guest?

- I did "virsh dumpxml anotherguest" which has sound card attached to it and was able to see the below line in the output.

....................
sound model='es1370'
....................

- I then did "virsh dumpxml xp" and was not able to see the above line in it. So fixing this is as simple as adding the above line to winxp configuration file.

How to do that?

- Dump the xml file to a file in the disk.

# virsh dumpxml xp > xp.xml

- Edit the xp.xml and add the below line to it.

sound model='es1370'

I added this immediately before the "devices" line.

- Then redefine the guest using the new configuration file.

# virsh define xp.xml

Restart the guest and the network card would be present in the guest. Hope we can add the sound card in F11 through virt-manager GUI.