Skip to content

Instantly share code, notes, and snippets.

@heisvoid
Created July 22, 2022 02:59
Show Gist options
  • Save heisvoid/1e9cb3e6bb60492ebde956c446131383 to your computer and use it in GitHub Desktop.
Save heisvoid/1e9cb3e6bb60492ebde956c446131383 to your computer and use it in GitHub Desktop.
kvm/qemu command example
#!/bin/sh
OPTS=""
OPTS="$OPTS -nodefaults"
OPTS="$OPTS -enable-kvm"
OPTS="$OPTS -cpu host,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time"
OPTS="$OPTS -smp 4"
OPTS="$OPTS -m 4G"
OPTS="$OPTS -usb -device usb-tablet"
OPTS="$OPTS -rtc base=utc,clock=host"
OPTS="$OPTS -nic user,ipv6=off,model=virtio-net-pci"
OPTS="$OPTS -device virtio-balloon"
OPTS="$OPTS -object rng-random,filename=/dev/urandom,id=rng0"
OPTS="$OPTS -device virtio-rng-pci,rng=rng0"
OPTS="$OPTS -monitor telnet:127.0.0.1:5931,server,nowait"
OPTS="$OPTS -daemonize"
OPTS="$OPTS -vga qxl"
OPTS="$OPTS -device virtio-serial-pci"
OPTS="$OPTS -spice port=5930,disable-ticketing=on"
OPTS="$OPTS -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0"
OPTS="$OPTS -chardev spicevmc,id=spicechannel0,name=vdagent"
## virtio-scsi
OPTS="$OPTS -object iothread,id=iothread0"
OPTS="$OPTS -device virtio-scsi-pci,iothread=iothread0,id=scsi0"
OPTS="$OPTS -device scsi-hd,drive=hdd0,bus=scsi0.0"
OPTS="$OPTS -drive file=/home/heisvoid/.qemu/win10.cow,format=qcow2,discard=unmap,cache=none,cache-size=16M,id=hdd0,if=none"
## virtio-blk
#OPTS="$OPTS -drive file=/home/heisvoid/.qemu/win10-blk.cow,format=qcow2,discard=unmap,if=virtio"
OPTS="$OPTS -drive file=/home/heisvoid/tmp/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso,media=cdrom,index=2"
OPTS="$OPTS -drive file=/home/heisvoid/tmp/virtio-win-0.1.217.iso,media=cdrom,index=3"
/usr/bin/qemu-system-x86_64 $OPTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment