Created
November 11, 2018 14:12
-
-
Save neuthral/078472957bd05d2e29ae6cd2964342c8 to your computer and use it in GitHub Desktop.
qemu example script #cli #qemu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
configfile=/etc/vfio-pci0.cfg | |
vfiobind() { | |
dev="$1" | |
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 | |
} | |
modprobe vfio-pci | |
cat $configfile | while read line;do | |
echo $line | grep ^# >/dev/null 2>&1 && continue | |
vfiobind $line | |
done | |
# ,romfile=XFX.HD7950.3072.121021.rom | |
sudo qemu-system-x86_64 -enable-kvm -M q35 -m 2048 -cpu host -smp 4,sockets=1,cores=2,threads=1 \ | |
-bios /usr/share/qemu/bios.bin -vga none \ | |
-device ioh3420,bus=pcie.0,addr=1c.0,multifunction=on,port=1,chassis=1,id=root.1 \ | |
-device piix4-ide,bus=pcie.0,id=piix4-ide \ | |
-device vfio-pci,host=02:00.0,bus=root.1,addr=00.0,multifunction=on,x-vga=on \ | |
-drive file=/home/bender/win_tiny7.img,id=disk,format=raw -device ide-hd,bus=ide.0,drive=disk \ | |
-boot menu=on | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment