Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- NVRAM_IMAGE=$1
- VM_IMAGE=$2
- DRIVE_IMAGE=$3
- QEMU_COMMAND_LINE=(
- /usr/bin/qemu-system-x86_64
- # Set name for top qemu process, name individual threads
- -name guest=tests,debug-threads=on
- # Do not start CPU at startup
- # -S
- # Choose emulated machine type and specify its properties
- # TODO: read about all the options
- -machine pc-q35-4.2,accel=kvm,usb=off,vmport=off,dump-guest-core=off,kernel_irqchip=on,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format
- # Select CPU model and its options
- # TODO: read about all the options
- -cpu "host,topoext=on,svm=off,apic=on,hypervisor=on,migratable=no,invtsc=on,kvm-pv-eoi=on,hv-time,hv-relaxed,hv-vapic,hv-spinlocks=0x1fff,hv-vpindex,hv_time,-x2apic,hv-reset,hv-vendor-id=ASUS X399-A,hv-frequencies,hv-reenlightenment,kvm=off"
- # RAM
- -m 8192
- # Tells qemu that host will or won't overcommit its resources, so qemu could lock memory and manage power state of host cpus
- -overcommit mem-lock=on,cpu-pm=on
- # CPU Topology settings
- -smp 12,sockets=1,cores=6,threads=2
- # Spawn IO thread that will serve guest IO requests
- -object iothread,id=iothread1
- # Machine UUID that is stored in SMBIOS
- -uuid 43a7c3e6-65f8-46f9-acd7-2661ea29b029
- # Do not load configs from sysconfdir
- -no-user-config
- # Do not create default devices: serial port, floppy, etc.
- #-nodefaults
- # Specify where emulated RTC gets time from. Also enable time drift fix
- -rtc base=localtime,driftfix=slew
- # Donβt exit QEMU on guest shutdown
- # -no-shutdown
- # -global driver.property=value; e.g. sets value of property "lost_tick_policy" for driver "kvm-pit"
- -global kvm-pit.lost_tick_policy=discard
- -global ICH9-LPC.disable_s3=1
- -global ICH9-LPC.disable_s4=1
- # Show EFI menu and use strict boot. TODO: what is strict boot?
- -boot menu=on,strict=on
- # Enable the spice remote desktop protoco
- # -spice port=5900,addr=127.0.0.1,disable-ticketing,image-compression=off,seamless-migration=on
- # Enable Seccomp mode 2 system call filter
- -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny
- # Prefix error messages with a timestamp
- -msg timestamp=on
- # Configure display. -display help. Also -nographic may be convenient
- -display gtk
- # -nographic
- # setup NoCloud cloud-init provider
- -smbios "type=1,serial=ds=nocloud-net;s=http://192.168.17.7:8000/"
- # Add monitor tab to gtk window
- # -monitor vc
- # Open command line monitor
- # -monitor stdio
- # Redirect monitor to socket. Then use `socat -,echo=0,icanon=0 unix-connect:qemu-monitor-socket` to open the monitor
- #-monitor unix:qemu-monitor-socket,server,nowait
- # Logging
- # -debugcon file:debug.log -global isa-debugcon.iobase=0x402
- # -serial file:serial.log
- #-serial null
- # ======================================== DEVICES ========================================
- #
- # -device driver[,prop[=value][,...]]
- # Add device driver. prop=value sets driver properties.
- # Valid properties depend on the driver. To get help on possible drivers and properties, use -device help and -device driver,help.
- # TODO: pcie-root-port, qemu-xhci, virtio-input-host-pci, qxl-vga
- # Add PCI slots
- -device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,addr=0x2
- -device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1
- # Add evdev passthrough
- -device virtio-input-host-pci,id=input2,evdev=/dev/input/qemu-virtual-keyboard,bus=pci.1,addr=0x0
- -device virtio-input-host-pci,id=input3,evdev=/dev/input/qemu-virtual-mouse,bus=pci.2,addr=0x0
- # NVMe passthrough
- -device pcie-root-port,port=0x13,chassis=4,id=pci.3,bus=pcie.0,addr=0x2.0x2
- -device vfio-pci,host=0000:09:00.0,id=hostdev0,bus=pci.3,addr=0x0
- # GPU passthrough
- -device pcie-root-port,id=gpu-port,chassis=0,slot=0,bus=pcie.0
- -set device.gpu-port.x-speed=8
- -set device.gpu-port.x-width=16
- -device vfio-pci,host=0a:00.0,bus=gpu-port,addr=00.0,multifunction=on
- -device vfio-pci,host=0a:00.1,bus=gpu-port,addr=00.1
- # USB passtrhough
- #-usb
- #-device usb-host,vendorid=0x04b8,productid=0x1121
- # Configure rootless network using existing TAP
- -netdev tap,id=network0,ifname=qtap,script=no,downscript=no
- -device e1000,netdev=network0,mac=52:54:00:12:34:56
- # Configure rootless user mode host network backend
- # -netdev user,id=network0,restrict=off
- # -device e1000,netdev=network0,mac=52:54:00:12:34:56
- # Add USB controller
- # -device qemu-xhci,id=usb,bus=pci.2,addr=0x0
- # Add vGPU
- #-device qxl-vga,id=video0,ram_size=134217728,vram_size=134217728,vram64_size_mb=0,vgamem_mb=128,max_outputs=1
- # Configure root drive
- -device ide-hd,drive=root_disk
- -drive if=none,id=root_disk,cache=none,aio=native,file=${VM_IMAGE}
- # Configure cdrom
- #-cdrom ${DRIVE_IMAGE}
- # -cdrom ${VM_IMAGE}
- # Attach program flash drive that stores OVMF UEFI firmware
- -blockdev "{'driver':'file','filename':'/usr/share/OVMF/OVMF_CODE.fd','node-name':'libvirt-pflash0-storage','auto-read-only':true,'discard':'unmap'}"
- -blockdev "{'node-name':'libvirt-pflash0-format','read-only':true,'driver':'raw','file':'libvirt-pflash0-storage'}"
- # Attach program flash drive that stores OVMF UEFI variables
- -blockdev "{'driver':'file','filename': \"${NVRAM_IMAGE}\",'node-name':'libvirt-pflash1-storage','auto-read-only':true,'discard':'unmap'}"
- -blockdev "{'node-name':'libvirt-pflash1-format','read-only':false,'driver':'raw','file':'libvirt-pflash1-storage'}"
- # Add characted device. Help: -chardev help. TODO: pty backend
- # -chardev pty,id=charserial0
- # -device isa-serial,chardev=charserial0,id=serial0
- # Add characted device. Help: -chardev help. TODO: spicevmc backend
- # -chardev spicevmc,id=charchannel0,name=vdagent
- # -device virtio-serial-pci
- # -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0
- # Add characted device. Help: -chardev help. spicevmc: pty backend
- #-chardev spicevmc,id=spicechannel0,name=vdagent
- )
- "${QEMU_COMMAND_LINE[@]}"
Add Comment
Please, Sign In to add comment