Home > Uncategorized > KVM (Kernel Based Virtual Machine)

KVM (Kernel Based Virtual Machine)

January 13th, 2011 Leave a comment Go to comments

KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. KVM also requires a modified QEMU although work is underway to get the required changes upstream.

Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc.

The kernel component of KVM is included in mainline Linux, as of 2.6.20.

KVM is open source software.

Проверяем, поддерживает ли процессор аппаратную виртуализацию:

grep vmx /proc/cpuinfo

Устанавливаем пакеты:

# yum install bridge-utils qemu-kvm virt-manager libvirt

Проверяем что модули подгрузились:

# lsmod | fgrep kvm
kvm_intel              45674  0 
kvm                   291811  1 kvm_intel

Запускаем демона:

# /etc/init.d/libvirtd start

Поднимаем br0 интерфейс:

# ifconfig eth0 0.0.0.0
# brctl addbr br0
# brctl addif br0 eth0
# ifconfig br0 192.168.1.200/24

Как настроить бридж для KVM на Red Hat Enterprise Linux 5.4

Не забыть включить форвардинг пакетов:

sysctl net.ipv4.ip_forward=1

И поправить правила iptables:

$ iptables -A FORWARD -m physdev --physdev-is-bridged -j ACCEPT 
$ iptables -t nat -A PREROUTING -d IP/32 -p tcp -m tcp --dport 222 -j DNAT --to-destination 192.168.122.2:22
$ iptables -t nat -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j SNAT --to-source IP

Работаем:

# virt-manager
Tags:
  1. No comments yet.
  1. No trackbacks yet.