QEMU
QEMU🔗
=this.img
= ("[Website](" + this.url + ")")
| = ("[Source](" + this.source + ")")
| = ("[Documentation](" + this.docs + ")")
= ("> " + this.desc-short)
- emulation tools and standard virtual hardware: processors, network interfaces, graphics cards, …
- can be used to create VMs, especially for old or uncommon hardware (ARM, PowerPC, SPARC, …) but emulation is slow
- if processor supports virtualisation, QEMU can use KVM to directly access the systems hardware with near native performance
Commands🔗
Images🔗
qemu-img
: create and handle images ^qemu-img
1 2 3 4 5 6 7 |
|
- growing disk: expand filesystem after
- shrinking disk: resize filesystem first
- disk operations are risky - backup!
qemu-nbd
: mount and inspect images as network storage devices (nbd) that can then be mounted the regular way ^qemu-nbd
1 2 3 4 5 6 7 8 9 10 |
|
System: create and run VMs🔗
qemu-system-<architecture>
: create VM
1 2 3 4 5 6 7 8 9 10 11 |
|
- CPU architecture: SMP[^SMP] or 1
- Access display through VNC viewer remote desktop viewer.
0
refers to last digit of port5900
, use1
,2
and so forth for higher ports in case of multiple guests ^vnc - boot device (letters from DOS)
d
: CD-ROM devicec
: first hard drive
- after installation, start machine by dropping last 2 arguments to boot from disk
-
verify guest system hardware, e.g. with
1 2 3 4 5 6 7 8 9 10 11 12
# General info hostnamectl # Output # Virtualization: kvm # CPU info lscpu # device info lspci # usb info lsusb # memory info lsmem
- monitor and debug with option
-monitor stdio
, enterhelp
for available commandschange_vnc_password
together with-vnc :0,password=on
system_powerdown
Display🔗
Use VNC as described above or if guest has GUI, local video can be used alternatively, providing much improved performance.
-display
options: GTK, SDL, VNC, curses, none
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Storage and File Sharing🔗
See Images for creating and inter-operating with disk image files.
File-sharing between guest and host: Plan 9 Filesystem Protocol (9P)
1 2 3 4 5 |
|
On guest mount with
1 2 |
|
Check extended attributes on host with getfattr -d shared/file.txt
.
Devices🔗
Host hardware can be passed through to guest.
USB🔗
- v1.1, v2 or v3 (using xHCI if supported)
- option
-usbdevice
uses USB 1.1 -
set up bus and connect device
1 2 3 4 5 6 7 8 9 10 11 12
# find usb device on host: bus, device/port, vendor id, product id lsusb # Create guest bus and connect device: # Accessing host USB devices requires root or setting up udev for user. # NOTE: -display gtk did not work for me with sudo (missing display permissions?), used -vnc :0 for this sudo qemu-system \ ... \ -vnc :0 \ -device qemu-xhci,id=xhci \ -device usb-host,bus=xhci.0,vendorid=0x$vendorid,productid=0x$productid # or access USB port (bus and device in lsusb output) -device usb-host,bus=xhci.0,hostbus=1,hostport=5
- if device is unplugged/not plugged in, QEMU keeps checking for it
- to make device available to host again, guest has to be shut down
Networking🔗
- user-mode networking on private NAT
Role | IP |
---|---|
DHCP | 10.0.2.2 |
DNS (forwarding) | 10.0.2.3 |
SMB | 10.0.2.4 |
Guest | 10.0.2.15 |