Mittwoch, 15. Juli 2015

Links und Skripte vom Video: Tutorial: SteamOS run in a KVM with physical GPU passthrough




Here the preparation video:


My hardware components:
Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz socket 1150
GA-Z97X-UD3H-BK
16GB DDR3 Memory
512GB SSD
NVIDIA GeForce GTX 780 (ASUS GTX780-DC2OC-3GD5) for passthrugh

Download from SteamOS:
http://store.steampowered.com/steamos/download/?ver=custom

To create the ISO file from ZIP file:
genisoimage -U -A "Steamos" -V "SteamOS" -volset "SteamOS" -J -joliet-long -r -v -T -o SteamOSInstaller.iso --eltorito-boot boot/grub/efi.img -no-emul-boot ./SteamOSInstaller


Script files:

kvm-install-steamos.sh
Please check the lines DEVICE1="01:00.0" und DEVICE2="01:00.1".
--------------------------------------------------- begin -------------------------------------------
#!/bin/sh

INSTALLFILE=steamos-uefi-x64_system.qcow2
FILESIZE=100G

INSTALLCD=/home/user/Downloads/SteamOSInstaller.iso
# if you use a hardware CD-ROM drive, check for the device. In most cases it's /dev/sr0
#INSTALLCD=/dev/sr0

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create installation file if not exist
if [ ! -e $INSTALLFILE ]; then
 qemu-img create -f qcow2 $INSTALLFILE $FILESIZE
fi

QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on,x-vga=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga none \
-device qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$INSTALLFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=unsafe \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 \
-drive file=$INSTALLCD,if=none,id=drive-ide0-0-0,readonly=on,format=raw \
-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-mouse \

-device usb-kbd

--------------------------------------------------- end -------------------------------------------

kvm-start-steamos.sh
--------------------------------------------------- begin -------------------------------------------

#!/bin/bash


INSTALLFILE=steamos-uefi-x64_system.qcow2
IMAGEFILE=steamos-uefi-x64_system-01.qcow2
#FILESIZE=50G

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/${dev}/vendor)
        device=$(cat /sys/bus/pci/devices/${dev}/device)
        if [ -e /sys/bus/pci/devices/${dev}/driver ]; then
                echo ${dev} > /sys/bus/pci/devices/${dev}/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create a imagefile from backingfile file if not exist
if [ ! -e $IMAGEFILE ]; then
 qemu-img create -f qcow2 -o backing_file=$INSTALLFILE,backing_fmt=qcow2 $IMAGEFILE
fi


QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
taskset -c 0-1 \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd `# SID version of OVMF` \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on,x-vga=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga none \
-device qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$IMAGEFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=none \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-mouse \
-device usb-kbd

--------------------------------------------------- end -------------------------------------------

Dienstag, 14. Juli 2015

Links und Skripte vom Video: Tutorial: SteamOS in einer KVM betreiben und die physikalische Grafikkarte nutzen.



Hier das Tutorial zur Vorbereitung:


Dieses sind meine eingesetzten Hardwarekomponenten:
Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz socket 1150
GA-Z97X-UD3H-BK 
16GB DDR3 Memory
512GB SSD
NVIDIA GeForce GTX 780 (ASUS GTX780-DC2OC-3GD5) zum durch reichen

Download des SteamOS:
http://store.steampowered.com/steamos/download/?ver=custom

Zum erstellen der ISO datei aus der ZIP Datei:
genisoimage -U -A "Steamos" -V "SteamOS" -volset "SteamOS" -J -joliet-long -r -v -T -o SteamOSInstaller.iso --eltorito-boot boot/grub/efi.img -no-emul-boot ./SteamOSInstaller


Skript Dateien:

kvm-install-steamos.sh
Bite Die Zeilen DEVICE1="01:00.0" und DEVICE2="01:00.1" prüfen, ob diese zur durchzureichenden Grafikkarte passt.
--------------------------------------------------- anfang ------------------------------------------- 
#!/bin/sh

INSTALLFILE=steamos-uefi-x64_system.qcow2
FILESIZE=100G

INSTALLCD=/home/user/Downloads/SteamOSInstaller.iso
# if you use a hardware CD-ROM drive, check for the device. In most cases it's /dev/sr0
#INSTALLCD=/dev/sr0

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create installation file if not exist
if [ ! -e $INSTALLFILE ]; then 
qemu-img create -f qcow2 $INSTALLFILE $FILESIZE
fi

QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on,x-vga=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga none \
-device qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$INSTALLFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=unsafe \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 \
-drive file=$INSTALLCD,if=none,id=drive-ide0-0-0,readonly=on,format=raw \
-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-mouse \

-device usb-kbd

--------------------------------------------------- ende ------------------------------------------- 

kvm-start-steamos.sh
--------------------------------------------------- anfang -------------------------------------------

#!/bin/bash



INSTALLFILE=steamos-uefi-x64_system.qcow2
IMAGEFILE=steamos-uefi-x64_system-01.qcow2
#FILESIZE=50G

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/${dev}/vendor)
        device=$(cat /sys/bus/pci/devices/${dev}/device)
        if [ -e /sys/bus/pci/devices/${dev}/driver ]; then
                echo ${dev} > /sys/bus/pci/devices/${dev}/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create a imagefile from backingfile file if not exist
if [ ! -e $IMAGEFILE ]; then
qemu-img create -f qcow2 -o backing_file=$INSTALLFILE,backing_fmt=qcow2 $IMAGEFILE
fi


QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
taskset -c 0-1 \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd `# SID version of OVMF` \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on,x-vga=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga none \
-device qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$IMAGEFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=none \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-mouse \
-device usb-kbd

--------------------------------------------------- ende ------------------------------------------- 

Montag, 6. Juli 2015

Tutorial Part 1, Debian 8, GPU Passthrough with OVMF powered by libvirt and Virt-Manager





Blog post from Alex Williamson about Libvirt with GPU passthrough and OVMF
http://vfio.blogspot.com/2015/05/vfio-gpu-how-to-series-part-4-our-first.html

Preparation for GPU passthrough:
http://kvm-exp.blogspot.com/2015/06/links-and-scripts-from-video.html

My hardware components:
Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz socket 1150
GA-Z97X-UD3H-BK
16GB DDR3 Memory
512GB SSD
NVIDIA GeForce GTX 780 (ASUS GTX780-DC2OC-3GD5) for passthrugh

Here are the used commands and configurations

Install needed applications:
sudo apt-get install libvirt-daemon virt-manager

Check your passthrough device:
lspci -nk

Check groups:
groups

Change groups for libvirt:
sudo usermod -a -G libvirt,libvirt-qemu USERNAME

Create imagefile that basesd on a backingfile or a masterimage:
qemu-img create -f qcow2 -o backing_file=win7-uefi-x64_system.qcow2,backing_fmt=qcow2 win7-uefi-libvirt-x64_system.qcow2

Check the new imagefile:
qemu-img info win7-uefi-libvirt-x64_system.qcow2

Edit the libvirt machine files manually:
sudo virsh edit "machine name"

Insert the OVMF Firmwarefile to XML (without # lines):
#  <os>
#    ..
    <loader readonly='yes' type='rom'>/usr/share/ovmf/OVMF.fd</loader>
#    ..
#  </os>

For Nvidia Users, use this (without # lines):
#  <features>
#    ..
    <kvm>
      <hidden state='on'/>
    </kvm>
#    ..
#  </features>

Delete tablet device, it's not helpfull with GPU passthrough:
delete    <input type='tablet' bus='usb'/>

change:
    <input type='mouse' bus='ps2'/>
    <input type='keyboard' bus='ps2'/>
to:
    <input type='mouse' bus='usb'/>
    <input type='keyboard' bus='usb'/>

Sonntag, 21. Juni 2015

Links and scripts from Video: Tutorial: Debian 8, howto passthrough your physical GPU to your virtual Windows7 with KVM and OVMF



Here are the links and scripts.

https://www.redhat.com/mailman/listinfo/vfio-users
Now is the successor of the archlinux forum part.
https://bbs.archlinux.org/viewtopic.php?id=162768
In Arch Linux You can find a nice and very active community, the first entry is a howto that addresses different configurations.

http://vfio.blogspot.com
In VFIO blog are a lot of information regarding the hardware virtualization.

https://docs.google.com/spreadsheets/d/1LnGpTrXalwGVNy0PWJDURhyxa3sgqkGXmvNCIvIMenk/edit?pli=1#gid=0
a list of working and non-working systems with different Linux distributions

My hardware components:
Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz socket 1150
GA-Z97X-UD3H-BK
16GB DDR3 Memory
512GB SSD
NVIDIA GeForce GTX 780 (ASUS GTX780-DC2OC-3GD5) for passthrugh

To check do the video card supports UEFI Boot.
http://vfio.blogspot.de/2014/08/does-my-graphics-card-rom-support-efi.html


For preparations:

http://kvm-exp.blogspot.de/2015/06/howto-debian-jessie-8-pcistub-config-to.html

VirtIo driver from Fedora
https://fedoraproject.org/wiki/Windows_Virtio_Drivers



Script files:

kvm-install.sh
--------------------------------------------------- begin -------------------------------------------
#!/bin/sh

INSTALLFILE=win7-uefi-x64_system.qcow2
FILESIZE=50G

INSTALLCD=/home/user/Downloads/W7SP1_PRO_DELL.iso
# if you use a hardware CD-ROM drive, check for the device. In most cases it's /dev/sr0
#INSTALLCD=/dev/sr0

DRIVERCD=/home/user/Downloads/virtio-win-0.1.96.iso

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create installation file if not exist
if [ ! -e $INSTALLFILE ]; then
    qemu-img create -f qcow2 $INSTALLFILE $FILESIZE
fi

QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd `# SID version of OVMF` \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$INSTALLCD,if=none,id=drive-ide0-0-0,readonly=on,format=raw \
-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-drive file=$INSTALLFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=unsafe \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 \
-drive file=$DRIVERCD,if=none,id=drive-ide0-1-0,readonly=on,format=raw \
-device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=3 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-tablet \
-device usb-kbd

--------------------------------------------------- end -------------------------------------------

kvm-start.sh
--------------------------------------------------- begin -------------------------------------------
#!/bin/bash

INSTALLFILE=win7-uefi-x64_system.qcow2
IMAGEFILE=win7-uefi-x64_system-01.qcow2
#FILESIZE=50G

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/${dev}/vendor)
        device=$(cat /sys/bus/pci/devices/${dev}/device)
        if [ -e /sys/bus/pci/devices/${dev}/driver ]; then
                echo ${dev} > /sys/bus/pci/devices/${dev}/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create a imagefile from backingfile file if not exist
if [ ! -e $IMAGEFILE ]; then
    qemu-img create -f qcow2 -o backing_file=$INSTALLFILE,backing_fmt=qcow2 $IMAGEFILE
fi


QEMU_PA_SAMPLES=6144 QEMU_AUDIO_DRV=pa \
taskset -c 0-1 \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd `# SID version of OVMF` \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on,x-vga=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga none \
-device qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$IMAGEFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=none \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-mouse \
-device usb-kbd
 
--------------------------------------------------- end ------------------------------------------- 


Freitag, 19. Juni 2015

Links und Skripte aus dem Video: Tutorial: Debian 8, KVM, OVMF, howto, eine echte Grafikkarte in einem virtuellen Windows7 benutzen




Hier sind die Links zu den hilfreichen Webseiten über KVM Virtualisierung mit Weiterleitung der Physikalischen Grafikkarte.

https://www.redhat.com/mailman/listinfo/vfio-users
Ist jetzt die nachfolger mailingliste des archlinux Forums
https://bbs.archlinux.org/viewtopic.php?id=162768
Bei Archlinux findet Ihr eine nette und sehr aktive community, im startpost befindet sich eine howto die auf verschiedene Konfigurationen eingeht.

http://vfio.blogspot.com
Im vfio Blog sind viele Informationen bezüglich der Hardwarevirtualisierung.

https://docs.google.com/spreadsheets/d/1LnGpTrXalwGVNy0PWJDURhyxa3sgqkGXmvNCIvIMenk/edit?pli=1#gid=0
In dieser Googletabelle findet Ihr von Usern getestete Konfigurationen und deren Ergebnisse dazu.

Dieses sind meine eingesetzten Hardwarekomponenten:
Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz socket 1150
GA-Z97X-UD3H-BK
16GB DDR3 Memory
512GB SSD
NVIDIA GeForce GTX 780 (ASUS GTX780-DC2OC-3GD5) zum durch reichen

Um zu Prüfen ob die verbaute Grafikkarte UEFI Boot unterstützt.
http://vfio.blogspot.de/2014/08/does-my-graphics-card-rom-support-efi.html


Für die Vorbereitungen:

http://kvm-exp.blogspot.de/2015/06/howto-debian-jessie-8-pcistub-config-to.html

VirtIo Driver von Fedora
https://fedoraproject.org/wiki/Windows_Virtio_Drivers



Skript Dateien:

kvm-install.sh
--------------------------------------------------- anfang -------------------------------------------
#!/bin/sh

INSTALLFILE=win7-uefi-x64_system.qcow2
FILESIZE=50G

INSTALLCD=/home/user/Downloads/W7SP1_PRO_DELL.iso
# if you use a hardware CD-ROM drive, check for the device. In most cases it's /dev/sr0
#INSTALLCD=/dev/sr0

DRIVERCD=/home/user/Downloads/virtio-win-0.1.96.iso

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/$dev/vendor)
        device=$(cat /sys/bus/pci/devices/$dev/device)
        if [ -e /sys/bus/pci/devices/$dev/driver ]; then
                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create installation file if not exist
if [ ! -e $INSTALLFILE ]; then
    qemu-img create -f qcow2 $INSTALLFILE $FILESIZE
fi

QEMU_PA_SAMPLES=4096 QEMU_AUDIO_DRV=pa \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd `# SID version of OVMF` \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$INSTALLCD,if=none,id=drive-ide0-0-0,readonly=on,format=raw \
-device ide-cd,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
-drive file=$INSTALLFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=unsafe \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 \
-drive file=$DRIVERCD,if=none,id=drive-ide0-1-0,readonly=on,format=raw \
-device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-1-0,id=ide0-1-0,bootindex=3 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-tablet \
-device usb-kbd

--------------------------------------------------- ende -------------------------------------------

kvm-start.sh
--------------------------------------------------- anfang -------------------------------------------
#!/bin/bash

INSTALLFILE=win7-uefi-x64_system.qcow2
IMAGEFILE=win7-uefi-x64_system-01.qcow2
#FILESIZE=50G

# PCI address of the passtrough devices
DEVICE1="01:00.0"
DEVICE2="01:00.1"

# load vfio-pci module
modprobe vfio-pci

for dev in "0000:$DEVICE1" "0000:$DEVICE2"; do
        vendor=$(cat /sys/bus/pci/devices/${dev}/vendor)
        device=$(cat /sys/bus/pci/devices/${dev}/device)
        if [ -e /sys/bus/pci/devices/${dev}/driver ]; then
                echo ${dev} > /sys/bus/pci/devices/${dev}/driver/unbind
        fi
        echo $vendor $device > /sys/bus/pci/drivers/vfio-pci/new_id
done

# create a imagefile from backingfile file if not exist
if [ ! -e $IMAGEFILE ]; then
    qemu-img create -f qcow2 -o backing_file=$INSTALLFILE,backing_fmt=qcow2 $IMAGEFILE
fi


QEMU_PA_SAMPLES=6144 QEMU_AUDIO_DRV=pa \
taskset -c 0-1 \
qemu-system-x86_64 \
-enable-kvm \
-m 4096 \
-cpu host,kvm=off \
-smp 2,sockets=1,cores=2,threads=1 \
-machine pc-i440fx-2.1,accel=kvm \
-soundhw hda \
-bios /usr/share/ovmf/OVMF.fd `# SID version of OVMF` \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=on,x-vga=on \
-device vfio-pci,host=$DEVICE2,addr=0x8.0x1 \
-vga none \
-device qxl \
-device virtio-net-pci,netdev=user.0,mac=52:54:00:a0:66:43 \
-netdev user,id=user.0 \
-drive file=$IMAGEFILE,if=none,id=drive-virtio-disk0,format=qcow2,cache=none \
-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 \
-rtc base=localtime,driftfix=slew \
-smb /home/user/Downloads/toinstall \
-usb \
-device usb-mouse \
-device usb-kbd
 
--------------------------------------------------- ende ------------------------------------------- 


HOWTO Debian Jessie 8 pci_stub config to hide PCI devices from device modules

# If you have to hide a PCI device like a GPU, you can use pci_stub

# to get the PCI port of your PCI device you can use lspci

   lspci

   ...
   01:00.0 VGA compatible controller: NVIDIA Corporation GK110 
   [GeForce GTX 780] (rev a1)   01:00.1 Audio device: NVIDIA Corporation GK110 HDMI Audio (rev a1)
   ...

# the GPU use the PCI Slot 01:00.0 and 01:00.1 for the Nvidia Audio device
# NOTE: It's important to passthrough both devices to the virtual machine.

# for pci_stub, we need the IDs, with "lspci -n" we see this IDs

   lspci
   ...
   01:00.0 0300: 10de:1004 (rev a1)
   01:00.1 0403: 10de:0e1a (rev a1)
   ...


# Use the grub cmdline for pci_stub initializations

sudo nano /etc/default/grub

# change GRUB_CMDLINE_LINUX_DEFAULT
# from "quiet" to
# "quiet intel_iommu=on pci_stub.ids=10de:1004,10de:0e1a"
# after save start update-grub

   sudo update-grub2

# Add pci_stub to the end of /etc/initramfs-tools/modules and update the initramfs

    sudo update-initramfs -u

# After this the pci_stub kernel line parameter is working.

# Now reboot and the given devices will not working until you wont this.

Donnerstag, 11. Juni 2015

HOWTO Debian Jessie 8 Kernel patch i915 VGA arbiter

# i915 VGA arbiter patch for Debian Jessie 8

   cd ~
   sudo apt-get install fakeroot build-essential devscripts quilt
   sudo apt-get build-dep

   mkdir src
   cd src
   apt-get source linux

# quilt instruction
# now you need the Patch
# i915 VGA arbiter patch from Alex Williamson
# save Patch between the lines with "---" as file "i915.patch" directly in new folder src
# NOTE: linux-3.16.7-ckt9 is the current version from 08.06.2015, this version can change # in the future.

   cd linux-3.16.7-ckt9/

   quilt import ../i915.patch
#     Importiere Patch ../i915.patch (abgelegt als 
#     debian/patches/i915.patch)

   quilt push i915.patch
#     ...
#     Patch debian/patches/i915.patch does not apply (enforce with -f)

   quilt push i915.patch -f
#     Wende Patch debian/patches/i915.patch an
#     patching file drivers/gpu/drm/i915/i915_dma.c
#     Hunk #1 succeeded at 1314 (offset 8 lines).
#     Hunk #2 succeeded at 1385 (offset 6 lines).
#     patching file drivers/gpu/drm/i915/i915_drv.h
#     Hunk #1 FAILED at 2080.
#     1 out of 1 hunk FAILED -- saving rejects to file 
#     drivers/gpu/drm/i915/i915_drv.h.rej
#     patching file drivers/gpu/drm/i915/i915_params.c
#     Hunk #1 FAILED at 47.
#     Hunk #2 FAILED at 152.
#     2 out of 2 hunks FAILED -- saving rejects to file 
#     drivers/gpu/drm/i915/i915_params.c.rej
#     patching file drivers/gpu/drm/i915/intel_display.c
#     Hunk #1 succeeded at 11748 (offset 464 lines).
#     Hunk #2 succeeded at 12108 (offset 487 lines).
#     Hunk #3 succeeded at 12370 (offset 494 lines).
#     patching file drivers/gpu/drm/i915/intel_drv.h
#     Hunk #1 succeeded at 997 (offset 63 lines).
#     patching file include/linux/vgaarb.h
#     Applied patch debian/patches/i915.patch (forced; needs refresh)

# Now open the *.rej files and patch the corresponding *.c files manually, then
# refresh the patch.

   quilt refresh i915.patch
#     Refreshed patch debian/patches/i915.patch

# save the patch from debian/patches/i915.patch for the next kernel update
# Instructions to compile the kernel the debian way.

# the first part it done on the top, I use the part to compile

# copy the config of your running kernel
# NOTE: the config filename can change in the future

   cp /boot/config-3.16.0-4-amd64 .config

# disable DEBUG_INFO if you don't want this.

   scripts/config --disable DEBUG_INFO

# If you have to rebuild, you can clean the files

   make clean

# The -j 4 depends on your cores, here I have a 4 x core CPU

   make deb-pkg -j 4
#     ...
#     dpkg-deb: building package `linux-image-3.16.7-ckt9' in 
#     `../linux-image-3.16.7-ckt9_3.16.7-ckt9-1_amd64.deb'.

# The kernel packages will build in the src folder, now you can install it.
# NOTE: Every kernel build will generate a new file, if you not delete them.

   sudo dpkg -i ../linux-image-3.16.7-ckt9_3.16.7-ckt9-1_amd64.deb

# Reboot and check, if all is working normal.

# Use the grub cmdline to activate the i915 patch

sudo nano /etc/default/grub

# change GRUB_CMDLINE_LINUX_DEFAULT
# from "quiet" to
# "quiet intel_iommu=on i915.enable_hd_vgaarb=1"
# after save start update grub

   sudo update-grub


# Now you can use the instructions on https://bbs.archlinux.org/viewtopic.php?id=162768