enricorossi.org

Enrico Rossi


Update on the qemu-system-x86_64 command line arguments.

If you, like me, does not like to have the whole libvirt just to run some VMs a couple of times per month, here is my working example for the qemu, updated, as far as I know, to the next Debian version (11 aka Bullseye). Note the use of pulseaudio, which work perfectly now.

To connect to the VM use the spicy command and connect to localhost port 5900.

Running a Debian Buster image.

#!/bin/sh

GUEST_NAME=Debian_Buster
SPICE_PORT=5900
STORAGE_DEVICE=/dev/vg1/vps-deb10
CDROM_DEVICE=/srv/scratch/debian-10.8.0-amd64-netinst.iso
CDROM_DEVICE=
MAC_ADDR=52:54:12:34:56:78
UUID=cf5839c5-1aa5-4bbb-8c16-6943bda49d58

# PCI address:
# 0x01 - intel hda
# 0x02 - VGA
# 0x03 - virtio-net-pci
# 0x04 - USB controller
# 0x05 - virtio serial
# 0x06 - virtio-blk-pci
# 0x07 - balloon
# 0x08 - xUSB

# USB:
# 0x4 - ich9-usb-ehci1
# 04.00 -
# 04.01 - tablet
# 04.02 - redir
# 04.03 - redir
# 04.04 -
# 
qemu-system-x86_64 \
	-enable-kvm \
	-name $GUEST_NAME \
	-machine q35,accel=kvm \
	-cpu host \
	-m 4096 \
	-smp 2 \
	-uuid $UUID \
	\
	-audiodev pa,id=audio-pa \
	-device intel-hda,addr=0x01 \
	-device hda-duplex,audiodev=audio-pa \
	\
	-monitor stdio \
	-tc base=utc,driftfix=slew \
	\
	-drive file=$STORAGE_DEVICE,format=raw,if=none,id=drive-virtio-disk0,cache=none \
	-device virtio-blk-pci,addr=0x06,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=2 \
	-drive file=$CDROM_DEVICE,if=none,id=drive-ide0-0-0,readonly=on \
	-device ide-cd,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 \
	-boot order=dc,menu=on,splash-time=5000 \
	\
	-netdev user,id=hostnet0 \
	-device virtio-net-pci,addr=0x03,netdev=hostnet0,id=net0,mac=$MAC_ADDR \
	\
	-device qemu-xhci,addr=0x04.0,multifunction=on \
	-device qemu-xhci,addr=0x04.1 \
	\
	-device virtio-keyboard,addr=0d,multifunction=on \
	-device virtio-tablet,addr=0d.1 \
	\
	-device virtio-serial-pci,id=virtio-serial0,addr=0x05 \
	\
	-chardev spicevmc,id=charchannel0,name=vdagent \
	-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 \
	-spice port=5900,addr=127.0.0.1,disable-ticketing,seamless-migration=on \
	-device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,vram64_size_mb=0,vgamem_mb=16,max_outputs=1,addr=0x02 \
	\
	-chardev spicevmc,id=charredir0,name=usbredir \
	-device usb-redir,chardev=charredir0 \
	-chardev spicevmc,id=charredir1,name=usbredir \
	-device usb-redir,chardev=charredir1 \
	-chardev spicevmc,id=charredir2,name=usbredir \
	-device usb-redir,chardev=charredir2 \
	-chardev spicevmc,id=charredir3,name=usbredir \
	-device usb-redir,chardev=charredir3 \
	-chardev spicevmc,id=charredir4,name=usbredir \
	-device usb-redir,chardev=charredir4 \
	-chardev spicevmc,id=charredir5,name=usbredir \
	-device usb-redir,chardev=charredir5 \
	-chardev spicevmc,id=charredir6,name=usbredir \
	-device usb-redir,chardev=charredir6 \
	-chardev spicevmc,id=charredir7,name=usbredir \
	-device usb-redir,chardev=charredir7 \
	-chardev spicevmc,id=charredir8,name=usbredir \
	-device usb-redir,chardev=charredir8 \
	\
	-device virtio-balloon-pci,id=balloon0,addr=0x07 \
	-msg timestamp=on

exit

To run a windows 10 image the latest fedora virtio driver virtio-win-0.1.190.iso must be used.

On linux VMs I’m experiencing a little alignment problem with the mouse, not investigated yet.