From 86bbee3264360de8ab5f8d2b277ac7d1045d0b80 Mon Sep 17 00:00:00 2001
From: johannst %N.Mf
, N
is the total number in
M
.
sprintf("fmt", expr, ...)
Format the expressions according to the format string. Similar as printf
,
+but this is a function and return value can be assigned to a variable.
strftime("fmt")
Print time stamp formatted by fmt
.
echo 'a b c d e f' | awk '{ print $NF $(NF-1) }'
-Access last fields with arithmetic on the NR
number of fields variable.
Access last fields with arithmetic on the NF
number of fields variable.
# /proc/<pid>/status
# Name: cat
diff --git a/tools/qemu.html b/tools/qemu.html
index 03fd8bc..fc88733 100644
--- a/tools/qemu.html
+++ b/tools/qemu.html
@@ -169,44 +169,55 @@ Ctrl+a c switch between monitor and console
Following command-line gives a good starting point to assemble a VM:
-qemu-system-x86_64 \
- -cpu host -enable-kvm -smp 4 \
- -m 8G \
- -vga virtio -display sdl,gl=on \
- -boot menu=on \
- -cdrom <iso> \
- -hda <disk> \
- -device qemu-xhci,id=xhci \
- -device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408,id=capture-card
+qemu-system-x86_64 \
+ -cpu host -enable-kvm -smp 4 \
+ -m 8G \
+ -vga virtio -display sdl,gl=on \
+ -boot menu=on \
+ -cdrom <iso> \
+ -hda <disk> \
+ -device qemu-xhci,id=xhci \
+ -device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408,id=capture-card
CPU & RAM
-
--cpu host
emulate host CPU in guest VM
--enable-kvm
use KVM instead software models (requires KVM on host machine)
--smp <N>
number of guest CPUs
-
-
-List available CPUs qemu-system-x86_64 -cpu help
.
-
-
--m 8G
size of guest RAM
-
+# Emulate host CPU in guest VM, enabling all supported host featured (requires KVM).
+# List available CPUs `qemu-system-x86_64 -cpu help`.
+-cpu host
+
+# Enable KVM instead software emulation.
+-enable-kvm
+
+# Configure number of guest CPUs.
+-smp <N>
+
+# Configure size of guest RAM.
+-m 8G
+
Graphic & Display
-
--vga virtio
use virtio as 3D video graphic accelerator (requires virgl in guest)
--display sdl,gl=on
use sdl window and enable openGL context
-
+# Use sdl window as display and enable openGL context.
+-display sdl,gl=on
+
+# Use vnc server as display (eg on display `:42` here).
+-display vnc=localhost:42
+
+# Confifure virtio as 3D video graphic accelerator (requires virgl in guest).
+-vga virtio
+
Boot Menu
-
--boot menu=on
enables boot menu to select boot device (enter with ESC
)
-
+# Enables boot menu to select boot device (enter with `ESC`).
+-boot menu=on
+
Block devices
-
--cdrom <iso>
attach cdrom drive with iso to a VM
--hda <disk>
attach disk drive to a VM
--drive file=<file>,format=qcow2
generic way to configure & attach a drive to a VM
-
-Create a disk with qemu-img
+# Attach cdrom drive with iso to a VM.
+-cdrom <iso>
+
+# Attach disk drive to a VM.
+-hda <disk>
+
+# Generic way to configure & attach a drive to a VM.
+-drive file=<file>,format=qcow2
+
+Create a disk with qemu-img
To create a qcow2
disk (qemu copy-on-write) of size 10G
:
qemu-img create -f qcow2 disk.qcow2 10G
@@ -231,24 +242,78 @@ lsblk -f /dev/sda
-device qemu-xhci,id=xhci
add XHCI USB controller to the VM (supports USB 3.0, 2.0, 1.1). id=xhci
creates a usb bus named xhci
.# Add XHCI USB controller to the VM (supports USB 3.0, 2.0, 1.1).
+# `id=xhci` creates a usb bus named `xhci`.
+-device qemu-xhci,id=xhci
+
-device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408
pass-through USB device from host identified by vendorid & productid and attach to usb bus xhci.0
(defined with controller id
)# Pass-through USB device from host identified by vendorid & productid and
+# attach to usb bus `xhci.0` (defined with controller `id`).
+-device usb-host,bus=xhci.0,vendorid=0x05e1,productid=0x0408
+
-gdb tcp::<port>
open gdbstub on tcp <port>
(-s
shorthand for -gdb tcp::1234
).-S
freeze CPU at startup.# Open gdbstub on tcp `<port>` (`-s` shorthand for `-gdb tcp::1234`).
+-gdb tcp::<port>
+
+# Freeze guest CPU at startup and wait for debugger connection.
+-S
+
+# Create raw tcp server for `serial IO` and wait until a client connects
+# before executing the guest.
+-serial tcp:localhost:12345,server,wait
+
+# Create telnet server for `serial IO` and wait until a client connects
+# before executing the guest.
+-serial telnet:localhost:12345,server,wait
+
+# Configure redirection for the QEMU `mointor`, arguments similar to `-serial`
+# above.
+-monitor ...
+
+++In
+server
mode usenowait
to execute guest without waiting for a client +connection.
# Redirect host tcp port `1234` to guest port `4321`.
+-nic user,hostfwd=tcp:localhost:1234-:4321
+
+# Attach a `virtio-9p-pci` device to the VM.
+# The guest requires 9p support and can mount the shared drive as:
+# mount -t 9p -o trans=virtio someName /mnt
+-virtfs local,id=someName,path=<someHostPath>,mount_tag=someName,security_model=none
+
+# List name of all trace points.
+-trace help
+
+# Enable trace points matching pattern and optionally write trace to file.
+-trace <pattern>[,file=<file>]
+
+# Enable trace points for all events listed in the <events> file.
+# File must contain one event/pattern per line.
+-trace events=<events>
+
+Kernel
bootExample command line to directly boot a Kernel
with an initrd
ramdisk.
qemu-system-x86_64 \
+ -cpu host \
+ -enable-kvm \
+ -kernel <dir>/arch/x86/boot/bzImage \
+ -append "earlyprintk=ttyS0 console=ttyS0 nokaslr init=/init debug" \
+ -initrd <dir>/initramfs.cpio.gz \
+ ...
+
+Instructions to build a minimal Kernel
and initrd
.