![KVM/Qemu 上的 Windows 客户机遭受严重的按键延迟](https://linux22.com/image/640607/KVM%2FQemu%20%E4%B8%8A%E7%9A%84%20Windows%20%E5%AE%A2%E6%88%B7%E6%9C%BA%E9%81%AD%E5%8F%97%E4%B8%A5%E9%87%8D%E7%9A%84%E6%8C%89%E9%94%AE%E5%BB%B6%E8%BF%9F.png)
主机操作系统是 Arch Linux,版本如下:-
qemu 2.1.0-2 libvirt 1.2.7-1 Linux 3.15.8-1
客户操作系统是Windows 7 64位。
我第一次创建并开始使用这个虚拟机时,这个问题并不存在,而是在某个时候出现的。遗憾的是,我无法将其归咎于特定的主机或客户机配置更改或软件更新。
使用 virt-manager viewer 运行虚拟机时,按键操作只需不到一秒的时间即可完成。鼠标操作没有延迟。机器整体运行速度并不明显缓慢 - 延迟似乎只出现在键盘输入上。
这是机器的定义:-
<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 + 内核中持续存在。
答案1
这不是发行版的问题,而是 Windows 中的一个错误:
http://keyliner.blogspot.se/2009/11/windows-7-slow-keyboard-response.html(第二条)
这对我有帮助:
开始运行,
regedit
找到这个键:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters
在详细信息侧,右键单击空白区域并添加一个新的“DWORD(32 位)”值。将键命名为
PollStatusIterations
。将值设置为十六进制 = 1
注意,还有其他具有类似名称的注册表项。
关闭 Regedit 并重新启动。
如果此值已存在于注册表中,请通过将其重命名为
xxPollStatusIterations
(右键单击,重命名)来禁用该键。重新启动并测试。