QEMU(1)
πΈ QEMU(1) πΈ
ok so this is the QEMU manual page, bestie β like, the whole qemu / qemu-kvm user documentation situation. buckle up, it's a long one π
β¨ NAME β¨
qemu β QEMU User Documentation π«Ά
β¨ SYNOPSIS β¨
qemu-kvm [options] [disk_image]
β¨ DESCRIPTION β¨
so the QEMU PC System emulator simulates all of these peripherals, and honestly the list is giving museum of vintage hardware:
- i440FX host PCI bridge and PIIX3 PCI to ISA bridge
- Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA extensions (hardware level, including all non standard modes).
- PS/2 mouse and keyboard
- 2 PCI IDE interfaces with hard disk and CD-ROM support
- Floppy disk
- PCI and ISA network adapters
- Serial ports
- IPMI BMC, either an internal or external one
- Creative SoundBlaster 16 sound card
- ENSONIQ AudioPCI ES1370 sound card
- Intel 82801AA AC97 Audio compatible sound card
- Intel HD Audio Controller and HDA codec
- Adlib (OPL2) - Yamaha YM3812 compatible chip
- Gravis Ultrasound GF1 sound card
- CS4231A compatible sound card
- PC speaker
- PCI UHCI, OHCI, EHCI or XHCI USB controller and a virtual USB-1.1 hub.
SMP is supported with a large number of virtual CPUs (upper limit is configuration dependent). π₯
QEMU uses the PC BIOS from the Seabios project and the Plex86/Bochs LGPL VGA BIOS.
QEMU uses YM3812 emulation by Tatsuyuki Satoh.
QEMU uses GUS emulation (GUSEMU32 http://www.deinmeister.de/gusemu/) by Tibor "TS" SchΓΌtz.
π heads up bestie: by default, GUS shares IRQ(7) with parallel ports, so QEMU must be told to not have parallel ports to have working GUS.
qemu-kvm dos.img -device gus -parallel none
Alternatively:
qemu-kvm dos.img -device gus,irq=5
Or some other unclaimed IRQ. pick your fighter β¨
CS4231A is the chip used in Windows Sound System and GUSMAX products
The PC speaker audio device can be configured using the pcspk-audiodev machine property, i.e.
qemu-kvm some.img -audiodev <backend>,id=<name> -machine pcspk-audiodev=<name>
π Machine-specific options π
It supports the following machine-specific options:
x-south-bridge=PIIX3|piix4-isa(Experimental option to select a particular south bridge. Default:PIIX3) β lowkey experimental, so don't come for me if it's weird π
β¨ OPTIONS β¨
disk_image is a raw hard disk image for IDE hard disk 0. Some targets do not need a disk image. (iykyk)
When dealing with options parameters as arbitrary strings containing commas, such as in "file=my,file" and "string=a,b", it's necessary to double the commas. For instance, "-fw_cfg name=z,string=a,,b" will be parsed as "-fw_cfg name=z,string=a,b". no cap, the double comma thing is real π«
π Standard options π
-hβ Display help and exit-versionβ Display version information and exit-machine [type=]name[,prop=value[,...]]β Select the emulated machine by name. Use-machine helpto list available machines.
For architectures which aim to support live migration compatibility across releases, each release will introduce a new versioned machine type. For example, the 2.8.0 release introduced machine types "pc-i440fx-2.8" and "pc-q35-2.8" for the x86_64/i686 architectures.
To allow live migration of guests from QEMU version 2.8.0, to QEMU version 2.9.0, the 2.9.0 version must support the "pc-i440fx-2.8" and "pc-q35-2.8" machines too. To allow users live migrating VMs to skip multiple intermediate releases when upgrading, new releases of QEMU will support machine types from many previous versions. β¨
Supported machine properties are:
accel=accels1[:accels2[:...]]β This is used to enable an accelerator. Depending on the target architecture,kvm,xen,hvf,nitro,nvmm,whpx,mshvortcgcan be available. By default,tcgis used. If there is more than one accelerator specified, the next one is used if the previous one fails to initialize.vmport=on|off|autoβ Enables emulation of VMWare IO port, for vmmouse etc.autosays to select the value based on accel and i8042. Foraccel=xenori8042=offthe default is off, otherwise the default is on.dump-guest-core=on|offβ Include guest memory in a core dump. The default ison.mem-merge=on|offβ Enables or disables memory merge support. This feature, when supported by the host, de-duplicates identical memory pages among VMs instances (enabled by default).aes-key-wrap=on|offβ Enables or disables AES key wrapping support on s390-ccw hosts. This feature controls whether AES wrapping keys will be created to allow execution of AES cryptographic functions. The default ison.dea-key-wrap=on|offβ Enables or disables DEA key wrapping support on s390-ccw hosts. This feature controls whether DEA wrapping keys will be created to allow execution of DEA cryptographic functions. The default ison.nvdimm=on|offβ Enables or disables NVDIMM support. The default isoff.confidential-guest-support=<id>β confidential guest support object to use. The default is none.memory-encryption=<id>β The alias ofconfidential-guest-support. Recommend to useconfidential-guest-support. (like, the alias is cute but use the real one bestie π«Ά)hmat=on|offβ Enables or disables ACPI Heterogeneous Memory Attribute Table (HMAT) support. The default isoff.spcr=on|offβ Enables or disables ACPI Serial Port Console Redirection Table (SPCR) support. The default ison.aux-ram-share=on|offβ Allocate auxiliary guest RAM as an anonymous file that is shareable with an external process. This option applies to memory allocated as a side effect of creating various devices. It does not apply tomemory-backend-objects, whether explicitly specified on the command line, or implicitly created by the-mcommand line option. The default isoff.
To use the cpr-transfer migration mode, you must set aux-ram-share=on.
memory-backend='id'β An alternative to legacy-mem-pathandmem-preallocoptions. Allows to use a memory backend as main RAM.
For example:
-object memory-backend-file,id=pc.ram,size=512M,mem-path=/hugetlbfs,prealloc=on,share=on
-machine memory-backend=pc.ram
-m 512M
Migration compatibility note:
- as backend id one shall use value of
'default-ram-id', advertised by machine type (available viaquery-machinesQMP command), if migration to/from old QEMU (<5.0) is expected. - for machine types 4.0 and older, user shall use
x-use-canonical-path-for-ramblock-id=offbackend option if migration to/from old QEMU (<5.0) is expected.
For example:
-object memory-backend-ram,id=pc.ram,size=512M,x-use-canonical-path-for-ramblock-id=off
-machine memory-backend=pc.ram
-m 512M
cxl-fmw.0.targets.0=firsttarget,cxl-fmw.0.targets.1=secondtarget,cxl-fmw.0.size=size[,cxl-fmw.0.interleave-granularity=granularity]β Define a CXL Fixed Memory Window (CFMW).
Described in the CXL 2.0 ECN: CEDT CFMWS & QTG _DSM.
They are regions of Host Physical Addresses (HPA) on a system which may be interleaved across one or more CXL host bridges. The system software will assign particular devices into these windows and configure the downstream Host-managed Device Memory (HDM) decoders in root ports, switch ports and devices appropriately to meet the interleave requirements before enabling the memory devices. π¦
targets.X=target provides the mapping to CXL host bridges which may be identified by the id provided in the -device entry. Multiple entries are needed to specify all the targets when the fixed memory window represents interleaved memory. X is the target index from 0.
size=size sets the size of the CFMW. This must be a multiple of 256MiB. The region will be aligned to 256MiB but the location is platform and configuration dependent.
interleave-granularity=granularity sets the granularity of interleave. Default 256 (bytes). Only 256, 512, 1k, 2k, 4k, 8k and 16k granularities supported.
Example:
-machine cxl-fmw.0.targets.0=cxl.0,cxl-fmw.0.targets.1=cxl.1,cxl-fmw.0.size=128G,cxl-fmw.0.interleave-granularity=512
sgx-epc.0.memdev=<memid>,sgx-epc.0.node=<numaid>β Define an SGX EPC section.smp-cache.0.cache=cachename,smp-cache.0.topology=topologylevelβ Define cache properties for SMP system.
cache=cachename specifies the cache that the properties will be applied on. This field is the combination of cache level and cache type. It supports l1d (L1 data cache), l1i (L1 instruction cache), l2 (L2 unified cache) and l3 (L3 unified cache).
topology=topologylevel sets the cache topology level. It accepts CPU topology levels including core, module, cluster, die, socket, book, drawer and a special value default. If default is set, then the cache topology will follow the architecture's default cache topology model. If another topology level is set, the cache will be shared at corresponding CPU topology level. For example, topology=core makes the cache shared by all threads within a core. The omitting cache will default to using the default level.
The default cache topology model for an i386 PC machine is as follows: l1d, l1i, and l2 caches are per core, while the l3 cache is per die. β¨
Example:
-machine smp-cache.0.cache=l1d,smp-cache.0.topology=core,smp-cache.1.cache=l1i,smp-cache.1.topology=core
-Mβ as-machine. (literally the same thing, just shorter π )-cpu modelβ Select CPU model (-cpu helpfor list and additional feature selection)
-accel name[,prop=value[,...]]β this is your "bestie, please go fast" switch π¨. It turns on an accelerator. Depending on the target architecture,kvm,xen,hvf,nitro,nvmm,whpx,mshvortcgcan be available. By default,tcgis used. And if there's more than one accelerator specified? Then the next one gets used if the previous one fails to initialize. So it's a little fallback chain, cute.igd-passthru=on|offβ when Xen is in use, this controls whether Intel integrated graphics devices can be passed through to the guest (default=off). off by default, so flip it on only if you actually mean it β¨kernel-irqchip=on|off|splitβ controls KVM in-kernel irqchip support. The default is full acceleration of the interrupt controllers. On x86,splitirqchip reduces the kernel attack surface, at a performance cost for non-MSI interrupts. Fully disabling the in-kernel irqchip? not recommended except for debugging purposes, periodt.kvm-shadow-mem=sizeβ defines the size of the KVM shadow MMU.one-insn-per-tb=on|offβ makes the TCG accelerator put only one guest instruction into each translation block. Heads up: this slows down emulation a lot, but it can be useful in some situations, like when you're trying to analyse the logs produced by the-doption. Little microscope mode π¬split-wx=on|offβ controls the use of split w^x mapping for the TCG code generation buffer. Some operating systems require this to be enabled, and in such a case this will default on. On other operating systems it defaults off, but you can enable it for testing or debugging. Slay for security testing π‘οΈtb-size=nβ controls the size (in MiB) of the TCG translation block cache.thread=single|multiβ controls number of TCG threads. When TCG is multi-threaded there'll be one thread per vCPU, therefore taking advantage of additional host cores. Default is to enable multi-threading where both the back-end and front-ends support it and no incompatible TCG features have been enabled (e.g.icount/replay). more cores = more better, usually π§dirty-ring-size=nβ when the KVM accelerator is used, this controls the size of the per-vCPU dirty page ring buffer (number of entries for each vCPU). It should be a value that's a power of two, and it should be1024or bigger (but still less than the maximum value that the kernel supports).4096could be a good initial value if you have no idea which is the best π Set this value to0to disable the feature. By default this feature is disabled (dirty-ring-size=0). When enabled, KVM will instead record dirty pages in a bitmap.eager-split-size=nβ okay so KVM implements dirty page logging at thePAGE_SIZEgranularity, and enabling dirty-logging on a huge-page requires breaking it intoPAGE_SIZEpages in the first place. KVM on ARM does this splitting lazily by default. There are performance benefits in doing huge-page split eagerly, especially in situations where TLBI costs associated with break-before-make sequences are considerable and also if guest workloads are read intensive. The size here specifies how many pages to break at a time and needs to be a valid block size, which is1GiB/2MiB/4KiB,32MiB/16KiBand512MiB/64KiBfor4KiB/16KiB/64KiBPAGE_SIZErespectively. Be wary of specifying a higher size β it'll have an impact on the memory. By default this feature is disabled (eager-split-size=0).notify-vmexit=run|internal-error|disable,notify-window=nβ enables or disables notify VM exit support on x86 host and specifies the corresponding notify window to trigger the VM exit if enabled. Therunoption enables the feature β it does nothing and continues if the exit happens. Theinternal-erroroption enables the feature and raises an internal error π Thedisableoption doesn't enable the feature. This feature can mitigate the CPU stuck issue due to event windows not opening up for a specified amount of time (i.e.notify-window). Default:notify-vmexit=run,notify-window=0.device=pathβ sets the path to the KVM device node. Defaults to/dev/kvm. This option can be used to pass the KVM device to use via a file descriptor by setting the value to/dev/fdset/NN.hyperv=on|off|autoβ for the WHPX backend, determines whether to enable Hyper-V enlightenments. Onx86_64, Hyper-V enlightenments are on by default. OnAArch64, they're off by default. arch-dependent defaults, iykyk π
-smpβ the "how many little guys do we spawn" option π―ββοΈ Full shape:
-smp [[cpus=]n][,maxcpus=maxcpus][,drawers=drawers][,books=books][,sockets=sockets][,dies=dies][,clusters=clusters][,modules=modules][,cores=cores][,threads=threads]
Simulate a SMP system with n CPUs initially present on the machine type board. On boards supporting CPU hotplug, the optional maxcpus parameter can be set to enable further CPUs to be added at runtime π«Ά When both parameters are omitted, the maximum number of CPUs will be calculated from the provided topology members and the initial CPU count will match the maximum number. When only one of them is given, then the omitted one will be set to its counterpart's value. Both parameters may be specified, but the maximum number of CPUs must be equal to or greater than the initial CPU count. Product of the CPU topology hierarchy must be equal to the maximum number of CPUs. Both parameters are subject to an upper limit determined by the specific machine type chosen.
To control reporting of CPU topology information, values of the topology parameters can be specified. Machines may only support a subset of the parameters, and different machines may have different subsets supported which vary depending on capacity of the corresponding CPU targets. So for a particular machine type board, an expected topology hierarchy can be defined through the supported sub-option. Unsupported parameters can also be provided in addition to the sub-option, but their values must be set as 1 in the purpose of correct parsing. Weird little rule but okay, we respect it π
Either the initial CPU count, or at least one of the topology parameters must be specified. The specified parameters must be greater than zero β explicit configuration like "cpus=0" is not allowed, no cap π Values for any omitted parameters will be computed from those which are given.
For example, the following sub-option defines a CPU topology hierarchy (2 sockets totally on the machine, 2 cores per socket, 2 threads per core) for a machine that only supports sockets/cores/threads. Some members of the option can be omitted but their values will be automatically computed:
-smp 8,sockets=2,cores=2,threads=2,maxcpus=8
The following sub-option defines a CPU topology hierarchy (2 sockets totally on the machine, 2 dies per socket, 2 modules per die, 2 cores per module, 2 threads per core) for PC machines which support sockets/dies/modules/cores/threads. Some members of the option can be omitted but their values will be automatically computed:
-smp 32,sockets=2,dies=2,modules=2,cores=2,threads=2,maxcpus=32
The following sub-option defines a CPU topology hierarchy (2 sockets totally on the machine, 2 clusters per socket, 2 cores per cluster, 2 threads per core) for ARM virt machines which support sockets/clusters/cores/threads. Some members of the option can be omitted but their values will be automatically computed:
-smp 16,sockets=2,clusters=2,cores=2,threads=2,maxcpus=16
Historically, preference was given to the coarsest topology parameters when computing missing values (ie sockets preferred over cores, which were preferred over threads), however, this behaviour is considered liable to change β οΈ Prior to 6.2 the preference was sockets over cores over threads. Since 6.2 the preference is cores over sockets over threads.
For example, the following option defines a machine board with 2 sockets of 1 core before 6.2 and 1 socket of 2 cores after 6.2:
-smp 2
Note: the cluster topology will only be generated in ACPI and exposed to guest if it's explicitly specified in -smp. No sneaky auto-clusters, bestie π
-numaβ the whole NUMA family π Six whole shapes, keep up:
-numa node[,mem=size][,cpus=firstcpu[-lastcpu]][,nodeid=node][,initiator=initiator]
-numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node][,initiator=initiator]
-numa dist,src=source,dst=destination,val=distance
-numa cpu,node-id=node[,socket-id=x][,core-id=y][,thread-id=z]
-numa hmat-lb,initiator=node,target=node,hierarchy=hierarchy,data-type=type[,latency=lat][,bandwidth=bw]
-numa hmat-cache,node-id=node,size=size,level=level[,associativity=str][,policy=str][,line=size]
Define a NUMA node and assign RAM and VCPUs to it β¨ Set the NUMA distance from a source node to a destination node. Set the ACPI Heterogeneous Memory Attributes for the given nodes.
Legacy VCPU assignment uses the cpus option, where firstcpu and lastcpu are CPU indexes. Each cpus option represents a contiguous range of CPU indexes (or a single VCPU if lastcpu is omitted). A non-contiguous set of VCPUs can be represented by providing multiple cpus options. If cpus is omitted on all nodes, VCPUs are automatically split between them. Auto-split, how thoughtful π§
For example, the following option assigns VCPUs 0, 1, 2 and 5 to a NUMA node:
-numa node,cpus=0-2,cpus=5
So the 'cpu' option is like, the new alternative to the 'cpus' option β it uses 'socket-id|core-id|thread-id' properties to assign CPU objects to a node, using the topology layout properties of CPU. The set of properties is machine specific and depends on the machine type / 'smp' options you're using. You can query them with the 'hotpluggable-cpus' monitor command. And the 'node-id' property specifies which node the CPU object gets assigned to β and it's required for the node to be declared with the 'node' option before you use it with the 'cpu' option. fr fr π
For example:
-M pc \
-smp 1,sockets=2,maxcpus=2 \
-numa node,nodeid=0 -numa node,nodeid=1 \
-numa cpu,node-id=0,socket-id=0 -numa cpu,node-id=1,socket-id=1
Okay next: the 'memdev' option assigns RAM from a given memory backend device to a node. And bestie, it is recommended to use 'memdev' over the legacy 'mem' option β because 'memdev' gives you better performance and more control over the backend's RAM (e.g. the 'prealloc' parameter of -memory-backend-ram lets you do memory preallocation). Obsessed π«Ά
For compatibility reasons, the legacy 'mem' option is supported in 5.0 and older machine types. Note that 'mem' and 'memdev' are mutually exclusive β if one node uses 'memdev', the rest of the nodes have to use 'memdev' too, and vice versa. No mixing, periodt β
Users must specify memory for all NUMA nodes via 'memdev' (or legacy 'mem' if available). And heads up: in QEMU 5.2, the support for -numa node without memory specified was removed. π
'initiator' is an additional option that points to an initiator NUMA node that has the best performance (the lowest latency or largest bandwidth) to this NUMA node. Note that this option can only be set when the machine property 'hmat' is set to 'on'.
The following example creates a machine with 2 NUMA nodes: node 0 has CPU, node 1 has only memory, and its initiator is node 0. Note that because node 0 has CPU, by default the initiator of node 0 is itself and must be itself.
-machine hmat=on \
-m 2G,slots=2,maxmem=4G \
-object memory-backend-ram,size=1G,id=m0 \
-object memory-backend-ram,size=1G,id=m1 \
-numa node,nodeid=0,memdev=m0 \
-numa node,nodeid=1,memdev=m1,initiator=0 \
-smp 2,sockets=2,maxcpus=2 \
-numa cpu,node-id=0,socket-id=0 \
-numa cpu,node-id=0,socket-id=1
So, the distance stuff: source and destination are NUMA node IDs. distance is the NUMA distance from source to destination. The distance from a node to itself is always 10. If any pair of nodes is given a distance, then all pairs must be given distances. Although β when distances are only given in one direction for each pair of nodes, then the distances in the opposite directions are assumed to be the same. If, however, an asymmetrical pair of distances is given for even one node pair, then all node pairs must be provided distance values for both directions, even when they are symmetrical. And when a node is unreachable from another node, set the pair's distance to 255. π
Note that the-numaoption doesn't allocate any of the specified resources β it just assigns existing resources to NUMA nodes. Which means you still have to use the-mand-smpoptions to allocate RAM and VCPUs respectively. Don't forget, bestie π
Use 'hmat-lb' to set System Locality Latency and Bandwidth Information between initiator and target NUMA nodes in the ACPI Heterogeneous Attribute Memory Table (HMAT). An initiator NUMA node can create memory requests β usually it has one or more processors. The target NUMA node contains addressable memory.
In the 'hmat-lb' option, node are NUMA node IDs. hierarchy is the memory hierarchy of the target NUMA node: if hierarchy is 'memory', the structure represents the memory performance; if hierarchy is 'first-level|second-level|third-level', this structure represents aggregated performance of memory side caches for each domain. The type of 'data-type' is the type of data represented by this structure instance: if 'hierarchy' is 'memory', 'data-type' is 'access|read|write' latency or 'access|read|write' bandwidth of the target memory; if 'hierarchy' is 'first-level|second-level|third-level', 'data-type' is 'access|read|write' hit latency or 'access|read|write' hit bandwidth of the target memory side cache. β¨
lat is the latency value in nanoseconds. bw is the bandwidth value β the possible value and units are NUM[M|G|T], meaning the bandwidth value is NUM bytes per second (or MiB/s, GiB/s or TiB/s depending on the used suffix). Note that if the latency or bandwidth value is 0, that means the corresponding latency or bandwidth information is not provided.
In the 'hmat-cache' option, node-id is the NUMA-id of the memory it belongs to. size is the size of the memory side cache in bytes. level is the cache level described in this structure β note that cache level 0 should not be used with the 'hmat-cache' option. associativity is the cache associativity, possible values being 'none/direct(direct-mapped)/complex(complex cache indexing)'. policy is the write policy. line is the cache Line size in bytes. π
For example β the following options describe 2 NUMA nodes. Node 0 has 2 cpus and a ram, node 1 has only a ram. The processors in node 0 access memory in node 0 with access-latency 5 nanoseconds, access-bandwidth is 200 MiB/s; the processors in NUMA node 0 access memory in NUMA node 1 with access-latency 10 nanoseconds, access-bandwidth is 100 MiB/s. And for memory side cache information, NUMA node 0 and 1 both have 1 level memory cache, size is 10KiB, policy is write-back, the cache Line size is 8 bytes:
-machine hmat=on \
-m 2G \
-object memory-backend-ram,size=1G,id=m0 \
-object memory-backend-ram,size=1G,id=m1 \
-smp 2,sockets=2,maxcpus=2 \
-numa node,nodeid=0,memdev=m0 \
-numa node,nodeid=1,memdev=m1,initiator=0 \
-numa cpu,node-id=0,socket-id=0 \
-numa cpu,node-id=0,socket-id=1 \
-numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-latency,latency=5 \
-numa hmat-lb,initiator=0,target=0,hierarchy=memory,data-type=access-bandwidth,bandwidth=200M \
-numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-latency,latency=10 \
-numa hmat-lb,initiator=0,target=1,hierarchy=memory,data-type=access-bandwidth,bandwidth=100M \
-numa hmat-cache,node-id=0,size=10K,level=1,associativity=direct,policy=write-back,line=8 \
-numa hmat-cache,node-id=1,size=10K,level=1,associativity=direct,policy=write-back,line=8
πΈ -add-fd fd=fd,set=set[,opaque=opaque]
Add a file descriptor to an fd set. Valid options are:
fd=fd β this option defines the file descriptor of which a duplicate is added to the fd set. The file descriptor cannot be stdin, stdout, or stderr. π«set=set β this option defines the ID of the fd set to add the file descriptor to.opaque=opaque β this option defines a free-form string that can be used to describe the fd.
You can open an image using pre-opened file descriptors from an fd set, like so:
qemu-kvm \
-add-fd fd=3,set=2,opaque="rdwr:/path/to/file" \
-add-fd fd=4,set=2,opaque="rdonly:/path/to/file" \
-drive file=/dev/fdset/2,index=0,media=disk
π¦ -set group.id.arg=value
Set parameter arg for item id of type group.
π
-global driver.prop=value
π
-global driver=driver,property=property,value=value
Set the default value of driver's property prop to value, e.g.:
qemu-kvm -global ide-hd.physical_block_size=4096 disk-image.img
In particular, you can use this to set driver properties for devices which are created automatically by the machine model. To create a device which is not created automatically and set properties on it, use -device instead.
-global driver.prop=value is shorthand for -global driver=driver,property=prop,value=value. And the longhand syntax works even when driver contains a dot. π
π -boot [order=drives][,once=drives][,menu=on|off][,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_timeout][,strict=on|off]
Specify the boot order drives as a string of drive letters. Valid drive letters depend on the target architecture. The x86 PC uses: a, b (floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot from network adapter 1-4) β and hard disk boot is the default. To apply a particular boot order only on the first startup, specify it via once. Note that the order or once parameter should not be used together with the bootindex property of devices, since the firmware implementations normally don't support both at the same time. π
Interactive boot menus/prompts can be enabled via menu=on, as far as firmware/BIOS supports them. The default is non-interactive boot.
A splash picture could be passed to the bios, letting the user show it as a logo, when the option splash=sp_name is given and menu=on β if firmware/BIOS supports them. Currently Seabios for X86 systems support it. Limitation: the splash file could be a jpeg file or a BMP file in 24 BPP format (true color). The resolution should be supported by the SVGA mode, so the recommended is 320x240, 640x480, 800x640. π
A timeout could be passed to the bios β the guest will pause for rb_timeout ms when boot failed, then reboot. If rb_timeout is '-1', the guest will not reboot, and qemu passes '-1' to the bios by default. Currently Seabios for X86 systems support it.
Do strict boot via strict=on, as far as firmware/BIOS supports it. This only has an effect when boot priority is changed by bootindex options. The default is non-strict boot.
# try to boot from network first, then from hard disk
qemu-kvm -boot order=nc
# boot from CD-ROM first, switch back to default order after reboot
qemu-kvm -boot once=d
# boot with a splash picture for 5 seconds.
qemu-kvm -boot menu=on,splash=/root/boot.bmp,splash-time=5000
β οΈ Note: the legacy format -boot drives is still supported, but bestie, its use is discouraged β it may be yeeted from future versions. π Consider this your warning.
-m [size=]megs[,slots=n,maxmem=size]β sets the guest's startup RAM to megs megabytes. Default is128MiB. You can optionally slap aMorGsuffix on there to mean megabytes or gigabytes respectively. The optionalslots+maxmempair lets you set how many hotpluggable memory slots exist and the max amount of memory. Heads up:maxmemmust be aligned to the page size. π
For example, this command line sets guest startup RAM to 1GiB, makes 3 slots for hotplugging extra memory, and caps the max memory the guest can reach at 4GiB:
qemu-kvm -m 1G,slots=3,maxmem=4G
If you don't specify slots and maxmem, memory hotplug just won't be enabled and the guest startup RAM will never increase. Simple as that. β¨
-mem-pathpath β allocates guest RAM from a temporarily created file in path.-mem-preallocβ preallocates memory when you're using-mem-path. π«Ά-klanguage β picks the keyboard layout language (likefrfor French). You only need this where it's not easy to grab raw PC keycodes (think Macs, some X11 servers, or a VNC or curses display). On PC/Linux or PC/Windows hosts you normally don't need it at all, ngl.
The available layouts are:
ar de-ch es fo fr-ca hu ja mk no pt-br sv
da en-gb et fr fr-ch is lt nl pl ru th
de en-us fi fr-be hr it lv nl-be pt sl tr
The default is en-us. π
-audio [driver=]driver[,model=value][,prop=value[,...]]β okay so if you specify themodeloption,-audiois basically a shortcut for configuring both the guest audio hardware and the host audio backend in one go. You set the guest hardware model withmodel=modelname. Usemodel=helpto list the available device types. π
These two examples do exactly the same thing β they're here to show how -audio can shorten your command line:
qemu-kvm -audiodev pa,id=pa -device sb16,audiodev=pa
qemu-kvm -audio pa,model=sb16
If you don't specify the model option, -audio instead configures a default audio backend that gets used whenever the audiodev property isn't set on a device or machine. In particular, -audio none guarantees no audio is produced, even for machines with embedded sound hardware. π¦
In both cases, the driver option is the same as with the corresponding -audiodev option below. Use driver=help to list the available drivers.
-audiodev [driver=]driver,id=id[,prop=value[,...]]β adds a new audio backend driver identified by id.
If no audio backend is specified, QEMU will attempt to select a default one. Lowkey the -display option may influence which backend gets picked. π
There are global and driver-specific properties. Some values can be set differently for input and output β those are marked with in|out.. You set the input's property with in.prop and the output's with out.prop. For example:
-audiodev alsa,id=example,in.frequency=44110,out.frequency=8000
-audiodev alsa,id=example,out.channels=1 # leaves in.channels unspecified
NOTE: parameter validation is known to be incomplete π¬ β in many cases specifying an invalid option causes QEMU to print an error message and just keep emulating without sound.
The valid global options are:
id=identifierβ identifies the audio backend.timer-period=periodβ sets the timer period used by the audio subsystem, in microseconds. Default is10000(10 ms).in|out.mixing-engine=on|offβ use QEMU's mixing engine to mix all streams inside QEMU and convert audio formats when the backend doesn't support them. When it'soff,fixed-settingsmust beofftoo. Note that disabling this means the selected backend must support multiple streams and the audio formats used by the virtual cards β otherwise you get no sound, periodt. Not recommended to disable it unless you want 5.1 or 7.1 audio, since the mixing engine only supports mono and stereo. Default ison.in|out.fixed-settings=on|offβ use fixed settings for host audio. Whenoff, it changes based on how the guest opens the sound card. In that case you must not specify frequency, channels or format. Default ison.in|out.frequency=frequencyβ the frequency to use when usingfixed-settings. Default is44100Hz.in|out.channels=channelsβ the number of channels to use when usingfixed-settings. Default is2(stereo).in|out.format=formatβ the sample format to use when usingfixed-settings. Valid values are:s8,s16,s32,u8,u16,u32,f32. Default iss16.in|out.voices=voicesβ the number of voices to use. Default is1.in|out.buffer-length=usecsβ sets the size of the buffer in microseconds.
-audiodev none,id=id[,prop=value[,...]]β creates a dummy backend that discards all outputs. This backend has no backend-specific properties. π«π-audiodev alsa,id=id[,prop=value[,...]]β creates a backend using the ALSA. This backend is only available on Linux. π§
ALSA-specific options are:
in|out.dev=deviceβ the ALSA device to use for input and/or output. Default isdefault.in|out.period-length=usecsβ sets the period length in microseconds.in|out.try-poll=on|offβ attempt to use poll mode with the device. Default isoff.threshold=thresholdβ threshold (in microseconds) for when playback starts. Default is0.
-audiodev coreaudio,id=id[,prop=value[,...]]β creates a backend using Apple's Core Audio. Only available on Mac OS, and only supports playback. π
Core Audio-specific options are:
in|out.buffer-count=countβ sets the count of the buffers.
-audiodev dbus,id=id[,prop=value[,...]]β creates a D-Bus backend. It must be associated with the display (as-display dbus,audiodev=id). (Since 7.0) π
D-Bus-specific options are:
nsamplesβ number of samples per read/write (defaults to480, 10ms at 48kHz) (Since 10.0)
-audiodev dsound,id=id[,prop=value[,...]]β creates a backend using Microsoft's DirectSound. Only available on Windows, and only supports playback. πͺ
DirectSound-specific options are:
latency=usecsβ adds an extra usecs microseconds of latency to playback. Default is10000(10 ms).
-audiodev oss,id=id[,prop=value[,...]]β creates a backend using OSS. Available on most Unix-like systems. π
OSS-specific options are:
in|out.dev=deviceβ the file name of the OSS device to use. Default is/dev/dsp.in|out.buffer-count=countβ sets the count of the buffers.in|out.try-poll=on|offβ attempt to use poll mode with the device. Default ison.try-mmap=on|offβ try using memory-mapped device access. Default isoff.exclusive=on|offβ open the device in exclusive mode (vmixwon't work in this case). Default isoff.dsp-policy=policyβ sets the timing policy (between0and10, where a smaller number means smaller latency but higher CPU usage). Use-1to use the buffer sizes specified bybufferandbuffer-count. This option is ignored if you don't have OSS 4. Default is5.
-audiodev pa,id=id[,prop=value[,...]]β creates a backend using PulseAudio. Available on most systems. π
PulseAudio-specific options are:
server=serverβ the PulseAudio server to connect to.in|out.name=sinkβ use the specified source/sink for recording/playback.in|out.latency=usecsβ desired latency in microseconds. The PulseAudio server will try to honor this value, but actual latencies may be lower or higher. π
-audiodev pipewire,id=id[,prop=value[,...]]β creates a backend using PipeWire. Available on most systems. π§
PipeWire-specific options are:
in|out.latency=usecsβ desired latency in microseconds.in|out.name=sinkβ use the specified source/sink for recording/playback.in|out.stream-nameβ the name of the PipeWire stream.
-audiodev sdl,id=id[,prop=value[,...]]β creates a backend using SDL. Available on most systems, but you should use your platform's native backend if you can. π
SDL-specific options are:
in|out.buffer-count=countβ sets the count of the buffers.
-audiodev sndio,id=id[,prop=value[,...]]β creates a backend using SNDIO. Available on OpenBSD and most other Unix-like systems. π‘
Sndio-specific options are:
in|out.dev=deviceβ the sndio device to use for input and/or output. Default isdefault.in|out.latency=usecsβ sets the desired period length in microseconds.
-audiodev spice,id=id[,prop=value[,...]]β creates a backend that sends audio through SPICE. This backend requires-spiceand is automatically selected in that case, so usually you can just ignore this option. It has no backend-specific properties. β¨-audiodev wav,id=id[,prop=value[,...]]β creates a backend that writes audio to a WAV file. π§
Backend-specific options are:
path=pathβ write recorded audio into the specified file. Default isqemu.wav.
-device driver[,prop=value[,...]]β okay so this is how you add a devicedriver.prop=valuesets driver properties, and valid properties depend on the driver. Need help? run-device helpand-device driver,helpto see possible drivers and properties. β¨
Some drivers are:
-device ipmi-bmc-sim,id=id[,prop=value[,...]]β add an IPMI BMC. This is a simulation of a hardware management interface processor that normally sits on a system. It provides a watchdog and the ability to reset and power control the system. You need to connect this to an IPMI interface to make it useful. π
The IPMI slave address to use for the BMC. The default is 0x20. This address is the BMC's address on the I2C network of management controllers. If you don't know what this means, it is safe to ignore it.
id=idβ the BMC id for interfaces to use this device.slave_addr=valβ define the slave address to use for the BMC. The default is0x20.sdrfile=fileβ file containing raw Sensor Data Records (SDR) data. The default isnone.fruareasize=valβ size of a Field Replaceable Unit (FRU) area. The default is1024.frudatafile=fileβ file containing raw Field Replaceable Unit (FRU) inventory data. The default isnone.guid=uuidβ value for the GUID for the BMC, in standard UUID format. If this is set, the"Get GUID"command to the BMC will return it. Otherwise"Get GUID"will return an error.lan.channel=valβ channel number of the fake LAN channel. It can be0or any integer from0x1to0xbinclusive. If set to0, the LAN channel is disabled; otherwise the LAN channel is enabled at the specified channel number. The default is0.lan.ipaddr=addrβ the ipv4 address of the BMC LAN channel.lan.ipsrc=valβ the ipv4 address source of the BMC LAN channel. It can be0(unspecified source),1(static address),2(DHCP),3(BIOS or system software), or4(other source). The default is0.lan.macaddr=macβ the mac address of the BMC LAN channel.lan.netmask=maskβ the ipv4 subnet mask for the BMC LAN channel.lan.defgw_ipaddr=addrβ the default gateway ipv4 address for the BMC LAN channel.lan.defgw_macaddr=macβ the default gateway mac address for the BMC LAN channel.
-device ipmi-bmc-extern,id=id,chardev=id[,slave_addr=val]β add a connection to an external IPMI BMC simulator. Instead of locally emulating the BMC like the item above, you connect out to an external entity that provides the IPMI services. π«Ά
A connection is made to an external BMC simulator. If you do this, it is strongly recommended that you use the reconnect-ms= chardev option to reconnect to the simulator if the connection is lost.
β οΈ Security tea: if this is not used carefully, it can be a security issue, as the interface has the ability to send resets, NMIs, and power off the VM. It's best if QEMU makes a connection to an external simulator running on a secure port on localhost, so neither the simulator nor QEMU is exposed to any outside network.
See the lanserv/README.vm file in the OpenIPMI library for more details on the external interface.
-device isa-ipmi-kcs,bmc=id[,ioport=val][,irq=val]β add a KCS IPMI interface on the ISA bus. This also adds corresponding ACPI and SMBIOS entries, if appropriate. β¨bmc=idβ the BMC to connect to, one ofipmi-bmc-simoripmi-bmc-externabove.ioport=valβ define the I/O address of the interface. The default is0xca0for KCS.irq=valβ define the interrupt to use. The default is5. To disable interrupts, set this to0.
-device isa-ipmi-bt,bmc=id[,ioport=val][,irq=val]β like the KCS interface, but defines a BT interface. The default port is0xe4and the default interrupt is5. π-device pci-ipmi-kcs,bmc=idβ add a KCS IPMI interface on the PCI bus.bmc=idβ the BMC to connect to, one ofipmi-bmc-simoripmi-bmc-externabove.
-device pci-ipmi-bt,bmc=idβ like the KCS interface, but defines a BT interface on the PCI bus. π-device intel-iommu[,option=...]β this is only supported by-machine q35, which will enable Intel VT-d emulation within the guest. It supports the options below: π₯intremap=on|off(default:auto) β enables the interrupt remapping feature. It's required to enable completex2apic. Currently it only supports kvmkernel-irqchipmodesofforsplit, while fullkernel-irqchipis not yet supported. The default value is"auto", which will be decided by the mode ofkernel-irqchip.caching-mode=on|off(default:off) β enables caching mode for the VT-d emulated device. Whencaching-modeis enabled, each guest DMA buffer mapping will generate an IOTLB invalidation from the guest IOMMU driver to the vIOMMU device in a synchronous way. It is required for-device vfio-pcito work with the VT-d device, because host-assigned devices need the DMA mapping set up on the host before guest DMA starts.device-iotlb=on|off(default:off) β enablesdevice-iotlbcapability for the emulated VT-d device. So farvirtio/vhostshould be the only real user for this parameter, paired withats=onconfigured for the device.aw-bits=39|48(default:39) β this decides the address width of the IOVA address space. The address space has 39 bits width for 3-level IOMMU page tables, and 48 bits for 4-level IOMMU page tables.
Please also refer to the wiki page for general scenarios of VT-d emulation in QEMU: https://wiki.qemu.org/Features/VT-d.
-device virtio-iommu-pci[,option=...]β this is only supported by-machine q35(x86_64) and-machine virt(ARM). It supports the options below: πΈgranule=valβ possible values are4k,8k,16k,64kandhost; default:host. This decides the default granule to be exposed by thevirtio-iommu. Ifhost, the granule matches the host page size.aw-bits=valβvalbetween32and64, default depends on machine. This decides the address width of the IOVA address space.
-device arm-smmuv3,primary-bus=id[,option=...]β this is only supported by-machine virt(ARM). π¦primary-bus=idβ accepts either the default root complex (pcie.0) or apxb-pciebased root complex.accel=on|off(default:off) β enables the guest to leverage host SMMUv3 features for acceleration. Enablingaccelconfigures the host SMMUv3 in nested mode to supportvfio-pcipassthrough.
The following options will be set to auto by default if not manually set. When accel=on and these properties are set to auto, the value is derived from the host SMMUv3 capabilities via IOMMU_GET_HW_INFO. With accel=on, this requires at least one cold-plugged vfio-pci device; if none is present at machine init, QEMU will abort.
If accel=off, auto values resolve to the non-accel defaults given below.
ril=on|off|auto(default:auto) β support for Range Invalidation, which allows the SMMUv3 driver to invalidate TLB entries for a range of IOVAs at once instead of issuing separate commands to invalidate each page. Must match with host SMMUv3 Range Invalidation support.- With
accel=off,autois resolved to'on'.
- With
ats=on|off|auto(default:auto) β support for Address Translation Services, which enables PCIe devices to cache address translations in their local TLB and reduce latency. Host SMMUv3 must support ATS in order to enable this feature for the vIOMMU.- With
accel=off,autois resolved to'off'.
- With
oas=val|auto(supported values are44and48; default:auto) β sets the Output Address Size in bits. The value set here must be less than or equal to the host SMMUv3's supported OAS, so that the intermediate physical addresses (IPA) consumed by host SMMU for stage-2 translation do not exceed the host's max supported IPA size.- With
accel=off,autois resolved to44.
- With
ssidsize=val|auto(valbetween0and20; default:auto) β sets the Substream ID size in bits. When set to a non-zero value, PASID capability is advertised to the vIOMMU and accelerated use cases such as Shared Virtual Addressing (SVA) are supported.- With
accel=off,autois resolved to0.
- With
cmdqv=on|off|auto(default:auto) β enable hardware Command Queue Virtualization (CMDQV) for the SMMUv3 command queue. Currently only the NVIDIA Tegra241 CMDQV implementation is supported.- With
accel=on,automeans the value is automatically derived from the host SMMU. - With
accel=off,autois resolved to'off'.
- With
-device amd-iommu[,option=...]β enables emulation of an AMD-Vi I/O Memory Management Unit (IOMMU). Only available with-machine q35, it supports the following options: πdma-remap=on|off(default:off) β support for DMA address translation and access permission checking for guests attaching passthrough devices to paging domains, using the AMD v1 I/O Page Table format. This enables-device vfio-pci,...to work correctly with a guest using the DMA remapping feature of the vIOMMU.
intremap=on|off(default:auto) β this is the generic x86 IOMMU glow-up that theamd-iommudevice serves π it turns on interrupt remapping for guests, which is also lowkey required to enable x2apic support. rn it's only available withkernel-irqchip=off|split, and it auto-enables when either of those modes is in use, then disables itself whenkernel-irqchip=on. it's giving automatic bestie behavior β¨xtsup=on|off(default:off) β makes the interrupt remapping table support x2apic mode, so the guest can use the 128-bit IRTE format with a 32-bit destination field. required if you wanna route interrupts to vCPUs with APIC IDs bigger than0xff. no cap, that's a big ID π«Ά
-name name β sets the name of the guest, bestie π this name shows up in the SDL window caption and is also used for the VNC server. it can optionally set the top visible process name on Linux too. and on Linux you can also enable naming of individual threads to help with debugging. iconic multitasking behavior π
-uuid uuid β sets the system UUID. simple as that, periodt β¨
π§ Block device options π§
okay so the QEMU block device handling options have a long history and have gone through several iterations as the feature set and complexity of the block layer have grown π many online guides to QEMU reference older and deprecated options, which is lowkey confusing af.
the most explicit way to describe disks is to use a combo of -device for the hardware device and -blockdev for the backend. the device defines what the guest sees, and the backend describes how QEMU handles the data. it's the only guaranteed stable interface for describing block devices, so it's the recommended one for management tools and scripting. main character energy fr fr π
the -drive option combines the device and backend into a single command line option, which is more human friendly. but there's no interface stability guarantee, although some older board models still need updating to work with the modern blockdev forms. it's giving legacy vibes ngl π
older options like -hda are basically macros that expand into -drive options for various drive interfaces. the original forms bake in a lot of assumptions from back when QEMU was emulating a legacy PC, so they're not recommended for modern configurations. we don't stan legacy assumptions here π
-fdafile-fdbfile β use file as floppy disk 0/1 image (see the Disk Images chapter in the System Emulation Users Guide). cute and retro π-hdafile-hdbfile-hdcfile-hddfile β use file as hard disk 0, 1, 2 or 3 image on the default bus of the emulated machine. this is for example the IDE bus on most x86 machines, but it can also be SCSI, virtio or something else on other target architectures. see also the Disk Images chapter in the System Emulation Users Guide. classic bus behavior β¨-cdromfile β use file as CD-ROM image on the default bus of the emulated machine (which is IDE1 master on x86, so you literally cannot use-hdcand-cdromat the same time there π). on systems that support it, you can use the host CD-ROM by using/dev/cdromas the filename. cute πΏ-blockdevoption[,option[,option[,...]]] β define a new block driver node. some options apply to all block drivers, others are only accepted for a specific block driver. see below for the generic options and options for the most common block drivers. this is the big one, bestie π
options that expect a reference to another node (e.g. file) can be given in two ways. either you specify the node name of an already existing node (file=node-name), or you define a new node inline by adding options for the referenced node after a dot (file.filename=path,file.aio=native). it's giving choose-your-own-adventure π¦
a block driver node created with -blockdev can be used for a guest device by specifying its node name for the drive property in a -device argument that defines a block device. slay β¨
valid options for any block driver node:
driverβ specifies the block driver to use for the given node.node-nameβ defines the name of the block driver node by which it will be referenced later. the name must be unique, i.e. it must not match the name of a different block driver node, or (if you use-driveas well) the ID of a drive. if no node name is specified, it's automatically generated. the generated node name is not intended to be predictable and changes between QEMU invocations. for the top level, an explicit node name must be specified. no slacking on top-level names, bestie πread-onlyβ open the node read-only. guest write attempts will fail. note that some block drivers support only read-only access, either generally or in certain configurations. in this case, the default valueread-only=offdoesn't work and the option must be specified explicitly. rude but valid πauto-read-onlyβ ifauto-read-only=onis set, QEMU may fall back to read-only usage even whenread-only=offis requested, or even switch between modes as needed, e.g. depending on whether the image file is writable or whether a writing user is attached to the node. flexible queen πΈforce-shareβ override the image locking system of QEMU by forcing the node to utilize weaker shared access for permissions where it would normally request exclusive access. when there's the potential for multiple instances to have the same file open (whether this invocation of QEMU is the first or the second instance), both instances must permit shared access for the second instance to succeed at opening the file. enablingforce-share=onrequiresread-only=on. sharing is caring but read the fine print π«Άcache.directβ the host page cache can be avoided withcache.direct=on. this will attempt to do disk IO directly to the guest's memory. QEMU may still perform an internal copy of the data. direct is giving efficient β¨cache.no-flushβ in case you don't care about data integrity over host failures, you can usecache.no-flush=on. this option tells QEMU that it never needs to write any data to the disk but can instead keep things in cache. if anything goes wrong, like your host losing power, the disk storage getting disconnected accidentally, etc. your image will most probably be rendered unusable. ππ bestie please be careful with this one, fr frdiscard=discardβ discard is one of"ignore"(or"off") or"unmap"(or"on") and controls whether discard (also known as trim or unmap) requests are ignored or passed to the filesystem. some machine types may not support discard requests. know your limits ig πdetect-zeroes=detect-zeroesβ detect-zeroes is"off","on"or"unmap"and enables the automatic conversion of plain zero writes by the OS to driver specific optimized zero write commands. you may even choose"unmap"if discard is set to"unmap"to allow a zero write to be converted to an unmap operation. optimized zero writes are so iconic β¨
ποΈ Driver-specific options for file ποΈ
this is the protocol-level block driver for accessing regular files.
filenameβ the path to the image file in the local filesystem.aioβ specifies the AIO backend (threads/native/io_uring, default:threads).lockingβ specifies whether the image file is protected with Linux OFD / POSIX locks. the default is to use the Linux Open File Descriptor API if available, otherwise no lock is applied. (auto/on/off, default:auto).
example:
-blockdev driver=file,node-name=disk,filename=disk.img
π§± Driver-specific options for raw π§±
this is the image format block driver for raw images. it's usually stacked on top of a protocol level block driver such as file.
fileβ reference to or definition of the data source block driver node (e.g. afiledriver node).
example 1:
-blockdev driver=file,node-name=disk_file,filename=disk.img
-blockdev driver=raw,node-name=disk,file=disk_file
example 2:
-blockdev driver=raw,node-name=disk,file.driver=file,file.filename=disk.img
π§ Driver-specific options for qcow2 π§
this is the image format block driver for qcow2 images. it's usually stacked on top of a protocol level block driver such as file.
fileβ reference to or definition of the data source block driver node (e.g. afiledriver node).backingβ reference to or definition of the backing file block device (default is taken from the image file). it's allowed to passnullhere in order to disable the default backing file. bold move but ok πlazy-refcountsβ whether to enable the lazy refcounts feature (on/off; default is taken from the image file).cache-sizeβ the maximum total size of the L2 table and refcount block caches in bytes (default: the sum ofl2-cache-sizeandrefcount-cache-size). big cache energy πΈ
l2-cache-size β¨
The max size of the L2 table cache, in bytes fr. Default goes like this: if cache-size isn't specified, it's 32M on Linux platforms and 8M on non-Linux platforms. Otherwise it's as large as possible inside the cache-size, while still permitting the requested or the minimal refcount cache size. π
refcount-cache-size π
The max size of the refcount block cache, in bytes. Default is 4 times the cluster size; or, if cache-size is specified, it's the part of it that isn't used for the L2 cache. π¦
cache-clean-interval π§
Cleans unused entries in the L2 and refcount caches. The interval is in seconds, bestie. Default is 600 on supporting platforms, and 0 on other platforms. Setting it to 0 disables the feature entirely β no cap. πΈ
pass-discard-request π₯
Whether discard requests to the qcow2 device should get forwarded to the data source (on/off; default: on if discard=unmap is specified, off otherwise). π
pass-discard-snapshot π
Whether discard requests for the data source should be issued when a snapshot operation (like deleting a snapshot, iykyk) frees clusters in the qcow2 file (on/off; default: on). β¨
pass-discard-other π
Whether discard requests for the data source should be issued on other occasions where a cluster gets freed (on/off; default: off). π
discard-no-unref π
When enabled, data clusters stay preallocated when they're no longer used β like, because they got discarded or converted to zero clusters. As usual, whether the old data is discarded or kept on the protocol level (i.e. in the image file) depends on the setting of the pass-discard-request option.
Keeping the clusters preallocated prevents qcow2 fragmentation that would otherwise be caused by freeing and re-allocating them later. And ngl, besides potential performance degradation, that kind of fragmentation can lead to increased allocation of clusters past the end of the image file β resulting in image files whose file length can grow much larger than their guest disk size would suggest. π So if image file length is of concern (e.g. when storing qcow2 images directly on block devices), you should seriously consider enabling this option. π«Ά
overlap-check β
Which overlap checks to perform for writes to the image (none/constant/cached/all; default: cached). For details or finer granularity control, refer to the QAPI documentation of blockdev-add. π
Example 1: π
-blockdev driver=file,node-name=my_file,filename=/tmp/disk.qcow2
-blockdev driver=qcow2,node-name=hda,file=my_file,overlap-check=none,cache-size=16777216
Example 2: π
-blockdev driver=qcow2,node-name=disk,file.driver=http,file.filename=http://example.com/image.qcow2
Driver-specific options for other drivers πΈ
Please refer to the QAPI documentation of the blockdev-add QMP command. That's it, that's the whole vibe. π
-drive option[,option[,option[,...]]] π
Okay so this one defines a new drive. It includes creating a block driver node (that's the backend) and a guest device, so it's basically a shortcut for defining the corresponding -blockdev and -device options. Iconic, honestly. β¨
-drive accepts all the options that -blockdev accepts. On top of that, it knows the following:
file=file β this defines which disk image to use with this drive (see the Disk Images chapter in the System Emulation Users Guide). Heads up: if the filename contains a comma, you gotta double it β for instance,"file=my,,file"to use the file"my,file". π
Special files such as iSCSI devices can be specified using protocol specific URLs. See the section for "Device URL Syntax" for more info.
if=interface β defines which type of interface the drive is connected to. Available types are:ide,scsi,sd,mtd,floppy,pflash,virtio,none. πbus=bus,unit=unit β these define where the drive is connected by defining the bus number and the unit id. πindex=index β defines where the drive is connected by using an index in the list of available connectors of a given interface type. π’media=media β defines the type of media:diskorcdrom. πΏsnapshot=snapshot β snapshot is"on"or"off"and controls snapshot mode for the given drive (see-snapshot). πΈcache=cache β cache is"none","writeback","unsafe","directsync"or"writethrough"and controls how the host cache is used to access block data. This is a shortcut that sets thecache.directandcache.no-flushoptions (as in-blockdev), and additionallycache.writeback, which provides a default for the write-cache option of block guest devices (as in-device). The modes correspond to the following settings: β‘writebackβcache.writeback=on,cache.direct=off,cache.no-flush=offnoneβcache.writeback=on,cache.direct=on,cache.no-flush=offwritethroughβcache.writeback=off,cache.direct=off,cache.no-flush=offdirectsyncβcache.writeback=off,cache.direct=on,cache.no-flush=offunsafeβcache.writeback=on,cache.direct=off,cache.no-flush=on
The default mode is cache=writeback. π
aio=aio β aio is"threads","native", or"io_uring"and selects between pthread based disk I/O, native Linux AIO, or the Linux io_uring API. π§΅format=format β specify which disk format will be used rather than detecting the format. You can use it to specifyformat=rawto avoid interpreting an untrusted format header. π‘οΈwerror=action,rerror=action β specify which action to take on write and read errors. Valid actions are:"ignore"(ignore the error and try to continue),"stop"(pause QEMU),"report"(report the error to the guest),"enospc"(pause QEMU only if the host disk is full; report the error to the guest otherwise). The default setting iswerror=enospcandrerror=report. π¨copy-on-read=copy-on-read β copy-on-read is"on"or"off"and enables whether to copy read backing file sectors into the image file. πbps=b,bps_rd=r,bps_wr=w β specify bandwidth throttling limits in bytes per second, either for all request types or for reads or writes only. Small values can lead to timeouts or hangs inside the guest, so a safe minimum for disks is2 MiB/s. π’bps_max=bm,bps_rd_max=rm,bps_wr_max=wm β specify bursts in bytes per second, either for all request types or for reads or writes only. Bursts allow the guest I/O to spike above the limit temporarily. πiops=i,iops_rd=r,iops_wr=w β specify request rate limits in requests per second, either for all request types or for reads or writes only. πiops_max=bm,iops_rd_max=rm,iops_wr_max=wm β specify bursts in requests per second, either for all request types or for reads or writes only. Bursts allow the guest I/O to spike above the limit temporarily, periodt. π₯iops_size=is β let every is bytes of a request count as a new request for iops throttling purposes. Use this option so guests can't circumvent iops limits by sending fewer but larger requests. Sneaky little guests, honestly. πgroup=g β join a throttling quota group with given name g. All drives that are members of the same group are accounted for together. Use this option to prevent guests from circumventing throttling limits by using many small disks instead of a single larger disk. π―ββοΈ
And the default cache vibe? By default, cache.writeback=on is what you get. What that means: QEMU reports data writes as completed the second the data shows up in the host page cache. It's safe β as long as your guest OS is out here correctly flushing disk caches where it needs to. But if your guest OS does not handle volatile disk write caches correctly, and your host crashes or loses power? Yeah. Your guest may experience data corruption. π Not cute. At. All.
So if you've got one of those guests, pls consider cache.writeback=off. That means the host page cache is still used to read and write data, but the write notification only goes to the guest after QEMU has made sure to flush each write to the disk. Heads up though: this has a major impact on performance. Like, major major. π
Oh and when you're using the -snapshot option? Unsafe caching is always used. Always. π
Copy-on-read avoids accessing the same backing file sectors over and over and over, and it's genuinely useful when the backing file lives over a slow network. By default copy-on-read is off.
Instead of -cdrom you can use:
qemu-kvm -drive file=file,index=2,media=cdrom
Instead of -hda, -hdb, -hdc, -hdd, you can use:
qemu-kvm -drive file=file,index=0,media=disk
qemu-kvm -drive file=file,index=1,media=disk
qemu-kvm -drive file=file,index=2,media=disk
qemu-kvm -drive file=file,index=3,media=disk
You can open an image using pre-opened file descriptors from an fd set β bestie this one is iconic:
qemu-kvm \
-add-fd fd=3,set=2,opaque="rdwr:/path/to/file" \
-add-fd fd=4,set=2,opaque="rdonly:/path/to/file" \
-drive file=/dev/fdset/2,index=0,media=disk
You can connect a CDROM to the slave of ide0:
qemu-kvm -drive file=file,if=ide,index=1,media=cdrom
If you don't specify the "file=" argument, you define an empty drive:
qemu-kvm -drive if=ide,index=1,media=cdrom
Instead of -fda, -fdb, you can use:
qemu-kvm -drive file=file,index=0,if=floppy
qemu-kvm -drive file=file,index=1,if=floppy
By default, interface is "ide" and index is automatically incremented:
qemu-kvm -drive file=a -drive file=b
which is interpreted like:
qemu-kvm -hda a -hdb b
-mtdblock fileβ use file as an on-board Flash memory image. π«Ά-sd fileβ use file as a SecureDigital card image. πΎβ¨-snapshotβ write to temporary files instead of disk image files. In this case the raw disk image you use is not written back. You can, however, force the write back by pressing C-a s (see the Disk Images chapter in the System Emulation Users Guide). π
WARNING: π¨snapshotis incompatible with-blockdevβ instead, useqemu-imgto manually create snapshot images to attach to yourblockdev. If you have mixed-blockdevand-drivedeclarations, you can use the'snapshot'property on your drive declarations instead of this global option.
-fsdev local,id=id,path=path,security_model=security_model[,writeout=writeout][,readonly=on][,fmode=fmode][,dmode=dmode][,max_xattr=max][,throttling.option=value[,throttling.option=value[,...]]]-fsdev synth,id=id[,readonly=on][,max_xattr=max]β define a new file system device. π Valid options are:localβ accesses to the filesystem are done by QEMU.synthβ synthetic filesystem, only used by QTests.id=idβ specifies the identifier for this device.path=pathβ specifies the export path for the file system device. Files under this path will be available to the 9p client on the guest.security_model=security_modelβ specifies the security model to be used for this export path. The supported security models are"passthrough","mapped-xattr","mapped-file"and"none". In the"passthrough"security model, files are stored using the same credentials as they are created on the guest β and that requires QEMU to run as root. π³ In the"mapped-xattr"security model, some of the file attributes like uid, gid, mode bits and link target are stored as file attributes. For"mapped-file"these attributes are stored in the hidden.virtfs_metadatadirectory. Directories exported by this security model cannot interact with other unix tools. The"none"security model is the same as passthrough except the server won't report failures if it fails to set file attributes like ownership. Security model is mandatory only for thelocalfsdriver.writeout=writeoutβ optional argument, bestie. The only supported value is"immediate". This means the host page cache will be used to read and write data, but the write notification will be sent to the guest only when the data has been reported as written by the storage subsystem.readonly=onβ enables exporting the 9p share as a readonly mount for guests. By default, read-write access is given.fmode=fmodeβ specifies the default mode for newly created files on the host. Works only with the security models"mapped-xattr"and"mapped-file".dmode=dmodeβ specifies the default mode for newly created directories on the host. Works only with the security models"mapped-xattr"and"mapped-file".throttling.bps-total=b,throttling.bps-read=r,throttling.bps-write=wβ specify bandwidth throttling limits in bytes per second, either for all request types or for reads or writes only.throttling.bps-total-max=bm,bps-read-max=rm,bps-write-max=wmβ specify bursts in bytes per second, either for all request types or for reads or writes only. Bursts let the guest I/O spike above the limit temporarily.throttling.iops-total=i,throttling.iops-read=r,throttling.iops-write=wβ specify request rate limits in requests per second, either for all request types or for reads or writes only.throttling.iops-total-max=im,throttling.iops-read-max=irm,throttling.iops-write-max=iwmβ specify bursts in requests per second, either for all request types or for reads or writes only. Bursts let the guest I/O spike above the limit temporarily.throttling.iops-size=isβ let every is bytes of a request count as a new request for iops throttling purposes.max_xattr=maxβ specifies the maximum number of concurrent xattr FIDs allowed for this export. The default is1024. Set to0to allow an infinite number of xattr FIDs. This limit prevents host memory exhaustion attacks by capping the number of simultaneous xattr FIDs. π₯
Also, the -fsdev option is used along with the -device driver "virtio-9p-...". They're a package deal, iykyk.
-device virtio-9p-type,fsdev=id,mount_tag=mount_tagβ options for thevirtio-9p-...driver are:typeβ specifies the variant to be used. Supported values are"pci","ccw"or"device", depending on the machine type.fsdev=idβ specifies the id value specified along with the-fsdevoption.mount_tag=mount_tagβ specifies the tag name to be used by the guest to mount this export point.
-virtfs local,path=path,mount_tag=mount_tag,security_model=security_model[,writeout=writeout][,readonly=on][,fmode=fmode][,dmode=dmode][,multidevs=multidevs][,max_xattr=max]-virtfs synth,mount_tag=mount_tag[,max_xattr=max]β define a new virtual filesystem device and expose it to the guest using avirtio-9p-device(a.k.a. 9pfs). Essentially that means a certain directory on the host is made directly accessible by the guest as a pass-through file system, using the 9P network protocol for communication between host and guests β and if you want, it can even be accessible, and shared, by several guests at the same time. π
Note that -virtfs is actually just a convenience shortcut for its generalized form -fsdev -device virtio-9p-pci. β¨
The general form of pass-through file system options are:
localβ accesses to the filesystem are done by QEMU.synthβ synthetic filesystem, only used by QTests.id=idβ specifies the identifier for the filesystem device.path=pathβ specifies the export path for the file system device. Files under this path will be available to the 9p client on the guest.security_model=security_modelβ specifies the security model to be used for this export path. The supported security models are"passthrough","mapped-xattr","mapped-file"and"none". In the"passthrough"security model, files are stored using the same credentials as they are created on the guest β which requires QEMU to run as root. π³ In the"mapped-xattr"security model, some of the file attributes like uid, gid, mode bits and link target are stored as file attributes. For"mapped-file"these attributes are stored in the hidden.virtfs_metadatadirectory. Directories exported by this security model cannot interact with other unix tools. The"none"security model is the same as passthrough except the server won't report failures if it fails to set file attributes like ownership. Security model is mandatory only for thelocalfsdriver.writeout=writeoutβ optional argument. The only supported value is"immediate". This means the host page cache will be used to read and write data, but the write notification will be sent to the guest only when the data has been reported as written by the storage subsystem.readonly=onβ enables exporting the 9p share as a readonly mount for guests. By default, read-write access is given.fmode=fmodeβ specifies the default mode for newly created files on the host. Works only with the security models"mapped-xattr"and"mapped-file".
dmode=dmodeβ sets the default mode for directories that get newly created on the host. π Ngl this one only works with the security models"mapped-xattr"and"mapped-file", so if you're using anything else it's just gonna sit there doing nothing.mount_tag=mount_tagβ the tag name your guest uses to mount this export point. It's literally the label on the door πͺβ¨max_xattr=maxβ caps how many concurrent xattr FIDs this export is allowed to have. Default is1024. Set it to0and you get infinite xattr FIDs. Why does this exist? Because it prevents host memory exhaustion attacks by capping the number of simultaneous xattr FIDs β so like, it's a bouncer for your RAM π«Άmultidevs=remap|forbid|warnβ tells QEMU how to deal with multiple devices being shared through the same 9p export, all so you don't get file ID collisions on the guest. The supported behaviours are"remap"(the default),"forbid", or"warn".remapβ assumes there's a real possibility that more than one device is shared with the same 9p export, so inode numbers from the host get remapped for the guest in a way that prevents file ID collisions. Remapping in these cases is required because the original device IDs from the host are never passed along and exposed on the guest β instead, all files of an export shared with virtfs always share the same device ID on the guest. So two files with identical inode numbers but from actually different devices on the host would otherwise cause a file ID collision, and hence potential severe misbehaviours on the guest. πwarnβ virtfs 9p expects only one device to be shared with the same export. If more than one device is shared and accessed via the same 9p export, then only a warning message gets logged (once) by qemu on the host side. No further action is performed to prevent file ID collisions on the guest. This could therefore lead to severe misbehaviours, like wrong files being accessed and data corruption on the exported tree. π Not the vibe.forbidβ assumes, like"warn", that only one device is shared by the same 9p export, but it will not only log a warning message, it'll also deny access to additional devices on the guest. Note though:"forbid"does currently not block all possible file access operations (e.g.readdir()would still return entries from other devices). π
-iscsiβ configure iSCSI session parameters.
π USB convenience options
-usbβ enables USB emulation on machine types that have an on-board USB host controller (if it's not already enabled by default). Heads up: on-board USB host controllers may not support USB 3.0 β in that case you can use-device qemu-xhciinstead, on machines with PCI. π¦-usbdevice devnameβ adds the USB device devname, and enables an on-board USB controller if that's possible and necessary (just like you can do it via-machine usb=on). Note that this option is mainly intended for the user's convenience only β more fine-grained control can be achieved by selecting a USB host controller (if necessary) and the desired USB device via the-deviceoption instead. For example, instead of using-usbdevice mouseit's possible to use-device qemu-xhci -device usb-mouseto connect the USB mouse to a USB 3.0 controller instead (at least on machines that support PCI and don't have a USB controller enabled by default yet). For more details, see the chapter about Connecting USB devices in the System Emulation Users Guide. π
Possible devices for devname are:
brailleβ braille device. This will use BrlAPI to display the braille output on a real or fake device (i.e. it also creates a corresponding braille chardev automatically beside theusb-brailleUSB device). π«Άkeyboardβ standard USB keyboard. Will override the PS/2 keyboard (if present).mouseβ virtual mouse. This will override the PS/2 mouse emulation when activated. πtabletβ pointer device that uses absolute coordinates (like a touchscreen). This means QEMU is able to report the mouse position without having to grab the mouse. Also overrides the PS/2 mouse emulation when activated. Iconic behaviour honestly.wacom-tabletβ Wacom PenPartner USB tablet. βοΈ
π₯οΈ Display options
-display typeβ picks the type of display to use. This may also influence the default audio backend selection, so it's lowkey doing two jobs. π
Use -display help to list the available display types. Valid values for type are:
spice-app[,gl=on|off]β starts QEMU as a Spice server and launches the default Spice client application. The Spice server will redirect the serial consoles and QEMU monitors. (Since 4.0)dbusβ exports the display over D-Bus interfaces. (Since 7.0) π
If no audio backend is specified and the dbus display backend is specified, the dbus audio backend is used by default.
The connection is registered with the "org.qemu" name (and queued when already owned).
addr=<dbusaddr>β D-Bus bus address to connect to.p2p=yes|noβ use peer-to-peer connection, accepted via QMPadd_client.gl=on|off|core|esβ use OpenGL for rendering (the D-Bus interface will share framebuffers with DMABUF file descriptors).
sdlβ display video output via SDL (usually in a separate graphics window; see the SDL documentation for other possibilities). Valid parameters are:grab-mod=<mods>β used to select the modifier keys for toggling the mouse grabbing in conjunction with the"g"key.<mods>can be eitherlshift-lctrl-laltorrctrl.gl=on|off|core|esβ use OpenGL for displaying.show-cursor=on|offβ force showing the mouse cursor.window-close=on|offβ allow quitting qemu with the window close button.
gtkβ display video output in a GTK window. This interface provides drop-down menus and other UI elements to configure and control the VM during runtime. Valid parameters are:clipboard=on|offβ enable host-guest clipboard sharing, defaults to"off".full-screen=on|offβ start in fullscreen mode.gl=on|offβ use OpenGL for displaying.grab-on-hover=on|offβ grab keyboard input on mouse hover.show-tabs=on|offβ display the tab bar for switching between the various graphical interfaces (e.g. VGA and virtual console character devices) by default.show-cursor=on|offβ force showing the mouse cursor.window-close=on|offβ allow quitting qemu with the window close button.show-menubar=on|offβ display the main window menubar, defaults to"on".zoom-to-fit=on|offβ expand video output to the window size, defaults to"off".
curses[,charset=<encoding>]β display video output via curses. For graphics device models which support a text mode, QEMU can display this output using a curses/ncurses interface. Nothing is displayed when the graphics device is in graphical mode or if the graphics device does not support a text mode. Generally only the VGA device models support text mode. The font charset used by the guest can be specified with the charset option, for examplecharset=CP850for IBM CP850 encoding. The default isCP437. πcocoaβ display video output in a Cocoa window. Mac only. π This interface provides drop-down menus and other UI elements to configure and control the VM during runtime. Valid parameters are:full-grab=on|offβ capture all key presses, including system combos. This requires accessibility permissions, since it performs a global grab on key events. (default:off) Seehttps://support.apple.com/en-in/guide/mac-help/mh32356/macswap-opt-cmd=on|offβ swap the Option and Command keys so that their key codes match their position on non-Mac keyboards and you can use Meta/Super and Alt where you expect them. (default:off)show-cursor=on|offβ force showing the mouse cursor.left-command-key=on|offβ disable forwarding the left command key to the host.full-screen=on|offβ start in fullscreen mode.zoom-to-fit=on|offβ expand video output to the window size, defaults to"off".
egl-headless[,rendernode=<file>]β offload all OpenGL operations to a local DRI device. For any graphical display, this display needs to be paired with either VNC or SPICE displays. βvnc=<display>β start a VNC server on display<display>.noneβ do not display video output. The guest will still see an emulated graphics card, but its output won't be displayed to the QEMU user. This option differs from the-nographicoption in that it only affects what is done with video output;-nographicalso changes the destination of the serial and parallel port data. π«₯
-nographicβ okay so normally, if QEMU is built with graphical window support, it pops guest graphics, guest console, and the QEMU monitor into a window. With this flag you can totally disable graphical output and make QEMU a simple command line application. The emulated serial port gets redirected onto the console and muxed with the monitor (unless you explicitly redirect it somewhere else). So yes, bestie, you can still use QEMU to debug a Linux kernel with a serial console. UseC-a hfor help switching between the console and monitor. π-spice option[,option[,...]]β enable the spice remote desktop protocol. Valid options are:port=<nr>β set the TCP port spice is listening on for plaintext channels. πaddr=<addr>β set the IP address spice is listening on. Default is any address. β¨ipv4=on|off;ipv6=on|off;unix=on|offβ force using the specified IP version. π¦password-secret=<secret-id>β set the ID of the secret object containing the password you need to authenticate. πsasl=on|offβ require that the client use SASL to authenticate with the spice. The exact choice of authentication method used is controlled from the system / user's SASL configuration file for theqemuservice. This is typically found in/etc/sasl2/qemu.conf. If running QEMU as an unprivileged user, an environment variableSASL_CONF_PATHcan be used to make it search alternate locations for the service config. While some SASL auth methods can also provide data encryption (egGSSAPI), it is recommended that SASL always be combined with thetlsandx509settings to enable use of SSL and server certificates. This ensures a data encryption preventing compromise of authentication credentials. π₯disable-ticketing=on|offβ allow client connects without authentication. πdisable-copy-paste=on|offβ disable copy paste between the client and the guest. βοΈdisable-agent-file-xfer=on|offβ disable spice-vdagent based file-xfer between the client and the guest. πtls-port=<nr>β set the TCP port spice is listening on for encrypted channels. πx509-dir=<dir>β set the x509 file directory. Expects same filenames as-vnc $display,x509=$dir. ποΈx509-key-file=<file>;x509-key-password=<file>;x509-cert-file=<file>;x509-cacert-file=<file>;x509-dh-key-file=<file>β the x509 file names can also be configured individually. πtls-ciphers=<list>β specify which ciphers to use. πtls-channel=main|display|cursor|inputs|record|playback;plaintext-channel=main|display|cursor|inputs|record|playbackβ force a specific channel to be used with or without TLS encryption. The options can be specified multiple times to configure multiple channels. The special name"default"can be used to set the default mode. For channels which are not explicitly forced into one mode the spice client is allowed to pick tls/plaintext as it pleases. πimage-compression=auto_glz|auto_lz|quic|glz|lz|offβ configure image compression (lossless). Default isauto_glz. πΌοΈjpeg-wan-compression=auto|never|always;zlib-glz-wan-compression=auto|never|alwaysβ configure wan image compression (lossy for slow links). Default isauto. πΈstreaming-video=off|all|filterβ configure video stream detection. Default isoff. π₯agent-mouse=on|offβ enable/disable passing mouse events via vdagent. Default ison. π±οΈplayback-compression=on|offβ enable/disable audio stream compression (using celt 0.5.1). Default ison. π§seamless-migration=on|offβ enable/disable spice seamless migration. Default isoff. π§video-codec=<codec>β provide the preferred codec the Spice server should use with the Gstreamer encoder. This option is only relevant whengl=onis specified. If no codec is provided, then the codecgstreamer:h264would be used as default. And, for the case wheregl=off, the default codec to be used is determined by the Spice server. π¬max-refresh-rate=rateβ provide the maximum refresh rate (or FPS) at which the encoding requests should be sent to the Spice server. Default would be30. β±οΈgl=on|offβ enable/disable OpenGL context. Default isoff. β¨rendernode=<file>β DRM render node for OpenGL rendering. If not specified, it will pick the first available. (Since 2.9) π
-vga typeβ select type of VGA card to emulate. Valid values for type are:cirrusβ Cirrus Logic GD5446 Video card. All Windows versions starting from Windows 95 should recognize and use this graphic card. For optimal performances, use 16 bit color depth in the guest and the host OS. (This card was the default before QEMU 2.2) π₯οΈstdβ Standard VGA card with Bochs VBE extensions. If your guest OS supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want to use high resolution modes (>= 1280x1024x16) then you should use this option. (This card is the default since QEMU 2.2) βvmwareβ VMWare SVGA-II compatible adapter. Use it if you have sufficiently recent XFree86/XOrg server or Windows guest with a driver for this card. πͺqxlβ QXL paravirtual graphic card. It is VGA compatible (including VESA 2.0 VBE support). Works best with qxl guest drivers installed though. Recommended choice when using the spice protocol. πtcxβ (sun4m only) Sun TCX framebuffer. This is the default framebuffer for sun4m machines and offers both 8-bit and 24-bit colour depths at a fixed resolution of1024x768. πcg3β (sun4m only) Sun cgthree framebuffer. This is a simple 8-bit framebuffer for sun4m machines available in both1024x768(OpenBIOS) and1152x900(OBP) resolutions aimed at people wishing to run older Solaris versions. π¦virtioβ Virtio VGA card. π§noneβ Disable VGA card. π
-full-screenβ start in full screen. π₯οΈβ¨-g widthxheight[xdepth]β set the initial graphical resolution and depth (PPC, SPARC only). πΈ
For PPC the default is 800x600x32.
For SPARC with the TCX graphics device, the default is 1024x768x8 with the option of 1024x768x24. For cgthree, the default is 1024x768x8 with the option of 1152x900x8 for people who wish to use OBP. π«Ά
-vnc display[,option[,option[,...]]]β okay so normally, if QEMU is compiled with graphical window support, it displays output such as guest graphics, guest console, and the QEMU monitor in a window. With this option, you can have QEMU listen on VNC display display and redirect the VGA display over the VNC session. It is very useful to enable the usb tablet device when using this option (option-device usb-tablet). When using the VNC display, you must use the-kparameter to set the keyboard layout if you are not usingen-us. Valid syntax for display is:to=Lβ with this option, QEMU will try next available VNC displays, until the number L, if the originally defined-vnc displayis not available, e.g. port5900+displayis already used by another application. By default,to=0. πhost:dβ TCP connections will only be allowed from host on display d. By convention the TCP port is5900+d. Optionally, host can be omitted in which case the server will accept connections from any host. πunix:pathβ connections will be allowed over UNIX domain sockets where path is the location of a unix socket to listen for connections on. πnoneβ VNC is initialized but not started. The monitorchangecommand can be used to later start the VNC server. βΈοΈ
Following the display value there may be one or more option flags separated by commas. Valid options are:
reverse=on|offβ connect to a listening VNC client via a"reverse"connection. The client is specified by the display. For reverse network connections likehost:dwithreverse, the d argument is a TCP port number, not a display number. πwebsocket=on|offβ opens an additional TCP listening port dedicated to VNC Websocket connections. If a barewebsocketoption is given, the Websocket port is5700+display. An alternative port can be specified with the syntaxwebsocket=port. πΈοΈ
If host is specified connections will only be allowed from this host. It is possible to control the websocket listen address independently, using the syntax websocket=host:port.
Websocket could be allowed over UNIX domain socket, using the syntax websocket=unix:path, where path is the location of a unix socket to listen for connections on.
If no TLS credentials are provided, the websocket connection runs in unencrypted mode. If TLS credentials are provided, the websocket connection requires encrypted client connections. π
password=on|offβ require that password based authentication is used for client connections. π
The password must be set separately using the set_password command in the QEMU Monitor. The syntax to change your password is: set_password <protocol> <password> where <protocol> could be either "vnc" or "spice". π
So if you wanna change a <protocol> password's expiration, you use expire_password <protocol> <expiration-time> β and the expiration time can be any of these: now, never, +seconds, or a straight-up UNIX timestamp. Like +60 makes the password expire in 60 seconds, and 1335196800 makes it expire on "Mon Apr 23 12:00:00 EDT 2012" (that's the UNIX time for that date and time, bestie).
You can also just use the keywords "now" or "never" as the expiration time so the <protocol> password expires immediately or literally never expires. π
password-secret=<secret-id>β makes password-based auth mandatory for client connections, using the password from the secret object with thatsecret-id. πtls-creds=IDβ hands over the ID of a TLS credentials set to secure the VNC server. These apply to both the normal VNC server socket and the websocket socket (if it's enabled). Setting TLS creds makes the VNC server socket turn on the VeNCrypt auth mechanism. And psst β those credentials should've already been made earlier with the-object tls-credsargument.tls-authz=IDβ the ID of the QAuthZ authorization object that the client's x509 distinguished name gets validated against. This object is only resolved at time of use, so you can delete and recreate it on the fly while the VNC server is still active. If it's missing, it defaults to denying access. πsasl=on|offβ requires the client to use SASL to authenticate with the VNC server. The exact auth method is controlled from the system / user's SASL configuration file for the'qemu'service β usually found at/etc/sasl2/qemu.conf. If you're running QEMU as an unprivileged user, you can use the environment variableSASL_CONF_PATHto make it search alternate places for the service config. Some SASL auth methods can also give you data encryption (egGSSAPI), but it's recommended that SASL always be combined with the'tls'and'x509'settings so SSL and server certificates are in play. That's what ensures data encryption preventing compromise of authentication credentials. See the VNC security section in the System Emulation Users Guide for the deets on SASL auth.sasl-authz=IDβ the ID of the QAuthZ authorization object the client's SASL username gets validated against. Again, only resolved at time of use, so delete-and-recreate on the fly while the VNC server is active is totally fine. Missing = access denied by default.acl=on|offβ the β¨legacyβ¨ way of enabling client authorization against the x509 distinguished name and SASL username. It creates twoauthz-listobjects with the IDsvnc.usernameandvnc.x509dname. You gotta configure the rules for those objects with the HMP ACL commands.
π¨ Deprecated alert β this option is deprecated and should no longer be used. The newsasl-authzandtls-authzoptions replace it. Periodt.
lossy=on|offβ enables lossy compression methods (gradient,JPEG, ...). With this set, the VNC client may receive lossy framebuffer updates depending on its encoding settings. It can save you so much bandwidth, at the expense of quality. Trade-offs, bestie πnon-adaptive=on|offβ disables adaptive encodings. Adaptive encodings are on by default. An adaptive encoding tries to detect frequently updated screen regions and sends updates there using a lossy encoding (like JPEG) β which is genuinely really helpful for saving bandwidth while playing videos. Disabling them restores the original static behavior of encodings like Tight. πshare=allow-exclusive|force-shared|ignoreβ sets the display sharing policy:'allow-exclusive'lets clients ask for exclusive access. As suggested by the rfb spec, this is implemented by dropping other connections. Connecting multiple clients in parallel requires all of them asking for a shared session (vncviewer:-sharedswitch). This is the default.'force-shared'disables exclusive client access. Super useful for shared desktop sessions where you don't want someone forgetting to specify-sharedand disconnecting everybody else. π'ignore'completely ignores the shared flag and lets everybody connect unconditionally. Doesn't conform to the rfb spec, but it's traditional QEMU behavior.
key-delay-msβ sets the keyboard delay for key down and key up events, in milliseconds. Default is10. Keyboards are low-bandwidth devices, so this slowdown helps the device and guest keep up and not lose events when they're arriving in bulk β causes for that being flaky network connections, or scripts for automated testing. β¨οΈaudiodev=audiodevβ uses the specified audiodev when the VNC client requests audio transmission. If you're not using an-audiodevargument, this option must be omitted; otherwise it must be present and specify a valid audiodev. π§power-control=on|offβ permits the remote client to issue shutdown, reboot or reset power control requests. Power to the people, lowkey.
πΈ i386 target only πΈ
-win2k-hack
Use this when you're installing Windows 2000 to dodge a disk full bug. Once Windows 2000 is installed you don't need it anymore β and ngl, this option slows down the IDE transfers. Synonym of -global ide-device.win2k-install-hack=on.
-no-fd-bootchk
Disables boot signature checking for floppy disks in BIOS. Might be needed to boot from old floppy disks. Synonym of -m fd-bootchk=off. πΎ
-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,data=file1[:file2]...]
Adds an ACPI table with the specified header fields and context from the specified files. With file=, it takes the whole ACPI table from the specified files, including all ACPI headers (possibly overridden by other options). With data=, only the data portion of the table is used β all header info comes from the command line. And heads up: if a SLIC table is supplied to QEMU, then the SLIC's oem_id and oem_table_id fields will override the same in the RSDT and the FADT (a.k.a. FACP), so the field matches what the Microsoft SLIC spec and the ACPI spec require. β¨
-smbios file=binary
Loads the SMBIOS entry from a binary file. π
-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d][,uefi=on|off]
Specify SMBIOS type 0 fields.
-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str][,uuid=uuid][,sku=str][,family=str]
Specify SMBIOS type 1 fields.
-smbios type=2[,manufacturer=str][,product=str][,version=str][,serial=str][,asset=str][,location=str]
Specify SMBIOS type 2 fields.
-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str][,sku=str]
Specify SMBIOS type 3 fields.
-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str][,asset=str][,part=str][,processor-family=%d][,processor-id=%d]
Specify SMBIOS type 4 fields.
-smbios type=9[,slot_designation=str][,slot_type=%d][,slot_data_bus_width=%d][,current_usage=%d][,slot_length=%d][,slot_id=%d][,slot_characteristics1=%d][,slot_characteristics12=%d][,pci_device=str]
Specify SMBIOS type 9 fields.
-smbios type=11[,value=str][,path=filename]
Specify SMBIOS type 11 fields.
This argument can be repeated multiple times, and values are added in the order they're parsed. Applications planning to use OEM strings data are encouraged to use their application name as a prefix for the value string β that makes it way easier to pass info for multiple applications at once. π«Ά
The value=str syntax gives the string data inline, while path=filename loads data from a file on disk. Note that the file is not permitted to contain any NUL bytes.
Both the value and path options can be repeated multiple times and get added to the SMBIOS table in the order they appear.
β οΈ Heads up: on the x86 architecture, the total size of all SMBIOS tables is limited to 65535 bytes. So OEM strings data is not suitable for passing large amounts of data into the guest β it should be used as an indicator to inform the guest where to find the real data set, like specifying the serial ID of a block device. π
An example passing three strings is:
-sm bios type=11,value=cloud-init:ds=nocloud-net;s=http://10.10.0.1:8000/,\
value=anaconda:method=http://dl.fedoraproject.org/pub/fedora/linux/releases/25/x86_64/os,\
path=/some/file/with/oemstringsdata.txt
In the guest OS this is visible with the dmidecode command:
$ dmidecode -t 11
Handle 0x0E00, DMI type 11, 5 bytes
OEM Strings
String 1: cloud-init:ds=nocloud-net;s=http://10.10.0.1:8000/
String 2: anaconda:method=http://dl.fedoraproject.org/pub/fedora/linux/releases/25/x86_64/os
String 3: myapp:some extra data
-smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str][,asset=str][,part=str][,speed=%d]
Specify SMBIOS type 17 fields.
-smbios type=41[,designation=str][,kind=str][,instance=%d][,pcidev=str]
Specify SMBIOS type 41 fields. π
-smbiosβ¦ wait, we're mid-thought, bestie β okay so this argument can be repeated multiple times, and its β¨ main character β¨ use is letting network interfaces be created asenoXon Linux, whereXis the instance number, instead of the name depending on the interface's position on the PCI bus. No more "why is my NIC named after a bus slot" meltdowns π
Here's an example of use:
-netdev user,id=internet \
-device virtio-net-pci,mac=50:54:00:00:00:42,netdev=internet,id=internet-dev \
-smbios type=41,designation='Onboard LAN',instance=1,kind=ethernet,pcidev=internet-dev
In the guest OS, the device should then appear as eno1:
$ ip -brief l
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eno1 UP 50:54:00:00:00:42 <BROADCAST,MULTICAST,UP,LOWER_UP>
Currently, the PCI device has to be attached to the root bus. That's the rule, bestie, no cap π«Ά
π Network options π
π¦ -nic
-nic [tap|passt|bridge|user|l2tpv3|vde|netmap|af-xdp|vhost-user|socket][,...][,mac=macaddr][,model=mn]
Okay so this one is the shortcut queen π β she configures both the on-board (default) guest NIC hardware and the host network backend in one go. The host backend options are literally the same as with the corresponding -netdev options below. You can set the guest NIC model with model=modelname β and yes, model=help lists all the available device types, slay. The hardware MAC address gets set with mac=macaddr.
The following two example do exactly the same β showing off how -nic can be used to shorten the command line length, because we love a low-effort high-impact moment β¨
qemu-kvm -netdev user,id=n1,ipv6=off -device e1000,netdev=n1,mac=52:54:98:76:54:32
qemu-kvm -nic user,ipv6=off,model=e1000,mac=52:54:98:76:54:32
π« -nic none
Indicate that no network devices should be configured. It's used to override the default configuration (that's the default NIC with the "user" host network backend) which gets activated if you don't provide any other networking options. It's giving "leave me alone, I'm offline" energy π
π§ -netdev passt,id=str[,option][,...]
Configure a passt network backend which requires no administrator privilege to run. Obsessed. Valid options are:
id=idβ assign a symbolic name for use in monitor commands.path=fileβ filename of the passt program to run. If it's not provided, thepasstcommand will be started with the help of thePATHenvironment variable.quiet=on|offβ by default,quiet=on, which disables informational messages from passt.quiet=onis passed as--quietto passt.vhost-user=on|offβ by default,vhost-user=offand QEMU uses the stream network backend to talk to passt. Ifvhost-user=on, passt is started with--vhost-userand QEMU uses the vhost-user network backend to communicate with passt.@mtuβ assign MTU via DHCP/NDPaddressβ IPv4 or IPv6 addressnetmaskβ IPv4 maskmacβ source MAC addressgatewayβ IPv4 or IPv6 address as gatewayinterfaceβ interface for addresses and routesoutboundβ bind to address as outbound sourceoutbound-if4β bind to outbound interface for IPv4outbound-if6β bind to outbound interface for IPv6dnsβ IPv4 or IPv6 address as DNSsearchβ search domainsfqdnβ FQDN to configure the client withdhcp-dnsβ enable/disable DNS list in DHCP/DHCPv6/NDPdhcp-searchβ enable/disable list in DHCP/DHCPv6/NDPmap-host-loopbackβ address to refer to hostmap-guest-addrβ addr to translate to the guest's addressdns-forwardβ forward DNS queries sent todns-hostβ host nameserver to direct queries totcpβ enable/disable TCPudpβ enable/disable UDPicmpβ enable/disable ICMPdhcpβ enable/disable DHCPndpβ enable/disable NDPdhcpv6β enable/disable DHCPv6raβ enable/disable route advertisementsfreebindβ bind to any address for forwardingipv4β enable/disable IPv4ipv6β enable/disable IPv6tcp-portsβ TCP ports to forwardudp-portsβ UDP ports to forwardparam=stringβstringwill be passed to passt as a command line parameter. We can have multiple occurrences of theparamparameter to pass multiple parameters to passt π
For instance, to pass --trace --log=trace.log:
qemu-kvm -nic passt,param=--trace,param=--log=trace.log
π -netdev user,id=id[,option][,option][,...]
Configure the user mode host network backend, which β say it with me β requires no administrator privilege to run. Iconic. Valid options are:
id=idβ assign a symbolic name for use in monitor commands.ipv4=on|offandipv6=on|offβ specify that either IPv4 or IPv6 must be enabled. If neither is specified, both protocols are enabled.net=addr[/mask]β set the IP network address the guest will see. Optionally specify the netmask, either in the forma.b.c.dor as a number of valid top-most bits. Default is10.0.2.0/24.host=addrβ specify the guest-visible address of the host. Default is the 2nd IP in the guest network, i.e.x.x.x.2.ipv6-net=addr[/int]β set the IPv6 network address the guest will see (default isfec0::/64). The network prefix is given in the usual hexadecimal IPv6 address notation. The prefix size is optional, and is given as the number of valid top-most bits (default is64).ipv6-host=addrβ specify the guest-visible IPv6 address of the host. Default is the 2nd IPv6 in the guest network, i.e.xxxx::2.restrict=on|offβ if this option is enabled, the guest will be isolated π, i.e. it will not be able to contact the host and no guest IP packets will be routed over the host to the outside. This option does not affect any explicitly set forwarding rules.hostname=nameβ specifies the client hostname reported by the built-in DHCP server.dhcpstart=addrβ specify the first of the 16 IPs the built-in DHCP server can assign. Default is the 15th to 31st IP in the guest network, i.e.x.x.x.15tox.x.x.31.dns=addrβ specify the guest-visible address of the virtual nameserver. The address must be different from the host address. Default is the 3rd IP in the guest network, i.e.x.x.x.3.ipv6-dns=addrβ specify the guest-visible address of the IPv6 virtual nameserver. The address must be different from the host address. Default is the 3rd IP in the guest network, i.e.xxxx::3.dnssearch=domainβ provides an entry for the domain-search list sent by the built-in DHCP server. More than one domain suffix can be transmitted by specifying this option multiple times. If supported, this will cause the guest to automatically try to append the given domain suffix(es) in case a domain name can not be resolved.
Example:
qemu-kvm -nic user,dnssearch=mgmt.example.org,dnssearch=example.org
domainname=domainβ specifies the client domain name reported by the built-in DHCP server.tftp=dirβ when using the user mode network stack, activate a built-in TFTP server. The files indirwill be exposed as the root of a TFTP server. The TFTP client on the guest must be configured in binary mode (use the commandbinof the Unix TFTP client). The built-in TFTP server is read-only β it does not implement any command for writing files. QEMU will not write to this directory. π«βοΈtftp-server-name=nameβ in the BOOTP reply, broadcastnameas the "TFTP server name" (RFC2132 option 66). This can be used to advise the guest to load boot files or configurations from a different server than the host address.bootfile=fileβ when using the user mode network stack, broadcastfileas the BOOTP filename. In conjunction withtftp, this can be used to network boot a guest from a local directory π₯Ύβ¨
Example (using pxelinux):
qemu-kvm -hda linux.img -boot n -device e1000,netdev=n1 \
-netdev user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0
smb=dir[,smbserver=addr]β when using the user mode network stack, activate a built-in SMB server so that Windows OSes can access the host files indirtransparently. The IP address of the SMB server can be set toaddr. By default the 4th IP in the guest network is used, i.e.x.x.x.4.
In the guest Windows OS, the line:
10.0.2.4 smbserver #PRE #NOFNR
must be added in the LMHOSTS file. In this line, #PRE requests pre-caching of the mapping, which speeds up the initial connection on some Windows versions. #NOFNR is necessary for Windows NT 3.1 to tell it not to send NBNS query packets that QEMU does not handle, and is harmlessly ignored on other versions.
The LMHOSTS file may be in different locations depending on the Windows version:
C:\WINDOWS\LMHOSTSfor Windows 3x/9x/MeC:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTSfor Windows NT/2000C:\WINDOWS\SYSTEM32\DRIVERS\ETC\LMHOSTSfor Windows XP and newer
Then dir can be accessed in \\smbserver\qemu.
Note that a SAMBA server must be installed on the host OS. Like, actually installed, bestie β this isn't magic π§
hostfwd=[tcp|udp|unix]:[[hostaddr]:hostport|hostpath]-[guestaddr]:guestportβ okay so this one redirects incoming TCP, UDP or UNIX connections to the host port hostport over to the guest IP address guestaddr on guest port guestport. If you don't specify guestaddr, it just defaults tox.x.x.15(that's the default first address the built-in DHCP server hands out, bestie π). And if you specify hostaddr, the rule gets bound to a specific host interface. No connection type set? Then TCP is what you get. You can give this option multiple times, stack 'em up π
Like, say you wanna redirect the host X11 connection from screen 1 to guest screen 0 β literally just:
# on the host
qemu-kvm -nic user,hostfwd=tcp:127.0.0.1:6001-:6000
# this host xterm should open in the guest X11 server
xterm -display :1
And to redirect telnet connections from host port 5555 to the telnet port on the guest:
# on the host
qemu-kvm -nic user,hostfwd=tcp::5555-:23
telnet localhost 5555
Then when you use telnet localhost 5555 on the host, you connect to the guest telnet server. slay β¨
And to redirect host unix socket /tmp/vm to guest tcp socket 23, use:
# on the host
qemu-kvm -nic user,hostfwd=unix:/tmp/vm-:23
guestfwd=[tcp]:server:port-dev;guestfwd=[tcp]:server:port-cmd:commandβ this one's the other direction, forwarding guest TCP connections to the IP address server on port port to the character device dev, or to a program executed bycmd:commandwhich gets spawned for each connection. Multiple times? Yes bestie, as many as you want π
You can either use a chardev directly and have that one used throughout QEMU's lifetime, like:
# open 10.10.1.1:4321 on bootup, connect 10.0.2.100:1234 to it whenever
# the guest accesses it
qemu-kvm -nic user,guestfwd=tcp:10.0.2.100:1234-tcp:10.10.1.1:4321
Or you can execute a command on every TCP connection established by the guest, so QEMU behaves similar to an inetd process for that virtual server:
# call "netcat 10.10.1.1 4321" on every TCP connection to 10.0.2.100:1234
# and connect the TCP stream to its stdin/stdout
qemu-kvm -nic 'user,id=n1,guestfwd=tcp:10.0.2.100:1234-cmd:netcat 10.10.1.1 4321'
π«Ά -netdev β the TAP one
tap,id=id[,fd=h][,ifname=name][,script=file][,downscript=dfile][,br=bridge][,helper=helper]β configures a host TAP network backend with ID id. Obsessed with a backend that's just named tap ngl π¦
So you use the network script file file to configure it, and the network script dfile to deconfigure it. If name isn't provided, the OS automatically provides one for you (iconic, no notes). The default network configure script is /etc/qemu-ifup and the default network deconfigure script is /etc/qemu-ifdown. Use script=no or downscript=no to disable script execution entirely π
If you're running QEMU as an unprivileged user, use the network helper helper to configure the TAP interface and attach it to the bridge. The default network helper executable is /path/to/qemu-bridge-helper and the default bridge device is br0.
And fd=h can be used to specify the handle of an already opened host TAP interface. iykyk β¨
Examples:
#launch a QEMU instance with the default network script
qemu-kvm linux.img -nic tap
#launch a QEMU instance with two NICs, each one connected
#to a TAP device
qemu-kvm linux.img \
-netdev tap,id=nd0,ifname=tap0 -device e1000,netdev=nd0 \
-netdev tap,id=nd1,ifname=tap1 -device rtl8139,netdev=nd1
#launch a QEMU instance with the default network helper to
#connect a TAP device to bridge br0
qemu-kvm linux.img -device virtio-net-pci,netdev=n1 \
-netdev tap,id=n1,"helper=/path/to/qemu-bridge-helper"
bridge,id=id[,br=bridge][,helper=helper]β connects a host TAP network interface to a host bridge device π
You use the network helper helper to configure the TAP interface and attach it to the bridge. The default network helper executable is /path/to/qemu-bridge-helper and the default bridge device is br0. Same defaults, different backend β we love consistency π
Examples:
#launch a QEMU instance with the default network helper to
#connect a TAP device to bridge br0
qemu-kvm linux.img -netdev bridge,id=n1 -device virtio-net,netdev=n1
#launch a QEMU instance with the default network helper to
#connect a TAP device to bridge qemubr0
qemu-kvm linux.img -netdev bridge,br=qemubr0,id=n1 -device virtio-net,netdev=n1
socket,id=id[,fd=h][,listen=[host]:port][,connect=host:port]β this host network backend links the guest's network to another QEMU virtual machine using a TCP socket connection. networking but make it a group chat π¬
If listen is specified, QEMU waits for incoming connections on port (host is optional). connect is used to connect to another QEMU instance using the listen option. And fd=h specifies an already opened TCP socket.
Example:
# launch a first QEMU instance
qemu-kvm linux.img \
-device e1000,netdev=n1,mac=52:54:00:12:34:56 \
-netdev socket,id=n1,listen=:1234
# connect the network of this instance to the network of the first instance
qemu-kvm linux.img \
-device e1000,netdev=n2,mac=52:54:00:12:34:57 \
-netdev socket,id=n2,connect=127.0.0.1:1234
socket,id=id[,fd=h][,mcast=maddr:port[,localaddr=addr]]β configures a socket host network backend to share the guest's network traffic with other QEMU virtual machines using a UDP multicast socket, effectively making a bus for every QEMU with the same multicast address maddr and port. a whole little bus, bestie πβ¨
NOTES (read these fr fr):
- Several QEMU can be running on different hosts and share same bus (assuming correct multicast setup for these hosts).
mcastsupport is compatible with User Mode Linux (argumentethN=mcast), seehttp://user-mode-linux.sf.net.- Use
fd=hto specify an already opened UDP multicast socket.
Example:
# launch one QEMU instance
qemu-kvm linux.img \
-device e1000,netdev=n1,mac=52:54:00:12:34:56 \
-netdev socket,id=n1,mcast=230.0.0.1:1234
# launch another QEMU instance on same "bus"
qemu-kvm linux.img \
-device e1000,netdev=n2,mac=52:54:00:12:34:57 \
-netdev socket,id=n2,mcast=230.0.0.1:1234
# launch yet another QEMU instance on same "bus"
qemu-kvm linux.img \
-device e1000,netdev=n3,mac=52:54:00:12:34:58 \
-netdev socket,id=n3,mcast=230.0.0.1:1234
Example (User Mode Linux compat.):
# launch QEMU instance (note mcast address selected is UML's default)
qemu-kvm linux.img \
-device e1000,netdev=n1,mac=52:54:00:12:34:56 \
-netdev socket,id=n1,mcast=239.192.168.1:1102
# launch UML
/path/to/linux ubd0=/path/to/root_fs eth0=mcast
Example (send packets from host's 1.2.3.4):
qemu-kvm linux.img \
-device e1000,netdev=n1,mac=52:54:00:12:34:56 \
-netdev socket,id=n1,mcast=239.192.168.1:1102,localaddr=1.2.3.4
stream,id=str[,server=on|off],addr.type=inet,addr.host=host,addr.port=port[,to=maxport][,numeric=on|off][,keep-alive=on|off][,mptcp=on|off][,addr.ipv4=on|off][,addr.ipv6=on|off][,reconnect-ms=milliseconds]β configures a network backend to connect to another QEMU virtual machine or a proxy using a TCP/IP socket π₯server=on|offβ ifoncreate a server socketaddr.host=host,addr.port=portβ socket address to listen on (server=on) or connect to (server=off)to=maxportβ if present, this is range of possible addresses, with port between port and maxport.numeric=on|offβ ifonhost and port are guaranteed to be numeric, otherwise a name resolution should be attempted (default:off)keep-alive=on|offβ enable keep-alive when connecting to this socket. Not supported for passive sockets.mptcp=on|offβ enable multipath TCPipv4=on|offβ whether to accept IPv4 addresses, default to try both IPv4 and IPv6ipv6=on|offβ whether to accept IPv6 addresses, default to try both IPv4 and IPv6reconnect-ms=millisecondsβ for a client socket, if a socket is disconnected, then attempt a reconnect after the given number of milliseconds. Setting this to zero disables this function. (default:0)
Example (two guests connected using a TCP/IP socket):
# first VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:56 \
-netdev stream,id=net0,server=on,addr.type=inet,addr.host=localhost,addr.port=1234
# second VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:57 \
-netdev stream,id=net0,server=off,addr.type=inet,addr.host=localhost,addr.port=1234,reconnect-ms=5000
stream,id=str[,server=on|off],addr.type=unix,addr.path=path[,abstract=on|off][,tight=on|off][,reconnect-ms=milliseconds]β same energy but it connects to another QEMU virtual machine or a proxy using a stream oriented unix domain socket π§server=on|offβ ifoncreate a server socketaddr.path=pathβ filesystem path to useabstract=on|offβ ifon, this is a Linux abstract socket address.tight=on|offβ if false, pad an abstract socket address with enough null bytes to make it fillstruct sockaddr_unmembersun_path.
reconnect-ms=millisecondsβ okay so if this is a client socket and it gets disconnected, it'll try to reconnect after this many milliseconds. Set it to zero and the whole reconnect thing is off. Default is0. π
Example (using passt as a glow-up replacement for -netdev user) β lowkey obsessed with this one:
# start passt server as a non privileged user
passt
UNIX domain socket bound at /tmp/passt_1.socket
# start QEMU to connect to passt
qemu-kvm linux.img \
-device virtio-net,netdev=net0 \
-netdev stream,id=net0,server=off,addr.type=unix,addr.path=/tmp/passt_1.socket
Example (two guests connected using a stream oriented unix domain socket) β bestie networking, fr fr:
# first VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:56 \
netdev stream,id=net0,server=on,addr.type=unix,addr.path=/tmp/qemu0
# second VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:57 \
-netdev stream,id=net0,server=off,addr.type=unix,addr.path=/tmp/qemu0,reconnect-ms=5000
π«Ά -netdev stream,id=str[,server=on|off],addr.type=fd,addr.str=file-descriptor[,reconnect-ms=milliseconds]
This one sets up a network backend that connects to another QEMU virtual machine or a proxy using a stream oriented socket file descriptor. Slay.
server=on|offβ if it'son, we create a server socket. That's the whole vibe.addr.str=file-descriptorβ the file descriptor number to use as a socket.reconnect-ms=millisecondsβ for a client socket: if the socket gets disconnected, attempt a reconnect after this many milliseconds. Setting it to zero disables this function. (default:0)
π¦ -netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=inet,local.host=addr]
Configure a network backend to connect to a multicast address. Yes, multicast. We're being social.
remote.host=maddr,remote.port=portβ the multicast address.local.host=addrβ specify the host address to send packets from.
Example β three icons on the same "bus", I cannot:
# launch one QEMU instance
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:56 \
-netdev dgram,id=net0,remote.type=inet,remote.host=224.0.0.1,remote.port=1234
# launch another QEMU instance on same "bus"
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:57 \
-netdev dgram,id=net0,remote.type=inet,remote.host=224.0.0.1,remote.port=1234
# launch yet another QEMU instance on same "bus"
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:58 \
-netdev dgram,id=net0,remote.type=inet,remote.host=224.0.0.1,remote.port=1234
π§ -netdev dgram,id=str,remote.type=inet,remote.host=maddr,remote.port=port[,local.type=fd,local.str=file-descriptor]
Same multicast energy, but this time it connects to a multicast address using a UDP socket file descriptor. Iconic variation.
remote.host=maddr,remote.port=portβ the multicast address.local.str=file-descriptorβ file descriptor to use to send packets.
π -netdev dgram,id=str,local.type=inet,local.host=addr,local.port=port[,remote.type=inet,remote.host=addr,remote.port=port]
Configure a network backend to connect to another QEMU virtual machine or a proxy using a datagram oriented unix domain socket. (Yes, that's what the manpage says, and yes, the flags are inet. We report, we don't judge. β¨)
local.host=addr,local.port=portβ IP address to use to send the packets from.remote.host=addr,remote.port=portβ destination IP address.
Example (two guests connected using an UDP/IP socket) β look at these matching port swaps, it's giving choreography:
# first VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:56 \
-netdev dgram,id=net0,local.type=inet,local.host=localhost,local.port=1234,remote.type=inet,remote.host=localhost,remote.port=1235
# second VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:56 \
-netdev dgram,id=net0,local.type=inet,local.host=localhost,local.port=1235,remote.type=inet,remote.host=localhost,remote.port=1234
πΈ -netdev dgram,id=str,local.type=unix,local.path=path[,remote.type=unix,remote.path=path]
Configure a network backend to connect to another QEMU virtual machine or a proxy using a datagram oriented unix socket. The unix-socket remix, we love her.
local.path=pathβ filesystem path to use to bind the socket.remote.path=pathβ filesystem path to use as a destination (seesendto(2)).
Example (two guests connected using an UDP/UNIX socket):
# first VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:56 \
-netdev dgram,id=net0,local.type=unix,local.path=/tmp/qemu0,remote.type=unix,remote.path=/tmp/qemu1
# second VM
qemu-kvm linux.img \
-device virtio-net,netdev=net0,mac=52:54:00:12:34:57 \
-netdev dgram,id=net0,local.type=unix,local.path=/tmp/qemu1,remote.type=unix,remote.path=/tmp/qemu0
π -netdev dgram,id=str,local.type=fd,local.str=file-descriptor
Configure a network backend to connect to another QEMU virtual machine or a proxy using a datagram oriented socket file descriptor. Short and sweet, we stan a concise queen.
local.str=file-descriptorβ file descriptor to use to send packets.
π₯ -netdev l2tpv3,id=id,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport],txsession=txsession[,rxsession=rxsession][,ipv6=on|off][,udp=on|off][,cookie64=on|off][,counter=on|off][,pincounter=on|off][,txcookie=txcookie][,rxcookie=rxcookie][,offset=offset]
Bestie. This configures an L2TPv3 pseudowire host network backend. L2TPv3 (RFC3931) is a popular protocol for transporting Ethernet (and other Layer 2) data frames between two systems. It lives in routers, firewalls, and the Linux kernel (from version 3.3 onwards). Main character protocol energy.
This transport lets a VM talk directly to another VM, router, or firewall. No middleman, no cap.
src=srcaddrβ source address (mandatory β οΈ).dst=dstaddrβ destination address (mandatory β οΈ).udp=onβ select udp encapsulation (default isip).srcport=srcportβ source udp port.dstport=dstportβ destination udp port.ipv6=onβ force v6, otherwise it defaults to v4.rxcookie=rxcookie;txcookie=txcookieβ cookies are a weak form of security in the l2tpv3 specification. Their function is mostly to prevent misconfiguration. By default they're 32 bit.cookie64=onβ set cookie size to 64 bit instead of the default 32.counter=offβ force a 'cut-down' L2TPv3 with no counter, as indraft-mkonstan-l2tpext-keyed-ipv6-tunnel-00.pincounter=onβ work around broken counter handling in the peer. This may also help on networks which have packet reorder.offset=offsetβ add an extra offset between header and data.
For example, to attach a VM running on host 4.3.2.1 via L2TPv3 to the bridge br-lan on the remote Linux host 1.2.3.4:
# Setup tunnel on linux host using raw ip as encapsulation
# on 1.2.3.4
ip l2tp add tunnel remote 4.3.2.1 local 1.2.3.4 tunnel_id 1 peer_tunnel_id 1 \
encap udp udp_sport 16384 udp_dport 16384
ip l2tp add session tunnel_id 1 name vmtunnel0 session_id \
0xFFFFFFFF peer_session_id 0xFFFFFFFF
ifconfig vmtunnel0 mtu 1500
ifconfig vmtunnel0 up
brctl addif br-lan vmtunnel0
# on 4.3.2.1
# launch QEMU instance - if your network has reorder or is very lossy add ,pincounter
qemu-kvm linux.img -device e1000,netdev=n1 \
-netdev l2tpv3,id=n1,src=4.2.3.1,dst=1.2.3.4,udp=on,srcport=16384,dstport=16384,rxsession=0xffffffff,txsession=0xffffffff,counter=on
β -netdev vde,id=id[,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]
Configure a VDE backend to connect to PORT n of a vde switch running on the host and listening for incoming connections on socketpath. Use GROUP groupname and MODE octalmode to change the default ownership and permissions for the communication port.
Heads up bestie π«Ά this option is only available if QEMU has been compiled with vde support enabled. No vde support, no vde for you. π
Example:
# launch vde switch
vde_switch -F -sock /tmp/myswitch
# launch QEMU instance
qemu-kvm linux.img -nic vde,sock=/tmp/myswitch
π -netdev af-xdp,id=str,ifname=name[,mode=native|skb][,force-copy=on|off][,queues=n][,start-queue=m][,inhibit=on|off][,sock-fds=x:y:...:z][,map-path=/path/to/socket/map][,map-start-index=i]
Configure an AF_XDP backend to connect to a network interface name using an AF_XDP socket. A specific program attach mode for a default XDP program can be forced with mode, and it defaults to best-effort, where the likely most performant mode will be in use. The number of queues n should generally match the number of queues in the interface, and defaults to 1. Traffic arriving on non-configured device queues will not be delivered to the network backend. π
# set number of queues to 4
ethtool -L eth0 combined 4
# launch QEMU instance
qemu-kvm linux.img -device virtio-net-pci,netdev=n1 \
-netdev af-xdp,id=n1,ifname=eth0,queues=4
The start-queue option can be specified if a particular range of queues [m, m + n] should be in use. For example, this may be necessary in order to use certain NICs in native mode. The kernel allows the driver to create a separate set of XDP queues on top of regular ones, and only these queues can be used for AF_XDP sockets. NICs that work this way may also require an additional traffic redirection with ethtool to these special queues. π¦
# set number of queues to 1
ethtool -L eth0 combined 1
# redirect all the traffic to the second queue (id: 1)
# note: drivers may require non-empty key/mask pair.
ethtool -N eth0 flow-type ether \
dst 00:00:00:00:00:00 m FF:FF:FF:FF:FF:FE action 1
ethtool -N eth0 flow-type ether \
dst 00:00:00:00:00:01 m FF:FF:FF:FF:FF:FE action 1
# launch QEMU instance
qemu-kvm linux.img -device virtio-net-pci,netdev=n1 \
-netdev af-xdp,id=n1,ifname=eth0,queues=1,start-queue=1
Bestie, you can also load the XDP program externally instead β¨ In that case the inhibit option should be set to on π
. And when inhibit is enabled you can use either sock-fds or map-path β pick one, okay? π«Ά sock-fds takes file descriptors for XDP sockets that are already open but not bound, and that are already added to a socket map for the corresponding queues. Literally one socket per queue π§
qemu-kvm linux.img -device virtio-net-pci,netdev=n1 \
-netdev af-xdp,id=n1,ifname=eth0,queues=3,inhibit=on,sock-fds=15:16:17
If you set inhibit to on and pair it with map-path, then the expectation is that the XDP program with the socket map is already loaded on the networking device, and that the map is pinned into the BPF file system π. The path to that pinned map gets passed to QEMU, and QEMU goes ahead and creates the file descriptors and inserts them into the existing socket map π
qemu-kvm linux.img -device virtio-net-pci,netdev=n1 \
-netdev af-xdp,id=n1,ifname=eth0,queues=2,inhibit=on,map-path=/sys/fs/bpf/xsks_map
Also, map-start-index exists so you can specify the start offset for insertion into the socket map π. And heads up: combining map-path and sock-fds together is not supported π.
-netdev vhost-user,chardev=id[,vhostforce=on|off][,queues=n]β sets up a vhost-user netdev, backed by a chardevidβ¨. That chardev should be a unix domain socket backed one, mmkay. vhost-user uses its own very specifically defined protocol to pass vhost ioctl replacement messages to an application sitting on the other end of the socket π . On non-MSIX guests you can force the feature withvhostforce. And usequeues=nto say how many queues you want created for multiqueue vhost-user π¦
Example, bestie:
qemu-kvm -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,share=on \
-numa node,memdev=mem \
-chardev socket,id=chr0,path=/path/to/socket \
-netdev type=vhost-user,id=net0,chardev=chr0 \
-device virtio-net-pci,netdev=net0
-netdev vhost-vdpa[,vhostdev=/path/to/dev][,vhostfd=h]β sets up a vhost-vdpa netdev πΈ. So what even is a vDPA device? It's a device that uses a datapath complying with the virtio specifications, but with a vendor specific control path, no cap. And vDPA devices can be physically on the hardware or emulated by software π-netdev hubport,id=id,hubid=hubid[,netdev=nd]β creates a hub port on the emulated hub with IDhubidπ. The hubport netdev is literally the thing that lets you connect a NIC to a QEMU emulated hub instead of to a single netdev. Or, if you'd rather, you can connect the hubport to another netdev with IDndusing thenetdev=ndoption π-net nic[,netdev=nd][,macaddr=mac][,model=type][,name=name][,addr=addr][,vectors=v]β the legacy option for configuring or creating an on-board (or machine default) Network Interface Card (NIC), and connecting it either to the emulated hub with ID0(i.e. the default hub) or to the netdevndπ.
If model is omitted, then the default NIC model associated with the machine type gets used β but π note that the default NIC model may change in future QEMU releases, so it is highly recommended to always specify a model, fr fr.
Optionally the MAC address can be changed to mac, the device address set to addr (PCI cards only π
), and a name can be assigned for use in monitor commands β¨.
Optionally, for PCI cards, you can specify the number v of MSI-X vectors that the card should have β this option currently only affects virtio cards, and setting v = 0 disables MSI-X π¦.
If no -net option is specified, a single NIC is created π. QEMU can emulate several different models of network card, and you can use -net nic,model=help for a list of available devices for your target π
-net user|passt|tap|bridge|socket|l2tpv3|vde[,...][,name=name]β configures a host network backend (with the options corresponding to the same-netdevoption) and hooks it up to the emulated hub0(the default hub) π. Usenameto specify the name of the hub port π
πΈ Character device options πΈ
The general form of a character device option is, okay:
-chardev backend,id=id[,mux=on|off][,options]
backend is one of: null, socket, udp, msmouse, hub, vc, ringbuf, file, pipe, console, serial, pty, stdio, braille, parallel, spicevmc, spiceport, dbus π. The specific backend determines which options actually apply to you π
Use -chardev help to print all the available chardev backend types, super handy β¨
Every device must have an id, which can be any string up to 127 characters long π. It's used to uniquely identify this device in other command line directives, iykyk π
A character device may be used in multiplexing mode by multiple front-ends β just specify mux=on to enable that mode π¦. A multiplexer is a "1:N" device, where the "1" end is your specified chardev backend and the "N" end is the various parts of QEMU that can talk to a chardev. So if you create a chardev with id=myid and mux=on, QEMU creates a multiplexer with your specified ID, and then you can configure multiple front ends to use that chardev ID for their input/output π. Up to four different front ends can connect to a single multiplexed chardev. (Without multiplexing enabled, a chardev can only be used by a single front end, facts are facts π.) For instance you could use this so a single stdio chardev gets used by two serial ports and the QEMU monitor π:
-chardev stdio,mux=on,id=char0 \
-object monitor-hmp,id=hmp0,chardev=char0 \
-serial chardev:char0 \
-serial chardev:char0
You can have more than one multiplexer in a system configuration too π for instance you could have a TCP port multiplexed between UART 0 and UART 1, and stdio multiplexed between the QEMU monitor and a parallel port:
-chardev stdio,mux=on,id=char0 \
-object monitor-hmp,id=hmp0,chardev=char0 \
-parallel chardev:char0 \
-chardev tcp,...,mux=on,id=char1 \
-serial chardev:char1 \
-serial chardev:char1
When you're using a multiplexed character device, some escape sequences get interpreted in the input π. See the chapter about Keys in the character backend multiplexer in the System Emulation Users Guide for more details, bestie π
Also note that some other command line options may implicitly create multiplexed character backends β for instance -serial mon:stdio creates a multiplexed stdio backend connected to the serial port and the QEMU monitor, and -nographic also multiplexes the console and the monitor to stdio π
If you need to aggregate data in the opposite direction (where one QEMU frontend interface receives input and output from multiple backend chardev devices), please refer to the paragraph below about the chardev hub aggregator device configuration π«Ά
Every backend supports the logfile option, which supplies the path to a file that records all data transmitted via the backend π. And the logappend option controls whether that log file gets truncated or appended to when it's opened β¨
The available backends are:
-chardev null,id=idβ a total void device π. It won't emit any data and it'll drop any data it receives. Thenullbackend takes no options at all, iconic minimalism π-chardev socket,id=id[,TCP options or unix options][,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect-ms=milliseconds][,tls-creds=id][,tls-authz=id]β creates a two-way stream socket, which can be either a TCP or a unix socket π. A unix socket gets created ifpathis specified. And behaviour is undefined if TCP options are specified for a unix socket, so don't do that π
server=on|off specifies that the socket shall be a listening socket π
wait=on|off specifies that QEMU should not block waiting for a client to connect to a listening socket π
telnet=on|off specifies that traffic on the socket should interpret telnet escape sequences πΊ
websocket=on|off specifies that the socket uses the WebSocket protocol for communication πΈοΈ
reconnect-ms sets the timeout for reconnecting on non-server sockets when the remote end goes away π. QEMU will delay this many milliseconds and then attempt to reconnect. Zero disables reconnecting, and zero is the default π
tls-creds requests enablement of the TLS protocol for encryption, and specifies the id of the TLS credentials to use for the handshake π. Those credentials must be previously created with the -object tls-creds argument, no shortcuts.
tls-auth provides the ID of the QAuthZ authorization object against which the client's x509 distinguished name will be validated π. This object is only resolved at time of use, so it can be deleted and recreated on the fly while the chardev server is active π€―. If it's missing, it will default to denying access β safest default ever tbh.
TCP and unix socket options are given below π
TCP options:
port=port[,host=host][,to=to][,ipv4=on|off][,ipv6=on|off][,nodelay=on|off]
hostfor a listening socket specifies the local address to be bound π. For a connecting socket it specifies the remote host to connect to π.hostis optional for listening sockets, and if it's not specified it defaults to0.0.0.0β¨portfor a listening socket specifies the local port to be bound π. For a connecting socket it specifies the port on the remote host to connect to.portcan be given as either a port number or a service name, andportis required periodt π
okay so continuing right where we left off with the socket chardev, bestie:
to is only relevant to listening sockets, fr. If you specify it, and port cannot be bound, QEMU will attempt to bind to subsequent ports up to and including to until it succeeds. to must be specified as a port number. That's it, that's the rule.
ipv4=on|off and ipv6=on|off specify that either IPv4 or IPv6 must be used. If neither is specified the socket may use either protocol. π
nodelay=on|off disables the Nagle algorithm. (Yes, that Nagle. He's not invited.)
π¦ unix options: path=path[,abstract=on|off][,tight=on|off]
pathspecifies the local path of the unix socket.pathis required, no skipping.abstract=on|offspecifies the use of the abstract socket namespace, rather than the filesystem. Optional, defaults tofalse.tight=on|offsets the socket length of abstract sockets to their minimum, rather than the fullsun_pathlength. Optional, defaults totrue.
-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr][,localport=localport][,ipv4=on|off][,ipv6=on|off]β sends all traffic from the guest to a remote host over UDP. πhostspecifies the remote host to connect to. If not specified it defaults tolocalhost.portspecifies the port on the remote host to connect to.portis required.localaddrspecifies the local address to bind to. If not specified it defaults to0.0.0.0.localportspecifies the local port to bind to. If not specified any available local port will be used.ipv4=on|offandipv6=on|offspecify that either IPv4 or IPv6 must be used. If neither is specified the device may use either protocol.
-chardev msmouse,id=idβ forward QEMU's emulated msmouse events to the guest.msmousedoes not take any options. iconic, minimal, no notes. β¨-chardev hub,id=id,chardevs.0=id[,chardevs.N=id]β explicitly create a chardev backend hub device, with the possibility to aggregate input from multiple backend devices and forward it to a single frontend device. Lowkey genius: the hub device also takes the output from the frontend device and sends it back to all the connected backend devices. This allows for seamless interaction between different backend devices and a single frontend interface. Aggregation supported for up to 4 chardev devices. (Since 10.0) π«Ά
For example, the following is a use case of 2 backend devices: virtual console vc0 and a pseudo TTY pty0 connected to a single virtio hvc console frontend device with a hub hub0 help. Virtual console renders text to an image, which can be shared over the VNC protocol. In turn, pty backend provides bidirectional communication to the virtio hvc console over the pseudo TTY file. The example configuration can be as follows:
-chardev pty,path=/tmp/pty,id=pty0 \
-chardev vc,id=vc0 \
-chardev hub,id=hub0,chardevs.0=pty0,chardevs.1=vc0 \
-device virtconsole,chardev=hub0 \
-vnc 0.0.0.0:0
Once QEMU starts VNC client and any TTY emulator can be used to control a single hvc console:
# Start TTY emulator
tio /tmp/pty
# Start VNC client and switch to virtual console Ctrl-Alt-2
vncviewer :0
π Several frontend devices is not supported. Stacking of multiplexers and hub devices is not supported as well. So don't try it, bestie, it's giving "undefined behaviour" energy.
-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]][,encoding=ENCODING]β connect to a QEMU text console. The implementation and supported feature set depend on the selected display backend. π- The GTK backend uses libvte for the emulation and display (when available).
- The D-Bus backend exports the character device as a Chardev object.
- spice-app backend exports it as a Spice port.
In other cases, QEMU uses its own emulated VT100, and vc may optionally be given a specific size.
width and height specify the width and height respectively of the console, in pixels.
cols and rows specify that the console be sized to fit a text console with the given dimensions.
encoding specifies the character set expected from the guest: utf8 or cp437 (8-bit Extended ASCII / VGA).
-chardev ringbuf,id=id[,size=size]β create a ring buffer with fixed sizesize.sizemust be a power of two and defaults to64K. Not me checking your math for you, but likeβ¦ check your math. π-chardev file,id=id,path=path[,input-path=input-path]β log all traffic received from the guest to a file. πpathspecifies the path of the file to be opened. This file will be created if it does not already exist, and overwritten if it does.pathis required.- If
input-pathis specified, this is the path of a second file which will be used for input. Ifinput-pathis not specified, no input will be available from the chardev.
π«Ά Note that input-path is not supported on Windows hosts.
-chardev pipe,id=id,path=pathβ create a two-way connection to the guest. The behaviour differs slightly between Windows hosts and other hosts:- On Windows, a single duplex pipe will be created at
\\.pipe\path. - On other hosts, 2 pipes will be created called
path.inandpath.out. Data written topath.inwill be received by the guest. Data written by the guest can be read frompath.out. QEMU will not create these fifos, and requires them to be present.
- On Windows, a single duplex pipe will be created at
path forms part of the pipe path as described above. path is required. β¨
-chardev console,id=idβ send traffic from the guest to QEMU's standard output.consoledoes not take any options.
console is only available on Windows hosts. Windows girlies rise up π
-chardev serial,id=id,path=pathβ send traffic from the guest to a serial device on the host.
On Unix hosts serial will actually accept any tty device, not only serial lines. (she's flexible like that)
path specifies the name of the serial device to open.
-chardev pty,id=id[,path=path]β create a new pseudo-terminal on the host and connect to it.
pty is not available on Windows hosts.
If path is specified, QEMU will create a symbolic link at that location which points to the new PTY device. This avoids having to make QMP or HMP monitor queries to find out what the new PTY device path is. πΈ
π Note that while QEMU will remove the symlink when it exits gracefully, it will not do so in case of crashes or on certain startup errors. It is recommended that the user checks and removes the symlink after QEMU terminates to account for this. Literally check your symlinks, bestie, for me.
-chardev stdio,id=id[,signal=on|off]β connect to standard input and standard output of the QEMU process.
signal controls if signals are enabled on the terminal, that includes exiting QEMU with the key sequence Control+c. This option is enabled by default, use signal=off to disable it. β
-chardev braille,id=idβ connect to a local BrlAPI server.brailledoes not take any options. accessibility icon behaviour, we love to see it π¦-chardev parallel,id=id,path=path
parallel is only available on Linux, FreeBSD and DragonFlyBSD hosts. π
Connect to a local parallel port.
path specifies the path to the parallel port device. path is required.
-chardev spicevmc,id=id,debug=debug,name=nameβspicevmcis only available when spice support is built in.debugβ debug level forspicevmcnameβ name of spice channel to connect to
Connect to a spice virtual machine channel, such as vdiport. β¨
-chardev spiceport,id=id,debug=debug,name=nameβspiceportis only available when spice support is built in.debugβ debug level forspicevmcnameβ name of spice port to connect to
Connect to a spice port, allowing a Spice client to handle the traffic identified by a name (preferably a fqdn). iykyk π
-chardev dbus,id=id,name=nameβdbusis only available when D-Bus display support is built in.nameβ name of the chardev as exported on the D-Bus display interface
Export the character device on the D-Bus display interface, so that a D-Bus client can connect to it. π«Ά
π§ TPM device options π§
The general form of a TPM device option is:
-tpmdev backend,id=id[,options]β the specific backend type will determine the applicable options. The-tpmdevoption creates the TPM backend and requires a-deviceoption that specifies the TPM frontend interface model.
Use -tpmdev help to print all available TPM backend types. π
The available backends are:
-tpmdev passthrough,id=id,path=path,cancel-path=cancel-pathβ (Linux-host only) enable access to the host's TPM using the passthrough driver. π§pathspecifies the path to the host's TPM device, i.e., on a Linux host this would be/dev/tpm0.pathis optional and by default/dev/tpm0is used.cancel-pathspecifies the path to the host TPM device's sysfs entry allowing for cancellation of an ongoing TPM command.cancel-pathis optional and by default QEMU will search for the sysfs entry to use.
Some notes about using the host's TPM with the passthrough driver, and bestie you're gonna wanna read these:
- The TPM device accessed by the passthrough driver must not be used by any other application on the host. Like, at all. It's taken. π
- Since the host's firmware (BIOS/UEFI) has already initialized the TPM, the VM's firmware (BIOS/UEFI) will not be able to initialize the TPM again and may therefore not show a TPM-specific menu that would otherwise allow the user to configure the TPM β e.g., allow the user to enable/disable or activate/deactivate the TPM. Further, if TPM ownership is released from within a VM then the host's TPM will get disabled and deactivated. To enable and activate the TPM again afterwards, the host has to be rebooted and the user is required to enter the firmware's menu to enable and activate the TPM. If the TPM is left disabled and/or deactivated most TPM commands will fail. π seriously, don't skip this part
To create a passthrough TPM use the following two options:
-tpmdev passthrough,id=tpm0 -device tpm-tis,tpmdev=tpm0
Note that the -tpmdev id is tpm0 and is referenced by tpmdev=tpm0 in the device option. Match your ids, bestie, it's literally the whole vibe. π
-tpmdev emulator,id=id,chardev=devβ bestie, this one is Linux-host only and it lets you tap into a TPM emulator using a Unix domain socket based chardev backend. π
chardev picks the unique ID of a character device backend that gives you the connection to the software TPM server. π«Ά
To create a TPM emulator backend device with the chardev socket backend:
-chardev socket,id=chrtpm,path=/tmp/swtpm-sock -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis,tpmdev=tpm0
π Boot Image or Kernel specific π
Okay so there are broadly 4 ways you can boot a system with QEMU:
- specify a firmware and let it control finding a kernel
- specify a firmware and pass a hint to the kernel to boot
- direct kernel image boot
- manually load files into the guest's address space
The third method is useful for quickly testing kernels, but β and this is the catch β as there is no firmware to pass configuration information to the kernel, the hardware must either be probeable, the kernel built for the exact configuration, or passed some configuration data (e.g. a DTB blob) which tells the kernel what drivers it needs. The exact details are often hardware specific. π
The final method is the most generic way of loading images into the guest address space and is used mostly for bare metal type development where the reset vectors of the processor are taken into account. π
For x86 machines and some other architectures -bios will generally do the right thing with whatever it is given. For other machines the more strict -pflash option needs an image that is sized for the flash device for the given machine type. β¨
Please see the QEMU System Emulator Targets section of the manual for more detailed documentation.
-bios fileβ set the filename for the BIOS. π§-pflash fileβ usefileas a parallel flash image. π¦
The kernel options were designed to work with Linux kernels although other things (like hypervisors) can be packaged up as a kernel executable image. The exact format of an executable image is usually architecture specific. π
The way in which the kernel is started (what address it is loaded at, what if any information is passed to it via CPU registers, the state of the hardware when it is started, and so on) is also architecture specific. Typically it follows the specification laid down by the Linux kernel for how kernels for that architecture must be started. πΈ
-kernel bzImageβ usebzImageas kernel image. The kernel can be either a Linux kernel or in multiboot format. π₯-shim shim.efiβ use'shim.efi'to boot the kernel. π-append cmdlineβ usecmdlineas kernel command line. π-initrd fileβ usefileas initial ram disk. π«Ά-initrd "file1 arg=foo,file2"β this syntax is only available with multiboot. Usefile1andfile2as modules and passarg=fooas parameter to the first module. Commas can be provided in module parameters by doubling them on the command line to escape them. π-initrd "bzImage earlyprintk=xen,,keep root=/dev/xvda1,initrd.img"β Multiboot only. UsebzImageas the first module with"earlyprintk=xen,keep root=/dev/xvda1"as its command line, andinitrd.imgas the second module. π-dtb fileβ usefileas a device tree binary (dtb) image and pass it to the kernel on boot. π
Finally you can also manually load images directly into the address space of the guest. This is most useful for developers who already know the layout of their guest and take care to ensure something sane will happen when the reset vector executes. π
The generic loader can be invoked by using the loader device:
-device loader,addr=<addr>,data=<data>,data-len=<data-len>[,data-be=<data-be>][,cpu-num=<cpu-num>]
There is also the guest loader which operates in a similar way but tweaks the DTB so a hypervisor loaded via -kernel can find where the guest image is:
-device guest-loader,addr=<addr>[,kernel=<path>,[bootargs=<arguments>]][,initrd=<path>]
π₯ Debug/Expert options π₯
-compat [deprecated-input=<input-policy>][,deprecated-output=<output-policy>]β set policy for handling deprecated management interfaces. This one is experimental. β οΈdeprecated-input=accept(default) β accept deprecated commands and arguments. βdeprecated-input=rejectβ reject deprecated commands and arguments. π«deprecated-input=crashβ crash on deprecated commands and arguments. πdeprecated-output=accept(default) β emit deprecated command results and events. βdeprecated-output=hideβ suppress deprecated command results and events. π
Limitation: covers only syntactic aspects of QMP. π«
-compat [unstable-input=<input-policy>][,unstable-output=<output-policy>]β set policy for handling unstable management interfaces. Also experimental. β¨unstable-input=accept(default) β accept unstable commands and arguments. βunstable-input=rejectβ reject unstable commands and arguments. π«unstable-input=crashβ crash on unstable commands and arguments. πunstable-output=accept(default) β emit unstable command results and events. βunstable-output=hideβ suppress unstable command results and events. π
Limitation: covers only syntactic aspects of QMP. π«
-fw_cfg [name=]name,file=fileβ add a named fw_cfg entry with contents from filefile. If the filename contains a comma, you must double it (for instance,"file=my,,file"to use file"my,file"). π-fw_cfg [name=]name,string=strβ add a named fw_cfg entry with contents from stringstr. If the string contains a comma, you must double it (for instance,"string=my,,string"to use file"my,string"). π
The terminating NUL character of the contents of str will not be included as part of the fw_cfg item data. To insert contents with embedded NUL characters, you have to use the file parameter. π‘
The fw_cfg entries are passed by QEMU through to the guest. π
Example:
-fw_cfg name=opt/com.mycompany/blob,file=./my_blob.bin
This creates an fw_cfg entry named opt/com.mycompany/blob with contents from ./my_blob.bin. π
-serial devβ redirect the virtual serial port to host character devicedev. The default device isvcin graphical mode andstdioin non graphical mode. π
This option can be used several times to simulate multiple serial ports. π
You can use -serial none to suppress the creation of default serial devices. π«
Available character devices are:
vc[:WxH]β virtual console. Optionally, a width and height can be given in pixels with:
vc:800x600
It is also possible to specify width or height in characters:
vc:80Cx24C
pty[:path]β [Linux only] pseudo TTY (a new PTY is automatically allocated). π§
If path is specified, QEMU will create a symbolic link at that location which points to the new PTY device. π
This avoids having to make QMP or HMP monitor queries to find out what the new PTY device path is. π
Note that while QEMU will remove the symlink when it exits gracefully, it will not do so in case of crashes or on certain startup errors. It is recommended that the user checks and removes the symlink after QEMU terminates to account for this. β οΈ
noneβ no device is allocated. Note that for machine types which emulate systems where a serial device is always present in real hardware, this may be equivalent to thenulloption, in that the serial device is still present but all output is discarded. For boards where the number of serial ports is truly variable, this suppresses the creation of the device. π«₯nullβ a guest will see the UART or serial device as present in the machine, but all output is discarded, and there is no input. Conceptually equivalent to redirecting the output to/dev/null. π³οΈchardev:idβ use a named character device defined with the-chardevoption. π·οΈ/dev/XXXβ [Linux only] use host tty, e.g./dev/ttyS0. The host serial port parameters are set according to the emulated ones. π§/dev/parportNβ [Linux only, parallel port only] use host parallel portN. Currently SPP and EPP parallel port features can be used. π¨οΈfile:filenameβ write output tofilename. No character can be read. πstdioβ [Unix only] standard input/output. π₯οΈpipe:filenameβ name pipefilename(yes, that's what it says π ). π§ͺCOMnβ [Windows only] use host serial portn. πͺudp:[remote_host]:remote_port[@[src_ip]:src_port]β this implements UDP Net Console. Whenremote_hostorsrc_ipare not specified they default to0.0.0.0. When not using a specifiedsrc_porta random port is automatically chosen. π
If you just want a simple readonly console you can use netcat or nc, by starting QEMU with: -serial udp::4555 and nc as: nc -u -l -p 4555. Any time QEMU writes something to that port it will appear in the netconsole session. π¬
If you plan to send characters back via netconsole or you want to stop and start QEMU a lot of times, you should have QEMU use the same source port each time by using something like -serial udp::4555@:4556 to QEMU. Another approach is to use a patched version of netcat which can listen to a TCP port and send and receive characters via udp. If you have a patched version of netcat which activates telnet remote echo and single char transfer, then you can use the following options to set up a netcat redirector to allow telnet on port 5555 to access the QEMU port. π οΈ
QEMU Options:
-serial udp::4555@:4556
netcat options:
-u -P 4555 -L 0.0.0.0:4556 -t -p 5555 -I -T
telnet options:
localhost 5555
So the serial backends keep going, and bestie, this is the part where things get β¨spicyβ¨. Buckle up. π
tcp:[host]:port[,server=on|off][,wait=on|off][,nodelay=on|off][,reconnect-ms=milliseconds]β okay so the TCP Net Console is genuinely a two-mode girlie. Mode one: it sends the serial I/O to a location. Mode two: it waits for a connection from a location. By default the TCP Net Console gets sent to host at the port. If you slapserver=onon, QEMU waits for a client socket application to connect to the port before continuing β unless you also saidwait=on|off, in which case that overrides it. Thenodelay=on|offoption disables the Nagle buffering algorithm (yes, that Nagle). Thereconnect-msoption only does anything ifserver=nois set β if the connection goes down it will attempt to reconnect at the given interval. If host is omitted,0.0.0.0is assumed. And heads up: only one TCP connection at a time is accepted. You can usetelnet=onto connect to the corresponding character device. π
Example to send tcp console to 192.168.0.2 port 4444:
-serial tcp:192.168.0.2:4444
Example to listen and wait on port 4444 for connection:
-serial tcp::4444,server=on
Example to not wait and listen on ip 192.168.0.100 port 4444:
-serial tcp:192.168.0.100:4444,server=on,wait=off
telnet:host:port[,server=on|off][,wait=on|off][,nodelay=on|off]β this one's the telnet-protocol version instead of raw tcp sockets. The options work the same as if you had specified-serial tcp. The difference? The port acts like a telnet server or client using telnet option negotiation. And it will also let you send theMAGIC_SYSRQsequence if you use a telnet that supports sending the break sequence. Typically in unix telnet you do it with Control+] and then type"send break"followed by pressing the enter key. cute, right? π¦websocket:host:port,server=on[,wait=on|off][,nodelay=on|off]β the WebSocket protocol is used instead of raw tcp socket. The port acts as a WebSocket server. Client mode is not supported β sorry bestie, that's just the vibe check result. πunix:path[,server=on|off][,wait=on|off][,reconnect-ms=milliseconds]β a unix domain socket is used instead of a tcp socket. The option works the same as if you had specified-serial tcpexcept the unix domain socket path is used for connections. πΈmon:dev_stringβ this is a special little icon to allow the monitor to be multiplexed onto another serial port. The monitor is accessed with the key sequence of Control+a and then pressing c. dev_string should be any one of the serial devices specified above. An example to multiplex the monitor onto a telnet server listening on port 4444 would be:
-serial mon:telnet::4444,server=on,wait=off
When the monitor is multiplexed to stdio in this way, Ctrl+C will not terminate QEMU any more but will be passed to the guest instead. so like, don't panic when it doesn't die, that's on purpose. π
brailleβ braille device! This will useBrlAPIto display the braille output on a real or fake device. accessibility main character energy fr fr. π«Άmsmouseβ three button serial mouse. Configure the guest to use Microsoft protocol. π±οΈ
parallel & monitor-adjacent things β¨
-parallel devβ redirect the virtual parallel port to host device dev (same devices as the serial port). On Linux hosts,/dev/parportNcan be used to use hardware devices connected on the corresponding host parallel port.
This option can be used several times to simulate up to 3 parallel ports. π
Use -parallel none to disable all parallel ports.
-monitor devβ redirect the monitor to host device dev (same devices as the serial port). The default device isvcin graphical mode andstdioin non graphical mode. Use-monitor noneto disable the default monitor. π
The use of -monitor dev is syntactic sugar for creating a character device from dev and pairing it with -object monitor-hmp. Both the character device and monitor object will be given an ID compat_monitorNNN where NNN is a counter starting from 0.
-qmp devβ like-monitorbut opens in'control'mode. For example, to make QMP available on localhost port 4444:
-qmp tcp:localhost:4444,server=on,wait=off
The use of -qmp dev is syntactic sugar for creating a character device from dev and pairing it with -object monitor-qmp. Both the character device and monitor object will be given an ID compat_monitorNNN where NNN is a counter starting from 0.
-qmp-pretty devβ like-qmpbut uses pretty JSON formatting. it's giving aesthetic. π-mon [chardev=]name[,mode=readline|control][,pretty=on|off]β set up a monitor connected to the chardev name. QEMU supports two monitors: the Human Monitor Protocol (HMP; for human interaction), and the QEMU Monitor Protocol (QMP; a JSON RPC-style protocol). The default is HMP;mode=controlselects QMP instead.prettyis only valid whenmode=control, turning on JSON pretty printing to ease human reading and debugging. π¦
For example:
-chardev socket,id=mon1,host=localhost,port=4444,server=on,wait=off \
-mon chardev=mon1,mode=control,pretty=on
enables the QMP monitor on localhost port 4444 with pretty-printing. slay.
The use of-mon mode=readlineis deprecated syntactic sugar for the new-object monitor-hmpoption, each use of which creates an object with the IDcompat_monitorNNNwhere NNN is a counter starting from0.
The use of-mon mode=controlis deprecated syntactic sugar for the new-object monitor-qmpoption, each use of which creates an object with the IDcompat_monitorNNNwhere NNN is a counter starting from0.
ngl, deprecated = move on bestie, the new -object way is the moment. π
-debugcon devβ redirect the debug console to host device dev (same devices as the serial port). The debug console is an I/O port which is typically port0xe9; writing to that I/O port sends output to this device. The default device isvcin graphical mode andstdioin non graphical mode. π₯-pidfile fileβ store the QEMU process PID in file. It is useful if you launch QEMU from a script. tiny but mighty. π--preconfigβ pause QEMU for interactive configuration before the machine is created, which allows querying and configuring properties that will affect machine initialization. Use QMP command'x-exit-preconfig'to exit the preconfig state and move to the next state (i.e. run guest if-Sisn't used or pause the second time if-Sis used). This option is experimental β οΈ β so like, she's cute but she's still in beta.-Sβ do not start CPU at startup (you must type'c'in the monitor). the "wait for me" of options tbh. β
overcommit, gdb & friends π
-overcommit mem-lock=on|off|on-fault-overcommit cpu-pm=on|off
Run qemu with hints about host resource overcommit. The default is to assume that host overcommits all resources. π
Locking qemu and guest memory can be enabled via mem-lock=on or mem-lock=on-fault (disabled by default). This works when host memory is not overcommitted and reduces the worst-case latency for guest. The on-fault option is better for reducing the memory footprint since it makes allocations lazy, but the pages still get locked in place once faulted by the guest or QEMU. Note that the two options are mutually exclusive. β οΈ pick a lane bestie.
Guest ability to manage power state of host cpus (increasing latency for other processes on the same host cpu, but decreasing latency for guest) can be enabled via cpu-pm=on (disabled by default). This works best when host CPU is not overcommitted. When used, host estimates of CPU cycle and power utilization will be incorrect, not taking into account guest idle time. π
-gdb devβ accept a gdb connection on device dev (see the GDB usage chapter in the System Emulation Users Guide). Note that this option does not pause QEMU execution β if you want QEMU to not start the guest until you connect with gdb and issue a continue command, you will need to also pass the-Soption to QEMU. π
The most usual configuration is to listen on a local TCP socket:
-gdb tcp::3117
but you can specify other backends; UDP, pseudo TTY, or even stdio are all reasonable use cases. For example, a stdio connection allows you to start QEMU from within gdb and establish the connection via a pipe:
(gdb) target remote | exec qemu-kvm -gdb stdio ...
-sβ shorthand for-gdb tcp::1234, i.e. open a gdbserver on TCP port1234(see the GDB usage chapter in the System Emulation Users Guide). β¨-d item1[,...]β enable logging of specified items. Use'-d help'for a list of log items. π-D logfileβ output log in logfile instead of to stderr.-dfilter range1[,...]β filter debug output to that relevant to a range of target addresses. The filter spec can be eitherstart+size,start-sizeorstart..endwhere start, end and size are the addresses and sizes required. For example:
-dfilter 0x8000..0x8fff,0xffffffc000080000+0x200,0xffffffc000060000-0x1000
Will dump output for any code in the 0x1000 sized block starting at 0x8000 and the 0x200 sized block starting at 0xffffffc000080000 and another 0x1000 sized block starting at 0xffffffc00005f000. math girlie behavior honestly. π§
-seed numberβ force the guest to use a deterministic pseudo-random number generator, seeded with number. This does not affect crypto routines within the host. π-L pathβ set the directory for the BIOS, VGA BIOS and keymaps. To list all the data directories, use-L help. π-enable-kvmβ enable KVM full virtualization support. This option is only available if KVM support is enabled when compiling. π-xen-domid idβ specify xen guest domain id (XEN only).-xen-attachβ attach to existing xen domain.libxlwill use this when starting QEMU (XEN only). Restrict set of available xen operations to specified domain id (XEN only). π-no-rebootβ exit instead of rebooting. truly the "I'm not doing this again" energy. π-no-shutdownβ ok so normally when the guest shuts down QEMU just dips, right? Not with this flag bestie π it makes QEMU only stop the emulation instead of exiting. Which means you can, like, switch over to the monitor and commit your changes to the disk image. Very much the "don't leave yet, I'm not done" energy.-action event=actionβ this is the generic glow-up for QEMU's default behavior when certain guest events happen β¨ It's literally the same behaviors that-no-rebootand-no-shutdowntweak, just expressed in one unified way.
Examples, bestie:
-action panic=none -action reboot=shutdown,shutdown=pause -device
i6300esb -action watchdog=pause
-loadvm fileβ start immediately from a saved state (basically theloadvmcommand in the monitor). Instant main-character entrance, no waiting π-daemonizeβ daemonize the QEMU process after initialization. And here's the cute part: QEMU will not detach from standard IO until it's actually ready to receive connections on any of its devices. So external programs can launch QEMU without having to deal with initialization race conditions π¦ lowkey a lifesaver.-option-rom fileβ loads the contents of file as an option ROM. Super useful for loading things like EtherBoot π-rtc[base=utc|localtime|datetime][,clock=host|rt|vm][,driftfix=none|slew]β the real-time clock knobs, bestie. So:- Set
basetoutcorlocaltimeto let the RTC start at the current UTC or local time respectively.<italic>localtime</italic>is required for the correct date in MS-DOS or Windows. If you wanna start at a specific point in time, hand overdatetimein the format2006-06-17T16:01:21or2006-06-17. The defaultbaseis UTC. - By default the RTC is driven by the host system time. That lets you use the RTC as an accurate reference clock inside the guest β specifically if the host time is smoothly following an accurate external reference clock, e.g. via NTP. If you want to isolate the guest time from the host, set
clocktortinstead, which gives you a host monotonic clock if the host supports it. To even stop the RTC from progressing during suspension, setclocktovm(virtual clock).clock=vmis recommended especially in icount mode to preserve determinism β but heads up, in icount mode the speed of the virtual clock is variable and can in general differ from the host clock π - Enable
driftfix(i386 targets only) if you're experiencing time drift problems, specifically with Windows' ACPI HAL. This option tries to figure out how many timer interrupts were not processed by the Windows guest and re-injects them. Very "we noticed you missed these, here you go" π«Ά
- Set
-icount[shift=N|auto][,align=on|off][,sleep=on|off][,rr=record|replay,rrfile=filename[,rrsnapshot=snapshot]]β enables the virtual instruction counter β¨ The virtual cpu executes one instruction every2^Nns of virtual time. Ifautois specified, the virtual cpu speed gets automatically adjusted to keep virtual time within a few seconds of real time.
Note that while this option can give deterministic behavior, it does not provide cycle-accurate emulation. Modern CPUs contain superscalar out-of-order cores with complex cache hierarchies, and the number of instructions executed often has little or no correlation with actual performance. It's giving "vibes, not benchmarks" π
When the virtual cpu is sleeping, virtual time advances at default speed unless sleep=off is specified. With sleep=off, virtual time jumps to the next timer deadline instantly whenever the virtual cpu goes into sleep mode, and won't advance if no timer is enabled. This gives deterministic execution times from the guest's point of view. The default when icount is enabled is sleep=on. sleep=off cannot be used together with either shift=auto or align=on π«
align=on activates the delay algorithm that tries to synchronise the host clock and the virtual clock. The goal is a guest running at the real frequency imposed by the shift option. Whenever the guest clock is behind the host clock and align=on is specified, a message gets printed to the user to inform about the delay. Currently this option does not work when shift is auto. Note: the sync algorithm works for those shift values for which the guest clock runs ahead of the host clock β typically when the shift value is high (how high depends on the host machine). The default when icount is enabled is align=off.
When the rr option is specified, deterministic record/replay is enabled. The rrfile= option must also be provided to specify the path to the replay log. In record mode data is written to this file, and in replay mode it's read back. If the rrsnapshot option is given, it specifies a VM snapshot name. In record mode, a new VM snapshot with the given name is created at the start of execution recording. In replay mode this option specifies the snapshot name used to load the initial VM state π¬
-watchdog-action actionβ controls what QEMU does when the watchdog timer expires. The default isreset(forcefully reset the guest). Other possible actions:shutdownβ attempt to gracefully shutdown the guestpoweroffβ forcefully poweroff the guestinject-nmiβ inject a NMI into the guestpauseβ pause the guestdebugβ print a debug message and continuenoneβ do nothing
Note that theshutdownaction requires the guest to respond to ACPI signals, which it may not be able to do in the sort of situations where the watchdog would have expired β and thus-watchdog-action shutdownis not recommended for production use π fr fr take this seriously.
Example:
-device i6300esb -watchdog-action pause
-echr numeric_ascii_valueβ changes the escape character used to switch to the monitor when using monitor and serial sharing. The default is0x01when using the-nographicoption, and0x01is equal to pressing Control+a. You can pick a different character from the ascii control keys, where 1 through 26 map to Control-a through Control-z. For instance, either of these changes the escape character to Control-t π
-echr 0x14; -echr 20
The -incoming option specifies the migration channel for an incoming migration. It may be used multiple times to specify multiple migration channel types π The channel type is specified in <channel>, or is main for all other forms of -incoming. If multiple -incoming options are specified for a channel type, the last one takes precedence.
-incoming tcp:[host]:port[,to=maxport][,ipv4=on|off][,ipv6=on|off]-incoming rdma:host:port[,ipv4=on|off][,ipv6=on|off]β prepare for incoming migration, listen on a given tcp port.-incoming unix:socketpathβ prepare for incoming migration, listen on a given unix socket π¦-incoming fd:fdβ accept incoming migration from a given file descriptor.-incoming file:filename[,offset=offset]β accept incoming migration from a given file starting atoffset.offsetallows the common size suffixes, or a0xprefix, but not both π-incoming exec:cmdlineβ accept incoming migration as an output from the specified external command.-incoming <channel>β accept incoming migration on the migration channel. For the syntax of<channel>, see the QAPI documentation ofMigrationChannel. Examples, bestie:
-incoming '{"channel-type": "main",
"addr": { "transport": "socket",
"type": "unix",
"path": "my.sock" }}'
-incoming main,addr.transport=socket,addr.type=unix,addr.path=my.sock
-incoming deferβ wait for the URI to be specified viamigrate_incoming. The monitor can be used to change settings (such as migration parameters) prior to issuing themigrate_incoming, so the migration can begin whenever you're ready β¨-only-migratableβ only allow migratable devices. Devices will not be allowed to enter an unmigratable state π-nodefaultsβ don't create default devices. Normally QEMU sets up default devices like the serial port, parallel port, virtual console, monitor device, VGA adapter, floppy and CD-ROM drive and others β-nodefaultsdisables all of those default devices. Very minimalist of you π-prom-env variable=valueβ set OpenBIOS nvram variable to the given value (PPC, SPARC only).
qemu-system-sparc -prom-env 'auto-boot?=false' \
-prom-env 'boot-device=sd(0,2,0):d' -prom-env 'boot-args=linux single'
qemu-system-ppc -prom-env 'auto-boot?=false' \
-prom-env 'boot-device=hd:2,\yaboot' \
-prom-env 'boot-args=conf=hd:2,\yaboot.conf'
-semihostingβ enable Semihosting mode (ARM, M68K, Xtensa, MIPS, RISC-V only).
WARNING: note that this allows the guest direct access to the host filesystem, so it should only be used with a trusted guest OS π please please please be careful.
See the -semihosting-config option documentation for further information about the facilities this enables π«Ά
-semihosting-config[enable=on|off][,target=native|gdb|auto][,chardev=id][,userspace=on|off][,arg=str[,...]]β enable and configure Semihosting (ARM, M68K, Xtensa, MIPS, RISC-V only).
WARNING: again β this allows the guest direct access to the host filesystem, so it should only be used with a trusted guest OS π
target=native|gdb|autoβ defines where the semihosting calls will be addressed: to QEMU (native) or to GDB (gdb). The default isauto, which meansgdbduring debug sessions andnativeotherwise.chardev=str1β send the output to a chardev backend output fornativeorautooutput when not in gdb.userspace=on|offβ allows code running in guest userspace to access the semihosting interface. The default is that only privileged guest code can make semihosting calls. Note that settinguserspace=onshould only be used if all guest code is trusted (for example, in bare-metal test case code) π
arg=str1,arg=str2,...β okay so this is how you hand QEMU a whole little list of input arguments, and bestie you can pass it multiple times and it just keeps stacking them up into one big gorgeous list π«Ά. The ancient-kernel/-appendway of passing a command line is still supported for backward compatibility (respect the elders π ). But if you specify both the--semihosting-config argthing and-kernel/-append, the former gets passed to semihosting, because it always takes precedence. Always. No negotiating.
-sandboxβ turn on the Seccomp mode 2 system call filter.'on'enables syscall filtering,'off'disables it. The default is'off'. Signature, exactly:
-sandbox arg[,obsolete=string][,elevateprivileges=string][,spawn=string][,resourcecontrol=string]
obsolete=stringβ enable Obsolete system calls.elevateprivileges=stringβ disableset*uid|gidsystem calls.spawn=stringβ disable*forkandexecve.resourcecontrol=stringβ disable process affinity and scheduler priority.
-readconfig fileβ reads device configuration from file. Super useful when you wanna spawn a QEMU process with, like, a million command line options but you do NOT wanna slam into the command line character limit π. Put it in a file, live your truth β¨.-no-user-configβ makes QEMU not load any of the user-provided config files on sysconfdir. That's it, that's the whole vibe. No user config, no drama.-traceβ specify tracing options. Signature:
-trace [[enable=]pattern][,events=file][,file=file]
[enable=]PATTERNβ immediately enable events matching PATTERN (either an event name or a globbing pattern). This option is only available if QEMU has been compiled with thesimple,logorftracetracing backend. To specify multiple events or patterns, just specify the-traceoption multiple times, go off π. And real talk: use-trace helpto print a list of names of trace points. iykyk.events=FILEβ immediately enable events listed in FILE. The file must contain one event name (as listed in thetrace-events-allfile) per line; globbing patterns are accepted too. This option is only available if QEMU has been compiled with thesimple,logorftracetracing backend.file=FILEβ log output traces to FILE. This option is only available if QEMU has been compiled with thesimpletracing backend. (Only that one. Not the others. Yeah.)
-pluginβ load a plugin. Signature:
-plugin file=file[,argname=argvalue]
file=fileβ load the given plugin from a shared library file.argname=argvalueβ argument passed to the plugin. (Can be given multiple times.) Stack 'em π
-run-withβ set QEMU process lifecycle options. Signature:
-run-with [async-teardown=on|off][,chroot=dir][,exit-with-parent=on|off][,user=username|uid:gid]
async-teardown=onenables asynchronous teardown. A new process called"cleanup/<QEMU_PID>"will be created at startup, sharing the address space with the main QEMU process, usingclone. It will wait for the main QEMU process to terminate completely, and then exit. This allows QEMU to terminate very quickly even if the guest was huge, leaving the teardown of the address space to the cleanup process. Since the cleanup process shares the same cgroups as the main QEMU process, accounting is performed correctly. β οΈ This only works if the cleanup process is not forcefully killed withSIGKILLbefore the main QEMU process has terminated completely. Do not do that.chroot=dircan be used for doing achrootto the specified directory immediately before starting the guest execution. This is especially useful in combination withuser=.... Chef's kiss combo π€exit-with-parent=oncauses QEMU to exit if the parent process of QEMU exits. This can be used when QEMU runs a captive appliance, where the lifetime of the appliance is scoped to the parent process. In case the parent process crashes, QEMU is still cleaned up. This only works on Linux, FreeBSD and macOS platforms. ππ§user=usernameoruser=uid:gidcan be used to drop root privileges before starting guest execution. QEMU will use thesetuidandsetgidsystem calls to switch to the specified identity. Note that theuser=usernamesyntax will also apply the full set of supplementary groups for the user, whereas theuser=uid:gidwill use only thegidgroup. Different vibes, different group situations, choose wisely π
-msgβ control error message format. Signature:
-msg [timestamp=on|off][,guest-name=on|off]
timestamp=on|offβ prefix messages with a timestamp. Default isoff.guest-name=on|offβ prefix messages with guest name, but only if the-name guestoption is set β otherwise the option is just ignored, no cap. Default isoff.
-dump-vmstate fileβ dump json-encoded vmstate information for current machine type to file in file. Just a lil json snapshot of the machine's state for you π§-enable-sync-profileβ enable synchronization profiling. Short, sweet, iconic.-perfmapβ generate a map file for Linux perf tools that will allow basic profiling information to be broken down into basic blocks. Profiling stans rise π₯-jitdumpβ generate a dump file for Linux perf tools that maps basic blocks to symbol names, line numbers and JITted code. The full deluxe version, we love to see it π
π§Έ Generic object creation π§Έ
-object typename[,prop1=value1,...]β create a new object of type typename, setting properties in the order they are specified. Lowkey important: note that the'id'property must be set. These objects are placed in the/objectspath. Okay now the specific ones π-object monitor-hmp,id=id,chardev=chardev_id,readline=on|offβ set up a monitor running the Human Monitor Protocol, connected to the chardev chardev_id.
The id parameter is a unique ID that can be used to dynamically delete the monitor at runtime. Note that monitors created using the historical syntax will be allocated IDs following the pattern compat_monmitorNNN. (Yes, that's spelled monmitor in the docs. We don't fix it. We respect it. π) Mixing -object with -monitor syntax is discouraged.
The readline parameter, which defaults to on, controls whether the monitor provides line editing. Fancy β¨
-object monitor-qmp,id=id,chardev=chardev_id,pretty=on|off,close-action=none|deleteβ set up a monitor running the QEMU Monitor Protocol, connected to the chardev chardev_id.
The id parameter is a unique ID that can be used to dynamically delete the monitor at runtime. Note that monitors created using the historical syntax will be allocated IDs following the pattern compat_monitorNNN. Mixing -object with -qmp and -qmp-pretty syntax is discouraged.
The pretty parameter, which defaults to off, controls whether the monitor responses are pretty printed as multi-line indented JSON, as opposed to constrained to a single line without extraneous whitespace. (Multi-line indented JSON is so aesthetically pleasing but it's your call π
)
The close-action parameter, which defaults to none, controls what happens when the connection to the monitor is terminated by the user. If set to delete, then the monitor-qmp object and its associated character device are both immediately deleted. This can be useful if an extra monitor was hotplugged for a specific task and should be unplugged when completed. Cleanup queen behaviour π§Ήπ
-object memory-backend-file,id=id,size=size,mem-path=dir,share=on|off,discard-data=on|off,merge=on|off,dump=on|off,prealloc=on|off,host-nodes=host-nodes,policy=default|preferred|bind|interleave,align=align,offset=offset,readonly=on|off,rom=on|off|autoβ creates a memory file backend object, which can be used to back the guest RAM with huge pages. Big paging energy π₯
The id parameter is a unique ID that will be used to reference this memory region in other parameters, e.g. -numa, -device nvdimm, etc.
The size option provides the size of the memory region, and accepts common suffixes, e.g. 500M.
The mem-path provides the path to either a shared memory or huge page filesystem mount.
The share boolean option determines whether the memory region is marked as private to QEMU, or shared. The latter allows a co-operating external process to access the QEMU memory region.
Settingshare=onmight affect the ability to configure NUMA bindings for the memory backend under some circumstances β seeDocumentation/vm/numa_memory_policy.txton the Linux kernel source tree for additional details.
Setting the discard-data boolean option to on indicates that file contents can be destroyed when QEMU exits, to avoid unnecessarily flushing data to the backing file. Note that discard-data is only an optimization, and QEMU might not discard file contents if it aborts unexpectedly or is terminated using SIGKILL. π So don't, like, rely on it for anything important, bestie.
The merge boolean option enables memory merge, also known as MADV_MERGEABLE, so that Kernel Samepage Merging will consider the pages for memory deduplication.
Setting the dump boolean option to off excludes the memory from core dumps. This feature is also known as MADV_DONTDUMP.
The prealloc boolean option enables memory preallocation.
The host-nodes option binds the memory range to a list of NUMA host nodes.
The policy option sets the NUMA policy to one of the following values:
defaultβ default host policypreferredβ prefer the given host node list for allocationbindβ restrict memory allocation to the given host node listinterleaveβ interleave memory allocations across the given host node list
alignβ sets the base address alignment QEMU uses when itmmap(2)smem-path, and it takes the usual suffixes, like2Mπ . Some backends out there (looking at you,mem-pathstores) need a different alignment than QEMU's default β for example the device DAX/dev/dax0.0wants2Malignment, not4K. In those cases you just tell QEMU what alignment you need with this option, and it slays accordingly.offsetβ says where inside the target file the region starts. Yes bestie, you can back multiple regions with a single file using this. Multiplexing, but make it memory β¨.pmemβ tells QEMU whether the backing file inmem-pathlives in host persistent memory that's accessible through the SNIA NVM programming model (think Intel NVDIMM, iykyk). Ifpmemison, QEMU does the necessary operations to guarantee that its own writes tomem-pathare persistent (this matters for, like, vNVDIMM label emulation and live migration π«Ά). It also maps the backend file with theMAP_SYNCflag, which keeps the file metadata in sync formem-pathif the host crashes or loses power. Heads up though:MAP_SYNCneeds support from both the host kernel (since Linux kernel 4.15) and the filesystem ofmem-pathmounted with the DAX option. No DAX, no sync, no cap π.readonlyβ whether the backing file gets opened read-only or read-write. Default is read-write, bestie.romβ whether to create Read Only Memory (ROM) that the VM literally cannot modify. Any write attempt to that ROM gets denied, periodt. Most use cases want actual RAM, not ROM β but selected use cases, like R/O NVDIMMs, genuinely benefit from ROM πΈ. Set it toonβ create ROM;offβ create writable RAM;auto(which is the default) β the value of thereadonlyoption is used. This option is mainly a lifesaver when you want writable RAM in configurations that would traditionally create ROM back before theromoption even existed: VM templating, where you want to open a file readonly (readonly=on) and mark the memory private for QEMU (share=off). In that use case you need writable RAM instead of ROM, so you also want to setrom=offβ¨.-object memory-backend-ram,id=id,merge=on|off,dump=on|off,share=on|off,prealloc=on|off,size=size,host-nodes=host-nodes,policy=default|preferred|bind|interleaveβ creates a memory backend object, which can be used to back the guest RAM. Memory backend objects give you way more control than the-moption that's traditionally used to define guest RAM. For what all these options actually do, go peek atmemory-backend-fileπ.-object memory-backend-memfd,id=id,merge=on|off,dump=on|off,share=on|off,prealloc=on|off,size=size,host-nodes=host-nodes,policy=default|preferred|bind|interleave,seal=on|off,hugetlb=on|off,hugetlbsize=sizeβ creates an anonymous memory file backend object, which lets QEMU share the memory with an external process (like when you're using vhost-user π¦). The memory is allocated withmemfdplus optional sealing. Linux only, obviously π .sealβ creates a sealed-file, which blocks any further resizing of the memory. It'sonby default, so likeβ¦ it comes pre-sealed.hugetlbβ says the file being created lives in thehugetlbfsfilesystem (since Linux 4.14). Used together with thehugetlboption, thehugetlbsizeoption specifies the hugetlb page size on systems that support multiple hugetlb page sizes (and ngl it must be a power of 2 value supported by the system).- β οΈ On some versions of Linux, the
hugetlboption is incompatible with thesealoption β it needs at least Linux 4.16 for them to coexist. - For a description of all the other options, please refer to
memory-backend-file.
And one more thing: the share boolean option is on by default with memfd π«Ά.
-object memory-backend-shm,id=id,merge=on|off,dump=on|off,share=on|off,prealloc=on|off,size=size,host-nodes=host-nodes,policy=default|preferred|bind|interleaveβ creates a POSIX shared memory backend object, which lets QEMU share the memory with an external process (again, vhost-user vibes π§).
memory-backend-shm is basically the more portable, less featureful version of memory-backend-memfd. So it can be used on any POSIX system, especially when memfd isn't supported π.
For a description of the options, refer to memory-backend-file.
The share boolean option is on by default with shm. Setting it to off will cause a failure during allocation, because this backend just doesn't support that β it's not being mean, it literally can't π.
-object iommufd,id=id[,fd=fd]β creates aniommufdbackend, which lets you control DMA mapping through the/dev/iommudevice π.
The id parameter is a unique ID which frontends (like vfio-pci or vdpa) will use to connect with the iommufd backend.
The fd parameter is an optional pre-opened file descriptor resulting from opening /dev/iommu. Usually the iommufd is shared across all subsystems, which brings you the benefit of centralized reference counting. Efficient and iconic β¨.
-object rng-builtin,id=idβ creates a random number generator backend that gets its entropy from QEMU builtin functions π. Theidparameter is a unique ID that will be used to reference this entropy backend from thevirtio-rngdevice. Fun fact: by default, thevirtio-rngdevice uses this RNG backend, so it's the main character of entropy sources π .-object rng-random,id=id,filename=/dev/randomβ creates a random number generator backend that gets entropy from a device on the host π. Theidparameter is a unique ID used to reference this entropy backend from thevirtio-rngdevice. Thefilenameparameter says which file to grab entropy from β and if you omit it, it defaults to/dev/urandom.-object rng-egd,id=id,chardev=chardevidβ creates a random number generator backend that gets entropy from an external daemon running on the host πΈ. Theidparameter is a unique ID used to reference this entropy backend from thevirtio-rngdevice. Thechardevparameter is the unique ID of a character device backend that provides the connection to the RNG daemon. Entropy, outsourced π.-object tls-creds-anon,id=id,endpoint=endpoint,dir=/path/to/cred/dir,verify-peer=on|offβ creates a TLS anonymous credentials object, which can be used to provide TLS support on network backends π₯. Theidparameter is a unique ID which network backends will use to access the credentials. Theendpointis eitherserverorclient, depending on whether the QEMU network backend using these credentials will be acting as a client or as a server. Ifverify-peeris enabled (and it is by default), then once the handshake is completed the peer credentials get verified β though for anonymous credentials that's a no-op, so it's kind of doing nothing with extra steps π.
The dir parameter tells QEMU where to find the credential files. For server endpoints, this directory may contain a file dh-params.pem providing diffie-hellman parameters to use for the TLS server. If that file is missing, QEMU will generate a set of DH parameters at startup β which is a computationally expensive operation that consumes random pool entropy, so it's recommended that you generate a persistent set of parameters up front and save them. Save your future self the pain, bestie π.
-object tls-creds-psk,id=id,endpoint=endpoint,dir=/path/to/keys/dir[,username=username]β creates a TLS Pre-Shared Keys (PSK) credentials object, which can be used to provide TLS support on network backends π¦. Theidparameter is a unique ID which network backends will use to access the credentials. Theendpointis eitherserverorclient, depending on whether the QEMU network backend using these credentials will be acting as a client or as a server. For clients only,usernameis the username that will be sent to the server β and if it's omitted it defaults to"qemu".
The dir parameter tells QEMU where to find the keys file. It's called "dir/keys.psk" and it contains "username:key" pairs. The easiest way to make this file is using the GnuTLS psktool program, no cap π
.
For server endpoints, dir may also contain a file dh-params.pem providing diffie-hellman parameters to use for the TLS server. If that file is missing, QEMU will generate a set of DH parameters at startup. This is a computationally expensive operation that consumes random pool entropy, so it's recommended that a persistent set of parameters be generated up front and saved β¨.
-object tls-creds-x509,id=id,endpoint=endpoint,dir=/path/to/cred/dir,priority=priority,verify-peer=on|off,passwordid=idβ creates a TLS anonymous credentials object, which can be used to provide TLS support on network backends π. Theidparameter is a unique ID which network backends will use to access the credentials. Theendpointis eitherserverorclient, depending on whether the QEMU network backend using these credentials will be acting as a client or as a server. Ifverify-peeris enabled (it's the default), then once the handshake is completed the peer credentials will be verified. With x509 certificates, this implies that the clients must be provided with valid client certificates too β so everyone shows their ID at the door π.
okay so back to the dir parameter π
β thatβs the one telling QEMU where to find the credential files. For server endpoints, this directory may contain a file dh-params.pem providing diffie-hellman parameters to use for the TLS server. If that file is missing, QEMU will generate a set of DH parameters at startup. That is a computationally expensive operation that consumes random pool entropy, so itβs recommended that a persistent set of parameters be generated upfront and saved. π«Ά
For x509 certificate credentials, the directory will contain further files providing the x509 certificates. The certificates must be stored in PEM format, in filenames ca-cert.pem, ca-crl.pem (optional), server-cert.pem (only servers), server-key.pem (only servers), client-cert.pem (only clients), and client-key.pem (only clients). β¨
For the server-key.pem and client-key.pem files which contain sensitive private keys, it is possible to use an encrypted version by providing the passwordid parameter. This provides the ID of a previously created secret object containing the password for decryption. π
The priority parameter allows overriding the global default priority used by gnutls. This can be useful if the system administrator needs to use a weaker set of crypto priorities for QEMU without potentially forcing the weakness onto all applications. Or conversely, if one wants a stronger default for QEMU than for all other applications, they can do this through this parameter. Its format is a gnutls priority string as described at https://gnutls.org/manual/html_node/Priority-Strings.html. π
-object tls-cipher-suites,id=id,priority=priorityβ creates a TLS cipher suites object, which can be used to control the TLS cipher/protocol algorithms that applications are permitted to use. π¦
The id parameter is a unique ID which frontends will use to access the ordered list of permitted TLS cipher suites from the host.
The priority parameter allows overriding the global default priority used by gnutls. This can be useful if the system administrator needs to use a weaker set of crypto priorities for QEMU without potentially forcing the weakness onto all applications. Or conversely, if one wants a stronger default for QEMU than for all other applications, they can do this through this parameter. Its format is a gnutls priority string as described at https://gnutls.org/manual/html_node/Priority-Strings.html.
An example of use of this object is to control UEFI HTTPS Boot. The tls-cipher-suites object exposes the ordered list of permitted TLS cipher suites from the host side to the guest firmware, via fw_cfg. The list is represented as an array of IANA_TLS_CIPHER objects. The firmware uses the IANA_TLS_CIPHER array for configuring guest-side TLS. π
In the following example, the priority at which the host-side policy is retrieved is given by the priority property. Given that QEMU uses GNUTLS, priority=@SYSTEM may be used to refer to /etc/crypto-policies/back-ends/gnutls.config.
# qemu-kvm \
-object tls-cipher-suites,id=mysuite0,priority=@SYSTEM \
-fw_cfg name=etc/edk2/https/ciphers,gen_id=mysuite0
-object filter-buffer,id=id,netdev=netdevid,interval=t[,queue=all|rx|tx][,status=on|off][,position=head|tail|id=<id>][,insert=behind|before]β intervaltcanβt be0; this filter batches packet delivery: all packets arriving in a given interval on netdevnetdevidare delayed until the end of the interval. Interval is in microseconds.statusis optional and indicates whether the netfilter is on (enabled) or off (disabled); the default status for netfilter will beon. πqueue all|rx|txis an option that can be applied to any netfilter.all: the filter is attached both to the receive and the transmit queue of the netdev (default).rx: the filter is attached to the receive queue of the netdev, where it will receive packets sent to the netdev.tx: the filter is attached to the transmit queue of the netdev, where it will receive packets sent by the netdev.
position head|tail|id=<id>is an option to specify where the filter should be inserted in the filter list. It can be applied to any netfilter.head: the filter is inserted at the head of the filter list, before any existing filters.tail: the filter is inserted at the tail of the filter list, behind any existing filters (default).id=<id>: the filter is inserted before or behind the filter specified by<id>, see theinsertoption below.
insert behind|beforeis an option to specify where to insert the new filter relative to the one specified withposition=id=<id>. It can be applied to any netfilter.before: insert before the specified filter.behind: insert behind the specified filter (default).
-object filter-mirror,id=id,netdev=netdevid,outdev=chardevid,queue=all|rx|tx[,vnet_hdr_support][,position=head|tail|id=<id>][,insert=behind|before]β filter-mirror on netdevnetdevidmirrors net packets to the chardevchardevid; if it has thevnet_hdr_supportflag, filter-mirror will mirror packets withvnet_hdr_len. πͺ-object filter-redirector,id=id,netdev=netdevid,indev=chardevid,outdev=chardevid,queue=all|rx|tx[,vnet_hdr_support][,position=head|tail|id=<id>][,insert=behind|before]β filter-redirector on netdevnetdevidredirects the filterβs net packet to chardevchardevid, and redirectsindevβs packet to the filter. If it has thevnet_hdr_supportflag, filter-redirector will redirect packets withvnet_hdr_len. To create a filter-redirector we need theoutdevid to differ from theindevid βidcanβt be the same. We can use justindevor justoutdev, but at least one ofindevoroutdevneeds to be specified. π―-object filter-rewriter,id=id,netdev=netdevid,queue=all|rx|tx,[vnet_hdr_support][,position=head|tail|id=<id>][,insert=behind|before]β filter-rewriter is a part of the COLO project. It will rewrite TCP packets to the secondary from the primary to keep the secondary TCP connection, and rewrite TCP packets to the primary from the secondary so the TCP packet can be handled by the client. If it has thevnet_hdr_supportflag, we can parse packets with a vnet header. π§
usage: colo secondary:
-object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
-object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
-object filter-rewriter,id=rew0,netdev=hn0,queue=all
-object filter-dump,id=id,netdev=dev[,file=filename][,maxlen=len][,position=head|tail|id=<id>][,insert=behind|before]β dump the network traffic on netdevdevto the file specified byfilename. At mostlenbytes (64kby default) per packet are stored. The file format is libpcap, so it can be analyzed with tools such astcpdumpor Wireshark. π¦-object colo-compare,id=<id>,primary_in=<chardevid>,secondary_in=<chardevid>,outdev=<chardevid>,iothread=<id>[,vnet_hdr_support][,notify_dev=<id>][,compare_timeout=<time_ms>][,expired_scan_cycle=<time_ms>][,max_queue_size=<maxsize>]β Colo-compare gets packets from the chardev backends specified byprimary_inandsecondary_in, and compares whether the payloads of the primary packet and the secondary packet are the same. If they match, it will output the primary packet to the chardev backend specified byoutdev; otherwise it will notify COLO-framework to do a checkpoint and send the primary packet tooutdev. π
In order to improve efficiency, we need to put the task of comparison in another iothread; the iothread option specifies that iothread object (which your commandline should create).
vnet_hdr_supporttells colo compare to pass the vnet header length when it sends and receives packets.compare_timeoutsets the maximum time that colo-compare will hold the packet for, in ms.expired_scan_cyclesets the period of scanning expired primary node network packets, in ms.max_queue_sizesets the max compare queue size.
If you want to use Xen COLO, you need to specify notify_dev to tell colo-compare how to notify Xen colo-frame to do a checkpoint.
important vibe check: COLO-compare must be used with the help offilter-mirror,filter-redirectorandfilter-rewriter. π
KVM COLO
okay bestie, here's the actual invocation for that colo-compare setup β primary side first, and every single flag is doing its job π
primary:
-netdev tap,id=hn0,vhost=off
-device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66
-chardev socket,id=mirror0,host=3.3.3.3,port=9003,server=on,wait=off
-chardev socket,id=compare1,host=3.3.3.3,port=9004,server=on,wait=off
-chardev socket,id=compare0,host=3.3.3.3,port=9001,server=on,wait=off
-chardev socket,id=compare0-0,host=3.3.3.3,port=9001
-chardev socket,id=compare_out,host=3.3.3.3,port=9005,server=on,wait=off
-chardev socket,id=compare_out0,host=3.3.3.3,port=9005
-object iothread,id=iothread1
-object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0
-object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out
-object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0
-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,iothread=iothread1
and the secondary side, which is giving "yes queen, mirror me" energy πͺβ¨
secondary:
-netdev tap,id=hn0,vhost=off
-device e1000,netdev=hn0,mac=52:a4:00:12:78:66
-chardev socket,id=red0,host=3.3.3.3,port=9003
-chardev socket,id=red1,host=3.3.3.3,port=9004
-object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
-object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
Xen COLO π§ β now the Xen flavour. It's this close to the one above, except it also spins up a notify_way chardev on port 9009 and hands notify_dev=notify_way to colo-compare so the two sides can gossip π
primary:
-netdev tap,id=hn0,vhost=off
-device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66
-chardev socket,id=mirror0,host=3.3.3.3,port=9003,server=on,wait=off
-chardev socket,id=compare1,host=3.3.3.3,port=9004,server=on,wait=off
-chardev socket,id=compare0,host=3.3.3.3,port=9001,server=on,wait=off
-chardev socket,id=compare0-0,host=3.3.3.3,port=9001
-chardev socket,id=compare_out,host=3.3.3.3,port=9005,server=on,wait=off
-chardev socket,id=compare_out0,host=3.3.3.3,port=9005
-chardev socket,id=notify_way,host=3.3.3.3,port=9009,server=on,wait=off
-object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0
-object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out
-object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0
-object iothread,id=iothread1
-object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0,notify_dev=notify_way,iothread=iothread1
secondary:
-netdev tap,id=hn0,vhost=off
-device e1000,netdev=hn0,mac=52:a4:00:12:78:66
-chardev socket,id=red0,host=3.3.3.3,port=9003
-chardev socket,id=red1,host=3.3.3.3,port=9004
-object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
-object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
if you're sitting here like "okay but what do all those lines mean" β the manpage says: if you want to know the detail of above command line, you can read the colo-compare git log. that's it, that's the hint π«Ά
π -object cryptodev-backend-builtin,id=id[,queues=queues]
makes a cryptodev backend that runs crypto operations straight from the QEMU cipher APIs π₯ the id is a unique ID you'll use later to reference this backend from the virtio-crypto device. queues is optional and sets the queue number of the cryptodev backend β default queues is 1.
# qemu-kvm \
[...] \
-object cryptodev-backend-builtin,id=cryptodev0 \
-device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0 \
[...]
πΈ -object cryptodev-vhost-user,id=id,chardev=chardevid[,queues=queues]
makes a vhost-user cryptodev backend, backed by a chardev called chardevid β¨ id is a unique ID you'll reference from the virtio-crypto device. heads up: the chardev should be a unix domain socket backed one β vhost-user uses a specifically defined protocol to pass vhost ioctl replacement messages to an application on the other end of that socket. queues is optional and sets the queue number of the cryptodev backend for multiqueue vhost-user; default is 1.
# qemu-kvm \
[...] \
-chardev socket,id=chardev0,path=/path/to/socket \
-object cryptodev-vhost-user,id=cryptodev0,chardev=chardev0 \
-device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0 \
[...]
π -object secret,id=id,data=string,format=raw|base64[,keyid=secretid,iv=string]
π -object secret,id=id,file=filename,format=raw|base64[,keyid=secretid,iv=string]
defines a secret β a password, an encryption key, or whatever else is sensitive π the sensitive data goes either directly in the data parameter or indirectly via the file parameter. and ngl, using data is insecure unless the sensitive data is already encrypted.
you can hand over that sensitive data in raw format (the default) or base64. when it's encoded as JSON, the raw format only supports valid UTF-8 characters, so base64 is the recommended move for sending binary data π¦ QEMU converts from whichever format you gave it into the format it needs internally β eg, an RBD password can be provided in raw format, even though it'll be base64 encoded when passed onto the RBD sever.
for extra protection you can encrypt the data tied to a secret using the AES-256-CBC cipher π‘οΈ you signal encryption by providing keyid and iv. the keyid parameter gives the ID of a previously defined secret that holds the AES-256 decryption key β that key should be 32 bytes long and base64 encoded. the iv parameter gives the random initialization vector used for encrypting this particular secret, and should be a base64 encrypted string of the 16-byte IV.
the simplest (insecure π) usage is putting the secret inline:
# qemu-kvm -object secret,id=sec0,data=letmein,format=raw
the simplest secure usage is handing the secret over via a file:
# printf "letmein" > mypasswd.txt
# QEMU_SYSTEM_MACRO -object secret,id=sec0,file=mypasswd.txt,format=raw
for greater security, AES-256-CBC should be used πͺ to illustrate, consider the openssl command line tool, which can encrypt the data. note that when encrypting, the plaintext must be padded to the cipher block size (32 bytes) using the standard PKCS#5/6 compatible padding algorithm.
first a master key needs to be created in base64 encoding:
# openssl rand -base64 32 > key.b64
# KEY=$(base64 -d key.b64 | hexdump -v -e '/1 "%02X"')
each secret to be encrypted needs a random initialization vector generated. these do not need to be kept secret π
# openssl rand -base64 16 > iv.b64
# IV=$(base64 -d iv.b64 | hexdump -v -e '/1 "%02X"')
now the secret to be defined can be encrypted β here we're telling openssl to base64 encode the result, but it could be left as raw bytes if you'd rather:
# SECRET=$(printf "letmein" |
openssl enc -aes-256-cbc -a -K $KEY -iv $IV)
when launching QEMU, create a master secret pointing to key.b64 and say that's the one to decrypt the user password with. pass the contents of iv.b64 to the second secret π
# qemu-kvm \
-object secret,id=secmaster0,format=base64,file=key.b64 \
-object secret,id=sec0,keyid=secmaster0,format=base64,\
data=$SECRET,iv=$(<iv.b64)
π -object sev-guest,id=id,cbitpos=cbitpos,reduced-phys-bits=val,[sev-device=string,policy=policy,handle=handle,dh-cert-file=file,session-file=file,kernel-hashes=on|off]
creates a Secure Encrypted Virtualization (SEV) guest object, which you can use to get guest memory encryption support on AMD processors π₯
when memory encryption is on, one of the physical address bits (aka the C-bit) is utilized to mark whether a memory page is protected π§ cbitpos provides the C-bit position. the C-bit position is Host family dependent, hence the user must provide this value. on EPYC, the value should be 47.
when memory encryption is on, we loose certain bits in physical address space. reduced-phys-bits provides the number of bits we loose in physical address space β like the C-bit, this is Host family dependent. on EPYC, a guest will lose a maximum of 1 bit, so the value should be 1.
sev-device gives the device file used to talk to the SEV firmware running inside the AMD Secure Processor. default device is /dev/sev β if the hardware supports memory encryption then /dev/sev devices are created by the CCP driver.
policy gives the guest policy that the SEV firmware enforces, restricting what configuration and operational commands the hypervisor can perform on this guest π« the policy should be provided by the guest owner and is bound to the guest β it can't be changed throughout the lifetime of the guest. the default is 0.
If the guest policy lets your SEV guest share its key with another SEV guest, then handle is how you pass in the handle of the guest you're sharing from. iykyk π
The dh-cert-file and session-file are where the guest owner's Public Diffie-Hellman key (as defined in the SEV spec) lives. The PDH and session params get used to set up a cryptographic session with the guest owner so y'all can negotiate the keys used for attestation. Both files must be base64 encoded β no cap, this is not a suggestion. π§
And kernel-hashes adds the hashes of your given kernel/initrd/cmdline to a designated guest firmware page, which is what you want for measured Linux boot with -kernel. Default is off. (Since 6.2) β¨
Like, e.g., to launch a SEV guest:
# qemu-kvm \
...... \
-object sev-guest,id=sev0,cbitpos=47,reduced-phys-bits=1 \
-machine ...,confidential-guest-support=sev0 \
.....
π -object tdx-guest,id=id,[attributes=attrs,sept-ve-disable=on|off,mrconfigid=sha384_digest,mrowner=sha384_digest,mrownerconfig=sha384_digest,quote-generation-socket=socketaddr]
Bestie, this one creates an Intel Trusted Domain eXtensions (TDX) guest object β which is the confidential-guest-support type of object. Then when you pass the object ID to the machine's confidential-guest-support property, boom π₯ you've got a TDX guest.
attributesβ a 64-bit integer that specifies the TD attributes of the TD.sept-ve-disableβ controls bit 28 of the TD attributes, specifically that bit. When it'son, the EPT violation conversion to#VEon guest access of PENDING pages is disabled. Some guest OSes (e.g., a Linux TD guest) may require this to be set, otherwise they flat-out refuse to boot. Default value ison. πmrconfigidβ a base64 encoded SHA384 digest that provides the ID for the non-owner-defined configuration of the guest TD, e.g., run-time or OS configuration. Default value is all zeros.mrownerβ a base64 encoded SHA384 digest that provides the ID for the guest TD's owner. Default value is all zeros.mrownerconfigβ a base64 encoded SHA384 digest that provides the ID for owner-defined configuration of the guest TD, e.g., the configuration specific to the workload rather than the run-time of the OS. Default value is all zeros.quote-generation-socketβ specifies the socket address of the Quote Generation Service (QGS). QGS is a daemon running on the host. QEMU forwards the<GetQuote>request from the TD guest to QGS, then sends the reply (which contains the generated QUOTE on success) from QGS back to the guest TD. π
# qemu-kvm \
...... \
-object '{"qom-type":"tdx-guest","id":"tdx","quote-generation-socket":{"type":"unix","path":"/var/run/qgs.socket"}}' \
-machine ...,confidential-guest-support=tdx \
......
π¦ -object igvm-cfg,file=file
Creates an IGVM configuration object that defines the initial state of the guest using a file that conforms to the Independent Guest Virtual Machine (IGVM) file format. Literally giving "I brought my own initial state" energy. β¨
Currently it's only supported by -machine q35 and -machine pc β so don't come at it with anything else, it's not gonna slay for you.
The file parameter is what you use to specify the IGVM file to load. When provided, the IGVM file is used to populate the initial memory of the virtual machine and, depending on the platform, can define the initial processor state, memory map and parameters.
Heads up bestie: the IGVM file is expected to contain the firmware for the virtual machine, so anigvm-cfgobject cannot be provided along with other ways of specifying firmware, such as the-biosparameter on x86 machines. Pick a lane. π
e.g. to launch a machine providing the firmware in an IGVM file:
# qemu-kvm \
...... \
-object igvm-cfg,id=igvm0,file=bios.igvm \
-machine ...,igvm-cfg=igvm0 \
.....
πΈ -object authz-simple,id=id,identity=string
Creates an authorization object that controls access to network services. Security era. π
The identity parameter identifies the user, and its format depends on the network service that the authorization object is associated with. For authorizing based on TLS x509 certificates, the identity must be the x509 distinguished name. Note that care must be taken to escape any commas in the distinguished name β commas are out here causing chaos fr fr.
An example authorization object to validate an x509 distinguished name would look like:
# qemu-kvm \
... \
-object 'authz-simple,id=auth0,identity=CN=laptop.example.com,,O=Example Org,,L=London,,ST=London,,C=GB' \
...
Note the use of quotes due to the x509 distinguished name containing whitespace, and the escaping of ','. π«Ά
π -object authz-listfile,id=id,filename=path,refresh=on|off
Creates an authorization object that controls access to network services. Same vibe, different delivery. β¨
The filename parameter is the fully qualified path to a file containing the access control list rules in JSON format.
An example set of rules that match against SASL usernames might look like:
{
"rules": [
{ "match": "fred", "policy": "allow", "format": "exact" },
{ "match": "bob", "policy": "allow", "format": "exact" },
{ "match": "danb", "policy": "deny", "format": "glob" },
{ "match": "dan*", "policy": "allow", "format": "exact" },
],
"policy": "deny"
}
When checking access, the object iterates over all the rules and the first rule to match has its policy value returned as the result. If no rules match, then the default policy value is returned. First come, first served, periodt. π
The rules can either be an exact string match, or they can use simple UNIX glob pattern matching to allow wildcards to be used.
If refresh is set to true, the file will be monitored and automatically reloaded whenever its content changes. Set it and forget it, iconic behaviour honestly. π
As with the authz-simple object, the format of the identity strings being matched depends on the network service, but it's usually a TLS x509 distinguished name, or a SASL username.
An example authorization object to validate a SASL username would look like:
# qemu-kvm \
... \
-object authz-simple,id=auth0,filename=/etc/qemu/vnc-sasl.acl,refresh=on \
...
π -object authz-pam,id=id,service=string
Creates an authorization object that controls access to network services. Third flavour of the same delicious thing. π
The service parameter provides the name of a PAM service to use for authorization. It requires that a file /etc/pam.d/service exist to provide the configuration for the account subsystem.
An example authorization object to validate a TLS x509 distinguished name would look like:
# qemu-kvm \
... \
-object authz-pam,id=auth0,service=qemu-vnc \
...
There would then be a corresponding config file for PAM at /etc/pam.d/qemu-vnc that contains:
account requisite pam_listfile.so item=user sense=allow \
file=/etc/qemu/vnc.allow
Finally the /etc/qemu/vnc.allow file would contain the list of x509 distinguished names that are permitted access:
CN=laptop.example.com,O=Example Home,L=London,ST=London,C=GB
π₯ -object iothread,id=id,poll-max-ns=poll-max-ns,poll-grow=poll-grow,poll-shrink=poll-shrink,poll-weight=poll-weight,aio-max-batch=aio-max-batch
Creates a dedicated event loop thread that devices can be assigned to. This is known as an IOThread, and honestly it's main character energy for scaling. By default, device emulation happens in vCPU threads or the main event loop thread, and that can become a scalability bottleneck. IOThreads let device emulation and I/O run on other host CPUs. Slay. π
The id parameter is a unique ID that's used to reference this IOThread from -device ...,iothread=id. Multiple devices can be assigned to a single IOThread. Note that not all devices support an iothread parameter β check before you commit, bestie. π
The query-iothreads QMP command lists IOThreads and reports their thread IDs, so you can configure host CPU pinning/affinity. π
IOThreads use an adaptive polling algorithm to reduce event loop latency. Instead of entering a blocking system call to monitor file descriptors and then paying the cost of being woken up when an event occurs, the polling algorithm spins waiting for events for a short time. The algorithm's default parameters are suitable for many cases, but can be adjusted based on knowledge of the workload and/or host device latency.
poll-max-nsβ the maximum number of nanoseconds to busy wait for events. Polling can be disabled by setting this value to0.poll-growβ the multiplier used to increase the polling time when the algorithm detects it's missing events due to not polling long enough.
poll-shrinkβ the divisor used to decrease the polling time when the algorithm notices it's been polling foreverrr without actually catching any events π΄ like bestie read the room.poll-weightβ the weight factor for adaptive polling. It decides how much the most recent event interval affects the next polling duration calculation. If you set it to0, the system default value of3is used. Typical values:1(high weight on recent interval),2-4(moderate weight on recent interval) πaio-max-batchβ the maximum number of requests in a batch for the AIO engine.0means the engine will use its default β¨
The IOThread parameters can be modified at run-time using the qom-set command (where iothread1 is the IOThread's id):
(qemu) qom-set /objects/iothread1 poll-max-ns 100000
π MULTIPLEXER KEYS π
During the graphical emulation, you can use special key combinations from the following table to change modes. By default the modifier is Ctrl+Alt (used in the table below) which can be changed with -display suboption mod= where appropriate. For example, -display sdl,grab-mod=lshift-lctrl-lalt changes the modifier key to Ctrl+Alt+Shift, while -display sdl,grab-mod=rctrl changes it to the right Ctrl key π
Ctrl+Alt+fβ Toggle full screen π₯οΈβ¨Ctrl+Alt++β Enlarge the screenCtrl+Alt+-β Shrink the screenCtrl+Alt+0β Restore the screen's un-scaled dimensionsCtrl+Alt+nβ Switch to virtual console 'n'. Standard console mappings are:1: Target system display2: Monitor3: Serial port
Ctrl+Alt+gβ Toggle mouse and keyboard grab π±οΈ
In the virtual consoles, you can use Ctrl+Up, Ctrl+Down, Ctrl+PageUp and Ctrl+PageDown to move in the back log π no cap, that's how you scroll back.
β¨οΈ MULTIPLEXER KEYS β¨οΈ <span>(yes, again β this is the other multiplexer, iykyk)</span>
During emulation, if you are using a character backend multiplexer (which is the default if you are using -nographic) then several commands are available via an escape sequence. These key sequences all start with an escape character, which is Ctrl+a by default, but can be changed with -echr. The list below assumes you're using the default π
Ctrl+a hβ Print this helpCtrl+a xβ Exit emulator πͺCtrl+a sβ Save disk data back to file (if-snapshot)Ctrl+a tβ Toggle console timestamps β±οΈCtrl+a bβ Send break (magic sysrq in Linux) πCtrl+a cβ Rotate between the frontends connected to the multiplexer (usually this switches between the monitor and the console) πCtrl+a Ctrl+aβ Send the escape character to the frontend
π NOTES π
In addition to using normal file images for the emulated storage devices, QEMU can also use networked resources such as iSCSI devices. These are specified using a special URL syntax π¦
π iSCSI
iSCSI support allows QEMU to access iSCSI resources directly and use as images for the guest storage. Both disk and cdrom images are supported πΎβ¨
Syntax for specifying iSCSI LUNs is:
"iscsi://<target-ip>[:<port>]/<target-iqn>/<lun>"
By default qemu will use the iSCSI initiator-name 'iqn.2008-11.org.linux-kvm[:<name>]' but this can also be set from the command line or a configuration file π
Since version QEMU 2.4 it is possible to specify a iSCSI request timeout to detect stalled requests and force a reestablishment of the session. The timeout is specified in seconds. The default is 0 which means no timeout. Libiscsi 1.15.0 or greater is required for this feature β οΈ like fr, check your libiscsi version first.
Example (without authentication):
qemu-kvm -iscsi initiator-name=iqn.2001-04.com.example:my-initiator \
-cdrom iscsi://192.0.2.1/iqn.2001-04.com.example/2 \
-drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
Example (CHAP username/password via URL):
qemu-kvm -drive file=iscsi://user%password@192.0.2.1/iqn.2001-04.com.example/1
Example (CHAP username/password via environment variables):
LIBISCSI_CHAP_USERNAME="user" \
LIBISCSI_CHAP_PASSWORD="password" \
qemu-kvm -drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
π NBD
QEMU supports NBD (Network Block Devices) both using TCP protocol as well as Unix Domain Sockets. With TCP, the default port is 10809 π
Syntax for specifying a NBD device using TCP, in preferred URI form:
"nbd://<server-ip>[:<port>]/[<export>]"
Syntax for specifying a NBD device using Unix Domain Sockets; remember that '?' is a shell glob character and may need quoting:
"nbd+unix:///[<export>]?socket=<domain-socket>"
Older syntax that is also recognized:
"nbd:<server-ip>:<port>[:exportname=<export>]"
Syntax for specifying a NBD device using Unix Domain Sockets
"nbd:unix:<domain-socket>[:exportname=<export>]"
Example for TCP
qemu-kvm --drive file=nbd:192.0.2.1:30000
Example for Unix Domain Sockets
qemu-kvm --drive file=nbd:unix:/tmp/nbd-socket
π§ SSH
QEMU supports SSH (Secure Shell) access to remote disks π
Examples:
qemu-kvm -drive file=ssh://user@host/path/to/disk.img
qemu-kvm -drive file.driver=ssh,file.user=user,file.host=host,file.port=22,file.path=/path/to/disk.img
Currently authentication must be done using ssh-agent. Other authentication methods may be supported in future π
π¦ HTTP/HTTPS/FTP/FTPS
QEMU supports read-only access to files accessed over http(s) and ftp(s) π (read-only bestie, don't try to write, it's not gonna happen).
Syntax using a single filename:
<protocol>://[<username>[:<password>]@]<host>/<path>
where:
protocolβ'http','https','ftp', or'ftps'.usernameβ Optional username for authentication to the remote server.passwordβ Optional password for authentication to the remote server π (maybe don't put this in your shell history, just saying).hostβ Address of the remote server.pathβ Path on the remote server, including any query string.
The following options are also supported, bestie β these are the extra lil knobs for the remote-driver vibe:
urlβ the full URL, used when you're passing options to the driver explicitly β¨readaheadβ how much data to read ahead with each range request to the remote server. This value can optionally wear a suffix:'T','G','M','K','k'or'b'. No suffix? Then it's assumed to be in bytes, no cap. The value must be a multiple of 512 bytes. Defaults to256kπsslverifyβ whether to verify the remote server's certificate when connecting over SSL. Takes the value'on'or'off'. Defaults to'on'β keep it on, she's protecting you πcookieβ send this cookie (it can also be a list of cookies separated by';') with each outgoing request. Only supported when using protocols like HTTP that actually support cookies β otherwise it's just ignored, no hard feelings πtimeoutβ sets the timeout in seconds of the CURL connection. This timeout is the time that CURL waits for a response from the remote server to get the size of the image to be downloaded. Not set? Then the default timeout of5seconds is used β±οΈforce-rangeβ don't issue a HEAD HTTP request to discover if the http server server supports range requests, and rely only on GET requests. This is especially useful for S3 presigned URLs where HEAD requests are unauthorized. Defaults to'false'π₯
Heads up bestie: when you're passing options to qemu explicitly,driveris the value of<protocol>. That's just how it is, iykyk π
Example: boot from a remote Fedora 20 live ISO image πΈ
qemu-kvm --drive media=cdrom,file=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso,readonly
qemu-kvm --drive media=cdrom,file.driver=http,file.url=http://archives.fedoraproject.org/pub/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso,readonly
Example: boot from a remote Fedora 20 cloud image using a local overlay for writes, copy-on-read, and a readahead of 64k π¦
qemu-img create -f qcow2 -o backing_file='json:{"file.driver":"http",, "file.url":"http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/20/Images/x86_64/Fedora-x86_64-20-20131211.1-sda.qcow2",, "file.readahead":"64k"}' /tmp/Fedora-x86_64-20-20131211.1-sda.qcow2
qemu-kvm -drive file=/tmp/Fedora-x86_64-20-20131211.1-sda.qcow2,copy-on-read=on
Example: boot from an image stored on a VMware vSphere server with a self-signed certificate using a local overlay for writes, a readahead of 64k and a timeout of 10 seconds. π§
qemu-img create -f qcow2 -o backing_file='json:{"file.driver":"https",, "file.url":"https://user:password@vsphere.example.com/folder/test/test-flat.vmdk?dcPath=Datacenter&dsName=datastore1",, "file.sslverify":"off",, "file.readahead":"64k",, "file.timeout":10}' /tmp/test.qcow2
qemu-kvm -drive file=/tmp/test.qcow2
π SEE ALSO π
The HTML documentation of QEMU for more precise information, plus Linux user mode emulator invocation. Go read the HTML docs, they're giving main character reference material energy π
π AUTHOR π
Fabrice Bellard β the icon himself, periodt.
π COPYRIGHT π
2026, The QEMU Project Developers
okay that's a wrap on the whole page, bestie!! π«Ά you just read the entire QEMU(1) man page, all 26 parts, and honestly? obsessed. this edition is version 11.1.0, dated Oct 26, 2026, and it's the QEMU(1) page β go forth and virtualize, slay, and remember: read the docs, verify your certs, and never skip the readahead π
β¨
π¦ where this page comes from
- centos-stream 10: qemu-kvm-common 18:11.1.0-3.el10 Β· GPL-2.0-only AND GPL-2.0-or-later AND CC-BY-3.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms