SlideShare uma empresa Scribd logo
1 de 24
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

Mais conteúdo relacionado

Mais procurados

Optimizing VM images for OpenStack with KVM/QEMU
Optimizing VM images for OpenStack with KVM/QEMUOptimizing VM images for OpenStack with KVM/QEMU
Optimizing VM images for OpenStack with KVM/QEMU
OpenStack Foundation
 
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologiess6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
Chris Huybregts
 

Mais procurados (20)

Control your service resources with systemd
 Control your service resources with systemd  Control your service resources with systemd
Control your service resources with systemd
 
Using cgroups in docker container
Using cgroups in docker containerUsing cgroups in docker container
Using cgroups in docker container
 
Improve your storage with bcachefs
Improve your storage with bcachefsImprove your storage with bcachefs
Improve your storage with bcachefs
 
Advanced Namespaces and cgroups
Advanced Namespaces and cgroupsAdvanced Namespaces and cgroups
Advanced Namespaces and cgroups
 
Optimizing VM images for OpenStack with KVM/QEMU
Optimizing VM images for OpenStack with KVM/QEMUOptimizing VM images for OpenStack with KVM/QEMU
Optimizing VM images for OpenStack with KVM/QEMU
 
Linux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware ManagementLinux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware Management
 
LSA2 - PostgreSQL
LSA2 - PostgreSQLLSA2 - PostgreSQL
LSA2 - PostgreSQL
 
Comparison of-foss-distributed-storage
Comparison of-foss-distributed-storageComparison of-foss-distributed-storage
Comparison of-foss-distributed-storage
 
First steps on CentOs7
First steps on CentOs7First steps on CentOs7
First steps on CentOs7
 
Improving the Performance of the qcow2 Format (KVM Forum 2017)
Improving the Performance of the qcow2 Format (KVM Forum 2017)Improving the Performance of the qcow2 Format (KVM Forum 2017)
Improving the Performance of the qcow2 Format (KVM Forum 2017)
 
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
Kernel Recipes 2016 - Understanding a Real-Time System (more than just a kernel)
 
FUSE Filesystems
FUSE FilesystemsFUSE Filesystems
FUSE Filesystems
 
Comparison of foss distributed storage
Comparison of foss distributed storageComparison of foss distributed storage
Comparison of foss distributed storage
 
Ha opensuse
Ha opensuseHa opensuse
Ha opensuse
 
Linux fundamental - Chap 08 proc
Linux fundamental - Chap 08 procLinux fundamental - Chap 08 proc
Linux fundamental - Chap 08 proc
 
DOXLON November 2016: Facebook Engineering on cgroupv2
DOXLON November 2016: Facebook Engineering on cgroupv2DOXLON November 2016: Facebook Engineering on cgroupv2
DOXLON November 2016: Facebook Engineering on cgroupv2
 
NetBSDworkshop
NetBSDworkshopNetBSDworkshop
NetBSDworkshop
 
XPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, Citrix
XPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, CitrixXPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, Citrix
XPDS14 - Scaling Xen's Aggregate Storage Performance - Felipe Franciosi, Citrix
 
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologiess6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
s6196-chris-huybregts-microsoft-new-gpu-virtualization-technologies
 
Linux kernel modules
Linux kernel modulesLinux kernel modules
Linux kernel modules
 

Destaque

Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)
Wan Leung Wong
 
Introduction to Virtualization, Virsh and Virt-Manager
Introduction to Virtualization, Virsh and Virt-ManagerIntroduction to Virtualization, Virsh and Virt-Manager
Introduction to Virtualization, Virsh and Virt-Manager
walkerchang
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Jim Yeh
 

Destaque (20)

Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)
 
Virtualization Architecture & KVM
Virtualization Architecture & KVMVirtualization Architecture & KVM
Virtualization Architecture & KVM
 
LSA2 - 02 chrooting
LSA2 - 02 chrootingLSA2 - 02 chrooting
LSA2 - 02 chrooting
 
Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)Virtualization - Kernel Virtual Machine (KVM)
Virtualization - Kernel Virtual Machine (KVM)
 
Introduction to Virtualization, Virsh and Virt-Manager
Introduction to Virtualization, Virsh and Virt-ManagerIntroduction to Virtualization, Virsh and Virt-Manager
Introduction to Virtualization, Virsh and Virt-Manager
 
Qemu & KVM Guide #1 (intro & basic)
Qemu & KVM Guide #1 (intro & basic)Qemu & KVM Guide #1 (intro & basic)
Qemu & KVM Guide #1 (intro & basic)
 
Mastering kvm virtualization- A complete guide of KVM virtualization
Mastering kvm virtualization- A complete guide of KVM virtualizationMastering kvm virtualization- A complete guide of KVM virtualization
Mastering kvm virtualization- A complete guide of KVM virtualization
 
Redis - BlagoevgradConf 2013
Redis - BlagoevgradConf 2013Redis - BlagoevgradConf 2013
Redis - BlagoevgradConf 2013
 
Kvm virtualization platform
Kvm virtualization platformKvm virtualization platform
Kvm virtualization platform
 
virtio
virtiovirtio
virtio
 
Kvm setup
Kvm setupKvm setup
Kvm setup
 
open source virtualization
open source virtualizationopen source virtualization
open source virtualization
 
Criação de ambientes em chroot
Criação de ambientes em chrootCriação de ambientes em chroot
Criação de ambientes em chroot
 
Namespace
NamespaceNamespace
Namespace
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
chroot and SELinux
chroot and SELinuxchroot and SELinux
chroot and SELinux
 
Open Virtualization Format - Detailed
Open Virtualization Format - DetailedOpen Virtualization Format - Detailed
Open Virtualization Format - Detailed
 
Dave Gilbert - KVM and QEMU
Dave Gilbert - KVM and QEMUDave Gilbert - KVM and QEMU
Dave Gilbert - KVM and QEMU
 
Chw00t: Breaking unices’ chroot solutions
Chw00t: Breaking unices’ chroot solutionsChw00t: Breaking unices’ chroot solutions
Chw00t: Breaking unices’ chroot solutions
 
LXD: The hypervisor that isn't
LXD: The hypervisor that isn'tLXD: The hypervisor that isn't
LXD: The hypervisor that isn't
 

Semelhante a LSA2 - 01 Virtualization with KVM

Overview of sheepdog
Overview of sheepdogOverview of sheepdog
Overview of sheepdog
Liu Yuan
 
Kernel compilation
Kernel compilationKernel compilation
Kernel compilation
mcganesh
 

Semelhante a LSA2 - 01 Virtualization with KVM (20)

Marian Marinov, 1H Ltd.
Marian Marinov, 1H Ltd.Marian Marinov, 1H Ltd.
Marian Marinov, 1H Ltd.
 
Performance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksPerformance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networks
 
KVM tools and enterprise usage
KVM tools and enterprise usageKVM tools and enterprise usage
KVM tools and enterprise usage
 
Performance Analysis Tools for Linux Kernel
Performance Analysis Tools for Linux KernelPerformance Analysis Tools for Linux Kernel
Performance Analysis Tools for Linux Kernel
 
The New Systems Performance
The New Systems PerformanceThe New Systems Performance
The New Systems Performance
 
Achieving the Ultimate Performance with KVM
Achieving the Ultimate Performance with KVMAchieving the Ultimate Performance with KVM
Achieving the Ultimate Performance with KVM
 
Containers with systemd-nspawn
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
 
Overview of sheepdog
Overview of sheepdogOverview of sheepdog
Overview of sheepdog
 
VMworld 2016: vSphere 6.x Host Resource Deep Dive
VMworld 2016: vSphere 6.x Host Resource Deep DiveVMworld 2016: vSphere 6.x Host Resource Deep Dive
VMworld 2016: vSphere 6.x Host Resource Deep Dive
 
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
 
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on CephBuild an High-Performance and High-Durable Block Storage Service Based on Ceph
Build an High-Performance and High-Durable Block Storage Service Based on Ceph
 
PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22PFIセミナー資料 H27.10.22
PFIセミナー資料 H27.10.22
 
Kernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysis
 
Qemu - Raspberry | while42 Singapore #2
Qemu - Raspberry | while42 Singapore #2Qemu - Raspberry | while42 Singapore #2
Qemu - Raspberry | while42 Singapore #2
 
php & performance
 php & performance php & performance
php & performance
 
Pitr Made Easy
Pitr Made EasyPitr Made Easy
Pitr Made Easy
 
Kernel compilation
Kernel compilationKernel compilation
Kernel compilation
 
Achieving the ultimate performance with KVM
Achieving the ultimate performance with KVMAchieving the ultimate performance with KVM
Achieving the ultimate performance with KVM
 
Basics_of_Kernel_Panic_Hang_and_ Kdump.pdf
Basics_of_Kernel_Panic_Hang_and_ Kdump.pdfBasics_of_Kernel_Panic_Hang_and_ Kdump.pdf
Basics_of_Kernel_Panic_Hang_and_ Kdump.pdf
 
PHP & Performance
PHP & PerformancePHP & Performance
PHP & Performance
 

Mais de Marian Marinov

Mais de Marian Marinov (20)

Dev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingDev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & Logging
 
Basic presentation of cryptography mechanisms
Basic presentation of cryptography mechanismsBasic presentation of cryptography mechanisms
Basic presentation of cryptography mechanisms
 
Microservices: Benefits, drawbacks and are they for me?
Microservices: Benefits, drawbacks and are they for me?Microservices: Benefits, drawbacks and are they for me?
Microservices: Benefits, drawbacks and are they for me?
 
Introduction and replication to DragonflyDB
Introduction and replication to DragonflyDBIntroduction and replication to DragonflyDB
Introduction and replication to DragonflyDB
 
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQMessage Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
 
How to successfully migrate to DevOps .pdf
How to successfully migrate to DevOps .pdfHow to successfully migrate to DevOps .pdf
How to successfully migrate to DevOps .pdf
 
How to survive in the work from home era
How to survive in the work from home eraHow to survive in the work from home era
How to survive in the work from home era
 
Managing sysadmins
Managing sysadminsManaging sysadmins
Managing sysadmins
 
Защо и как да обогатяваме знанията си?
Защо и как да обогатяваме знанията си?Защо и как да обогатяваме знанията си?
Защо и как да обогатяваме знанията си?
 
Securing your MySQL server
Securing your MySQL serverSecuring your MySQL server
Securing your MySQL server
 
Sysadmin vs. dev ops
Sysadmin vs. dev opsSysadmin vs. dev ops
Sysadmin vs. dev ops
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDK
 
Challenges with high density networks
Challenges with high density networksChallenges with high density networks
Challenges with high density networks
 
SiteGround building automation
SiteGround building automationSiteGround building automation
SiteGround building automation
 
Preventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel trackingPreventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel tracking
 
Managing a lot of servers
Managing a lot of serversManaging a lot of servers
Managing a lot of servers
 
Let's Encrypt failures
Let's Encrypt failuresLet's Encrypt failures
Let's Encrypt failures
 
Preventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel trackingPreventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel tracking
 
How to build your own anycast service
How to build your own anycast serviceHow to build your own anycast service
How to build your own anycast service
 
Electrical workshop
Electrical workshopElectrical workshop
Electrical workshop
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
SanaAli374401
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 

Último (20)

This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

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