Virtual-Machine

如何在 KVM 上執行 Android-x86 以獲得更好的 2D 圖形性能?

  • May 21, 2021

我通過虛擬機管理器在 QEMU/KVM 中執行 Android-x86。這是我之前使用 VMWare 從 Windows 主機執行的虛擬機。我現在設法在 Linux QEMU/KVM 中執行它,但是 2D 性能非常非常差。

這是虛擬機程式碼(/etc/libvirt/qemu/generic.xml):

<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
 virsh edit generic
or other application using the libvirt API.
-->

<domain type='kvm'>
 <name>generic</name>
 <uuid>386c966a-0cdf-427d-aa24-7fe71583ab85</uuid>
 <memory unit='KiB'>2097152</memory>
 <currentMemory unit='KiB'>2097152</currentMemory>
 <vcpu placement='static'>4</vcpu>
 <os>
   <type arch='x86_64' machine='pc-i440fx-2.9'>hvm</type>
   <boot dev='hd'/>
 </os>
 <features>
   <acpi/>
   <apic/>
   <vmport state='off'/>
 </features>
 <cpu mode='host-model' check='partial'>
   <model fallback='allow'/>
 </cpu>
 <clock offset='utc'>
   <timer name='rtc' tickpolicy='catchup'/>
   <timer name='pit' tickpolicy='delay'/>
   <timer name='hpet' present='no'/>
 </clock>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>restart</on_reboot>
 <on_crash>destroy</on_crash>
 <pm>
   <suspend-to-mem enabled='no'/>
   <suspend-to-disk enabled='no'/>
 </pm>
 <devices>
   <emulator>/usr/sbin/qemu-system-x86_64</emulator>
   <disk type='file' device='disk'>
     <driver name='qemu' type='vmdk'/>
     <source file='/vms/android-x86-6.0-rc1.vmdk'/>
     <target dev='sda' bus='sata'/>
     <address type='drive' controller='0' bus='0' target='0' unit='0'/>
   </disk>
   <controller type='usb' index='0' model='ich9-ehci1'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x7'/>
   </controller>
   <controller type='usb' index='0' model='ich9-uhci1'>
     <master startport='0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0' multifunction='on'/>
   </controller>
   <controller type='usb' index='0' model='ich9-uhci2'>
     <master startport='2'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x1'/>
   </controller>
   <controller type='usb' index='0' model='ich9-uhci3'>
     <master startport='4'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x2'/>
   </controller>
   <controller type='pci' index='0' model='pci-root'/>
   <controller type='sata' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
   </controller>
   <controller type='virtio-serial' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
   </controller>
   <interface type='direct'>
     <mac address='52:54:00:06:96:fd'/>
     <source dev='enp10s0' mode='bridge'/>
     <model type='rtl8139'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <serial type='pty'>
     <target port='0'/>
   </serial>
   <console type='pty'>
     <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='mouse' bus='ps2'/>
   <input type='keyboard' bus='ps2'/>
   <graphics type='spice' autoport='yes'>
     <listen type='address'/>
     <gl enable='no' rendernode='/dev/dri/by-path/pci-0000:01:00.0-render'/>
   </graphics>
   <sound model='ich6'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </sound>
   <video>
     <model type='qxl' ram='131072' vram='131072' vgamem='131072' heads='1' primary='yes'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
   </video>
   <redirdev bus='usb' type='spicevmc'>
     <address type='usb' bus='0' port='1'/>
   </redirdev>
   <redirdev bus='usb' type='spicevmc'>
     <address type='usb' bus='0' port='2'/>
   </redirdev>
   <memballoon model='virtio'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
   </memballoon>
 </devices>
</domain>

我之前嘗試過一張VMVGA卡,但在閱讀此處後,我將其更改為QXL並啟用了 Spice,如程式碼中所示。我還手動分配了 128MB 的虛擬圖形記憶體並重新啟動了主機。

儘管如此,2D 圖形還是非常緩慢。除了安裝 VMWare 或購買第二張顯卡外,有什麼解決方案嗎?

$$ Edit $$:我的硬體是 8GB RAM 和 R9 280x GPU(AMD GCN 1.0、1070 Mhz、3GB GDDR5)。此外,由於在 VMWare 下的性能非常好,我確信這是一個軟體問題。我使用 Arch Linux 64 位作為主機和開源 AMDGPU 驅動程序。

當我將 qcow2 磁碟映像移動到 SSD 時,2d 圖形性能得到了顯著提高。

我把它移回硬碟,它又變慢了。也測試了其他 Android-x86 安裝(32 位和 64 位)。確認的。

不知道為什麼。

我沒有足夠的聲譽發表評論,但它的 2021 年和仍然 VMWare 驅動程序是 Windows 和 Linux 上 Android x86(我使用 9.0r2-k49)的最佳選擇。Virtualbox 驅動程序完全是一團糟,QEMU 在 Windows 上的執行就像一個障礙,而在 Linux 上的 virtio-vga 提供了相當的性能,但螢幕撕裂。

我認為 virglvulkan 可能是未來的解決方案

引用自:https://unix.stackexchange.com/questions/371210