Author: Xu FC
KVM 部署见: KVM + Openvswitch 环境 在 CentOS 7 上的安装
WebVirtMgr 部署见: WebVirtMgr + NGINX 环境 在 CentOS 7 上的部署
网络配置
-
Bridge 和 vSwitch 配置见: KVM + Openvswitch 环境 在 CentOS 7 上的安装
-
添加网络 -- bridge
-
添加网络 -- vswitch
添加存储池
-
添加 ISO 镜像卷,用于挂载 ISO 镜像
-
添加目录类型卷,用于存放 image
创建虚拟机
-
添加镜像,该镜像为 guest OS 的虚拟硬盘
-
添加虚拟机,指定 vCPU 个数、内存以及网卡
在虚拟机中安装系统
- 根据 ISO 镜像大小,修改 nginx 配置文件:
vi /etc/nginx/conf.d/webvirtmgr.conf
client_max_body_size 5120M; # Set higher depending on your needs
修改后 reload nginx:
systemctl reload nginx
-
上传 ISO 镜像
-
连接 ISO 镜像
-
启动虚拟机,进入控制台,安装系统
添加网卡
-
添加网卡前,查看虚拟机,只有一个网卡
-
关闭虚拟机
编辑虚拟机XML配置文件,为虚拟机添加网卡
<interface type='network'>
<source network='xufc_avx1'/>
<model type='virtio'/>
</interface>
-
启动虚拟机,产看 interface,变为两块网卡,网卡添加成功
修改 CPU Model
-
原 CPU model 为 Westmere
查看 qemu-kvm 支持模拟哪些 CPU model
[root@localhost bin]# qemu-kvm -cpu help
x86 qemu64 QEMU Virtual CPU version 1.5.3
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 1.5.3
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 1.5.3
x86 n270 Intel(R) Atom(TM) CPU N270 @ 1.60GHz
x86 cpu64-rhel6 QEMU Virtual CPU version (cpu64-rhel6)
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 Nehalem-IBRS Intel Core i7 9xx (Nehalem Core i7, IBRS update)I
x86 Westmere Westmere E56xx/L56xx/X56xx (Nehalem-C) <<<<<<<<<<<<< 原 CPU model
x86 Westmere-IBRS Westmere E56xx/L56xx/X56xx (IBRS update)
x86 SandyBridge Intel Xeon E312xx (Sandy Bridge)
x86 SandyBridge-IBRS Intel Xeon E312xx (Sandy Bridge, IBRS update)
x86 IvyBridge Intel Xeon E3-12xx v2 (Ivy Bridge)
x86 IvyBridge-IBRS Intel Xeon E3-12xx v2 (Ivy Bridge, IBRS)
x86 Haswell Intel Core Processor (Haswell)
x86 Haswell-IBRS Intel Core Processor (Haswell, IBRS)
x86 Broadwell Intel Core Processor (Broadwell)
x86 Broadwell-IBRS Intel Core Processor (Broadwell, IBRS)
x86 Skylake-Client Intel Core Processor (Skylake)
x86 Skylake-Client-IBRS Intel Core Processor (Skylake, IBRS)
x86 Skylake-Server Intel Xeon Processor (Skylake)
x86 Skylake-Server-IBRS Intel Xeon Processor (Skylake, IBRS)
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 EPYC AMD EPYC Processor
x86 EPYC-IBPB AMD EPYC Processor (with IBPB)
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
avx512vl avx512bw sha-ni avx512cd avx512er avx512pf clwb clflushopt pcommit avx512ifma smap adx rdseed avx512dq avx512f mpx rtm invpcid erms bmi2 smep avx2 hle bmi1 fsgsbase
avx512-vpopcntdq ospke pku avx512vbmi
ssbd arch-facilities stibp spec-ctrl avx512-4fmaps avx512-4vnniw
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
ibpb
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
xsaves xgetbv1 xsavec xsaveopt
-
关闭虚拟机,修改配置文件中的 CPU model
保存配置,启动虚拟机失败,提示
operation failed: guest CPU doesn't match specification: extra features: hypervisor, missing features: pclmuldq,fma,movbe,aes,xsave,avx,f16c,rdrand,arat,fsgsbase,bmi1,hle,avx2,smep,bmi2,erms,invpcid,rtm,mpx,avx512f,avx512dq,rdseed,adx,smap,clwb,avx512cd,avx512bw,avx512vl,xsaveopt,xsavec,xgetbv1,abm,3dnowprefetch
- 再次编辑配置文件,disable 提示中所列的 features
<cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>Skylake-Server</model>
<feature policy='disable' name='pclmuldq'/>
<feature policy='disable' name='fma'/>
<feature policy='disable' name='x2apic'/>
<feature policy='disable' name='movbe'/>
<feature policy='disable' name='tsc-deadline'/>
<feature policy='disable' name='aes'/>
<feature policy='disable' name='xsave'/>
<feature policy='disable' name='avx'/>
<feature policy='disable' name='f16c'/>
<feature policy='disable' name='rdrand'/>
<feature policy='disable' name='fsgsbase'/>
<feature policy='disable' name='bmi1'/>
<feature policy='disable' name='hle'/>
<feature policy='disable' name='avx2'/>
<feature policy='disable' name='smep'/>
<feature policy='disable' name='bmi2'/>
<feature policy='disable' name='erms'/>
<feature policy='disable' name='invpcid'/>
<feature policy='disable' name='rtm'/>
<feature policy='disable' name='mpx'/>
<feature policy='disable' name='avx512f'/>
<feature policy='disable' name='avx512dq'/>
<feature policy='disable' name='rdseed'/>
<feature policy='disable' name='adx'/>
<feature policy='disable' name='smap'/>
<feature policy='disable' name='clwb'/>
<feature policy='disable' name='avx512cd'/>
<feature policy='disable' name='avx512bw'/>
<feature policy='disable' name='avx512vl'/>
<feature policy='disable' name='xsaveopt'/>
<feature policy='disable' name='xsavec'/>
<feature policy='disable' name='xgetbv1'/>
<feature policy='disable' name='abm'/>
<feature policy='disable' name='3dnowprefetch'/>
<feature policy='disable' name='hypervisor'/>
<feature policy='disable' name='arat'/>
</cpu>
-
查看修改后的 CPU model,变为 Skylake,修改成功
虚拟机(guest OS)创建成功啦!
- 可通过 virsh 命令查看和配置虚拟机
[root@localhost ~]# virsh list --all
Id Name State
----------------------------------------------------
5 test_ubuntu running
- test shut off
[root@localhost ~]# virsh dominfo test_ubuntu
Id: 5
Name: test_ubuntu
UUID: b1a3e608-c8d1-aad1-8434-24ae763f2830
OS Type: hvm
State: running
CPU(s): 2
CPU time: 123.2s
Max memory: 4194304 KiB
Used memory: 4194304 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: none
Security DOI: 0
[root@localhost ~]# virsh domiflist test_ubuntu
Interface Type Source Model MAC
-------------------------------------------------------
vnet0 bridge mgmt virtio 52:54:00:fe:6d:c1
[root@localhost ~]# virsh dumpxml test_ubuntu
<domain type='kvm' id='5'>
<name>test_ubuntu</name>
<uuid>b1a3e608-c8d1-aad1-8434-24ae763f2830</uuid>
<description>None</description>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<vcpu placement='static'>2</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<boot dev='hd'/>
<boot dev='cdrom'/>
<bootmenu enable='yes'/>
</os>
......
Windows 虚拟机部署见: WebVirtMgr + KVM 环境中的Windows虚拟机部署