SlideShare a Scribd company logo
Virtualization
What is virtualization?
What is virtualization?
●

●

●

mov

Full virtualization

cmp
jmp

Para virtualization

call
push

Partial virtualization

pop
int

RAM

nop

MMU

CPU
What is virtualization?
●

●

●

mov

Full virtualization

cmp
jmp

Para virtualization

call
push

Partial virtualization

pop
int

RAM

nop

MMU

CPU
Find out if your CPU is 
virtualization enabled
For Intel VT-x
$ grep –color vmx /proc/cpuinfo
For AMD V
$ grep –color svm /proc/cpuinfo
flags
: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov
pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm
constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf
eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr
pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx lahf_lm
ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
Organization
Host kernel
●

KVM

●
●

Kernel

Kernel

VM

VM

Kernel

Kernel

VM

VM

Kernel

Kernel

VM

VM

KVM
- in the kernel
QEMU - System virtualization
Libvirt - management simplification
KVM Kernel configuration
CONFIG_KVM_GUEST=y

CONFIG_PARAVIRT=y

# CONFIG_KVM_DEBUG_FS is not set

# CONFIG_PARAVIRT_DEBUG is not set

CONFIG_HAVE_KVM=y
CONFIG_HAVE_KVM_IRQCHIP=y

CONFIG_PARAVIRT_SPINLOCKS=y
CONFIG_PARAVIRT_TIME_ACCOUNTING=y
CONFIG_PARAVIRT_CLOCK=y

CONFIG_HAVE_KVM_IRQ_ROUTING=y

CONFIG_VIRT_TO_BUS=y

CONFIG_HAVE_KVM_EVENTFD=y

CONFIG_VIRTIO_BLK=m

CONFIG_KVM_APIC_ARCHITECTURE=y

CONFIG_SCSI_VIRTIO=m

CONFIG_KVM_MMIO=y

CONFIG_VIRTIO_NET=m

CONFIG_KVM_ASYNC_PF=y
CONFIG_HAVE_KVM_MSI=y

CONFIG_VIRTIO_CONSOLE=y
CONFIG_HW_RANDOM_VIRTIO=m
CONFIG_VIRT_DRIVERS=y

CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT CONFIG_VIRTIO=y
=y
# Virtio drivers
CONFIG_KVM=y

CONFIG_VIRTIO_PCI=y

CONFIG_KVM_INTEL=y

CONFIG_VIRTIO_BALLOON=m

# CONFIG_KVM_AMD is not set

CONFIG_VIRTIO_MMIO=m

# CONFIG_KVM_MMU_AUDIT is not set
CONFIG_KVM_DEVICE_ASSIGNMENT=y

CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y
# CONFIG_DEBUG_VIRTUAL is not set
CONFIG_VIRTUALIZATION=y
KVM Kernel configuration
Processor type and features ->
Linux guest support -> *
BUS options -> PCI IOV
Device Drivers ->
Block devices -> Virtio block driver
SCSI device support -> SCSI low-level drivers -> virtio-scsi
Network device support -> Virtio network driver
Character devices ->
* HW Random Number Generator
Virtio console
Virtio drivers -> *
Virtualization -> *
Create
● Start
● Talk to QEMU
●
KVM tools

●

virsh

●

virt-manager
KVM information
●

List VMs
–
–

●

virsh list
virsh list – all (including the suspended and stopped)

Node Information
–

virsh nodeinfo – information about the host node

–

virsh dominfo vm_name - information about the VM

–

virsh vcpuinfo vm_name - CPU info about the VM
●

Start
–

●

VM Management :)

virsh start vm_name

Stop
–

- soft shutdown

–
●

virsh shutdown vm_name
virsh destroy vm_name

- power down

Restart
–
–

virsh shutdown vm_name

–

virsh destroy vm_name

–
●

virsh reboot vm_name

virsh start vm_name

- power cycle

Suspend
–

virsh suspend vm_name

- to RAM
Hibernate
●

Save - save the VM state to a file
–
–

●

virsh save vm_name
virsh save-image-define save-file.img

Restore
–

●

virsh restore save-file.img

File location
–

/var/lib/libvirt/qemu/
Network
●

List all defined networks
–

●

Get information for predefined network
–

●

virsh net-info net_name

Activate a network on Host boot
–

●

virsh net-list

virsh net-autostart net_name

Start/Stop/Remove network
–

virsh net-start net_name

–

virsh net-destroy net_name

–

virsh net-undefine net_name
Storage pools
●

List all defined storage pools
–

●

Get information for predefined pool
–

●

virsh pool-info pool_name

Activate a storage pool on Host boot
–

●

virsh pool-list

virsh pool-autostart pool_name

Start/Stop/Remove network
–

virsh pool-start net_name

–

virsh pool-destroy net_name

–

virsh pool-undefine net_name
Storage pools
●

Create a pool
# virsh pool-create pool.xml
# virsh pool-create-as --name pesho 
--type [dir,disk,fs,logical,netfs...] 
--target (depending on the type) 

●

Refresh the files/volume in a pool
# virsh pool-refresh pool_name
Volumes
●

Create
# virsh vol-create volume.xml
# virsh vol-create-as --pool=pool_name 
--name pesho_be 
--capacity (int in Bytes) 
--format [raw,bochs,qcow,qcow2,qed,vmdk]

●

Clone
# virsh vol-clone vol_name new_name --pool pool_name

●

Delete
# virsh vol-delete vol_name --pool pool_name
Snapshots
# virsh snapshot-create-as vm_name snapshot1
"backup1" --disk-only --atomic
# virsh snapshot-list vm_name
# virsh snapshot-info vm_name 
--snapshotname snapshot1
Migration
●

Migration with shared storage
virsh migrate --live Jab2 qemu+ssh://192.168.0.5/system

●

Migration with local storage
# qemu-img info /vm/vm-test.img
image: /vm/jivko-test.img
file format: raw
virtual size: 8.0G (8589934592 bytes)
disk size: 8.0G

# qemu-img create -f raw /vm/vm-test.img 8G
Formatting '/vm/jivko-test.img', fmt=raw size=8589934592

# virsh migrate --persistent --live --copy-storage-all Jab2
qemu+ssh://192.168.0.5/system
Create a new VM
●

Installation image

●

Command
–

qemu -drive file=ubuntu-lucid.img,if=virtio 
/path/to/kernel/bzImage 

-kernel

-append "console=ttyS0 root=/dev/vda" 
-m 512 -smp 1 -fsdev
local,id=test_dev,path=shared,security_model=none
-enable-kvm
Backups
Configuration
●

Fuck... it's XML based...
/etc/libvirt/qemu/vm_name.xml
/etc/libvirt/qemu/autostart
/etc/libvirt/qemu/networks
/var/lib/libvirt/images
Console & 
Debugging
●

Console
–
–

virsh console vm_name
/usr/bin/virsh -c 
'qemu+ssh://root@IP:22/system' console vm_name

–

●

Install virt-manager and setup connection to the host node,
then connect to the vm with double click :)

Debugging
# qemu -gdb tcp:127.0.0.1:1212 [...]
# gdb vmlinux-of-guest
(gdb) target remote tcp:127.0.0.1:1212
Common issues
●

Sometimes libvirt can't start some VMs
–

check if they have .save files in
●

–

check if there are files with the VM name in
●

–

/var/lib/libvirt/qemu/images
/var/lib/libvirt/qemu/save

If there are any files for that VM in either of these
dirs, remove them and the VM should start

More Related Content

ODP
LSA2 - 02 Control Groups
Marian Marinov
 
PDF
Reconnaissance of Virtio: What’s new and how it’s all connected?
Samsung Open Source Group
 
ODP
LSA2 - 02 Namespaces
Marian Marinov
 
PDF
Kvm optimizations
OpenNebula Project
 
PDF
SiteGround Tech TeamBuilding
Marian Marinov
 
PDF
Kvm performance optimization for ubuntu
Sim Janghoon
 
PPTX
Linux Kernel Init Process
Kernel TLV
 
PDF
Achieving the Ultimate Performance with KVM
DevOps.com
 
LSA2 - 02 Control Groups
Marian Marinov
 
Reconnaissance of Virtio: What’s new and how it’s all connected?
Samsung Open Source Group
 
LSA2 - 02 Namespaces
Marian Marinov
 
Kvm optimizations
OpenNebula Project
 
SiteGround Tech TeamBuilding
Marian Marinov
 
Kvm performance optimization for ubuntu
Sim Janghoon
 
Linux Kernel Init Process
Kernel TLV
 
Achieving the Ultimate Performance with KVM
DevOps.com
 

What's hot (20)

PDF
Control your service resources with systemd
Marian Marinov
 
DOCX
Using cgroups in docker container
Vinay Jindal
 
PDF
Improve your storage with bcachefs
Marian Marinov
 
PDF
Advanced Namespaces and cgroups
Kernel TLV
 
PPTX
Optimizing VM images for OpenStack with KVM/QEMU
OpenStack Foundation
 
PDF
Linux fundamental - Chap 12 Hardware Management
Kenny (netman)
 
PDF
LSA2 - PostgreSQL
Marian Marinov
 
PDF
Comparison of-foss-distributed-storage
Marian Marinov
 
PPTX
First steps on CentOs7
Marc Cortinas Val
 
PDF
Improving the Performance of the qcow2 Format (KVM Forum 2017)
Igalia
 
PDF
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Anne Nicolas
 
PDF
FUSE Filesystems
elliando dias
 
PDF
Comparison of foss distributed storage
Marian Marinov
 
PDF
Ha opensuse
Kenny (netman)
 
PDF
Linux fundamental - Chap 08 proc
Kenny (netman)
 
PDF
DOXLON November 2016: Facebook Engineering on cgroupv2
Outlyer
 
PDF
NetBSDworkshop
Jun Ebihara
 
PDF
XPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, Citrix
The Linux Foundation
 
PDF
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
Chris Huybregts
 
PPT
Linux kernel modules
Hao-Ran Liu
 
Control your service resources with systemd
Marian Marinov
 
Using cgroups in docker container
Vinay Jindal
 
Improve your storage with bcachefs
Marian Marinov
 
Advanced Namespaces and cgroups
Kernel TLV
 
Optimizing VM images for OpenStack with KVM/QEMU
OpenStack Foundation
 
Linux fundamental - Chap 12 Hardware Management
Kenny (netman)
 
LSA2 - PostgreSQL
Marian Marinov
 
Comparison of-foss-distributed-storage
Marian Marinov
 
First steps on CentOs7
Marc Cortinas Val
 
Improving the Performance of the qcow2 Format (KVM Forum 2017)
Igalia
 
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Anne Nicolas
 
FUSE Filesystems
elliando dias
 
Comparison of foss distributed storage
Marian Marinov
 
Ha opensuse
Kenny (netman)
 
Linux fundamental - Chap 08 proc
Kenny (netman)
 
DOXLON November 2016: Facebook Engineering on cgroupv2
Outlyer
 
NetBSDworkshop
Jun Ebihara
 
XPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, Citrix
The Linux Foundation
 
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
Chris Huybregts
 
Linux kernel modules
Hao-Ran Liu
 
Ad

Viewers also liked (20)

PDF
Virtualization with KVM (Kernel-based Virtual Machine)
Novell
 
PDF
Virtualization Architecture & KVM
Pradeep Kumar
 
ODP
LSA2 - 02 chrooting
Marian Marinov
 
PDF
Virtualization - Kernel Virtual Machine (KVM)
Wan Leung Wong
 
PPTX
Introduction to Virtualization, Virsh and Virt-Manager
walkerchang
 
PDF
Qemu & KVM Guide #1 (intro & basic)
JungIn Jung
 
ODP
Mastering kvm virtualization- A complete guide of KVM virtualization
Humble Chirammal
 
ODP
Redis - BlagoevgradConf 2013
svilen.ivanov
 
ODP
Kvm virtualization platform
Ahmad Hafeezi
 
PDF
virtio
zhaobrian
 
PPTX
Kvm setup
Pradeep Yadav 🌩️
 
ODP
open source virtualization
Kris Buytaert
 
PDF
Criação de ambientes em chroot
Rudá Moura
 
PDF
Namespace
Luís Eduardo
 
PDF
Introduction to docker
Jim Yeh
 
ODP
chroot and SELinux
Shay Cohen
 
PPT
Open Virtualization Format - Detailed
Mahesh. Rudrachar
 
PDF
Dave Gilbert - KVM and QEMU
Danny Abukalam
 
PDF
Chw00t: Breaking unices’ chroot solutions
Positive Hack Days
 
PDF
LXD: The hypervisor that isn't
tych0
 
Virtualization with KVM (Kernel-based Virtual Machine)
Novell
 
Virtualization Architecture & KVM
Pradeep Kumar
 
LSA2 - 02 chrooting
Marian Marinov
 
Virtualization - Kernel Virtual Machine (KVM)
Wan Leung Wong
 
Introduction to Virtualization, Virsh and Virt-Manager
walkerchang
 
Qemu & KVM Guide #1 (intro & basic)
JungIn Jung
 
Mastering kvm virtualization- A complete guide of KVM virtualization
Humble Chirammal
 
Redis - BlagoevgradConf 2013
svilen.ivanov
 
Kvm virtualization platform
Ahmad Hafeezi
 
virtio
zhaobrian
 
open source virtualization
Kris Buytaert
 
Criação de ambientes em chroot
Rudá Moura
 
Namespace
Luís Eduardo
 
Introduction to docker
Jim Yeh
 
chroot and SELinux
Shay Cohen
 
Open Virtualization Format - Detailed
Mahesh. Rudrachar
 
Dave Gilbert - KVM and QEMU
Danny Abukalam
 
Chw00t: Breaking unices’ chroot solutions
Positive Hack Days
 
LXD: The hypervisor that isn't
tych0
 
Ad

Similar to LSA2 - 01 Virtualization with KVM (20)

PDF
KVM tools and enterprise usage
vincentvdk
 
PDF
Alterar memória kvm virtual machine
Carlos Eduardo
 
PDF
Libvirt/KVM Driver Update (Kilo)
Stephen Gordon
 
ODP
Kvm and libvirt
plarsen67
 
PPTX
Virtualization-Presentation-with-History
Sachin Darekar
 
PDF
Rmll Virtualization As Is Tool 20090707 V1.0
guest72e8c1
 
PDF
RMLL / LSM 2009
Franck_Villaume
 
ODP
S4 xen hypervisor_20080622
Todd Deshane
 
PPTX
VirtualOS-using-Qemu
Girish Patoliya
 
DOCX
Krenel Based Virtual Machine In Centos7
a_ratra
 
ODP
Mastering KVM Virtualization - Overview
Anil Vettathu
 
PDF
OSDC 2019 | Virtualisation in Docker, using KVM as Hypervisor by Kososochukwu...
NETWAYS
 
PDF
Aplura virtualization slides
The Linux Foundation
 
PPTX
Virtualization technolegys for amdocs
Samuel Dratwa
 
PPT
Virtualization
satchipatra
 
PPT
Redhat Virualization Technology: A Detailed Manual.
Ankur Verma
 
PDF
Dev ops
Tom Hall
 
PDF
Virtualization with KVM
Danishka Navin
 
PDF
Achieving the Ultimate Performance with KVM
data://disrupted®
 
PDF
Esx.sc.quickref
hellocn
 
KVM tools and enterprise usage
vincentvdk
 
Alterar memória kvm virtual machine
Carlos Eduardo
 
Libvirt/KVM Driver Update (Kilo)
Stephen Gordon
 
Kvm and libvirt
plarsen67
 
Virtualization-Presentation-with-History
Sachin Darekar
 
Rmll Virtualization As Is Tool 20090707 V1.0
guest72e8c1
 
RMLL / LSM 2009
Franck_Villaume
 
S4 xen hypervisor_20080622
Todd Deshane
 
VirtualOS-using-Qemu
Girish Patoliya
 
Krenel Based Virtual Machine In Centos7
a_ratra
 
Mastering KVM Virtualization - Overview
Anil Vettathu
 
OSDC 2019 | Virtualisation in Docker, using KVM as Hypervisor by Kososochukwu...
NETWAYS
 
Aplura virtualization slides
The Linux Foundation
 
Virtualization technolegys for amdocs
Samuel Dratwa
 
Virtualization
satchipatra
 
Redhat Virualization Technology: A Detailed Manual.
Ankur Verma
 
Dev ops
Tom Hall
 
Virtualization with KVM
Danishka Navin
 
Achieving the Ultimate Performance with KVM
data://disrupted®
 
Esx.sc.quickref
hellocn
 

More from Marian Marinov (20)

PDF
How to start and then move forward in IT
Marian Marinov
 
PDF
Thinking about highly-available systems and their setup
Marian Marinov
 
PDF
Understanding your memory usage under Linux
Marian Marinov
 
PDF
How to implement PassKeys in your application
Marian Marinov
 
PDF
Dev.bg DevOps March 2024 Monitoring & Logging
Marian Marinov
 
PDF
Basic presentation of cryptography mechanisms
Marian Marinov
 
PDF
Microservices: Benefits, drawbacks and are they for me?
Marian Marinov
 
PDF
Introduction and replication to DragonflyDB
Marian Marinov
 
PDF
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Marian Marinov
 
PDF
How to successfully migrate to DevOps .pdf
Marian Marinov
 
PDF
How to survive in the work from home era
Marian Marinov
 
PDF
Managing sysadmins
Marian Marinov
 
PDF
Защо и как да обогатяваме знанията си?
Marian Marinov
 
PDF
Securing your MySQL server
Marian Marinov
 
PDF
Sysadmin vs. dev ops
Marian Marinov
 
PDF
DoS and DDoS mitigations with eBPF, XDP and DPDK
Marian Marinov
 
PDF
Challenges with high density networks
Marian Marinov
 
PDF
SiteGround building automation
Marian Marinov
 
PDF
Preventing cpu side channel attacks with kernel tracking
Marian Marinov
 
PDF
Managing a lot of servers
Marian Marinov
 
How to start and then move forward in IT
Marian Marinov
 
Thinking about highly-available systems and their setup
Marian Marinov
 
Understanding your memory usage under Linux
Marian Marinov
 
How to implement PassKeys in your application
Marian Marinov
 
Dev.bg DevOps March 2024 Monitoring & Logging
Marian Marinov
 
Basic presentation of cryptography mechanisms
Marian Marinov
 
Microservices: Benefits, drawbacks and are they for me?
Marian Marinov
 
Introduction and replication to DragonflyDB
Marian Marinov
 
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Marian Marinov
 
How to successfully migrate to DevOps .pdf
Marian Marinov
 
How to survive in the work from home era
Marian Marinov
 
Managing sysadmins
Marian Marinov
 
Защо и как да обогатяваме знанията си?
Marian Marinov
 
Securing your MySQL server
Marian Marinov
 
Sysadmin vs. dev ops
Marian Marinov
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
Marian Marinov
 
Challenges with high density networks
Marian Marinov
 
SiteGround building automation
Marian Marinov
 
Preventing cpu side channel attacks with kernel tracking
Marian Marinov
 
Managing a lot of servers
Marian Marinov
 

Recently uploaded (20)

PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PPTX
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
Measures_of_location_-_Averages_and__percentiles_by_DR SURYA K.pptx
Surya Ganesh
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Basics and rules of probability with real-life uses
ravatkaran694
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 

LSA2 - 01 Virtualization with KVM

  • 5. Find out if your CPU is  virtualization enabled For Intel VT-x $ grep –color vmx /proc/cpuinfo For AMD V $ grep –color svm /proc/cpuinfo flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx rdtscp lm constant_tsc arch_perfmon pebs bts xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx lahf_lm ida arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
  • 6. Organization Host kernel ● KVM ● ● Kernel Kernel VM VM Kernel Kernel VM VM Kernel Kernel VM VM KVM - in the kernel QEMU - System virtualization Libvirt - management simplification
  • 7. KVM Kernel configuration CONFIG_KVM_GUEST=y CONFIG_PARAVIRT=y # CONFIG_KVM_DEBUG_FS is not set # CONFIG_PARAVIRT_DEBUG is not set CONFIG_HAVE_KVM=y CONFIG_HAVE_KVM_IRQCHIP=y CONFIG_PARAVIRT_SPINLOCKS=y CONFIG_PARAVIRT_TIME_ACCOUNTING=y CONFIG_PARAVIRT_CLOCK=y CONFIG_HAVE_KVM_IRQ_ROUTING=y CONFIG_VIRT_TO_BUS=y CONFIG_HAVE_KVM_EVENTFD=y CONFIG_VIRTIO_BLK=m CONFIG_KVM_APIC_ARCHITECTURE=y CONFIG_SCSI_VIRTIO=m CONFIG_KVM_MMIO=y CONFIG_VIRTIO_NET=m CONFIG_KVM_ASYNC_PF=y CONFIG_HAVE_KVM_MSI=y CONFIG_VIRTIO_CONSOLE=y CONFIG_HW_RANDOM_VIRTIO=m CONFIG_VIRT_DRIVERS=y CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT CONFIG_VIRTIO=y =y # Virtio drivers CONFIG_KVM=y CONFIG_VIRTIO_PCI=y CONFIG_KVM_INTEL=y CONFIG_VIRTIO_BALLOON=m # CONFIG_KVM_AMD is not set CONFIG_VIRTIO_MMIO=m # CONFIG_KVM_MMU_AUDIT is not set CONFIG_KVM_DEVICE_ASSIGNMENT=y CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES=y # CONFIG_DEBUG_VIRTUAL is not set CONFIG_VIRTUALIZATION=y
  • 8. KVM Kernel configuration Processor type and features -> Linux guest support -> * BUS options -> PCI IOV Device Drivers -> Block devices -> Virtio block driver SCSI device support -> SCSI low-level drivers -> virtio-scsi Network device support -> Virtio network driver Character devices -> * HW Random Number Generator Virtio console Virtio drivers -> * Virtualization -> *
  • 11. KVM information ● List VMs – – ● virsh list virsh list – all (including the suspended and stopped) Node Information – virsh nodeinfo – information about the host node – virsh dominfo vm_name - information about the VM – virsh vcpuinfo vm_name - CPU info about the VM
  • 12. ● Start – ● VM Management :) virsh start vm_name Stop – - soft shutdown – ● virsh shutdown vm_name virsh destroy vm_name - power down Restart – – virsh shutdown vm_name – virsh destroy vm_name – ● virsh reboot vm_name virsh start vm_name - power cycle Suspend – virsh suspend vm_name - to RAM
  • 13. Hibernate ● Save - save the VM state to a file – – ● virsh save vm_name virsh save-image-define save-file.img Restore – ● virsh restore save-file.img File location – /var/lib/libvirt/qemu/
  • 14. Network ● List all defined networks – ● Get information for predefined network – ● virsh net-info net_name Activate a network on Host boot – ● virsh net-list virsh net-autostart net_name Start/Stop/Remove network – virsh net-start net_name – virsh net-destroy net_name – virsh net-undefine net_name
  • 15. Storage pools ● List all defined storage pools – ● Get information for predefined pool – ● virsh pool-info pool_name Activate a storage pool on Host boot – ● virsh pool-list virsh pool-autostart pool_name Start/Stop/Remove network – virsh pool-start net_name – virsh pool-destroy net_name – virsh pool-undefine net_name
  • 16. Storage pools ● Create a pool # virsh pool-create pool.xml # virsh pool-create-as --name pesho --type [dir,disk,fs,logical,netfs...] --target (depending on the type) ● Refresh the files/volume in a pool # virsh pool-refresh pool_name
  • 17. Volumes ● Create # virsh vol-create volume.xml # virsh vol-create-as --pool=pool_name --name pesho_be --capacity (int in Bytes) --format [raw,bochs,qcow,qcow2,qed,vmdk] ● Clone # virsh vol-clone vol_name new_name --pool pool_name ● Delete # virsh vol-delete vol_name --pool pool_name
  • 18. Snapshots # virsh snapshot-create-as vm_name snapshot1 "backup1" --disk-only --atomic # virsh snapshot-list vm_name # virsh snapshot-info vm_name --snapshotname snapshot1
  • 19. Migration ● Migration with shared storage virsh migrate --live Jab2 qemu+ssh://192.168.0.5/system ● Migration with local storage # qemu-img info /vm/vm-test.img image: /vm/jivko-test.img file format: raw virtual size: 8.0G (8589934592 bytes) disk size: 8.0G # qemu-img create -f raw /vm/vm-test.img 8G Formatting '/vm/jivko-test.img', fmt=raw size=8589934592 # virsh migrate --persistent --live --copy-storage-all Jab2 qemu+ssh://192.168.0.5/system
  • 20. Create a new VM ● Installation image ● Command – qemu -drive file=ubuntu-lucid.img,if=virtio /path/to/kernel/bzImage -kernel -append "console=ttyS0 root=/dev/vda" -m 512 -smp 1 -fsdev local,id=test_dev,path=shared,security_model=none -enable-kvm
  • 22. Configuration ● Fuck... it's XML based... /etc/libvirt/qemu/vm_name.xml /etc/libvirt/qemu/autostart /etc/libvirt/qemu/networks /var/lib/libvirt/images
  • 23. Console &  Debugging ● Console – – virsh console vm_name /usr/bin/virsh -c 'qemu+ssh://root@IP:22/system' console vm_name – ● Install virt-manager and setup connection to the host node, then connect to the vm with double click :) Debugging # qemu -gdb tcp:127.0.0.1:1212 [...] # gdb vmlinux-of-guest (gdb) target remote tcp:127.0.0.1:1212
  • 24. Common issues ● Sometimes libvirt can't start some VMs – check if they have .save files in ● – check if there are files with the VM name in ● – /var/lib/libvirt/qemu/images /var/lib/libvirt/qemu/save If there are any files for that VM in either of these dirs, remove them and the VM should start