User:Andy Crowd/QEMU

From ArchWiki

Direct connect physical devices

Direct connect USB device

$ lsusb | grep Huawei
Bus 001 Device 009: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
</nowiki> 
--enable-kvm -usb -device usb-host,hostbus=1,hostaddr=9

KVM modules

List all needed for kvm kernel modules

$ ls -R /lib/modules/`uname -r`/kernel/ | grep -e virt -e 9p -e kvm | awk -F'.' '{print $1}' | grep -v -e '/' -e amd | sort

Run boot-able ISO with QEMU

ISO mime types:

application/x-iso9660-image; charset=binary
application/octet-stream; charset=binary

Check if ISO is bootable and run QEMU if it is.

iso-run.sh
#!/bin/bash
if [ 'XX'"$1" != 'XX' ]; then
 if [ -f "$1" ];then
IfExec=$(isoinfo -d -i "$1" | grep '(bootable)')
  if [  'XX'"$IfExec" != 'XX'  ]; then
qemu-system-x86_64 -soundhw ac97  -k sv -vga std -machine accel=kvm,kernel_irqchip=on -cpu host -m 1G -cdrom "$1"
  else echo The '"' "$1" '"' is NOT boot-able.
  fi
 else echo The '"' "$1" '"' is not valid.
 fi
else Use path to the bootable ISO file
fi

In the examples are used KVM modules that need to be loaded depends on your system architecture.

#kvm
#kvm-amd   # For AMD CPUs
#kvm-intel # For Intel CPUs

List more details about specific options

$ qemu-system-x86_64 -soundhw help
qemu-system-x86_64 -soundhw help
Valid sound card names (comma separated):
sb16        Creative Sound Blaster 16
es1370      ENSONIQ AudioPCI ES1370
ac97        Intel 82801AA AC97 Audio
adlib       Yamaha YM3812 (OPL2)
gus         Gravis Ultrasound GF1
cs4231a     CS4231A
hda         Intel HD Audio
pcspk       PC speaker

-soundhw all will enable all of the above
$ qemu-system-x86_64 -audio-help | grep 'Name'
Name: spice
Name: pa
Name: alsa
Name: sdl
Name: none
Name: wav

Set pulseaudio output and input

export QEMU_AUDIO_DRV=pa
export QEMU_PA_SINK=alsa_output.pci-0000_04_01.0.analog-stereo.monitor
export QEMU_PA_SOURCE=input

Start ISO from the command line

$ qemu-system-x86_64 -soundhw ac97 -k sv -vga std -machine accel=kvm,kernel_irqchip=on -cpu host -m 1G -cdrom  wmlive_2013-06-05-amd64.iso

Create shortcut for use with xdg-mime:

/usr/share/applications/qemu-x86_64-run-cdrom.desktop
[Desktop Entry]
Name=qemu x86_64
Comment=Hardware emulator for x86_64 CD-ROM images
MimeType=application/octet-stream
Exec=qemu-system-x86_64 -soundhw ac97 -k sv -vga std -machine accel=kvm,kernel_irqchip=on -cpu host -m 1G -cdrom
Terminal=false
Type=Application
Encoding=UTF-8
Icon=qemu_48x48
Categories=System;Emulator;


Associate the shortcut with the mime type:

xdg-mime default qemu-x86_64-run-cdrom.desktop application/octet-stream