简介
记录如何解决虚机内软件、游戏启动报错:Sorry, This Application Cannot Run Under A Virtual Machine
关键点
虚拟化检测点可参考文档:操作系统能否知道自己处于虚拟机中?
CPU model and topology
- 禁用CPU的
hypervisor
功能。
- 使用
host-passthrough
模式,透传主机CPU能力。
参考xml相关配置:
1 2 3 4 5 6 7 8 9
| ... <cpu mode='host-passthrough' check='none'> <topology sockets='2' cores='2' threads='2'/> <feature policy='disable' name='hypervisor'/> <numa> <cell id='0' cpus='0-7' memory='33554432' unit='KiB' memAccess='shared'/> </numa> </cpu> ...
|
- 屏蔽透传给主机的底层系统信息,可修改为PC厂商的信息,或直接使用host模式。
参考xml相关配置:
1 2 3 4 5 6
| ... <os> <smbios mode="host"/> ... </os> ...
|
Windows系统内可通过systeminfo
命令查看效果。
smbios mode为smbios
时,系统内部可查看到的信息如下:
smbios mode为host
时,系统内部可查看到的信息如下:
Hypervisor features
- 隐藏kvm特性。
- 若启用了hyperv,则需要隐藏hyperv的vendor_id。在未来,可能需要启用hyperv能力。
参考xml相关配置:
1 2 3 4 5 6 7 8 9 10 11 12
| ... <features> ... <hyperv> <vendor_id state="on" value="1234567890ab"/> </hyperv> <kvm> <hidden state="on"/> </kvm> ... </features> ...
|
标准OpenStack XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
| <domain type='kvm'> <name>instance-0000014f</name> <uuid>3ba2abc6-8141-4782-9b57-18c8773a12c0</uuid> <metadata> <nova:instance xmlns:nova="http://openstack.org/xmlns/libvirt/nova/1.0"> <nova:package version="20.6.1"/> <nova:name>test-vgpu-6</nova:name> <nova:creationTime>2022-11-15 02:33:55</nova:creationTime> <nova:flavor name="test-8u16g-vgpu"> <nova:memory>16384</nova:memory> <nova:disk>200</nova:disk> <nova:swap>0</nova:swap> <nova:ephemeral>0</nova:ephemeral> <nova:vcpus>8</nova:vcpus> </nova:flavor> <nova:owner> <nova:user uuid="144ffda4d33c431095051cd5bebaf071">admin</nova:user> <nova:project uuid="a6fa603c739749e9b5edf31327bd507f">admin</nova:project> </nova:owner> </nova:instance> </metadata> <memory unit='KiB'>16777216</memory> <currentMemory unit='KiB'>16777216</currentMemory> <memoryBacking> <hugepages> <page size='1048576' unit='KiB' nodeset='0'/> </hugepages> </memoryBacking> <vcpu placement='static'>8</vcpu> <cputune> <shares>8192</shares> <vcpupin vcpu='0' cpuset='16'/> <vcpupin vcpu='1' cpuset='48'/> <vcpupin vcpu='2' cpuset='21'/> <vcpupin vcpu='3' cpuset='53'/> <vcpupin vcpu='4' cpuset='29'/> <vcpupin vcpu='5' cpuset='61'/> <vcpupin vcpu='6' cpuset='54'/> <vcpupin vcpu='7' cpuset='22'/> <emulatorpin cpuset='16,21-22,29,48,53-54,61'/> </cputune> <numatune> <memory mode='strict' nodeset='1'/> <memnode cellid='0' mode='strict' nodeset='1'/> </numatune> <sysinfo type='smbios'> <system> <entry name='manufacturer'>OpenStack Foundation</entry> <entry name='product'>OpenStack Nova</entry> <entry name='version'>20.6.1</entry> <entry name='serial'>3ba2abc6-8141-4782-9b57-18c8773a12c0</entry> <entry name='uuid'>3ba2abc6-8141-4782-9b57-18c8773a12c0</entry> <entry name='family'>Virtual Machine</entry> </system> </sysinfo> <os> <type arch='x86_64' machine='pc-i440fx-rhel7.2.0'>hvm</type> <boot dev='hd'/> <smbios mode='smbios'/> </os> <features> <acpi/> <apic/> <kvm> <hidden state='on'/> </kvm> </features> <cpu mode='custom' match='exact' check='partial'> <model fallback='allow'>Broadwell</model> <topology sockets='2' cores='4' threads='1'/> <feature policy='disable' name='hypervisor'/> <numa> <cell id='0' cpus='0-7' memory='16777216' unit='KiB' memAccess='shared'/> </numa> </cpu> <clock offset='utc'> <timer name='pit' tickpolicy='delay'/> <timer name='rtc' tickpolicy='catchup'/> <timer name='hpet' present='no'/> </clock> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/libexec/qemu-kvm</emulator> <disk type='network' device='disk'> <driver name='qemu' type='raw' cache='writeback' discard='unmap'/> <auth username='cinder'> <secret type='ceph' uuid='457eb676-33da-42ec-9a8c-9293d545c337'/> </auth> <source protocol='rbd' name='cinder-volumes/fd82f85e-0c67-4c4c-8738-d8e7ea3b9d0a'> <host name='111.111.9.207' port='6789'/> </source> <target dev='vda' bus='virtio'/> <serial>fd82f85e-0c67-4c4c-8738-d8e7ea3b9d0a</serial> <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> </disk> <controller type='usb' index='0' model='piix3-uhci'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='usb' index='1' model='ehci'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </controller> <controller type='usb' index='2' model='nec-xhci'> <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/> </controller> <controller type='usb' index='3' model='ehci'> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </controller> <controller type='usb' index='4' model='nec-xhci'> <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/> </controller> <controller type='pci' index='0' model='pci-root'/> <controller type='virtio-serial' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> </controller> <interface type='bridge'> <mac address='fa:16:3e:fa:21:60'/> <source bridge='br-int'/> <virtualport type='openvswitch'> <parameters interfaceid='e0f2760f-3652-4d68-9332-f95b77c8ff03'/> </virtualport> <target dev='tape0f2760f-36'/> <model type='virtio'/> <mtu size='1500'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <interface type='bridge'> <mac address='fa:16:3e:fa:21:60'/> <source bridge='br-int'/> <virtualport type='openvswitch'> <parameters interfaceid='e0f2760f-3652-4d68-9332-f95b77c8ff03'/> </virtualport> <target dev='tape0f2760f-36'/> <model type='virtio'/> <mtu size='1500'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <serial type='pty'> <log file='/var/lib/nova/instances/3ba2abc6-8141-4782-9b57-18c8773a12c0/console.log' append='off'/> <target type='isa-serial' port='0'> <model name='isa-serial'/> </target> </serial> <console type='pty'> <log file='/var/lib/nova/instances/3ba2abc6-8141-4782-9b57-18c8773a12c0/console.log' append='off'/> <target type='serial' port='0'/> </console> <channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> <address type='virtio-serial' controller='0' bus='0' port='1'/> </channel> <input type='tablet' bus='usb'> <address type='usb' bus='0' port='1'/> </input> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> <graphics type='spice' autoport='yes' listen='0.0.0.0'> <listen type='address' address='0.0.0.0'/> </graphics> <sound model='ac97'> <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> </sound> <video> <model type='qxl' ram='65536' vram='65536' vgamem='32768' heads='1' primary='yes'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <hostdev mode='subsystem' type='mdev' managed='yes' model='vfio-pci' display='off'> <source> <address uuid='df8b83b3-0abc-4228-8311-1f82ea846165'/> </source> <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/> </hostdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='3' port='1'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='3' port='2'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='4' port='1'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='4' port='2'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='3' port='3'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='3' port='4'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='4' port='3'/> </redirdev> <redirdev bus='usb' type='spicevmc'> <address type='usb' bus='4' port='4'/> </redirdev> <memballoon model='virtio'> <stats period='10'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/> </memballoon> </devices> </domain>
|
参考文档