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

Wednesday, July 10, 2013

Find KVM Vm Ip address

Let assume we have a Virtual Machine running (started).
The VM is connected to the network thru a bridge ethernet.
We need to know its IP address, how?

Algorithm:
  • Ping all the ip address of the network.
    • If IP exist ARP will add a line to the ARP table with IP and MAC address.
  • Compare the MAC address saved in the KVM XML with all the MAC-IP saved inside ARP table.
    • When Match print the IP address
How to call: script_name <number\name of running VM>

example:

find_ip.sh Windows

#!/bin/bash

#Variables
network="192.168.1."

for end in {1..254}
do

  ping $network$end -c2 >/dev/null 2>/dev/null &
done

# Wait all ping to end
wait

for kvm_addr in `virsh dumpxml $1 | \

                 awk 'BEGIN {FS="\47"} /mac address/ {print $2}'`
do

  for arp_addr in `arp | awk '/ether/ {print $3"-"$1}'`
    do
    if [ "$kvm_addr" == ${arp_addr:0:17} ];
    then
      echo "Match: " $arp_addr
    fi
  done
done

Tuesday, March 13, 2012

Migrate from Virtualbox to KVM

Some days ago I decided to migrate some of my Oracle Virtualbox test VM on a KVM server.

Why? easy, KVM\QEMU is better Oracle Virtualbox for a lot of reason. Probably this link will be enough to convince you.


Have a computer with virtualbox make everything easier but I wanted to do everything without virtuabox. (Link with virtuabox)

So we have to converto VDI images into somethink KVM can read. I used a simple ".RAW" images. This step is easy, and you can find tons of post online:
http://blog.bodhizazen.net/linux/convert-virtualbox-vdi-to-kvm-qcow/
http://xpapad.wordpress.com/2010/02/21/migrating-from-virtualbox-to-vmware-in-linux/
http://www.dedoimedo.com/computers/virtualbox-convert.html
http://kevin.deldycke.com/2007/04/how-to-grow-any-qemu-system-image/

Edit 16/12/12: Anyway this will make a .RAW as big as the dimension assigned to your virtual hard drive.

I started with my VirtualBox VM Debian6 test server, where I usually try new stuff before put it on a real PC or anyway in the main VM.
Convert the hard drive from VDI to RAW, I used the RAW image inside a KVM VM and everything worked fine.

Windows XP:
After conver the VDI image and put the RAW inside a KVM VM i had this issue:

 0x0000007B
BLUE SCREEN OF DEATH (BSOD)
 
This blue screen arrived at the first second third and ALL boot after the conversion....
I searched and I found something.
Talking on IRC I realized the problem was the hard drive controller.
What we have to do? touch a bit WinXp registry... how to do it easily?
I found 2 solutions:
  1. With virtualbox: This "patch". Run it before your turn off the last time your virtualbox machine before the migration. I will say to XP to accept all HD chipset (or something similar)
  2. Without virtualbox: HIREN's boot cd or as a lot of SysAdmin know it... Ass saver! Simply boot micro XP goes on the tools and find "Fix Hard disk controller" under Registry. And DONE!


I found another problem, something I really though I wasn't to solve it fast, read a lot of stuff, like reinstall windows over the existing one or make a brand new VM.
I didn't want! so I pass more time searching than the time I needed to reinstall windows! But I Found it

Fist the problem (link):

So what happened? I haven't only moved my VM from Virtualbox to KVM on the same machine but I moved it from an AMD Athlon x2 to two different PC (to test) an AMD phenon x6 and Intel SB i5. On the AMD I haven't had this problem, but on the Intel I had! So I had problem because the processor type isn't the same.

Thanks to this AWESOME GUY we have a solution for this problem too....
http://blogs.msdn.com/b/virtual_pc_guy/archive/2005/10/24/484461.aspx

I just start my VM XP in safe mode and edit the register like he wrote

And here we are! true you won't have reconized the CPU on hardware manager on Windows, but who care it's Windows! :D

Hope this post will help somebody.
Have a nice day!