• 沒有找到結果。

Introduction to VM, libvirt, KVM

N/A
N/A
Protected

Academic year: 2022

Share "Introduction to VM, libvirt, KVM"

Copied!
35
0
0

全文

(1)

Introduction to VM, libvirt, KVM

Robert Wang 2014/5/26

(2)

What is a virtual machine

(3)
(4)
(5)

Virtual Machine

System VM

provide a environment for executing an OS

usually does hardware virtualization

Process VM

executing a single process

(6)

Why do we need virtual machines

(7)

Resource Sharing/Consolidation

Example: Need to run web, mail, file, x, y, z, total of 10 servers. Do we need 10 physical servers?

Put them into one server?

How?

(8)

Massive Deployment

Example: Build 100 the web frontend servers.

Install manually?

Install via scripts?

(9)

Isolation

(10)

Run Legacy Software

(11)

Software Development

(12)

Snapshot

(13)

System VMs

(14)

Concept

Hardware Hypervisor

Guest OS Guest OS Guest OS

App App App App App App App App App

(15)

Hypervisor

also called virtual machine monitor (VMM)

manage mappings

disks, memory

manage sharing

cpus, network

(16)

x86 Protection Ring: No Virtualization

Hardware Guest OS

App App App

Guest OS executes privileged instructions for App.

(17)

x86 Protection Ring: With Virtualization

Hardware Guest OS

App App App

Hypervisor

Hypervisor executes privileged instructions for Guest OS.

(18)

Types of Hypervisor

Type 1: native (bare metal)

need to implement its own drivers

(eg. Xen, VMware ESX/ESXi)

Type 2: hosted

can reuse OSes’

implementations.

(eg. VirtualBox, VMware Workstation)

(19)

Types of Hardware Virtualization

Full Virtualization

Para-virtualization

Hardware-assisted virtualization

!

[NOTE: they are not disjoint.]

(20)

Full Virtualization

Complete simulation of hardware devices.

Not quite possible on x86 until some hardware support.

Binary translation.

Slow!

(21)

Para-virtualization

Modified OS to avoid most trapping instructions.

Custom I/O drivers.

(eg. Virtio)

(22)

Hardware-assisted Virtualization

Aim to provide high performance full virtualization.

Intel VT-x, AMD-V instruction set.

(23)
(24)

Kernel Virtual Machine

(25)

KVM

Strictly speaking, KVM is a linux kernel module.

Provides a set of APIs to accelerate virtualization.

Utilizing Intel VT-x or AMD-V.

I/O part is handled by QEMU.

(26)

KVM

(27)

Using KVM — Simple Way

Create a virtual disk file

qemu-img create -f qcow2 vdisk.img 10G

Boot the machine (w/ install CD)

kvm -hda vdisk.img -cdrom /path/to/boot-media.iso - boot d -m 512

(“kvm” may be named “qemu-system-x86_64” on some distributions.)

(28)

Using KVM — The complex way

qemu-system-x86_64 -machine accel=kvm:tcg -name robertabcd -S - machine pc-q35-1.6,accel=kvm,usb=off -cpu host -m 1024 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid

f68ef371-4cd6-2406-d5e0-41ad6210c22c -nographic -no-user-config - nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/

qemu/robertabcd.monitor,server,nowait -

monchardev=charmonitor,id=monitor,mode=control -rtc base=utc -no- shutdown -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1 - device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x1 -

device piix3-usb-uhci,id=usb,bus=pci.2,addr=0x1.0x2 -drive file=/

dev/vmhost/robertabcd.img,if=none,id=drive-virtio-

disk0,format=raw -device virtio-blk-pci,scsi=off,bus=pci.

2,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 - netdev tap,fd=25,id=hostnet0,vhost=on,vhostfd=32 -device virtio- net-pci,netdev=hostnet0,id=net0,mac=52:54:00:b3:08:a8,bus=pci.

2,addr=0x3 -chardev pty,id=charserial0 -device isa-

serial,chardev=charserial0,id=serial0 -device virtio-balloon- pci,id=balloon0,bus=pci.2,addr=0x4

(29)

libvirt

(30)

What is “libvirt”?

A toolkit to interact with virtualization softwares.

A long term stable API.

Supports a wide range of hypervisors:

(31)

Setup VMs

libvirt uses XML for definitions.

You “define/undefine” a virtual machine.

You “start/destroy” a domain (think a running virtual machine).

(32)
(33)

“virtinst” Package

virt-install 


--connect qemu:///system 
 -n "robertabcd" 


-r 1024 


--vcpus 2 


--accelerate 


--disk /dev/vg/disk,bus=virtio,format=raw 
 -w bridge=br0 


--nographics 


-x console=ttyS0 
 --location “…”

(34)

Hate CLI?

It has a GUI manager: “virt-manager”.

Think twice before using GUI.

(35)

Reference

Getting Started (Debian/Ubuntu)

https://help.ubuntu.com/12.04/serverguide/libvirt.html

See libvirt documentation for tunable options and APIs

http://libvirt.org/

參考文獻

相關文件

‡ In an ordered binary tree (usually called just a binary tree), if an internal vertex has two children, the first child is called the left child and the second one is called

In this case Lagrange’s method is to look for extreme values by solving five equations in the five unknowns x, y, z, λ, and µ ... Example 5

Particles near (x, y, z) in the fluid tend to rotate about the axis that points in the direction of curl F(x, y, z), and the length of this curl vector is a measure of how quickly

Partial Volume Segmentation with Voxel Histograms; Higher Order Statistics for Tissue Segmentation; III Quantification; Two-dimensional Shape and Texture

• Goal is to construct a no-arbitrage interest rate tree consistent with the yields and/or yield volatilities of zero-coupon bonds of all maturities.. – This procedure is

include domain knowledge by specific kernel design (e.g. train a generative model for feature extraction, and use the extracted feature in SVM to get discriminative power).

(Class): Apples are somewhat circular, somewhat red, possibly green, and may have stems at the top. Hsuan-Tien

The best way to picture a vector field is to draw the arrow representing the vector F(x, y) starting at the point (x, y).. Of course, it’s impossible to do this for all points (x,

Recycling Techniques are Available to Address Specific Pavement Distress and/or Pavement Structural Requirement.. Introduction to Asphalt Introduction

 The nanostructure with anisotropic transmission characteristics on ITO films induced by fs laser can be used for the alignment layer , polarizer and conducting layer in LCD cell.

(A) File Transfer Protocol, FTP (B) Electronic Mail, E-Mail (C) World Wide Web, WWW (D) Word Wide Web,

 一般我們如過是透過分享器或集線器來連接電腦 的話,只需要壓制平行線即可(平行線:兩端接 頭皆為EIA/TIA 568B),

 一般我們如過是透過分享器或集線器來連接電腦 的話,只需要壓制平行線即可(平行線:兩端接 頭皆為 EIA/TIA 568B ), 如果是接機器對機器 的話,需要製作跳線( Crossover :一端為

3) 請先充分地搓 揉預計切除的部 分。這樣使外皮 會與裡面芯線產 生間隙。.. 4) 將網路線夾在剝 皮工具的最外側溝

3) 請先充分地搓 揉預計切除的部 分。這樣使外皮 會與裡面芯線產 生間隙。?. 4) 將網路線夾在剝 皮工具的最外側溝

• However, inv(A) may return a weird result even if A is ill-conditioned, indicates how much the output value of the function can change for a small change in the

JRE (Java Runtime Environment): for users, JVM + basic libraries JDK (Java Development Kit): JRE + compilers + ... —jdk-6u12-windows-i586-p.exe or other platform

• Visit the primary school before school starts, find out about the learning environment and children’s impression of the school and help children adapt to the new school after the

Triple Room A room that can accommodate three persons and has been fitted with three twin beds, one double bed and one twin bed or two double beds... Different types of room in

„ There is no Hamilton circuit in G2 (this can be seen by nothing that any circuit containing every vertex must contain the edge {a,b} twice), but G2 does have a Hamilton

A marble texture can be made by using a Perlin function as an offset using a Perlin function as an offset to a cosine function. texture = cosine( x +

When renaming a file without changing file systems, the actual contents of the file need not be movedall that needs to be done is to add a new directory entry that points to

To illustrate how LINDO can be used to solve a preemptive goal programming problem, let’s look at the Priceler example with our original set of priorities (HIM followed by LIP