QEMU KVM Libvirt手册(7): 硬件虚拟化
在openstack中,如果我們啟動一個虛擬機,我們會看到非常復雜的參數
qemu-system-x86_64
-enable-kvm
-name instance-00000024
-S
-machine pc-i440fx-trusty,accel=kvm,usb=off
-cpu SandyBridge,+erms,+smep,+fsgsbase,+pdpe1gb,+rdrand,+f16c,+osxsave,+dca,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme
-m 2048 -realtime mlock=off
-smp 1,sockets=1,cores=1,threads=1
-uuid 1f8e6f7e-5a70-4780-89c1-464dc0e7f308
-smbios type=1,manufacturer=OpenStack Foundation,product=OpenStack Nova,version=2014.1,serial=80590690-87d2-e311-b1b0-a0481cabdfb4,uuid=1f8e6f7e-5a70-4780-89c1-464dc0e7f308
-no-user-config
-nodefaults
-chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/instance-00000024.monitor,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control
-rtc base=utc,driftfix=slew
-global kvm-pit.lost_tick_policy=discard
-no-hpet
-no-shutdown
-boot strict=on
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2
-drive file=/var/lib/nova/instances/1f8e6f7e-5a70-4780-89c1-464dc0e7f308/disk,if=none,id=drive-virtio-disk0,format=qcow2,cache=none
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
-netdev tap,fd=32,id=hostnet0,vhost=on,vhostfd=37
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:d1:2d:99,bus=pci.0,addr=0x3
-chardev file,id=charserial0,path=/var/lib/nova/instances/1f8e6f7e-5a70-4780-89c1-464dc0e7f308/console.log
-device isa-serial,chardev=charserial0,id=serial0
-chardev pty,id=charserial1
-device isa-serial,chardev=charserial1,id=serial1
-device usb-tablet,id=input0
-vnc 0.0.0.0:12
-k en-us
-device cirrus-vga,id=video0,bus=pci.0,addr=0x2
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
這節我們會一一解析
QEMU會模擬多種Processor architectures, 常用的是PC (x86 or x86_64 processor), Mac99 PowerMac (PowerPC processor), Sun4u/Sun4v (64-bit Sparc processor), MIPS magnum (64-bit MIPS processor)
通過下面的命令我們可以列出支持的PC bus architecture
?
# qemu-system-x86_64 --machine ?
Supported machines are:
pc-0.13????????????? Standard PC (i440FX + PIIX, 1996)
pc-i440fx-2.0??????? Standard PC (i440FX + PIIX, 1996)
pc-1.0?????????????? Standard PC (i440FX + PIIX, 1996)
pc-q35-1.7?????????? Standard PC (Q35 + ICH9, 2009)
pc-1.1?????????????? Standard PC (i440FX + PIIX, 1996)
q35????????????????? Standard PC (Q35 + ICH9, 2009) (alias of pc-q35-2.0)
pc-q35-2.0?????????? Standard PC (Q35 + ICH9, 2009)
pc-i440fx-1.4??????? Standard PC (i440FX + PIIX, 1996)
pc-i440fx-1.5??????? Standard PC (i440FX + PIIX, 1996)
pc-0.14????????????? Standard PC (i440FX + PIIX, 1996)
pc-0.15????????????? Standard PC (i440FX + PIIX, 1996)
xenfv??????????????? Xen Fully-virtualized PC
pc-q35-1.4?????????? Standard PC (Q35 + ICH9, 2009)
isapc??????????????? ISA-only PC
pc-0.10????????????? Standard PC (i440FX + PIIX, 1996)
pc?????????????????? Ubuntu 14.04 PC (i440FX + PIIX, 1996) (alias of pc-i440fx-trusty)
pc-i440fx-trusty???? Ubuntu 14.04 PC (i440FX + PIIX, 1996) (default)
pc-1.2?????????????? Standard PC (i440FX + PIIX, 1996)
pc-0.11????????????? Standard PC (i440FX + PIIX, 1996)
pc-i440fx-1.7??????? Standard PC (i440FX + PIIX, 1996)
pc-i440fx-1.6??????? Standard PC (i440FX + PIIX, 1996)
none???????????????? empty machine
xenpv??????????????? Xen Para-virtualized PC
pc-q35-1.5?????????? Standard PC (Q35 + ICH9, 2009)
pc-q35-1.6?????????? Standard PC (Q35 + ICH9, 2009)
pc-0.12????????????? Standard PC (i440FX + PIIX, 1996)
pc-1.3?????????????? Standard PC (i440FX + PIIX, 1996)
默認的是pc-i440fx-trusty,所以在上面的參數中我們可以看到
-machine pc-i440fx-trusty,accel=kvm,usb=off
在x86 architecture下,很多硬件都可以被模擬
SeaBIOS (from QEMU 0.12.0), PC BIOS from the Bochs project (up QEMU 0.11)
Plex86/Bochs LGPL VGA BIOS
Symmetric multiprocessor system (SMP) for up to 255 CPUs
PC bus: PCI or ISA system (i440FX Host PCI Bridge and PCI to ISA Bridge PIIX3)
Two PCI IDE interfaces with support for up to four (virtual) hard drives or CD / DVD-ROMs
two floppy disk drives
CD or DVD drive
Graphics card (Cirrus CLGD 5446 PCI VGA card or standard VGA graphics card with Bochs VESA BIOS Extension)
2 mouse and keyboard
PCI UHCI USB controller and a virtual USB hub
PCI-/ISA-Netzwerkadapter
Network cards (Intel e1000 and others)
Parallel port
Serial ports
Sound card (Creative Sound Blaster 16, ENSONIQ AudioPCI ES1370 PCI, Intel 82801AA AC97, Adlib OPL2 Yamaha
YM3812, Gravis Ultrasound GF1, CS4231A)
Supervisor Mode Execution Prevention (SMEP) from Intel
Functionalities of VIA CPUs.
CPU
下面的命令可以列出支持的CPU
# qemu-system-x86_64 --cpu ?
x86?????????? qemu64? QEMU Virtual CPU version 2.0.0?????????????????
x86?????????? phenom? AMD Phenom(tm) 9550 Quad-Core Processor????????
x86???????? core2duo? Intel(R) Core(TM)2 Duo CPU???? T7700? @ 2.40GHz
x86??????????? kvm64? Common KVM processor???????????????????????????
x86?????????? qemu32? QEMU Virtual CPU version 2.0.0?????????????????
x86??????????? kvm32? Common 32-bit KVM processor????????????????????
x86????????? coreduo? Genuine Intel(R) CPU?????????? T2600? @ 2.16GHz
x86????????????? 486?????????????????????????????????????????????????
x86????????? pentium?????????????????????????????????????????????????
x86???????? pentium2?????????????????????????????????????????????????
x86???????? pentium3?????????????????????????????????????????????????
x86?????????? athlon? QEMU Virtual CPU version 2.0.0?????????????????
x86???????????? n270? Intel(R) Atom(TM) CPU N270?? @ 1.60GHz?????????
x86?????????? Conroe? Intel Celeron_4x0 (Conroe/Merom Class Core 2)??
x86?????????? Penryn? Intel Core 2 Duo P9xxx (Penryn Class Core 2)???
x86????????? Nehalem? Intel Core i7 9xx (Nehalem Class Core i7)??????
x86???????? Westmere? Westmere E56xx/L56xx/X56xx (Nehalem-C)?????????
x86????? SandyBridge? Intel Xeon E312xx (Sandy Bridge)???????????????
x86????????? Haswell? Intel Core Processor (Haswell)?????????????????
x86?????? Opteron_G1? AMD Opteron 240 (Gen 1 Class Opteron)??????????
x86?????? Opteron_G2? AMD Opteron 22xx (Gen 2 Class Opteron)?????????
x86?????? Opteron_G3? AMD Opteron 23xx (Gen 3 Class Opteron)?????????
x86?????? Opteron_G4? AMD Opteron 62xx class CPU?????????????????????
x86?????? Opteron_G5? AMD Opteron 63xx class CPU?????????????????????
x86???????????? host? KVM processor with all supported host features (only available in KVM mode)
Recognized CPUID flags:
? pbe ia64 tm ht ss sse2 sse fxsr mmx acpi ds clflush pn pse36 pat cmov mca pge mtrr sep apic cx8 mce pae msr tsc pse de vme fpu
? hypervisor rdrand f16c avx osxsave xsave aes tsc-deadline popcnt movbe x2apic sse4.2|sse4_2 sse4.1|sse4_1 dca pcid pdcm xtpr cx16 fma cid ssse3 tm2 est smx vmx ds_cpl monitor dtes64 pclmulqdq|pclmuldq pni|sse3
? smap adx rdseed rtm invpcid erms bmi2 smep avx2 hle bmi1 fsgsbase
? 3dnow 3dnowext lm|i64 rdtscp pdpe1gb fxsr_opt|ffxsr mmxext nx|xd syscall
? perfctr_nb perfctr_core topoext tbm nodeid_msr tce fma4 lwp wdt skinit xop ibs osvw 3dnowprefetch misalignsse sse4a abm cr8legacy extapic svm cmp_legacy lahf_lm
? pmm-en pmm phe-en phe ace2-en ace2 xcrypt-en xcrypt xstore-en xstore
? kvm_pv_unhalt kvm_pv_eoi kvm_steal_time kvm_asyncpf kvmclock kvm_mmu kvm_nopiodelay kvmclock
? pfthreshold pause_filter decodeassists flushbyasid vmcb_clean tsc_scale nrip_save svm_lock lbrv npt
所以我們的參數中有下面的CPU設置及添加的flag
-cpu SandyBridge,+erms,+smep,+fsgsbase,+pdpe1gb,+rdrand,+f16c,+osxsave,+dca,+pcid,+pdcm,+xtpr,+tm2,+est,+smx,+vmx,+ds_cpl,+monitor,+dtes64,+pbe,+tm,+ht,+ss,+acpi,+ds,+vme
SMP對稱多處理器
對稱多處理"(Symmetrical Multi-Processing)簡稱SMP,是指在一個計算機上匯集了一組處理器(多CPU),各CPU之間共享內存子系統以及總線結構。
在這種架構中,一臺電腦不再由單個CPU組成,而同時由多個處理器運行操作系統的單一復本,并共享內存和一臺計算機的其他資源。雖然同時使用多個CPU,但是從管理的角度來看,它們的表現就像一臺單機一樣。系統將任務隊列對稱地分布于多個CPU之上,從而極大地提高了整個系統的數據處理能力。所有的處理器都可以平等地訪問內存、I/O和外部中斷。在對稱多處理系統中,系統資源被系統中所有CPU共享,工作負載能夠均勻地分配到所有可用處理器之上。
QEMU and KVM 可以最多模擬SMP到255個CPU.
我們的參數中有
-smp 1,sockets=1,cores=1,threads=1
qemu仿真了一個具有1個vcpu,一個socket,一個core,一個threads的處理器。
socket, core, threads是什么概念呢
(1)socket就是主板上插cpu的槽的數目,也即管理員說的”路“
(2)core就是我們平時說的”核“,即雙核,4核等
(3)thread就是每個core的硬件線程數,即超線程
具體例子,某個服務器是:2路4核超線程(一般默認為2個線程),那么,通過cat /proc/cpuinfo看到的是2*4*2=16個processor,很多人也習慣成為16核了!
如果使用KVM hardware-assisted virtualization,也即nova-compute.conf中的libvirt_type=kvm,也即BIOS中VD-T是打開的,則參數中accel=kvm
如果不使用hardware-assisted virtualization,也即nova-compute.conf中的libvirt_type=qemu,用的是純模擬,則有參數accel = tcg,-no-kvm
When you install Microsoft Windows as a guest operating system, the KVM hardware-assisted virtualization should be disabled. After installation, the KVM hardware-assisted virtualization can be enabled on all Windows versions.
其他硬件
還模擬了其他的設備,可以使用默認配置,如果不使用默認配置,則有參數-nodefaults
在monitor中,用下面的命令可以打印出所有的device
virsh # qemu-monitor-command instance-00000024 --hmp "info qtree"
bus: main-system-bus
? type System
? dev: kvm-ioapic, id ""
??? gpio-in 24
??? gsi_base = 0 (0)
??? irq 0
??? mmio 00000000fec00000/0000000000001000
? dev: i440FX-pcihost, id ""
??? pci-hole64-size = 18446744073709551615 (16 EiB)
??? short_root_bus = 0 (0)
??? irq 0
??? bus: pci.0
????? type PCI
????? dev: virtio-balloon-pci, id "balloon0"
??????? indirect_desc = true
??????? event_idx = true
??????? class = 255 (0xff)
??????? addr = 05.0
??????? romfile = ""
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class Class 00ff, addr 00:05.0, pci id 1af4:1002 (sub 1af4:0005)
??????? bar 0: i/o at 0xc080 [0xc09f]
??????? bus: virtio-bus
????????? type virtio-pci-bus
????????? dev: virtio-balloon-device, id ""
????? dev: cirrus-vga, id "video0"
??????? vgamem_mb = 8 (0x8)
??????? addr = 02.0
??????? romfile = "vgabios-cirrus.bin"
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class VGA controller, addr 00:02.0, pci id 1013:00b8 (sub 1af4:1100)
??????? bar 0: mem at 0xfc000000 [0xfdffffff]
??????? bar 1: mem at 0xfebd0000 [0xfebd0fff]
??????? bar 6: mem at 0xffffffffffffffff [0xfffe]
????? dev: virtio-net-pci, id "net0"
??????? ioeventfd = false
??????? vectors = 3 (0x3)
??????? indirect_desc = true
??????? event_idx = true
??????? any_layout = true
??????? csum = true
??????? guest_csum = true
??????? gso = true
??????? guest_tso4 = true
??????? guest_tso6 = true
??????? guest_ecn = true
??????? guest_ufo = true
??????? host_tso4 = true
??????? host_tso6 = true
??????? host_ecn = true
??????? host_ufo = true
??????? mrg_rxbuf = true
??????? status = true
??????? ctrl_vq = true
??????? ctrl_rx = true
??????? ctrl_vlan = true
??????? ctrl_rx_extra = true
??????? ctrl_mac_addr = true
??????? ctrl_guest_offloads = true
??????? mq = false
??????? mac = "fa:16:3e:d1:2d:99"
??????? vlan = <null>
??????? netdev = "hostnet0"
??????? bootindex = -1 (0xffffffffffffffff)
??????? x-txtimer = 150000 (0x249f0)
??????? x-txburst = 256 (0x100)
??????? tx = ""
??????? addr = 03.0
??????? romfile = "efi-virtio.rom"
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class Ethernet controller, addr 00:03.0, pci id 1af4:1000 (sub 1af4:0001)
??????? bar 0: i/o at 0xc060 [0xc07f]
??????? bar 1: mem at 0xfebd1000 [0xfebd1fff]
??????? bar 6: mem at 0xffffffffffffffff [0x3fffe]
??????? bus: virtio-bus
????????? type virtio-pci-bus
????????? dev: virtio-net-device, id ""
??????????? mac = "fa:16:3e:d1:2d:99"
??????????? vlan = <null>
??????????? netdev = "hostnet0"
??????????? bootindex = -1 (0xffffffffffffffff)
??????????? x-txtimer = 150000 (0x249f0)
??????????? x-txburst = 256 (0x100)
??????????? tx = ""
????? dev: virtio-blk-pci, id "virtio-disk0"
??????? class = 0 (0)
??????? ioeventfd = true
??????? vectors = 2 (0x2)
??????? x-data-plane = false
??????? indirect_desc = true
??????? event_idx = true
??????? drive = "drive-virtio-disk0"
??????? logical_block_size = 512 (0x200)
??????? physical_block_size = 512 (0x200)
??????? min_io_size = 0 (0)
??????? opt_io_size = 0 (0)
??????? bootindex = 1 (0x1)
??????? discard_granularity = 4294967295 (0xffffffff)
??????? cyls = 0 (0)
??????? heads = 0 (0)
??????? secs = 0 (0)
??????? serial = ""
??????? config-wce = true
??????? scsi = false
??????? x-iothread = ""
??????? addr = 04.0
??????? romfile = ""
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class SCSI controller, addr 00:04.0, pci id 1af4:1001 (sub 1af4:0002)
??????? bar 0: i/o at 0xc000 [0xc03f]
??????? bar 1: mem at 0xfebd2000 [0xfebd2fff]
??????? bus: virtio-bus
????????? type virtio-pci-bus
????????? dev: virtio-blk-device, id ""
??????????? drive = "drive-virtio-disk0"
??????????? logical_block_size = 512 (0x200)
??????????? physical_block_size = 512 (0x200)
??????????? min_io_size = 0 (0)
??????????? opt_io_size = 0 (0)
??????????? bootindex = 1 (0x1)
??????????? discard_granularity = 4294967295 (0xffffffff)
??????????? cyls = 16383 (0x3fff)
??????????? heads = 16 (0x10)
??????????? secs = 63 (0x3f)
??????????? serial = ""
??????????? config-wce = true
??????????? scsi = false
??????????? x-iothread = ""
????? dev: piix3-usb-uhci, id "usb"
??????? masterbus = ""
??????? firstport = 0 (0)
??????? bandwidth = 1280 (0x500)
??????? maxframes = 128 (0x80)
??????? addr = 01.2
??????? romfile = ""
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class USB controller, addr 00:01.2, pci id 8086:7020 (sub 1af4:1100)
??????? bar 4: i/o at 0xc040 [0xc05f]
??????? bus: usb.0
????????? type usb-bus
????????? dev: usb-tablet, id "input0"
??????????? usb_version = 2 (0x2)
??????????? port = ""
??????????? serial = ""
??????????? full-path = true
??????????? msos-desc = true
??????????? addr 0.2, port 1, speed 12, name QEMU USB Tablet, attached
????? dev: PIIX4_PM, id ""
??????? smb_io_base = 45312 (0xb100)
??????? disable_s3 = 0 (0)
??????? disable_s4 = 0 (0)
??????? s4_val = 2 (0x2)
??????? acpi-pci-hotplug-with-bridge-support = true
??????? addr = 01.3
??????? romfile = ""
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class Bridge, addr 00:01.3, pci id 8086:7113 (sub 1af4:1100)
??????? bus: i2c
????????? type i2c-bus
????????? dev: smbus-eeprom, id ""
??????????? address = 87 (0x57)
????????? dev: smbus-eeprom, id ""
??????????? address = 86 (0x56)
????????? dev: smbus-eeprom, id ""
??????????? address = 85 (0x55)
????????? dev: smbus-eeprom, id ""
??????????? address = 84 (0x54)
????????? dev: smbus-eeprom, id ""
??????????? address = 83 (0x53)
????????? dev: smbus-eeprom, id ""
??????????? address = 82 (0x52)
????????? dev: smbus-eeprom, id ""
??????????? address = 81 (0x51)
????????? dev: smbus-eeprom, id ""
??????????? address = 80 (0x50)
????? dev: piix3-ide, id ""
??????? addr = 01.1
??????? romfile = ""
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class IDE controller, addr 00:01.1, pci id 8086:7010 (sub 1af4:1100)
??????? bar 4: i/o at 0xc0a0 [0xc0af]
??????? bus: ide.1
????????? type IDE
??????? bus: ide.0
????????? type IDE
????? dev: PIIX3, id ""
??????? addr = 01.0
??????? romfile = ""
??????? rombar = 1 (0x1)
??????? multifunction = true
??????? command_serr_enable = true
??????? class ISA bridge, addr 00:01.0, pci id 8086:7000 (sub 1af4:1100)
??????? bus: isa.0
????????? type ISA
????????? dev: isa-serial, id "serial1"
??????????? index = 1 (0x1)
??????????? iobase = 760 (0x2f8)
??????????? irq = 3 (0x3)
??????????? chardev = "charserial1"
??????????? wakeup = 0 (0)
??????????? isa irq 3
????????? dev: isa-serial, id "serial0"
??????????? index = 0 (0)
??????????? iobase = 1016 (0x3f8)
??????????? irq = 4 (0x4)
??????????? chardev = "charserial0"
??????????? wakeup = 0 (0)
??????????? isa irq 4
????????? dev: isa-fdc, id ""
??????????? iobase = 1008 (0x3f0)
??????????? irq = 6 (0x6)
??????????? dma = 2 (0x2)
??????????? driveA = ""
??????????? driveB = ""
??????????? bootindexA = -1 (0xffffffffffffffff)
??????????? bootindexB = -1 (0xffffffffffffffff)
??????????? check_media_rate = true
??????????? isa irq 6
????????? dev: port92, id ""
????????? dev: vmmouse, id ""
????????? dev: vmport, id ""
????????? dev: i8042, id ""
??????????? isa irqs 1,12
????????? dev: isa-pcspk, id ""
??????????? iobase = 97 (0x61)
????????? dev: kvm-pit, id ""
??????????? gpio-in 1
??????????? iobase = 64 (0x40)
??????????? lost_tick_policy = "discard"
????????? dev: mc146818rtc, id ""
??????????? base_year = 0 (0)
??????????? lost_tick_policy = "slew"
??????????? isa irq 8
????????? dev: kvm-i8259, id ""
??????????? iobase = 160 (0xa0)
??????????? elcr_addr = 1233 (0x4d1)
??????????? elcr_mask = 222 (0xde)
??????????? master = false
????????? dev: kvm-i8259, id ""
??????????? iobase = 32 (0x20)
??????????? elcr_addr = 1232 (0x4d0)
??????????? elcr_mask = 248 (0xf8)
??????????? master = true
????? dev: i440FX, id ""
??????? addr = 00.0
??????? romfile = ""
??????? rombar = 1 (0x1)
??????? multifunction = false
??????? command_serr_enable = true
??????? class Host bridge, addr 00:00.0, pci id 8086:1237 (sub 1af4:1100)
? dev: fw_cfg, id ""
??? ctl_iobase = 1296 (0x510)
??? data_iobase = 1297 (0x511)
??? irq 0
??? mmio ffffffffffffffff/0000000000000002
??? mmio ffffffffffffffff/0000000000000001
? dev: kvmclock, id ""
??? irq 0
? dev: kvmvapic, id ""
??? irq 0
? dev: icc-bridge, id ""
??? irq 0
??? mmio 00000000fee00000/0000000000100000
??? bus: icc
????? type icc-bus
????? dev: kvm-apic, id ""
??????? id = 0 (0)
??????? vapic = true
????? dev: SandyBridge-x86_64-cpu, id ""
??????? pmu = false
??????? hv-spinlocks = -1 (0xffffffffffffffff)
??????? hv-relaxed = false
??????? hv-vapic = false
??????? hv-time = false
??????? check = false
??????? enforce = false
SMBIOS
SMBIOS全稱System Management BIOS,用于表示x86 architectures的硬件信息
在unix系統上,可以使用下面的命令dmidecode得到,SMBIOS的信息被分為多個table中,稱為type
type 0是BIOS信息
# dmidecode --type 0
# dmidecode 2.12
# SMBIOS entry point at 0xcbadeb98
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
??????? Vendor: Hewlett-Packard
??????? Version: J61 v03.69
??????? Release Date: 03/25/2014
??????? Address: 0xF0000
??????? Runtime Size: 64 kB
??????? ROM Size: 16384 kB
??????? Characteristics:
??????????????? PCI is supported
??????????????? PNP is supported
??????????????? BIOS is upgradeable
??????????????? BIOS shadowing is allowed
??????????????? Boot from CD is supported
??????????????? Selectable boot is supported
??????????????? EDD is supported
??????????????? Print screen service is supported (int 5h)
??????????????? 8042 keyboard services are supported (int 9h)
??????????????? Serial services are supported (int 14h)
??????????????? Printer services are supported (int 17h)
??????????????? ACPI is supported
??????????????? USB legacy is supported
??????????????? BIOS boot specification is supported
??????????????? Function key-initiated network boot is supported
??????????????? Targeted content distribution is supported
??????????????? UEFI is supported
??????? BIOS Revision: 3.69
type 1是系統信息
# dmidecode --type 1
# dmidecode 2.12
# SMBIOS entry point at 0xcbadeb98
SMBIOS 2.7 present.
Handle 0x0001, DMI type 1, 27 bytes
System Information
??????? Manufacturer: Hewlett-Packard
??????? Product Name: HP Z620 Workstation
??????? Version: Not Specified
??????? Serial Number: 6CR419WFHT
??????? UUID: 90065980-D287-11E3-B1B0-A0481CABDFB4
??????? Wake-up Type: Power Switch
??????? SKU Number: G2F14UC#AB2
??????? Family: 103C_53335X G=D
type 2是主板信息
# dmidecode --type 2
# dmidecode 2.12
# SMBIOS entry point at 0xcbadeb98
SMBIOS 2.7 present.
Handle 0x0002, DMI type 2, 15 bytes
Base Board Information
??????? Manufacturer: Hewlett-Packard
??????? Product Name: 158A
??????? Version: 0.00
??????? Serial Number: 6CR419WFHT
??????? Asset Tag: 6CR419WFHT
??????? Features:
??????????????? Board is a hosting board
??????????????? Board is removable
??????????????? Board is replaceable
??????? Location In Chassis: Not Specified
??????? Chassis Handle: 0x0003
??????? Type: Motherboard
??????? Contained Object Handles: 0
type 3是背板信息
# dmidecode --type 3
# dmidecode 2.12
# SMBIOS entry point at 0xcbadeb98
SMBIOS 2.7 present.
Handle 0x0003, DMI type 3, 22 bytes
Chassis Information
??????? Manufacturer: Hewlett-Packard
??????? Type: Mini Tower
??????? Lock: Not Present
??????? Version: Not Specified
??????? Serial Number: 6CR419WFHT
??????? Asset Tag: 6CR419WFHT
??????? Boot-up State: Safe
??????? Power Supply State: Safe
??????? Thermal State: Safe
??????? Security Status: Unknown
??????? OEM Information: 0x00000000
??????? Height: Unspecified
??????? Number Of Power Cords: 1
??????? Contained Elements: 0
??????? SKU Number: Not Specified
type 4是CPU信息
# dmidecode --type 4
# dmidecode 2.12
# SMBIOS entry point at 0xcbadeb98
SMBIOS 2.7 present.
Handle 0x0004, DMI type 4, 42 bytes
Processor Information
??????? Socket Designation: CPU0
??????? Type: Central Processor
??????? Family: Xeon
??????? Manufacturer: Intel
??????? ID: E4 06 03 00 FF FB EB BF
??????? Signature: Type 0, Family 6, Model 62, Stepping 4
??????? Flags:
??????????????? FPU (Floating-point unit on-chip)
??????????????? VME (Virtual mode extension)
??????????????? DE (Debugging extension)
??????????????? PSE (Page size extension)
??????????????? TSC (Time stamp counter)
??????????????? MSR (Model specific registers)
??????????????? PAE (Physical address extension)
??????????????? MCE (Machine check exception)
??????????????? CX8 (CMPXCHG8 instruction supported)
??????????????? APIC (On-chip APIC hardware supported)
??????????????? SEP (Fast system call)
??????????????? MTRR (Memory type range registers)
??????????????? PGE (Page global enable)
??????????????? MCA (Machine check architecture)
??????????????? CMOV (Conditional move instruction supported)
??????????????? PAT (Page attribute table)
??????????????? PSE-36 (36-bit page size extension)
??????????????? CLFSH (CLFLUSH instruction supported)
??????????????? DS (Debug store)
??????????????? ACPI (ACPI supported)
??????????????? MMX (MMX technology supported)
??????????????? FXSR (FXSAVE and FXSTOR instructions supported)
??????????????? SSE (Streaming SIMD extensions)
??????????????? SSE2 (Streaming SIMD extensions 2)
??????????????? SS (Self-snoop)
??????????????? HTT (Multi-threading)
??????????????? TM (Thermal monitor supported)
??????????????? PBE (Pending break enabled)
??????? Version: Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
??????? Voltage: 1.0 V
??????? External Clock: 100 MHz
??????? Max Speed: 3800 MHz
??????? Current Speed: 2800 MHz
??????? Status: Populated, Enabled
??????? Upgrade: Socket LGA2011
??????? L1 Cache Handle: 0x0005
??????? L2 Cache Handle: 0x0006
??????? L3 Cache Handle: 0x0007
??????? Serial Number: Not Specified
??????? Asset Tag: Not Specified
??????? Part Number: Not Specified
??????? Core Count: 10
??????? Core Enabled: 10
??????? Thread Count: 20
??????? Characteristics:
??????????????? 64-bit capable
??????????????? Multi-Core
??????????????? Hardware Thread
??????????????? Execute Protection
??????????????? Enhanced Virtualization
??????????????? Power/Performance Control
所以我們有參數
-smbios type=1,manufacturer=OpenStack Foundation,product=OpenStack Nova,version=2014.1,serial=80590690-87d2-e311-b1b0-a0481cabdfb4,uuid=1f8e6f7e-5a70-4780-89c1-464dc0e7f308
指定了type 1的信息
RAM
內存的大小在參數中,用-m來指定
-m 2048
If the guest system allocated a large RAM under Linux host system, there may be problems if there is insufficient shared memory type. QEMU then complains about insufficient space in / dev / shm . It is better to expand the file system. For a permanent configuration file is / etc / default / tmpfs (Ubuntu) adapt.
Host ~ # umount / dev / shm
host ~ # mount-t tmpfs-o remount, size = 144m none / dev / shm
guest真正運行態的占用的內存的大小,是用Memory Ballooning來調整
ACPI
The Advanced Configuration and Power Interface (ACPI) is an open industry standard for power management in computers.
ACPI is the default in QEMU.
If there are problems with the guest operating system, you ACPI disabled with the option -no-acpi .
System Clock
系統時間由參數-rtc指定
-rtc [base = utc | localtime | date] [, clock = host | vm] [, driftfix = none | slew]
For problems with the time-drift in Microsoft Windows ACPI HAL option is driftfix = slew apply (only for x86 architectures).
High Precision Event Timer (HPET)是可以更準確的設定時間的
我們的參數中有
-rtc base=utc,driftfix=slew
-no-hpet
USB
USB的好處就是即插即用
參數-usb,可以模擬一個PCI UHCI USB控制器
通過-usbdevice devname,可以添加一個USB device
mouse
??? Virtual Mouse. This will override the PS/2 mouse emulation when activated.
tablet
??? Pointer device that uses absolute coordinates (like a touchscreen). This means QEMU is able to report the
??? mouse position without having to grab the mouse. Also overrides the PS/2 mouse emulation when activated.
disk:[format=format]:file
??? Mass storage device based on file. The optional format argument will be used rather than detecting the
??? format. Can be used to specifiy "format=raw" to avoid interpreting an untrusted format header.
host:bus.addr
??? Pass through the host device identified by bus.addr (Linux only).
host:vendor_id:product_id
??? Pass through the host device identified by vendor_id:product_id (Linux only).
serial:[vendorid=vendor_id][,productid=product_id]:dev
??? Serial converter to host character device dev, see "-serial" for the available devices.
braille
??? Braille device.? This will use BrlAPI to display the braille output on a real or fake device.
net:options
??? Network adapter that supports CDC ethernet and RNDIS protocols.
我們在參數里面看到的是
-device usb-tablet,id=input0
通過tablet,鼠標可以在HOST和GUEST機器之間自由的切換
# qemu-monitor-command instance-00000024 --hmp "info usb"
? Device 0.2, Port 1, Speed 12 Mb/s, Product QEMU USB Tablet
PCI
PCI (Peripheral Component Interconnect)是設備總線標準
There are 4 components to the PCI subsytem:
Bus Number?
Device Number
Function Number
Register Number
There are up to 256 available Buses on a PCI system, most commonly all the cards and chips will be located on Bus 0 and Bus 1.
When scanning for hardware, it's a good idea to scan all 256 buses as it won't take that much additional time.
A Device is a physical thing on the PCI bus.? It could be a video card, an ethernet card, a Northbridge, anything.? There is a software maximum of 32 devices that can exist on each bus.? The physical hardware limit is much lower than this due to electrical loading issues, but we won't get into that.
Devices on a motherboard are typically scattered throughout the 32 devices, holes can and will exist. Your software must scan all 32 devices on each bus.
All devices have at least 1 function, function #0.? There are 8 possible functions per device, numbered 0-7.? Any device that has more than 1 function is (hey clever!) called a multi-function device.? Multi-function devices, such as a combination modem+soundcard will usually have 2 uniquely addressable functions, numbered 0 and 1.
Every function of a device has 256 eight-bit registers.? Registers 0-3F are defined by the PCI specification and provide a wealth of information about the particular function.? Registers 40-FF are vendor defined and control the properties of the function itself.? Without vendor specific documentation, these registers should probably be left untouched.
virsh # qemu-monitor-command instance-00000024 --hmp "info pci"
? Bus? 0, device?? 0, function 0:
??? Host bridge: PCI device 8086:1237
????? id ""
? Bus? 0, device?? 1, function 0:
??? ISA bridge: PCI device 8086:7000
????? id ""
? Bus? 0, device?? 1, function 1:
??? IDE controller: PCI device 8086:7010
????? BAR4: I/O at 0xc0a0 [0xc0af].
????? id ""
? Bus? 0, device?? 1, function 2:
??? USB controller: PCI device 8086:7020
????? IRQ 11.
????? BAR4: I/O at 0xc040 [0xc05f].
????? id "usb"
? Bus? 0, device?? 1, function 3:
??? Bridge: PCI device 8086:7113
????? IRQ 9.
????? id ""
? Bus? 0, device?? 2, function 0:
??? VGA controller: PCI device 1013:00b8
????? BAR0: 32 bit prefetchable memory at 0xfc000000 [0xfdffffff].
????? BAR1: 32 bit memory at 0xfebd0000 [0xfebd0fff].
????? BAR6: 32 bit memory at 0xffffffffffffffff [0x0000fffe].
????? id "video0"
? Bus? 0, device?? 3, function 0:
??? Ethernet controller: PCI device 1af4:1000
????? IRQ 11.
????? BAR0: I/O at 0xc060 [0xc07f].
????? BAR1: 32 bit memory at 0xfebd1000 [0xfebd1fff].
????? BAR6: 32 bit memory at 0xffffffffffffffff [0x0003fffe].
????? id "net0"
? Bus? 0, device?? 4, function 0:
??? SCSI controller: PCI device 1af4:1001
????? IRQ 11.
????? BAR0: I/O at 0xc000 [0xc03f].
????? BAR1: 32 bit memory at 0xfebd2000 [0xfebd2fff].
????? id "virtio-disk0"
? Bus? 0, device?? 5, function 0:
??? Class 0255: PCI device 1af4:1002
????? IRQ 10.
????? BAR0: I/O at 0xc080 [0xc09f].
????? id "balloon0"
可以看到總線上的設備
這些設備分別對應參數
USB
-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2
顯示器
-device cirrus-vga,id=video0,bus=pci.0,addr=0x2
網卡
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=fa:16:3e:d1:2d:99,bus=pci.0,addr=0x3
硬盤
-device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
內存
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
顯示器
用參數-vga設置,默認為cirrus,它模擬了CL-GD5446 PCI VGA card
聲卡
# qemu-system-x86_64 -soundhw ?
Valid sound card names (comma separated):
ac97??????? Intel 82801AA AC97 Audio
adlib?????? Yamaha YM3812 (OPL2)
cs4231a???? CS4231A
es1370????? ENSONIQ AudioPCI ES1370
gus???????? Gravis Ultrasound GF1
hda???????? Intel HD Audio
pcspk?????? PC speaker
sb16??????? Creative Sound Blaster 16
-soundhw all will enable all of the above
網卡
使用-net參數
The -device option
其實所有的外設都能通過-device來設定
# qemu-system-x86_64 -device ?
Controller/Bridge/Hub devices:
name "i82801b11-bridge", bus PCI
name "ioh3420", bus PCI, desc "Intel IOH device id 3420 PCIE Root Port"
name "pci-bridge", bus PCI, desc "Standard PCI Bridge"
name "usb-host", bus usb-bus
name "usb-hub", bus usb-bus
name "x3130-upstream", bus PCI, desc "TI X3130 Upstream Port of PCI Express Switch"
name "xio3130-downstream", bus PCI, desc "TI X3130 Downstream Port of PCI Express Switch"
USB devices:
name "ich9-usb-ehci1", bus PCI
name "ich9-usb-ehci2", bus PCI
name "ich9-usb-uhci1", bus PCI
name "ich9-usb-uhci2", bus PCI
name "ich9-usb-uhci3", bus PCI
name "ich9-usb-uhci4", bus PCI
name "ich9-usb-uhci5", bus PCI
name "ich9-usb-uhci6", bus PCI
name "nec-usb-xhci", bus PCI
name "pci-ohci", bus PCI, desc "Apple USB Controller"
name "piix3-usb-uhci", bus PCI
name "piix4-usb-uhci", bus PCI
name "usb-ehci", bus PCI
name "vt82c686b-usb-uhci", bus PCI
Storage devices:
name "am53c974", bus PCI, desc "AMD Am53c974 PCscsi-PCI SCSI adapter"
name "dc390", bus PCI, desc "Tekram DC-390 SCSI adapter"
name "ich9-ahci", bus PCI, alias "ahci"
name "ide-cd", bus IDE, desc "virtual IDE CD-ROM"
name "ide-drive", bus IDE, desc "virtual IDE disk or CD-ROM (legacy)"
name "ide-hd", bus IDE, desc "virtual IDE disk"
name "isa-fdc", bus ISA
name "isa-ide", bus ISA
name "lsi53c810", bus PCI
name "lsi53c895a", bus PCI, alias "lsi"
name "megasas", bus PCI, desc "LSI MegaRAID SAS 1078"
name "nvme", bus PCI, desc "Non-Volatile Memory Express"
name "piix3-ide", bus PCI
name "piix3-ide-xen", bus PCI
name "piix4-ide", bus PCI
name "pvscsi", bus PCI
name "scsi-block", bus SCSI, desc "SCSI block device passthrough"
name "scsi-cd", bus SCSI, desc "virtual SCSI CD-ROM"
name "scsi-disk", bus SCSI, desc "virtual SCSI disk or CD-ROM (legacy)"
name "scsi-generic", bus SCSI, desc "pass through generic scsi device (/dev/sg*)"
name "scsi-hd", bus SCSI, desc "virtual SCSI disk"
name "usb-bot", bus usb-bus
name "usb-storage", bus usb-bus
name "usb-uas", bus usb-bus
name "vhost-scsi", bus virtio-bus
name "vhost-scsi-pci", bus PCI
name "virtio-9p-device", bus virtio-bus
name "virtio-9p-pci", bus PCI
name "virtio-blk-device", bus virtio-bus
name "virtio-blk-pci", bus PCI, alias "virtio-blk"
name "virtio-scsi-device", bus virtio-bus
name "virtio-scsi-pci", bus PCI
Network devices:
name "e1000", bus PCI, desc "Intel Gigabit Ethernet"
name "i82550", bus PCI, desc "Intel i82550 Ethernet"
name "i82551", bus PCI, desc "Intel i82551 Ethernet"
name "i82557a", bus PCI, desc "Intel i82557A Ethernet"
name "i82557b", bus PCI, desc "Intel i82557B Ethernet"
name "i82557c", bus PCI, desc "Intel i82557C Ethernet"
name "i82558a", bus PCI, desc "Intel i82558A Ethernet"
name "i82558b", bus PCI, desc "Intel i82558B Ethernet"
name "i82559a", bus PCI, desc "Intel i82559A Ethernet"
name "i82559b", bus PCI, desc "Intel i82559B Ethernet"
name "i82559c", bus PCI, desc "Intel i82559C Ethernet"
name "i82559er", bus PCI, desc "Intel i82559ER Ethernet"
name "i82562", bus PCI, desc "Intel i82562 Ethernet"
name "i82801", bus PCI, desc "Intel i82801 Ethernet"
name "ne2k_isa", bus ISA
name "ne2k_pci", bus PCI
name "pcnet", bus PCI
name "rtl8139", bus PCI
name "usb-bt-dongle", bus usb-bus
name "usb-net", bus usb-bus
name "virtio-net-device", bus virtio-bus
name "virtio-net-pci", bus PCI, alias "virtio-net"
name "vmxnet3", bus PCI, desc "VMWare Paravirtualized Ethernet v3"
Input devices:
name "ccid-card-passthru", bus ccid-bus, desc "passthrough smartcard"
name "ipoctal232", bus IndustryPack, desc "GE IP-Octal 232 8-channel RS-232 IndustryPack"
name "isa-parallel", bus ISA
name "isa-serial", bus ISA
name "pci-serial", bus PCI
name "pci-serial-2x", bus PCI
name "pci-serial-4x", bus PCI
name "tpci200", bus PCI, desc "TEWS TPCI200 IndustryPack carrier"
name "usb-braille", bus usb-bus
name "usb-ccid", bus usb-bus, desc "CCID Rev 1.1 smartcard reader"
name "usb-kbd", bus usb-bus
name "usb-mouse", bus usb-bus
name "usb-serial", bus usb-bus
name "usb-tablet", bus usb-bus
name "usb-wacom-tablet", bus usb-bus, desc "QEMU PenPartner Tablet"
name "virtconsole", bus virtio-serial-bus
name "virtio-serial-device", bus virtio-bus
name "virtio-serial-pci", bus PCI, alias "virtio-serial"
name "virtserialport", bus virtio-serial-bus
Display devices:
name "cirrus-vga", bus PCI, desc "Cirrus CLGD 54xx VGA"
name "isa-cirrus-vga", bus ISA
name "isa-vga", bus ISA
name "qxl", bus PCI, desc "Spice QXL GPU (secondary)"
name "qxl-vga", bus PCI, desc "Spice QXL GPU (primary, vga compatible)"
name "sga", bus ISA, desc "Serial Graphics Adapter"
name "VGA", bus PCI
name "vmware-svga", bus PCI
Sound devices:
name "AC97", bus PCI, desc "Intel 82801AA AC97 Audio"
name "adlib", bus ISA, desc "Yamaha YM3812 (OPL2)"
name "cs4231a", bus ISA, desc "Crystal Semiconductor CS4231A"
name "ES1370", bus PCI, desc "ENSONIQ AudioPCI ES1370"
name "gus", bus ISA, desc "Gravis Ultrasound GF1"
name "hda-duplex", bus HDA, desc "HDA Audio Codec, duplex (line-out, line-in)"
name "hda-micro", bus HDA, desc "HDA Audio Codec, duplex (speaker, microphone)"
name "hda-output", bus HDA, desc "HDA Audio Codec, output-only (line-out)"
name "ich9-intel-hda", bus PCI, desc "Intel HD Audio Controller (ich9)"
name "intel-hda", bus PCI, desc "Intel HD Audio Controller (ich6)"
name "sb16", bus ISA, desc "Creative Sound Blaster 16"
name "usb-audio", bus usb-bus
Misc devices:
name "i6300esb", bus PCI
name "ib700", bus ISA
name "isa-applesmc", bus ISA
name "isa-debug-exit", bus ISA
name "isa-debugcon", bus ISA
name "ivshmem", bus PCI
name "kvm-pci-assign", bus PCI, alias "pci-assign", desc "KVM-based PCI passthrough"
name "pc-testdev", bus ISA
name "pci-testdev", bus PCI, desc "PCI Test Device"
name "pvpanic", bus ISA
name "usb-redir", bus usb-bus
name "vfio-pci", bus PCI, desc "VFIO-based PCI device assignment"
name "virtio-balloon-device", bus virtio-bus
name "virtio-balloon-pci", bus PCI, alias "virtio-balloon"
name "virtio-rng-device", bus virtio-bus
name "virtio-rng-pci", bus PCI
name "xen-pci-passthrough", bus PCI, desc "Assign an host PCI device with Xen"
name "xen-platform", bus PCI, desc "XEN platform pci device"
Uncategorized devices:
name "i8042", bus ISA
name "xen-pvdevice", bus PCI, desc "Xen PV Device"
Character Devices
Character device (character device) transmit only one character or one byte at a time (serial communication).
使用參數-chardev,每個device都有一個ID,有各種各樣的類型type
-chardev null, id = id [, mux = on | off]
-chardev socket, id = id [, host = host ], port = host [, to = to ] [, ipv4] [, ipv6] [, nodelay][, Server] [, nowait] [, telnet] [, mux = on | off] (tcp)
-chardev socket, id = id , path = path [, server] [, nowait] [, telnet], [mux = on | off] (unix)
-chardev udp, id = id [, host = host ], port = port [, localaddr = localaddr ][, Localport = localport ] [, ipv4] [, ipv6] [, mux = on | off]
-chardev msmouse, id = id [, mux = on | off]
-chardev vc, id = id [[, width = width ] [, height = height ]] [[, cols = cols ] [, rows = rows ]][, Mux = on | off]
-chardev file, id = id , path = path [, mux = on | off]
-chardev pipe, id = id , path = path [, mux = on | off]
-chardev pty, id = id [, mux = on | off]
-chardev stdio, id = id [, mux = on | off] [, signal = on | off]
-chardev braille, id = id [, mux = on | off]
-chardev tty, id = id , path = path [, mux = on | off]
-chardev parport, id = id , path = path [, mux = on | off]
-chardev spicevmc, id = id , debug = debug , name = name [, mux = on | off]
在我們的參數中,有下面的設置。
我們可以在monitor中列出所有的chardev
virsh # qemu-monitor-command instance-00000024 --hmp "info chardev"
charserial1: filename=pty:/dev/pts/28
charserial0: filename=file
charmonitor: filename=unix:/var/lib/libvirt/qemu/instance-00000024.monitor,server
第一個chardev是pty
-chardev pty,id=charserial1
-device isa-serial,chardev=charserial1,id=serial1
第二個chardev是file
-chardev file,id=charserial0,path=/var/lib/nova/instances/1f8e6f7e-5a70-4780-89c1-464dc0e7f308/console.log
-device isa-serial,chardev=charserial0,id=serial0
第三個chardev是unix socket
-chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/instance-00000024.monitor,server,nowait
-mon chardev=charmonitor,id=monitor,mode=control
轉載于:https://www.cnblogs.com/popsuper1982/p/3840340.html
總結
以上是生活随笔為你收集整理的QEMU KVM Libvirt手册(7): 硬件虚拟化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JavaScript基础---语言基础(
- 下一篇: 关于java同步包中Concurrent