lost and found ( for me ? )

Compile QEMU-KVM on Linux Mint 12 64bit ver.

Here’s an explanation of how to switch from the KVM installed via apt-get to the KVM building from the source.
I’ve installed the KVM ( kvm , libvirtd , virt-manager ) via apt-get and it works well.

This explanation is:

Use KVM kernel modules installed via apt-get ( kvm , kvm_intel or kvm_amd )
Use qemu-kvm built from the source.
# uname –ri
3.0.0-14-generic x86_64

# tail -1 /etc/lsb-release

# kvm –version  <- installed via apt-get
QEMU emulator version 0.15.0 (qemu-kvm-devel), Copyright (c) 2003-2008 Fabrice Bellard

# libvirtd –version <- installed via apt-get
libvirtd (libvirt) 0.9.2

# virt-manager –version <- installed via apt-get

- the preparation before building qemu-kvm from source

Install the following packages via apt-get to build qemu-kvm.
# LANG=C apt-get install gcc gcc-4.6 libsdl1.2-dev make libz-dev uuid-d
ev libasound2-dev gcc libc6-dev zlib1g-dev linux-headers-3.0.0-14
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'zlib1g-dev' instead of 'libz-dev'
gcc is already the newest version.
gcc-4.6 is already the newest version.
libc6-dev is already the newest version.
make is already the newest version.
zlib1g-dev is already the newest version.
The following extra packages will be installed:
 libaa1-dev libaudio-dev libaudiofile-dev libavahi-client-dev
 libavahi-common-dev libcaca-dev libdbus-1-dev libdrm-dev libesd0-dev
 libgl1-mesa-dev libglu1-mesa-dev libkms1 libncurses5-dev libpulse-dev
 libslang2-dev libtinfo-dev libxt-dev mesa-common-dev
Suggested packages:
 libasound2-doc ncurses-doc
The following NEW packages will be installed:
 libaa1-dev libasound2-dev libaudio-dev libaudiofile-dev libavahi-client-dev
 libavahi-common-dev libcaca-dev libdbus-1-dev libdrm-dev libesd0-dev
 libgl1-mesa-dev libglu1-mesa-dev libkms1 libncurses5-dev libpulse-dev
 libsdl1.2-dev libslang2-dev libtinfo-dev libxt-dev mesa-common-dev uuid-dev
0 upgraded, 21 newly installed, 0 to remove and 0 not upgraded.
Need to get 5447 kB of archives.
After this operation, 25.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

Get the latest KVM source ( qemu-kvm-1.0.tar.gz ) from http://sourceforge.net/projects/kvm/files/
# ls

- compile qemu-kvm

qemu-kvm does not include kvm-kmod ( KVM kernel modules )
I use KVM kernel modules which I have installed via apt-get.
# tar xzvf qemu-kvm-1.0.tar.gz
# cd qemu-kvm-1.0/

# ./configure --prefix=/usr/local/kvm
KVM support       yes
# make
# make install

# ls /usr/local/kvm/*
qemu-ga  qemu-img  qemu-io  qemu-nbd  qemu-system-x86_64



# /usr/local/kvm/bin/qemu-system-x86_64 --version
QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice Bellard

make sure your OS has loaded KVM kernel modules.
# lsmod | grep kvm
kvm_intel              61643  0
kvm                   383781  1 kvm_intel

- start the VM with qemu-kvm 1.0

I’ve already had the VM ( CentOS 6.2 ) , so I’ll fly this VM with qemu-kvm 1.0.
# /usr/local/kvm/bin/qemu-system-x86_64 -m 1024 -hda /var/disk1/libvirt/images/centos6-vm1.img -monitor telnet::4444,server,nowait -vnc :0 –daemonize

- Connect to the VM via VNC

check the PID of the VM.
# ps aux | grep qemu-system | grep centos
/usr/local/kvm/bin/qemu-system-x86_64 -m 1024 -hda /var/disk1/libvirt/images/centos6-vm1.img -monitor telnet::4444,server,nowait -vnc :0 –daemonize

check the listen ports
# lsof -np 25904 | grep -i tcp
qemu-syst 25904 root    3u  IPv4 2434434         0t0      TCP *:4444 (LISTEN)
qemu-syst 25904 root   14u  IPv4 2432962         0t0      TCP *:5900 (LISTEN)

TCP port 5900 is for VNC access ( -vnc :0 )
TCP port 4444 is for qemu-monitor access. (-monitor telnet::4444,server,nowait )

start VNC viewer
$ vncviewer  ( or vncviewer )

- access to the qemu monitor via telnet
# telnet 127.1 4444
Connected to 127.1.
Escape character is '^]'.
QEMU 1.0 monitor - type 'help' for more information
(qemu) info vnc
       auth: none
 x509_dname: none
   username: none
(qemu) info version
1.0.0 (qemu-kvm-1.0)
(qemu) info status
VM status: running
(qemu) info kvm
kvm support: enabled
(qemu) system_powerdown
(qemu) Connection closed by foreign host.

- memo

The binary file of qemu-kvm installed via apt-get is /usr/bin/kvm which is the symbolic link file of /usr/bin/qemu-system-x86_64.
# ls –l /usr/bin/kvm  ( install via apt-get )
lrwxrwxrwx 1 root root  /usr/bin/kvm -> qemu-system-x86_64

# ls -l /usr/bin/qemu-system-x86_64 ( install via apt-get )
-rwxr-xr-x 1 root root  /usr/bin/qemu-system-x86_64

The binary file of qemu-kvm built from the source is /usr/local/kvm/bin/qemu-system-x86_64
# ls /usr/local/kvm/bin/qemu-system-x86_64 ( built from the source )

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.