Introduction to Virtualization, Virsh and Virt-Manager
-
Upload
walkerchang -
Category
Software
-
view
511 -
download
14
description
Transcript of Introduction to Virtualization, Virsh and Virt-Manager
![Page 1: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/1.jpg)
Introduction to Virtualization, Virsh Commands and Virt-Manager
Chin Pin Chang
04/07/2014
1
![Page 2: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/2.jpg)
Outline• Virtualization
– Introduction– Types of Virtualization – KVM– Practice: KVM Installation
• Virsh Commands– Introduction– Practice: 3 Units
• Virt-Manager • Conclusion• References
2
![Page 3: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/3.jpg)
3
Virtualization Introduction
• Virtualization is a broad term that refers to the abstraction of computer physical resources such as servers, network, memory and storage
![Page 4: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/4.jpg)
4
Virtualization Introduction (cont.)
• Without Virtualization • With Virtualization
![Page 5: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/5.jpg)
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
![Page 6: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/6.jpg)
6
Types of Virtualization• Server Virtualization
– Full virtualization, Paravirtualization, Hardware-assisted virtualization
• Application Virtualization• Desktop Virtualization• Presentation Virtualization• Network Virtualization• Storage Virtualization
![Page 7: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/7.jpg)
7
KVM Introduction• KVM (Kernel-based Virtual Machine)
– A Linux kernel module that turns Linux into a hypervisor– Full virtualization
![Page 8: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/8.jpg)
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
![Page 9: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/9.jpg)
9
Install KVM (cont.)
• Check BIOS– Support
– Not support
![Page 10: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/10.jpg)
10
Install KVM (cont.)
• Install necessary packages– qemu-kvm– libvirt-bin – ubuntu-vm-builder – bridge-utils
![Page 11: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/11.jpg)
11
Add Users to Libvirtd and KVM Groups
• Add user "username" to libvirtd
• Add user " username" to KVM
• Need to re-login
![Page 12: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/12.jpg)
12
Verify Installation
• Check groups
• Verify Installation
• Change the device's group
![Page 13: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/13.jpg)
13
Install Virt-manager
• Install virt-manager
• Start virt-manager
![Page 14: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/14.jpg)
14
Step 1 - Create new virtual machine
![Page 15: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/15.jpg)
15
Step 2 – Locate install media
![Page 16: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/16.jpg)
16
Step 3 – Specify CPU and Memory
![Page 17: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/17.jpg)
17
Step 4 – Specify Storage
![Page 18: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/18.jpg)
18
Step 5 – Specify Network
![Page 19: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/19.jpg)
19
Install Ubuntu Server
![Page 20: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/20.jpg)
20
Virsh Introduction
• Virsh is a command line interface tool for managing VM and the hypervisor
![Page 21: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/21.jpg)
21
Virsh Introduction (cont.)
• Virsh Commands Classification– Domain management commands – Domain monitoring commands– Host and hypervisor commands– Interface commands– Network filter commands– Virtual networking commands– Node device commands– Secrets commands– Domain snapshot commands– Storage pool commands– Storage volume commands– Virsh commands
![Page 22: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/22.jpg)
22
Virsh Commands
Unit 1Domain Management
![Page 23: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/23.jpg)
23
Introduction
• Domain management– Is used to manage VM– Major commands: define, start, destroy, suspend,
resume and so on
![Page 24: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/24.jpg)
How to use virsh
24
![Page 25: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/25.jpg)
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
![Page 26: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/26.jpg)
Define a VM
26
![Page 27: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/27.jpg)
XML for VM
<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'> <name>vm1</name> <uuid>b7cb10e2-c6af-a328-ad75-3e09747f0564</uuid> <memory>524288</memory> <currentMemory>524288</currentMemory> <vcpu>1</vcpu> <os> <type arch='armv7l' machine='vexpress-a15'>hvm</type> <kernel>/root/zImage</kernel> <cmdline>earlyprintk=ttyAMA0 console=ttyAMA0 mem=512M root=/dev/vda rw ip=192.168.20.56::192.168.20.101:vm1:eth0:off --no-log</cmdline> <dtb>/root/guest-vexpress.dtb</dtb> </os> <features> <acpi/> <pae/> </features><!-- <cpu> <model>cortex-a15</model> </cpu> -->
27
![Page 28: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/28.jpg)
XML for VM (cont.)
<clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/bin/qemu-system-arm</emulator> <disk type='file' device='disk'> <driver name='qemu' type='raw' cache='none'/> <source file='/root/nfs/ubuntu1G.img'/> <target dev='vda' bus='virtio'/> </disk> <interface type='bridge'> <source bridge='virbr0'/> <mac address='52:54:00:12:34:55'/> <model type='virtio'/> </interface> <console type='pty'/> </devices></domain>
28
![Page 29: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/29.jpg)
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
![Page 30: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/30.jpg)
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
![Page 31: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/31.jpg)
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
![Page 32: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/32.jpg)
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
![Page 33: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/33.jpg)
Start VM
33
![Page 34: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/34.jpg)
domid
Item Content
Description Convert a domain name or UUID to domain id
Input 1. domain
Example # domid vm1
Response 1
34
![Page 35: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/35.jpg)
domname
Item Content
Description Convert a guest domain id or UUID to guest domain name
Input 1. domain
Example # domname 1
Response vm1
35
![Page 36: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/36.jpg)
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
![Page 37: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/37.jpg)
VM Information
• The domain ID
• The domain name
• The domain uuid
37
![Page 38: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/38.jpg)
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
![Page 39: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/39.jpg)
Auto start VM
39
![Page 40: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/40.jpg)
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
![Page 41: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/41.jpg)
List VM
41
![Page 42: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/42.jpg)
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
![Page 43: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/43.jpg)
Connect to VM
43
![Page 44: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/44.jpg)
Connect to VM (cont.)
44
• Launch Apache service
• Check Apache service
![Page 45: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/45.jpg)
Connect to VM (cont.)
• Check the IP of the VM
45
![Page 46: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/46.jpg)
Connect to VM (cont.)
• Check /var/www/index.html
• Web page
46
![Page 47: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/47.jpg)
suspend
Item Content
Description Suspend a running guest domain
Input 1.domain
Example # suspend vm1
Response Domain vm1 suspended
47
![Page 48: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/48.jpg)
Suspend VM
• Web page
48
![Page 49: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/49.jpg)
resume
Item Content
Description Resume a guest domain
Input 1.domain
Example # resume vm1
Response Domain vm1 resumed
49
![Page 50: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/50.jpg)
Resume VM
• Web page
50
![Page 51: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/51.jpg)
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
![Page 52: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/52.jpg)
restore
Item Content
Description Restore a guest domain
Input 1.file
Example # restore image
Response Domain restored from image
52
![Page 53: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/53.jpg)
53
Save and Restore scenario
S0
Save the VM
Restore the VM
Start the VM
Modify index.htm
S0S2S1
Step 4Step 3Step 2Step 1
![Page 54: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/54.jpg)
Step 1
• Save the VM
• The saved file
54
![Page 55: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/55.jpg)
Step 2 and 3
• Start the VM• Modify /var/www/index.html
• Web page
55
![Page 56: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/56.jpg)
Step 4
• Restore the VM
• Web page
56
![Page 57: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/57.jpg)
destroy
Item Content
Description Immediately terminates a running guest domain, releasing any resources in use by it
Input 1.domain
Example # destroy vm1
Response Domain vm1 destroyed
57
![Page 58: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/58.jpg)
Destroy VM
58
![Page 59: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/59.jpg)
The memory information of the host
• Before destroying the VM
• After destroying the VM
59
![Page 60: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/60.jpg)
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
![Page 61: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/61.jpg)
Undefine VM
61
![Page 62: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/62.jpg)
62
Virsh Commands
Unit 2Interface Management and
Network Management
![Page 63: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/63.jpg)
63
Introduction
• Interface management– To create an interface on the host for VM
![Page 64: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/64.jpg)
64
iface-define
Item Content
Description Define a physical host network interface
Input 1. XML file
Example # iface-define br1.xml
Response Interface br1 defined from br1.xml
![Page 65: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/65.jpg)
65
Define an interface
• Interface br1
![Page 66: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/66.jpg)
66
XML for Interface<interface type='bridge' name='br1'> <start mode='onboot'/> <bridge> <interface type='vlan' name='bond0.1'> <vlan tag='1'> <interface name='bond1'/> </vlan> </interface> </bridge> </interface>
![Page 67: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/67.jpg)
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
![Page 68: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/68.jpg)
68
iface-start
Item Content
Description Enables and starts a physical host network interface
Input 1. interface
Example # iface-start br1
Response Interface br1 started
![Page 69: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/69.jpg)
69
Start interface
![Page 70: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/70.jpg)
70
iface-name
Item Content
Description Returns the physical host interface name for a MAC address
Input 1. interface(MAC address)
Example # iface-name 3a:a0:42:19:ca:b2
Response br1
![Page 71: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/71.jpg)
71
iface-mac
Item Content
Description Returns the MAC address for a physical host network interface
Input 1. interface
Example # iface-mac br1
Response 3a:a0:42:19:ca:b2
![Page 72: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/72.jpg)
72
Interface Information
• The interface name
• The interface mac
![Page 73: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/73.jpg)
73
iface-destroy
Item Content
Description Shut down and disable a physical host network interface
Input 1. interface
Example # iface-destroy br1
Response Interface br1 destroyed
![Page 74: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/74.jpg)
74
Destroy interface
![Page 75: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/75.jpg)
75
iface-undefine
Item Content
Description Removes the configuration information for a physical host network interface
Input 1. interface
Example # iface-undefine br1
Response Interface br1 undefined
![Page 76: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/76.jpg)
76
Undefine interface
![Page 77: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/77.jpg)
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
![Page 78: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/78.jpg)
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
![Page 79: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/79.jpg)
79
Define network
• Network vlan1
![Page 80: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/80.jpg)
80
XML for Network<network > <name>vlan1</name> <forward mode='bridge'/> <bridge name='br1' /></network>
![Page 81: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/81.jpg)
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
![Page 82: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/82.jpg)
82
net-start
Item Content
Description Starts a (previously defined) inactive virtual network
Input 1. network
Example # net-start vlan1
Response Network vlan1 started
![Page 83: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/83.jpg)
83
Start network
![Page 84: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/84.jpg)
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
![Page 85: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/85.jpg)
85
Auto start network
![Page 86: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/86.jpg)
86
net-infoItem Content
Description Displays basic information for a virtual network
Input 1. network
Example # net-info vlan1
Response
Name vlan1 UUID f1f1cd7e-b623-4d7e-94c8-2047da1decef Active: yes Persistent: yes Autostart: yes Bridge: br1
![Page 87: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/87.jpg)
87
Network Information
![Page 88: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/88.jpg)
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
![Page 89: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/89.jpg)
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
![Page 90: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/90.jpg)
90
Network Information
• The network name
• The network uuid
![Page 91: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/91.jpg)
91
net-destroy
Item Content
Description Shuts down a running virtual network
Input 1. network
Example # net-destroy vlan1
Response Network vlan1 destroyed
![Page 92: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/92.jpg)
92
Destroy network
![Page 93: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/93.jpg)
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
![Page 94: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/94.jpg)
94
Undefine network
![Page 95: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/95.jpg)
95
Interface and Network scenario
Hostvirbr0
br1 br2
VM1 VM2 VM3
IP: 192.168.1.101 192.168.1.102 192.168.1.103
vlan1
vlan2
![Page 96: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/96.jpg)
96
Example
• Define the interfaces br1 and br2
![Page 97: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/97.jpg)
97
XML for host
• br1.xml<interface type='bridge' name='br1'> <start mode='onboot'/> <bridge> <interface type='vlan' name='bond0.1'> <vlan tag='1'> <interface name='bond1'/> </vlan> </interface> </bridge> </interface>
![Page 98: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/98.jpg)
98
XML for host (cont.)
• br2.xml<interface type='bridge' name='br2'> <start mode='onboot'/> <bridge> <interface type='vlan' name='bond0.2'> <vlan tag=‘2'> <interface name='bond2'/> </vlan> </interface> </bridge> </interface>
![Page 99: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/99.jpg)
99
XML for VM• Modify VM1.xml
• Modify VM2.xml
• Modify VM3.xml
![Page 100: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/100.jpg)
100
Define VM
• Define VM1, VM2 and VM3
![Page 101: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/101.jpg)
101
Start VM
• Start VM1, VM2 and VM3
![Page 102: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/102.jpg)
102
Start interface
• Start interface br1 and br2
![Page 103: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/103.jpg)
103
Connect to VM
• Assign IP (192.168.0.101) to VM1
![Page 104: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/104.jpg)
104
Connect to VM (cont.)
• Assign IP (192.168.0.102) to VM2
![Page 105: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/105.jpg)
105
Connect to VM (cont.)
• Assign IP (192.168.0.103) to VM3
![Page 106: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/106.jpg)
106
Result
• VM1 ping VM2
• VM1 ping VM3
![Page 107: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/107.jpg)
107
Result (cont.)
• VM3 ping VM1
• VM3 ping VM2
![Page 108: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/108.jpg)
108
Virsh Commands
Unit 3Snapshot and Migrate
![Page 109: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/109.jpg)
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
![Page 110: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/110.jpg)
110
Snapshot scenario
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
![Page 111: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/111.jpg)
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'
![Page 112: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/112.jpg)
112
• Start VM• Take a snapshot
Create a snapshot for VM
![Page 113: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/113.jpg)
113
Create a folder in VM
• Start VM• Create a folder "test"
![Page 114: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/114.jpg)
Launch Apache service
• Check /var/www/index.html
• Web page
114
![Page 115: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/115.jpg)
Launch Apache service (cont.)
• Modify the /var/www/index.html
• Web page
115
![Page 116: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/116.jpg)
116
snapshot-revert
Item Content
Description Reverts a domain to a given snapshot
Input 1. domain 2. snapshotname
Example # snapshot-revert vm1 snaptest
Response N/A
![Page 117: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/117.jpg)
117
Revert snapshot
• Folder
• Web page
![Page 118: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/118.jpg)
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
![Page 119: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/119.jpg)
119
Delete snapshot
![Page 120: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/120.jpg)
120
Introduction
• Migrate– Migration is the process of moving a virtual
machine from one host or storage location to another
![Page 121: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/121.jpg)
121
Migration
Source
VMDownload
a file
Destination
VMDownload
a file
Migration
Network
IP: 192.92.26.120 IP: 192.92.26.108
NFS/Data/image
VMimage
![Page 122: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/122.jpg)
122
Set up NFS server for images
• Install NFS server packages – nfs-common– nfs-kernel-server
• Set shared path and permission
![Page 123: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/123.jpg)
123
Set up NFS server for images (cont.)
• Start NFS server
• Check NFS path
![Page 124: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/124.jpg)
124
Set up NFS client – hypervisor
• Install NFS client packages – nfs-common
• Mount image
• Check
![Page 125: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/125.jpg)
125
Set up NFS client – hypervisor (cont.)
• Restart NFS server
• Check image on client
![Page 126: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/126.jpg)
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
![Page 127: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/127.jpg)
127
Start VM
![Page 128: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/128.jpg)
128
Download a file to VM
![Page 129: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/129.jpg)
129
Migrate VM to destination host
• Source host
The URI of the destination host
![Page 130: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/130.jpg)
130
After migration
• Destination host
![Page 131: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/131.jpg)
131
Verify the file
• The file size
![Page 132: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/132.jpg)
132
Virt-manager Introduction• The virt-manager (Virtual Machine Manager)
application is a graphic user interface for managing virtual machines through libvirt
![Page 133: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/133.jpg)
133
Main window
![Page 134: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/134.jpg)
134
Connection window
![Page 135: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/135.jpg)
Define VM
135
![Page 136: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/136.jpg)
Start VM
136
![Page 137: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/137.jpg)
Connect to VM
137
![Page 138: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/138.jpg)
Verify connection
138
• Virt-manager
![Page 139: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/139.jpg)
Suspend VM
139
![Page 140: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/140.jpg)
Resume VM
140
![Page 141: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/141.jpg)
Save VM
141
![Page 142: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/142.jpg)
Save VM (cont.)
142
![Page 143: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/143.jpg)
Restore VM
143
![Page 144: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/144.jpg)
Clone VM
144
![Page 145: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/145.jpg)
Check CPU usage of VM
145
![Page 146: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/146.jpg)
Destroy VM
146
![Page 147: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/147.jpg)
Delete VM
147
![Page 148: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/148.jpg)
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
![Page 150: Introduction to Virtualization, Virsh and Virt-Manager](https://reader038.fdocuments.in/reader038/viewer/2022102610/54c42ccc4a7959a52d8b467e/html5/thumbnails/150.jpg)
150
References• http://libvirt.org/• http://en.wikipedia.org/wiki/Virtualization• http://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine • http://www.slideshare.net/trupti242/virtuallization-
questions#• https://access.redhat.com/site/documentation/en-US/
Red_Hat_Enterprise_Linux/• http://trac.nchc.org.tw/cloud• https://help.ubuntu.com/community/KVM/Installation• http://www.ubuntu-tw.org/modules/tinyd0/