LINUX.ORG.RU

История изменений

Исправление NeverLoved, (текущая версия) :

Ура, я осилил!

Включил в ведре hugepages support, заодно пересобрал kvm и kvm-amd как модули, добавил опцию «npt=0» для kvm-amd, руками определил топологию процессора в конфиге виртуалки.

Итоговая конфигурация:

$ cat /etc/modprobe.d/{kvm*,vfio_iommu_type1.conf}
options kvm-amd npt=0
options kvm ignore_msrs=1
options vfio_iommu_type1 allow_unsafe_interrupts=1
# virsh dumpxml qwerty_nosound
<domain type='kvm' id='2'>
  <name>qwerty_nosound</name>
  <uuid>d616d9cd-aa9d-564a-7999-704787e5ea6c</uuid>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>8</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.0'>hvm</type>
    <boot dev='hd'/>
    <bootmenu enable='no'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='8' threads='1'/>
  </cpu>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none' io='native'/>
      <source file='/home/neverloved/work/qemu_windows/windows.img'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <shareable/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none' io='native'/>
      <source file='/home/neverloved/work/qemu_windows/windows_games.img'/>
      <backingStore/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='sata0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>
    <filesystem type='mount' accessmode='mapped'>
      <source dir='/home/neverloved'/>
      <target dir='share'/>
      <alias name='fs0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </filesystem>
    <interface type='bridge'>
      <mac address='52:54:00:34:a4:74'/>
      <source bridge='br0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/3'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <sound model='ich6'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
      </source>
      <alias name='hostdev2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x12' function='0x2'/>
      </source>
      <alias name='hostdev3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </hostdev>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='none'/>
</domain>

virsh запускает qemu вот так:

/usr/bin/qemu-system-x86_64
 -name qwerty_nosound
 -S
 -machine pc-i440fx-2.0,accel=kvm,usb=off
 -cpu host
 -m 4096
 -realtime mlock=off
 -smp 8,sockets=1,cores=8,threads=1
 -uuid d616d9cd-aa9d-564a-7999-704787e5ea6c
 -no-user-config
 -nodefaults
 -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/qwerty_nosound.monitor,server,nowait
 -mon chardev=charmonitor,id=monitor,mode=control
 -rtc base=localtime
 -no-shutdown
 -boot menu=off,strict=on
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2
 -device ahci,id=ahci0,bus=pci.0,addr=0x7
 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5
 -drive file=/home/neverloved/work/qemu_windows/windows.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,aio=native
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0xe,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
 -drive file=/home/neverloved/work/qemu_windows/windows_games.img,if=none,id=drive-virtio-disk1,format=qcow2,cache=none,aio=native
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0xd,drive=drive-virtio-disk1,id=virtio-disk1
 -fsdev local,security_model=mapped,id=fsdev-fs0,path=/home/neverloved
 -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=share,bus=pci.0,addr=0xc
 -netdev tap,fd=19,id=hostnet0
 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:34:a4:74,bus=pci.0,addr=0x3
 -chardev pty,id=charserial0
 -device isa-serial,chardev=charserial0,id=serial0
 -vnc 127.0.0.1:0
 -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2
 -device intel-hda,id=sound0,bus=pci.0,addr=0x4
 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0
 -device vfio-pci,host=03:00.1,id=hostdev0,bus=pci.0,addr=0x8
 -device vfio-pci,host=03:00.0,id=hostdev1,bus=pci.0,addr=0x9
 -device vfio-pci,host=00:12.0,id=hostdev2,bus=pci.0,addr=0xa
 -device vfio-pci,host=00:12.2,id=hostdev3,bus=pci.0,addr=0xb
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
 -msg timestamp=on

Пульса запущена в режиме system-wide, из-за чего отвалился звуковой виджет в awesome. Да и фиг с ним, регулирую с помощью volwheel, как и раньше.

Вечером ещё переведусь на hugetlbfs, по идее будет ещё быстрее. И со временем отдам виртуалке не виртуальный диск, а раздел винта.

Алсо, с sound=ac97 были проблемы со звуком - закания, подлагивания. Вылечилось с помощью sound=ich6.

Пойду на радостях пить и играть в Assassin's Creed III.
</thread>

Исходная версия NeverLoved, :

Ура, я осилил!

Включил в ведре hugepages support, заодно пересобрал kvm и kvm-amd как модули, добавил опцию «npt=0» для kvm-amd.

Итоговая конфигурация:

$ cat /etc/modprobe.d/{kvm*,vfio_iommu_type1.conf}
options kvm-amd npt=0
options kvm ignore_msrs=1
options vfio_iommu_type1 allow_unsafe_interrupts=1
# virsh dumpxml qwerty_nosound
<domain type='kvm' id='2'>
  <name>qwerty_nosound</name>
  <uuid>d616d9cd-aa9d-564a-7999-704787e5ea6c</uuid>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>8</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-i440fx-2.0'>hvm</type>
    <boot dev='hd'/>
    <bootmenu enable='no'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <pae/>
  </features>
  <cpu mode='host-passthrough'>
    <topology sockets='1' cores='8' threads='1'/>
  </cpu>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>restart</on_crash>
  <devices>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none' io='native'/>
      <source file='/home/neverloved/work/qemu_windows/windows.img'/>
      <backingStore/>
      <target dev='vda' bus='virtio'/>
      <shareable/>
      <alias name='virtio-disk0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' cache='none' io='native'/>
      <source file='/home/neverloved/work/qemu_windows/windows_games.img'/>
      <backingStore/>
      <target dev='vdb' bus='virtio'/>
      <alias name='virtio-disk1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
    </disk>
    <controller type='usb' index='0'>
      <alias name='usb0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pci-root'>
      <alias name='pci.0'/>
    </controller>
    <controller type='ide' index='0'>
      <alias name='ide0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='sata0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
    </controller>
    <filesystem type='mount' accessmode='mapped'>
      <source dir='/home/neverloved'/>
      <target dir='share'/>
      <alias name='fs0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
    </filesystem>
    <interface type='bridge'>
      <mac address='52:54:00:34:a4:74'/>
      <source bridge='br0'/>
      <target dev='vnet0'/>
      <model type='virtio'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/3'/>
      <target port='0'/>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/3'>
      <source path='/dev/pts/3'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
    </graphics>
    <sound model='ich6'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
    </sound>
    <video>
      <model type='qxl' ram='65536' vram='65536' heads='1'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </video>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x1'/>
      </source>
      <alias name='hostdev0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
      </source>
      <alias name='hostdev1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
      </source>
      <alias name='hostdev2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
    </hostdev>
    <hostdev mode='subsystem' type='pci' managed='yes'>
      <driver name='vfio'/>
      <source>
        <address domain='0x0000' bus='0x00' slot='0x12' function='0x2'/>
      </source>
      <alias name='hostdev3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
    </hostdev>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='none'/>
</domain>

virsh запускает qemu вот так:

/usr/bin/qemu-system-x86_64
 -name qwerty_nosound
 -S
 -machine pc-i440fx-2.0,accel=kvm,usb=off
 -cpu host
 -m 4096
 -realtime mlock=off
 -smp 8,sockets=1,cores=8,threads=1
 -uuid d616d9cd-aa9d-564a-7999-704787e5ea6c
 -no-user-config
 -nodefaults
 -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/qwerty_nosound.monitor,server,nowait
 -mon chardev=charmonitor,id=monitor,mode=control
 -rtc base=localtime
 -no-shutdown
 -boot menu=off,strict=on
 -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2
 -device ahci,id=ahci0,bus=pci.0,addr=0x7
 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x5
 -drive file=/home/neverloved/work/qemu_windows/windows.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,aio=native
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0xe,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
 -drive file=/home/neverloved/work/qemu_windows/windows_games.img,if=none,id=drive-virtio-disk1,format=qcow2,cache=none,aio=native
 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0xd,drive=drive-virtio-disk1,id=virtio-disk1
 -fsdev local,security_model=mapped,id=fsdev-fs0,path=/home/neverloved
 -device virtio-9p-pci,id=fs0,fsdev=fsdev-fs0,mount_tag=share,bus=pci.0,addr=0xc
 -netdev tap,fd=19,id=hostnet0
 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:34:a4:74,bus=pci.0,addr=0x3
 -chardev pty,id=charserial0
 -device isa-serial,chardev=charserial0,id=serial0
 -vnc 127.0.0.1:0
 -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,addr=0x2
 -device intel-hda,id=sound0,bus=pci.0,addr=0x4
 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0
 -device vfio-pci,host=03:00.1,id=hostdev0,bus=pci.0,addr=0x8
 -device vfio-pci,host=03:00.0,id=hostdev1,bus=pci.0,addr=0x9
 -device vfio-pci,host=00:12.0,id=hostdev2,bus=pci.0,addr=0xa
 -device vfio-pci,host=00:12.2,id=hostdev3,bus=pci.0,addr=0xb
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
 -msg timestamp=on

Пульса запущена в режиме system-wide, из-за чего отвалился звуковой виджет в awesome. Да и фиг с ним, регулирую с помощью volwheel, как и раньше.

Вечером ещё переведусь на hugetlbfs, по идее будет ещё быстрее. И со временем отдам виртуалке не виртуальный диск, а раздел винта.

Алсо, с sound=ac97 были проблемы со звуком - закания, подлагивания. Вылечилось с помощью sound=ich6.

Пойду на радостях пить и играть в Assassin's Creed III.
</thread>