Skip to content

Instantly share code, notes, and snippets.

@luqmana
Created December 16, 2020 03:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luqmana/8abd0f61e55e62e02043907ae83939ba to your computer and use it in GitHub Desktop.
Save luqmana/8abd0f61e55e62e02043907ae83939ba to your computer and use it in GitHub Desktop.
#!/bin/sh
# mkdir qemu-bionic
# cd qemu-bionic
# apt source qemu-kvm/bionic
# cd qemu-2.11*
# patch -p1 < ~/Develop/qemu-stuff/qemu-audio-fix.patch
# patch -p1 < ~/Develop/qemu-stuff/qemu-bionic-on-focal-fixes.patch
# DEBEMAIL="Luqman Aden <me@luqman.ca>" debchange -lluqman
# dpkg-buildpackage -rfakeroot -uc -b
# ~/valo/qemu-bionic/qemu-2.11+dfsg/debian/qemu-system-x86/usr/bin/qemu-system-x86_64
# qemu-img create -f qcow2 base.img 60G
# qemu-img create -f qcow2 -F qcow2 -b base.img snapshot.img
#cp /usr/share/OVMF/OVMF_CODE.fd .
#cp /usr/share/OVMF/OVMF_VARS.fd .
#sudoip tuntap add dev valonet mode tap
#sudoip link set dev valonet master vmbr
#sudoip link set dev valonet up
#sudo ip link set dev valonet nomaster
#sudo ip link del valonet
# -drive if=pflash,format=raw,readonly,file=/home/luqman/valo/OVMF_CODE.fd \
# -drive if=pflash,format=raw,file=/home/luqman/valo/OVMF_VARS.fd \
# -device ide-cd,drive=installdisk,id=cd-disk1,unit=0,bus=ide.0 \
# -drive file=/lfs/ISOs/OSs/en_windows_10_business_editions_version_2004_updated_nov_2020_x64_dvd_29ee42db.iso,if=none,id=installdisk,media=cdrom \
# -device ide-cd,drive=virtio-disk,id=cd-disk2,unit=0,bus=ide.1 \
# -drive file=/lfs/ISOs/Support/virtio-win.iso,if=none,id=virtio-disk,media=cdrom \
# Newer QEMU
# -audiodev pa,id=hda,server=localhost,out.stream-name=valovm \
# -device intel-hda -device hda-duplex,audiodev=hda \
# Skylake-Client-noTSX-IBRS
echo -n "Binding GFX Card..."
for dev in "0000:01:00.0" "0000:01:00.1"; 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}" | tee /sys/bus/pci/devices/${dev}/driver/unbind > /dev/null
while [ -e /sys/bus/pci/devices/${dev}/driver ]; do
sleep 0.1
done
fi
echo "${vendor} ${device}" | tee /sys/bus/pci/drivers/vfio-pci/new_id > /dev/null
done
echo "done"
export QEMU_AUDIO_DRV=pa
export QEMU_PA_SERVER="tcp:luq-home-pc:4713 tcp6:luq-home-pc:4713"
export QEMU_PA_ADJUST_LATENCY_IN=0
#/usr/bin/qemu-system-x86_64 \
/home/luqman/valo/qemu-bionic/qemu-2.11+dfsg/debian/qemu-system-x86/usr/bin/qemu-system-x86_64 \
-name guest=valo,debug-threads=on \
-serial none \
-enable-kvm \
-nodefaults \
-no-user-config \
-M q35,accel=kvm,kernel_irqchip=on,mem-merge=off \
-m 8192 -mem-prealloc -no-hpet \
-cpu host,kvm=off,l3-cache=on,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,hv_vendor_id=3dfx,+invtsc \
-smp 8,sockets=1,cores=4,threads=2 \
-smbios 'type=0,vendor=American Megatrends Inc.,version=F2b,date=10/26/2017,release=5.12' \
-smbios 'type=1,manufacturer=Gigabyte Technology Co.,, Ltd.,product=Z370N WIFI,uuid=ec1fcce2-283f-41da-bf77-c177d8f3ecfd' \
-global kvm-pit.lost_tick_policy=discard \
-rtc base=localtime \
-boot order=c \
-usb \
-device pcie-root-port,bus=pcie.0,id=root_port1,chassis=0,slot=0 \
-device vfio-pci,host=01:00.0,id=hostdev1,bus=root_port1,addr=0x00,multifunction=on \
-device vfio-pci,host=01:00.1,id=hostdev2,bus=root_port1,addr=0x00.1 \
-drive if=pflash,format=raw,readonly,file=/home/luqman/valo/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/home/luqman/valo/OVMF_VARS.fd \
-drive if=none,id=drivec,file=/home/luqman/valo/snapshot.img,format=qcow2,cache=none,aio=threads \
-object iothread,id=iothread1 \
-device virtio-blk-pci,drive=drivec,scsi=off,iothread=iothread1 \
-monitor unix:/tmp/monitor.sock,server,nowait \
-device virtio-mouse-pci,id=input0 \
-device virtio-keyboard-pci,id=input1 \
-object input-linux,id=kbd1,evdev=/dev/input/by-id/usb-DELL_Alienware_Advanced_Gaming_Keyboard_AW568_000000000000-if01-event-kbd,grab_all=yes,repeat=on \
-object input-linux,id=mouse1,evdev=/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse \
-netdev tap,ifname=valonet,id=net0,script=no,downscript=no \
-device e1000,netdev=net0,mac=52:54:00:2f:60:f6 \
-device ich9-intel-hda -device hda-duplex
<domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
<name>valo</name>
<uuid>a1948fa9-3945-491e-a07e-cde9ba4a0ece</uuid>
<title>Valorant VM</title>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://microsoft.com/win/10"/>
</libosinfo:libosinfo>
</metadata>
<memory unit="KiB">8388608</memory>
<currentMemory unit="KiB">8388608</currentMemory>
<vcpu placement="static">8</vcpu>
<iothreads>1</iothreads>
<cputune>
<vcpupin vcpu="0" cpuset="2"/>
<vcpupin vcpu="1" cpuset="8"/>
<vcpupin vcpu="2" cpuset="3"/>
<vcpupin vcpu="3" cpuset="9"/>
<vcpupin vcpu="4" cpuset="4"/>
<vcpupin vcpu="5" cpuset="10"/>
<vcpupin vcpu="6" cpuset="5"/>
<vcpupin vcpu="7" cpuset="11"/>
<emulatorpin cpuset="0,6"/>
<iothreadpin iothread="1" cpuset="0,6"/>
</cputune>
<os>
<type arch="x86_64" machine="pc-q35-2.11">hvm</type>
<loader readonly="yes" type="pflash">/usr/share/OVMF/OVMF_CODE.fd</loader>
<nvram>/var/lib/libvirt/qemu/nvram/valo_VARS.fd</nvram>
</os>
<features>
<acpi/>
<apic/>
<hyperv>
<relaxed state="on"/>
<vapic state="on"/>
<spinlocks state="on" retries="8191"/>
<vpindex state="on"/>
<runtime state="on"/>
<synic state="on"/>
<stimer state="on"/>
<vendor_id state="on" value="SHHHHHHHHHHH"/>
<evmcs state="off"/>
</hyperv>
<kvm>
<hidden state="on"/>
</kvm>
<vmport state="off"/>
<ioapic driver="kvm"/>
</features>
<cpu mode="host-passthrough" check="none">
<topology sockets="1" cores="4" threads="2"/>
<cache mode="passthrough"/>
<feature policy="require" name="invtsc"/>
</cpu>
<clock offset="localtime">
<timer name="rtc" present="no" tickpolicy="catchup"/>
<timer name="pit" present="no" tickpolicy="discard"/>
<timer name="hpet" present="no"/>
<timer name="kvmclock" present="no"/>
<timer name="hypervclock" present="yes"/>
<timer name="tsc" present="yes" mode="native"/>
</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/local/bin/qemu-2.11-system-x86_64</emulator>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" cache="writeback" io="threads"/>
<source file="/var/lib/libvirt/images/valo.qcow2"/>
<target dev="vda" bus="virtio"/>
<boot order="1"/>
<address type="pci" domain="0x0000" bus="0x03" slot="0x00" function="0x0"/>
</disk>
<controller type="usb" index="0" model="qemu-xhci" ports="15">
<address type="pci" domain="0x0000" bus="0x02" slot="0x00" function="0x0"/>
</controller>
<controller type="sata" index="0">
<address type="pci" domain="0x0000" bus="0x00" slot="0x1f" function="0x2"/>
</controller>
<controller type="pci" index="0" model="pcie-root"/>
<controller type="pci" index="1" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="1" port="0x8"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x0" multifunction="on"/>
</controller>
<controller type="pci" index="2" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="2" port="0x9"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x1"/>
</controller>
<controller type="pci" index="3" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="3" port="0xa"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x2"/>
</controller>
<controller type="pci" index="4" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="4" port="0xb"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x3"/>
</controller>
<controller type="pci" index="5" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="5" port="0xc"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x4"/>
</controller>
<controller type="pci" index="6" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="6" port="0xd"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x5"/>
</controller>
<controller type="pci" index="7" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="7" port="0xe"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x6"/>
</controller>
<controller type="pci" index="8" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="8" port="0xf"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x01" function="0x7"/>
</controller>
<controller type="pci" index="9" model="pcie-root-port">
<model name="pcie-root-port"/>
<target chassis="9" port="0x10"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x02" function="0x0"/>
</controller>
<interface type="network">
<mac address="52:54:00:eb:de:68"/>
<source network="guest-vm-net"/>
<model type="e1000e"/>
<address type="pci" domain="0x0000" bus="0x01" slot="0x00" 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>
<input type="keyboard" bus="virtio">
<address type="pci" domain="0x0000" bus="0x07" slot="0x00" function="0x0"/>
</input>
<input type="mouse" bus="virtio">
<address type="pci" domain="0x0000" bus="0x08" slot="0x00" function="0x0"/>
</input>
<input type="mouse" bus="ps2"/>
<input type="keyboard" bus="ps2"/>
<sound model="ich9">
<address type="pci" domain="0x0000" bus="0x00" slot="0x1b" 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="0x04" slot="0x00" 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="0x05" slot="0x00" function="0x0"/>
</hostdev>
<memballoon model="virtio">
<address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
</memballoon>
</devices>
<qemu:commandline>
<qemu:arg value="-object"/>
<qemu:arg value="input-linux,id=kbd1,evdev=/dev/input/by-id/usb-DELL_Alienware_Advanced_Gaming_Keyboard_AW568_000000000000-if01-event-kbd,grab_all=yes,repeat=on"/>
<qemu:arg value="-object"/>
<qemu:arg value="input-linux,id=mouse1,evdev=/dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-mouse"/>
<qemu:arg value="-smbios"/>
<qemu:arg value="type=0,vendor=American Megatrends Inc.,version=F2b,date=10/26/2017,release=5.12"/>
<qemu:arg value="-smbios"/>
<qemu:arg value="type=1,manufacturer=Gigabyte Technology Co.,, Ltd.,product=Z370N WIFI,uuid=ec1fcce2-283f-41da-bf77-c177d8f3ecfd"/>
<qemu:env name="QEMU_AUDIO_DRV" value="pa"/>
<qemu:env name="QEMU_PA_SERVER" value="tcp:luq-home-pc:4713 tcp6:luq-home-pc:4713"/>
<qemu:env name="QEMU_PA_ADJUST_LATENCY_IN" value="0"/>
</qemu:commandline>
</domain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment