Linux KVM

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску

KVM

KVM - система виртуализации котороая включена в состав ядра linux начиная с 2.6.20. Вероятно, наиболее прогрессивная система, т.к. RedHat переключилась на нее с XEN. Задача - запускать внутри виртуальных машин ОС отличную от хостовой (в моем случае - win32, FreeBSD, linux но другие версии ядра отличные от хостовых).

Сейчас использую VMWare, решил отказаться из-за следующих недостатков

  • Неудобство управления (нужно держать под рукой vmware-console)
  • Большие накладные расходы.
  • VMWare не позволяет эмулировать более 2 процессоров (проверить!)
  • Иногда - проблемы при обновлении ядра.
  • Нет механизмов ограничения процессорного времени. (или я о них не знаю)

Hardware

KVM требует наличия x86-совместимого процессора с поддержкой одной из технологий аппаратной виртуализации — Intel VT либо AMD SVM. На данный момент KVM в состоянии запускать в качестве гостевых ОС GNU/Linux (32-битные и 64-битные), Windows (32-битные и 64-битные) и другие системы.

Для полноценной работы немодифицированных гостевых ОС потребуется процессор с поддержкой аппаратной виртуализации: Проверить наличие поддержки можно по наличию соответвующих флагов - комманда ниже должна дать непустой результат

# cat /proc/cpuinfo | egrep flags.*'svm|vmx'

В моем случае это

#cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 107
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+
stepping        : 1
cpu MHz         : 2310.439
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch
bogomips        : 4620.87
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc 100mhzsteps

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 107
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor 4400+
stepping        : 1
cpu MHz         : 2310.439
cache size      : 512 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
apicid          : 1
initial apicid  : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow rep_good pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy 3dnowprefetch
bogomips        : 4621.05
TLB size        : 1024 4K pages
clflush size    : 64
cache_alignment : 64
address sizes   : 40 bits physical, 48 bits virtual
power management: ts fid vid ttp tm stc 100mhzsteps

Конфигурация ядра

Kernel configuration

To enable the KVM, you need to make sure you have selected the following option in your kernel:

Linux Kernel Configuration: Enable KVM
Device Drivers --->
    [*] Virtualization --->
            --- Virtualization
            <M> Kernel-based Virtual Machine (KVM) support
            <M>   KVM for Intel processors support 
            < >   KVM for AMD processors support
Note: This is valid for the kernel-2.6.24-r4. In newer versions of the kernel, the Virtualization is placed at the same level as the Device Drivers menu.

If you have an AMD CPU, choose the other option.

If you plan to enable the networking in your Guest OS, do not compile your kernel yet, jump to Kernel configuration for networking, then come back here to go on with the setting up of KVM.

Ссылки

Есть некоторая доля вероятности, что какую-то из ссылок которой я воспользовался я забыл указать. Потому, если такое вдруг случиться - укажите мне на ошибку. Я исправлю.