5. Why Virtualization
• Resource sharing
• High utilization of resource
• Reduce the number of physical servers
• Ability to bring up new server quickly
• Easy maintenance and monitoring
5
6. Types of Virtualization
• Server Virtualization
– Full virtualization, Paravirtualization, Hardware-assisted
virtualization
• Application Virtualization
• Desktop Virtualization
• Presentation Virtualization
• Network Virtualization
• Storage Virtualization
6
7. KVM Introduction
• KVM (Kernel-based Virtual Machine)
– A Linux kernel module that turns Linux into a hypervisor
– Full virtualization
7
8. Install KVM
• Check that your CPU supports hardware
virtualization
– 0 indicates that your CPU doesn’t support hardware
virtualization
– 1 or more indicates that it supports hardware
virtualization
8
25. define
Item Content
Description Define, but don't start, a guest domain from an XML file
Input 1. XML file
Example # define vm1.xml
Response Domain vm1 defined from vm1.xml
25
29. XML parameters
• name
– Virtual machine name
• uuid
– A globally unique identifier for the virtual machine
• current memory
– The actual allocation of memory for the VM
• type
– The type of operating system in the virtual machine
• kernel
– The fully-qualified path to the kernel image in the host OS
29
30. XML parameters (cont.)
• cmdline
– The arguments to be passed to the kernel at boot time
• dtb
– The fully-qualified path to the device tree binary image in
the host OS
• emulator
– The fully qualified path to the device model emulator
binary
• disk
– The main container for describing disks
• source file
– The resource on the host that is being accessed in the
guest
30
31. XML parameters (cont.)
• target
– The source can be accessed in the guest
• interface type
– A network interface visible to the guest
• source bridge
– The interface of the network
• mac address
– The address of the network
• model type
– The model of emulated network interface
31
32. start
Item Content
Description
Start a guest domain, either from the last managed save
state, or via a fresh boot if no managed save state is
present
Input 1.domain
Example # start vm1
Response Domain vm1 started
32
36. domuuid
Item Content
Description
Convert a guest domain name or id to guest domain
UUID
Input 1. domain
Example # domuuid vm1
Response b7cb10e2-c6af-a328-ad75-3e09747f0564
36
38. autostart
Item Content
Description
Enable and disable the automatic starting of a guest
domain when the libvirt daemon starts
Input 1. domain
Example # autostart vm1
Response Domain vm1 marked as autostarted
38
40. list
Item Content
Description Returns a list of guest domains
Input N/A
Example # list
Response
virsh # list
Id Name State
----------------------------------------------------
1 vm1 running
40
42. console
Item Content
Description Connect the virtual serial console for the guest
Input 1. domain
Example # console vm1
Response
Connected to domain vm1
Escape character is ^]
42
51. save
Item Content
Description Save the running state of a guest domain to a file
Input
1.domain
2.file
Example # save vm1 image
Response Domain vm1 saved to image
51
59. The memory information of the host
• Before destroying the VM
• After destroying the VM
59
60. undefine
Item Content
Description Remove the configuration for an inactive guest domain
Input 1.domain
Example # undefine vm1
Response
Domain vm1 has been undefined
60
67. XML parameters
• interface type
– Network interface type
• interface name
– The name of interface
• bridge type
– The type of bridge
• vlan tag
– Use to tag of the vlan
67
77. Introduction
• Network management
– Libvirt has the capability to define virtual
networks which can then be used by domains
and linked to actual network devices
77
78. net-define
Item Content
Description
Adds a new permanent virtual network from an XML file,
without starting it
Input 1. file
Example # net-define vlan1.xml
Response Network vlan1 defined from vlan1.xml
78
80. XML for Network
<network >
<name>vlan1</name>
<forward mode='bridge'/>
<bridge name='br1' />
</network>
80
81. XML parameters
• name
– Virtual network name
• forward mode
– Inclusion of the forward element indicates that the virtual
network is to be connected to the physical LAN
• bridge name
– The name of a bridge device
81
82. net-start
Item Content
Description Starts a (previously defined) inactive virtual network
Input 1. network
Example # net-start vlan1
Response Network vlan1 started
82
84. net-autostart
Item Content
Description
Enable or disable the automatic starting of a virtual
network, when the libvirt daemon starts
Input 1. network
Example # net-autostart vlan1
Response Network vlan1 marked as autostarted
84
88. net-name
Item Content
Description
When given a network UUID, returns its corresponding
network name
Input 1. network
Example # net-name f1f1cd7e-b623-4d7e-94c8-2047da1decef
Response vlan1
88
89. net-uuid
Item Content
Description
When given a network name, returns its
corresponding UUID
Input 1. network
Example # net-uuid vlan1
Response f1f1cd7e-b623-4d7e-94c8-2047da1decef
89
93. net-undefine
Item Content
Description
Removes an inactive virtual network from the libvirt
configuration
Input 1. network
Example # net-undefine vlan1
Response Network vlan1 has been undefined
93
109. Introduction
• Snapshot
– Snapshots take the disk, memory, and device state
of a VM at a point-of-time, and save it for future
use
• --disk-only
– The snapshot will only include disk state
109
110. Snapshot scenario
110
Create a
folder and
modify
index.htm
Start
the
VM
Restart
the
VM
Revert
the
snapshot
Step 4Step 3Step 2Step 1
S0 S3S2S1 S1
Step 5
111. snapshot-create
Item Content
Description Create a snapshot (disk and RAM) from XML
Input
1. domain
2. xml
Example # snapshot-create vm1 snaptest.xml
Response
Domain snapshot snaptest created from
'snaptest.xml'
111
118. snapshot-delete
Item Content
Description
Removes a snapshot, and all of it's children, from a
domain
Input
1. domain
2. snapshotname
Example # snapshot-delete --domain vm1 snaptest --metadata
Response Domain snapshot snaptest deleted
118
122. Set up NFS server for images
• Install NFS server packages
– nfs-common
– nfs-kernel-server
122
• Set shared path and permission
123. Set up NFS server for images (cont.)
• Start NFS server
123
• Check NFS path
124. Set up NFS client – hypervisor
• Install NFS client packages
– nfs-common
124
• Mount image
• Check
125. Set up NFS client – hypervisor (cont.)
• Restart NFS server
125
• Check image on client
126. migrate
Item Content
Description Migrates a guest domain to another host
Input
1.domain
2.dest uri
Example # migrate vm1 qemu+ssh://140.92.26.108/system
Response pass
126
132. Virt-manager Introduction
• The virt-manager (Virtual Machine Manager)
application is a graphic user interface for managing
virtual machines through libvirt
132
148. Conclusion
• Virtualization
– High utilization of physical resource
• Virsh
– The main interface for managing virtualization
environment through Libvirt
• Virt-manager
– Graphic user interface for managing virtualization
environment through Libvirt
148