Kvm-Virtualization

KVM/Qemu 上的 Windows 客戶機遭受可怕的密鑰延遲

  • May 21, 2018

主機作業系統是 Arch Linux,具有以下版本:-

qemu 2.1.0-2 libvirt 1.2.7-1 linux 3.15.8-1

來賓作業系統是 Windows 7 64 位。

當我第一次創建這個虛擬機並開始使用它時,這個問題並不存在,而是在某個時候出現了。不幸的是,我無法將其歸結為特定的主機或訪客配置更改或軟體更新。

使用 virt-manager 查看器執行 VM 時,按鍵只需不到一秒的時間即可註冊。滑鼠操作不會延遲。機器整體執行速度並不明顯 - 延遲似乎僅在鍵盤輸入中。

這是機器的定義:-

<domain type='kvm'>
 <name>Windows7</name>
 <uuid>ad22629b-64eb-7444-359f-f97d458336cb</uuid>
 <memory unit='KiB'>4194304</memory>
 <currentMemory unit='KiB'>2097152</currentMemory>
 <vcpu placement='static'>4</vcpu>
 <os>
   <type arch='x86_64' machine='pc-i440fx-1.5'>hvm</type>
   <boot dev='hd'/>
 </os>
 <features>
   <acpi/>
   <apic/>
   <pae/>
 </features>
 <cpu mode='custom' match='exact'>
   <model fallback='allow'>Nehalem</model>
   <vendor>Intel</vendor>
   <topology sockets='1' cores='2' threads='4'/>
   <feature policy='require' name='avx'/>
   <feature policy='require' name='vme'/>
   <feature policy='require' name='dtes64'/>
   <feature policy='require' name='xsave'/>
   <feature policy='require' name='vmx'/>
   <feature policy='require' name='xtpr'/>
   <feature policy='require' name='pcid'/>
   <feature policy='require' name='est'/>
   <feature policy='require' name='monitor'/>
   <feature policy='require' name='tm'/>
   <feature policy='require' name='pclmuldq'/>
   <feature policy='require' name='acpi'/>
   <feature policy='require' name='tsc-deadline'/>
   <feature policy='require' name='osxsave'/>
   <feature policy='require' name='tm2'/>
   <feature policy='require' name='ht'/>
   <feature policy='require' name='pdcm'/>
   <feature policy='require' name='ds'/>
   <feature policy='require' name='rdtscp'/>
   <feature policy='require' name='ss'/>
   <feature policy='require' name='pbe'/>
   <feature policy='require' name='ds_cpl'/>
 </cpu>
 <clock offset='utc'/>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>restart</on_reboot>
 <on_crash>restart</on_crash>
 <devices>
   <emulator>/usr/sbin/qemu-system-x86_64</emulator>
   <disk type='file' device='cdrom'>
     <driver name='qemu' type='raw'/>
     <target dev='hdc' bus='ide'/>
     <readonly/>
     <address type='drive' controller='0' bus='1' target='0' unit='0'/>
   </disk>
   <disk type='block' device='disk'>
     <driver name='qemu' type='raw' cache='writethrough'/>
     <source dev='/dev/volgrp1/qemu_windows7'/>
     <target dev='vda' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
   </disk>
   <disk type='block' device='disk'>
     <driver name='qemu' type='raw' cache='none' io='native'/>
     <source dev='/dev/mapper/volgrp2-qemu_windows7_data'/>
     <target dev='vdb' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
   </disk>
   <controller type='pci' index='0' model='pci-root'/>
   <controller type='ide' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
   </controller>
   <controller type='usb' index='0' model='ich9-ehci1'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x7'/>
   </controller>
   <controller type='usb' index='0' model='ich9-uhci1'>
     <master startport='0'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0' multifunction='on'/>
   </controller>
   <controller type='usb' index='0' model='ich9-uhci2'>
     <master startport='2'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x1'/>
   </controller>
   <controller type='usb' index='0' model='ich9-uhci3'>
     <master startport='4'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x2'/>
   </controller>
   <controller type='virtio-serial' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
   </controller>
   <interface type='direct'>
     <mac address='52:54:00:f0:f8:5b'/>
     <source dev='eth0' mode='bridge'/>
     <model type='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <interface type='network'>
     <mac address='52:54:00:c4:a5:2a'/>
     <source network='isolated'/>
     <model type='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x09' 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='2'/>
   </channel>
   <input type='mouse' bus='ps2'/>
   <input type='keyboard' bus='ps2'/>
   <graphics type='spice' autoport='yes' listen='127.0.0.1'>
     <listen type='address' address='127.0.0.1'/>
   </graphics>
   <sound model='ich6'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </sound>
   <video>
     <model type='qxl' ram='65536' vram='65536' heads='1'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
   </video>
   <memballoon model='virtio'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
   </memballoon>
 </devices>
</domain>

有沒有人對問題可能有任何建議?我找不到任何有用的 Google 連結。我希望它會是一個會再次消失的錯誤,但它現在已經存在於 Qemu + 核心的多個版本中。

這不是發行版問題,而是 Windows 中的錯誤:

http://keyliner.blogspot.se/2009/11/windows-7-slow-keyboard-response.html(第二條)

這對我有幫助:

  1. 開始執行,regedit
  2. 找到這個鍵: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters
  3. 在詳細資訊一側,右鍵點擊空白區域並添加一個新的“DWORD(32 位)”值。命名密鑰PollStatusIterations

將值設置為十六進制 = 1

注意,還有其他具有相似名稱的系統資料庫項。 4. 關閉 Regedit 並重新啟動。 5. 如果此值已在系統資料庫中,請通過將其重命名為xxPollStatusIterations(右鍵點擊,重命名)來禁用該鍵。重新啟動並測試。

引用自:https://serverfault.com/questions/624690