Skip to content

Instantly share code, notes, and snippets.

@markzz
Created March 8, 2016 02:09
Show Gist options
  • Save markzz/6c80a3f43b988a6f3dd9 to your computer and use it in GitHub Desktop.
Save markzz/6c80a3f43b988a6f3dd9 to your computer and use it in GitHub Desktop.
#!/bin/bash
INSTALLFILE=win10-uefi-x64_system.qcow2
IMAGEFILE=win10-uefi-x64_system-01.qcow2
#FILESIZE=50G
# PCI address of the passtrough devices
DEVICE1="02:00.0"
DEVICE2="02: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} | sudo tee /sys/bus/pci/devices/${dev}/driver/unbind
fi
echo $vendor $device | sudo tee /sys/bus/pci/drivers/vfio-pci/new_id
done
# create an 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
# Stop Steam if running
echo "Stopping Steam if open!"
killall -9 steam
xrandr --output VGA-0 --off --output DVI-0 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-0 --off
echo "Starting Synergy"
/usr/bin/synergys --daemon --config /etc/synergy.conf
QEMU_AUDIO_DRV=pa \
qemu-system-x86_64 \
-serial none \
-parallel none \
-nodefaults \
-nodefconfig \
-enable-kvm \
-m 10240 \
-cpu host,kvm=off,check \
-smp threads=2,cores=4,sockets=1 \
-name Windows\ 10 \
-machine pc,accel=kvm \
-soundhw hda \
-usb \
-device ich9-usb-uhci3,id=uhci \
-device usb-ehci,id=ehci \
-device nec-usb-xhci,id=xhci \
-usbdevice mouse \
-monitor unix:./win10.sock,server,nowait \
-bios /usr/share/ovmf/x64/ovmf_x64.bin `# SID version of OVMF` \
-device vfio-pci,host=$DEVICE1,addr=0x8.0x0,multifunction=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,drive=drive-virtio-disk0 \
-drive file=/dev/sdc,if=none,index=1,id=drive-virtio-disk1,media=disk,format=raw \
-device virtio-blk-pci,drive=drive-virtio-disk1 \
-rtc base=localtime,driftfix=slew \
-nographic \
-smb /var/VMs/win10/shared \
-daemonize
#-hdb /dev/sdc
lsusb
nc -U ./win10.sock
echo "Stopping Synergy"
pkill synergys
xrandr --output VGA-0 --primary --mode 1920x1080 --pos 1920x0 --rotate normal --output DVI-0 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-0 --off
#-i440fx-2.1
#-device virtio-blk-pci,scsi=off,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment