您尚未登录。

#1 2018-07-05 21:42:44

Kurobac
小白
注册时间: 2018-05-12
帖子: 85

[已解决]几个虚拟机的问题

为了好好玩游戏,爬了两天Wiki配了KVM+QEMU+libvirt+virt-manager的虚拟机。
客户机系统Windows10,使用UEFI,配置了pci passthrough,将我的RX480分配给了虚拟机,还用USB passthrough分配了键鼠和手柄。
大多数功能都工作正常,但是有几个小问题。
第一个问题,客户机启动必定会失败,启动时转几圈就会进到故障恢复界面……但很奇怪的是,只要在故障恢复里选择重启到UEFI设置,之后在UEFI设置里面再次重启就能正常进入系统,如果在UEFI里面选择continue就会继续启动失败…
是因为显卡无法正常reset导致的,见二楼。
第二个问题,我按照Wiki配置了音频,并且配置了msi,但还是有兹拉兹啦的噪音…不过可能直接把板载音频分给虚拟机可以解决
在Windows里调下采样可以缓解,可以忍受。
第三个问题,有没有什么方法能快速把USB设备的控制权交还给宿主机?要操作宿主机就必须把虚拟机关掉这也太蠢了……
这个帖子。Linux和Windows下各写一个脚本就好了。

<domain type='kvm' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
  <name>win10</name>
  <uuid>f53572f9-46d2-4f4c-960a-144f9bb75792</uuid>
  <memory unit='KiB'>8388608</memory>
  <currentMemory unit='KiB'>8388608</currentMemory>
  <vcpu placement='static'>4</vcpu>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.12'>hvm</type>
    <loader readonly='yes' type='pflash'>/usr/share/ovmf/x64/OVMF_CODE.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/win10_VARS.fd</nvram>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
    <vmport state='off'/>
  </features>
  <cpu mode='host-model' check='partial'>
    <model fallback='allow'/>
    <topology sockets='2' cores='2' threads='1'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </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/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/kurobac/virtio-win.iso'/>
      <target dev='sda' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/home/kurobac/.deepinwine/Deepin-ThunderSpeed/drive_c/迅雷下载/cn_windows_10_consumer_editions_version_1803_updated_march_2018_x64_dvd_12063766.iso'/>
      <target dev='sdb' bus='sata'/>
      <readonly/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/win10.qcow2'/>
      <target dev='vda' bus='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </disk>
    <controller type='pci' index='0' model='pci-root'/>
    <controller type='virtio-serial' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>
    <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='sata' index='0'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </controller>
    <interface type='direct'>
      <mac address='52:54:00:c0:82:4e'/>
      <source dev='enp6s0' mode='bridge'/>
      <model type='virtio'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
    </interface>
    <serial type='pty'>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
    </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'/>
    <sound model='ich6'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </sound>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <source>
        <address domain='0x0000' bus='0x01' slot='0x00' function='0x1'/>
      </source>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x045e'/>
        <product id='0x02d1'/>
      </source>
      <address type='usb' bus='0' port='6'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x04b4'/>
        <product id='0x0823'/>
      </source>
      <address type='usb' bus='0' port='5'/>
    </hostdev>
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x046d'/>
        <product id='0xc332'/>
      </source>
      <address type='usb' bus='0' port='1'/>
    </hostdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='2'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='3'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <address type='usb' bus='0' port='4'/>
    </redirdev>
    <memballoon model='virtio'>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </memballoon>
    <rng model='virtio'>
      <backend model='random'>/dev/urandom</backend>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </rng>
  </devices>
  <qemu:commandline>
    <qemu:env name='QEMU_AUDIO_DRV' value='pa'/>
    <qemu:env name='QEMU_PA_SERVER' value='/run/user/1000/pulse/native'/>
  </qemu:commandline>
</domain>

最近编辑记录 Kurobac (2018-07-07 15:36:09)


# pacman -Syu

离线

#2 2018-07-06 03:54:39

Kurobac
小白
注册时间: 2018-05-12
帖子: 85

Re: [已解决]几个虚拟机的问题

我突然发现,我都不知道这玩意是怎么能跑起来的。
就重启了几次,虚拟机就再也启动不了了,必须要把qxl加回去才能启动。
重装虚拟机,GPU passthrough还是没法正常工作……然而设备管理器里RX480就好好的在那躺着。
如果删掉qxl,开机自动重启几次就会一直卡在UEFI启动画面…保留qxl就能开机,但RX480仍然没有输出。用RDP连接表现出的弱鸡性能来看,还是qxl在跑…显卡完全打酱油。
----------------------------------------------------------
不知为何,虚拟机又能正常启动了…但是显卡还是没有输出。通过RDP可以连上…可是不知道是freerdp的性能问题还是我配置有问题,体验就一个字——卡
----------------------------------------------------------
我可能是来搞笑的
为什么没信号
因为线没插好
----------------------------------------------------------
嗯…好像发现问题了
一旦虚拟机关闭之后,再次打开就会无法启动…宿主机重启即可恢复
好像找到解决办法了
https://lime-technology.com/forums/topi … issue-amd/

最近编辑记录 Kurobac (2018-07-06 17:26:16)


# pacman -Syu

离线

#3 2018-07-06 09:31:12

驿窗
驿窗
所在地: 基础开源研究
注册时间: 2016-06-03
帖子: 927
个人网站

Re: [已解决]几个虚拟机的问题

第三个,usb控制权的问题,如果不用USB passthrough,是不是USB设备控制权就可以随时切换到宿主机(Redirect USB device)?


开源/Linux大众化,从驿窗开始~

离线

#4 2018-07-06 18:41:08

Kurobac
小白
注册时间: 2018-05-12
帖子: 85

Re: [已解决]几个虚拟机的问题

piter 说:

第三个,usb控制权的问题,如果不用USB passthrough,是不是USB设备控制权就可以随时切换到宿主机(Redirect USB device)?

嗯…大概Google了一下,不是很明白passthrough和redirect之间的区别…有什么相关的文章吗?


# pacman -Syu

离线

#5 2018-07-07 09:10:48

驿窗
驿窗
所在地: 基础开源研究
注册时间: 2016-06-03
帖子: 927
个人网站

Re: [已解决]几个虚拟机的问题

文章没什么印象了;
你USB passthrough分配了键鼠和手柄,导致虚拟机独占键鼠,这样宿主机无法使用键鼠;所以,在操作宿主机的时候,没有键鼠可用;
我理解,你据说的 要操作宿主机就必须把虚拟机关掉应该就是指这个了;

如果是这样,那还真和redirect没什么关系,不用管;你试试,键鼠不要使用passthrough就好,虚拟机和宿主机之间无缝使用;


开源/Linux大众化,从驿窗开始~

离线

#6 2018-07-07 13:54:34

Kurobac
小白
注册时间: 2018-05-12
帖子: 85

Re: [已解决]几个虚拟机的问题

piter 说:

文章没什么印象了;
你USB passthrough分配了键鼠和手柄,导致虚拟机独占键鼠,这样宿主机无法使用键鼠;所以,在操作宿主机的时候,没有键鼠可用;
我理解,你据说的 要操作宿主机就必须把虚拟机关掉应该就是指这个了;

如果是这样,那还真和redirect没什么关系,不用管;你试试,键鼠不要使用passthrough就好,虚拟机和宿主机之间无缝使用;

我这虚拟机的信号是独显输出的啊,virt-manager的图形控制台是看不到画面的,所以虚拟出来的键鼠并不能用…

轻度使用可以靠RDP,想要玩游戏之类的还是要把显示器信号切过去。


# pacman -Syu

离线

#7 2018-07-07 18:16:57

驿窗
驿窗
所在地: 基础开源研究
注册时间: 2016-06-03
帖子: 927
个人网站

Re: [已解决]几个虚拟机的问题

是我out了...
我以为和U盘一样~

是不是真的需要两套键鼠...

网上有说用synergy来解决鼠标键盘问题,不知道是不是可行,我的cpu不支持Vt-d,没试过~
https://momoka.net/posts/2017/2017-0002 … rough.html

最近编辑记录 驿窗 (2018-07-07 18:46:36)


开源/Linux大众化,从驿窗开始~

离线

#8 2018-07-07 20:06:21

Kurobac
小白
注册时间: 2018-05-12
帖子: 85

Re: [已解决]几个虚拟机的问题

piter 说:

是我out了...
我以为和U盘一样~

是不是真的需要两套键鼠...

网上有说用synergy来解决鼠标键盘问题,不知道是不是可行,我的cpu不支持Vt-d,没试过~
https://momoka.net/posts/2017/2017-0002 … rough.html

搜了一圈,发现virsh有命令可以控制USB passthrough,Linux下写两个脚本就行了。虚拟机切回宿主机也就是一条ssh命令,写个bat绑个快捷键就OK。


# pacman -Syu

离线

#9 2018-07-07 20:32:09

驿窗
驿窗
所在地: 基础开源研究
注册时间: 2016-06-03
帖子: 927
个人网站

Re: [已解决]几个虚拟机的问题


开源/Linux大众化,从驿窗开始~

离线

#10 2018-07-08 00:56:00

Kurobac
小白
注册时间: 2018-05-12
帖子: 85

Re: [已解决]几个虚拟机的问题

piter 说:

是。


# pacman -Syu

离线

#11 2018-07-08 07:04:39

驿窗
驿窗
所在地: 基础开源研究
注册时间: 2016-06-03
帖子: 927
个人网站

Re: [已解决]几个虚拟机的问题

我才知道,原来是这么用的~


开源/Linux大众化,从驿窗开始~

离线

页脚