QEMU Monitor

QEMU monitor

The QEMU monitor is used to give complex commands to the QEMU emulator. You can use it to:

  • Remove or insert removable media images (such as CD-ROM or floppies).
  • Freeze/unfreeze the Virtual Machine (VM) and save or restore its state from a disk file.
  • Inspect the VM state without an external debugger.

Commands

The following commands are available:

help or ? [cmd]
help

Show the help for all commands or just for command cmd.

commit
commit

Commit changes to the disk images (if -snapshot is used) or backing files. If the backing file is smaller than the snapshot, then the backing file will be resized to be the same size as the snapshot. If the snapshot is smaller than the backing file, the backing file will not be truncated. If you want the backing file to match the size of the smaller snapshot, you can safely truncate it yourself once the commit operation successfully completes.

q or quit
quit

Quit the emulator.

block_resize
block_resize

Resize a block image while a guest is running. Usually requires guest action to see the updated size. Resize to a lower size is supported, but should be used with extreme caution. Note that this command only resizes image files, it can not resize block devices like LVM volumes.

block_stream
block_stream

Copy data from a backing file into a block device.

block_job_set_speed
block_job_set_speed

Set maximum speed for a background block operation.

block_job_cancel
block_job_cancel

Stop an active background block operation (streaming, mirroring).

block_job_complete
block_job_complete

Manually trigger completion of an active background block operation. For mirroring, this will switch the device to the destination path.

block_job_pause
block_job_pause

Pause an active block streaming operation.

block_job_resume
block_job_resume

Resume a paused block streaming operation.

eject [-f] device
eject

Eject a removable medium (use -f to force it).

drive_del device
drive_del

Remove host block device. The result is that guest generated IO is no longer submitted against the host device underlying the disk. Once a drive has been deleted, the QEMU Block layer returns -EIO which results in IO errors in the guest for applications that are reading/writing to the device. These errors are always reported to the guest, regardless of the drive’s error actions (drive options rerror, werror).

change device setting
change

Change the configuration of a device.

change diskdevice filename [format [read-only-mode]]

Change the medium for a removable disk device to point to filename. eg

(qemu) change ide1-cd0 /path/to/some.iso

format is optional.

read-only-mode may be used to change the read-only status of the device. It accepts the following values:

retain
Retains the current status; this is the default.
read-only
Makes the device read-only.
read-write
Makes the device writable.
change vnc display,options

Change the configuration of the VNC server. The valid syntax for display and options are described at sec_invocation. eg

(qemu) change vnc localhost:1
change vnc password [password]

Change the password associated with the VNC server. If the new password is not supplied, the monitor will prompt for it to be entered. VNC passwords are only significant up to 8 letters. eg

(qemu) change vnc password
Password: ********
screendump filename
screendump

Save screen into PPM image filename.

logfile filename
logfile

Output logs to filename.

trace-event
trace-event

changes status of a trace event

trace-file on|off|flush
trace-file

Open, close, or flush the trace file. If no argument is given, the status of the trace file is displayed.

log item1[,...]
log

Activate logging of the specified items.

savevm [tag|id]
savevm

Create a snapshot of the whole virtual machine. If tag is provided, it is used as human readable identifier. If there is already a snapshot with the same tag or ID, it is replaced. More info at vm_snapshots.

loadvm tag|id
loadvm

Set the whole virtual machine to the snapshot identified by the tag tag or the unique snapshot ID id.

delvm tag|id
delvm

Delete the snapshot identified by tag or id.

singlestep [off]
singlestep

Run the emulation in single step mode. If called with option off, the emulation returns to normal mode.

stop
stop

Stop emulation.

c or cont
cont

Resume emulation.

system_wakeup
system_wakeup

Wakeup guest from suspend.

gdbserver [port]
gdbserver

Start gdbserver session (default port=1234)

x/fmt addr
x

Virtual memory dump starting at addr.

xp /fmt addr
xp

Physical memory dump starting at addr.

fmt is a format which tells the command how to format the data. Its syntax is: /{count}{format}{size}

count
is the number of items to be dumped.
format
can be x (hex), d (signed decimal), u (unsigned decimal), o (octal), c (char) or i (asm instruction).
size
can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86, h or w can be specified with the i format to respectively select 16 or 32 bit code instruction size.

Examples:

  • Dump 10 instructions at the current instruction pointer:

    (qemu) x/10i $eip
    0x90107063:  ret
    0x90107064:  sti
    0x90107065:  lea    0x0(%esi,1),%esi
    0x90107069:  lea    0x0(%edi,1),%edi
    0x90107070:  ret
    0x90107071:  jmp    0x90107080
    0x90107073:  nop
    0x90107074:  nop
    0x90107075:  nop
    0x90107076:  nop
    
  • Dump 80 16 bit values at the start of the video memory.

    (qemu) xp/80hx 0xb8000
    0x000b8000: 0x0b50 0x0b6c 0x0b65 0x0b78 0x0b38 0x0b36 0x0b2f 0x0b42
    0x000b8010: 0x0b6f 0x0b63 0x0b68 0x0b73 0x0b20 0x0b56 0x0b47 0x0b41
    0x000b8020: 0x0b42 0x0b69 0x0b6f 0x0b73 0x0b20 0x0b63 0x0b75 0x0b72
    0x000b8030: 0x0b72 0x0b65 0x0b6e 0x0b74 0x0b2d 0x0b63 0x0b76 0x0b73
    0x000b8040: 0x0b20 0x0b30 0x0b35 0x0b20 0x0b4e 0x0b6f 0x0b76 0x0b20
    0x000b8050: 0x0b32 0x0b30 0x0b30 0x0b33 0x0720 0x0720 0x0720 0x0720
    0x000b8060: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
    0x000b8070: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
    0x000b8080: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
    0x000b8090: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
    
p or print/fmt expr
print

Print expression value. Only the format part of fmt is used.

i/fmt addr [.index]
i

Read I/O port.

o/fmt addr val
o

Write to I/O port.

sendkey keys
sendkey

Send keys to the guest. keys could be the name of the key or the raw value in hexadecimal format. Use - to press several keys simultaneously. Example:

sendkey ctrl-alt-f1

This command is useful to send keys that your graphical user interface intercepts at low level, such as ctrl-alt-f1 in X Window.

system_reset
system_reset

Reset the system.

system_powerdown
system_powerdown

Power down the system (if supported).

sum addr size
sum

Compute the checksum of a memory region.

usb_add devname
usb_add

Add the USB device devname. For details of available devices see usb_devices

usb_del devname
usb_del

Remove the USB device devname from the QEMU virtual USB hub. devname has the syntax bus.addr. Use the monitor command info usb to see the devices you can remove.

device_add config
device_add

Add device.

device_del id
device_del

Remove device id. id may be a short ID or a QOM object path.

cpu index
cpu

Set the default CPU.

mouse_move dx dy [dz]
mouse_move

Move the active mouse to the specified coordinates dx dy with optional scroll axis dz.

mouse_button val
mouse_button

Change the active mouse button state val (1=L, 2=M, 4=R).

mouse_set index
mouse_set

Set which mouse device receives events at given index, index can be obtained with

info mice
wavcapture filename [frequency [bits [channels]]]
wavcapture

Capture audio into filename. Using sample rate frequency bits per sample bits and number of channels channels.

Defaults:

  • Sample rate = 44100 Hz - CD quality
  • Bits = 16
  • Number of channels = 2 - Stereo
stopcapture index
stopcapture

Stop capture with a given index, index can be obtained with

info capture
memsave addr size file
memsave

save to disk virtual memory dump starting at addr of size size.

pmemsave addr size file
pmemsave

save to disk physical memory dump starting at addr of size size.

boot_set bootdevicelist
boot_set

Define new values for the boot device list. Those values will override the values specified on the command line through the -boot option.

The values that can be specified here depend on the machine type, but are the same that can be specified in the -boot command line option.

nmi cpu
nmi

Inject an NMI on the default CPU (x86/s390) or all CPUs (ppc64).

ringbuf_write device data
ringbuf_write

Write data to ring buffer character device device. data must be a UTF-8 string.

ringbuf_read device
ringbuf_read

Read and print up to size bytes from ring buffer character device device. Certain non-printable characters are printed \uXXXX, where XXXX is the character code in hexadecimal. Character \ is printed \\. Bug: can screw up when the buffer contains invalid UTF-8 sequences, NUL characters, after the ring buffer lost data, and when reading stops because the size limit is reached.

migrate [-d] [-b] [-i] uri
migrate

Migrate to uri (using -d to not wait for completion). -b for migration with full copy of disk -i for migration with incremental copy of disk (base image is shared)

migrate_cancel
migrate_cancel

Cancel the current VM migration.

migrate_incoming uri
migrate_incoming

Continue an incoming migration using the uri (that has the same syntax as the -incoming option).

migrate_set_cache_size value
migrate_set_cache_size

Set cache size to value (in bytes) for xbzrle migrations.

migrate_set_speed value
migrate_set_speed

Set maximum speed to value (in bytes) for migrations.

migrate_set_downtime second
migrate_set_downtime

Set maximum tolerated downtime (in seconds) for migration.

migrate_set_capability capability state
migrate_set_capability

Enable/Disable the usage of a capability capability for migration.

migrate_set_parameter parameter value
migrate_set_parameter

Set the parameter parameter for migration.

migrate_start_postcopy
migrate_start_postcopy

Switch in-progress migration to postcopy mode. Ignored after the end of migration (or once already in postcopy).

x_colo_lost_heartbeat
x_colo_lost_heartbeat

Tell COLO that heartbeat is lost, a failover or takeover is needed.

client_migrate_info protocol hostname port tls-port cert-subject
client_migrate_info

Set migration information for remote display. This makes the server ask the client to automatically reconnect using the new parameters once migration finished successfully. Only implemented for SPICE.

dump-guest-memory [-p] filename begin length
dump-guest-memory [-z|-l|-s] filename
dump-guest-memory

Dump guest memory to protocol. The file can be processed with crash or gdb. Without -z|-l|-s, the dump format is ELF. -p: do paging to get guest’s memory mapping. -z: dump in kdump-compressed format, with zlib compression. -l: dump in kdump-compressed format, with lzo compression. -s: dump in kdump-compressed format, with snappy compression. filename: dump file name. begin: the starting physical address. It’s optional, and should be specified together with length. length: the memory size, in bytes. It’s optional, and should be specified together with begin.

dump-skeys filename
dump-skeys

Save guest storage keys to a file.

snapshot_blkdev
snapshot_blkdev

Snapshot device, using snapshot file as target if provided

snapshot_blkdev_internal
snapshot_blkdev_internal

Take an internal snapshot on device if it support

snapshot_delete_blkdev_internal
snapshot_delete_blkdev_internal

Delete an internal snapshot on device if it support

drive_mirror
drive_mirror

Start mirroring a block device’s writes to a new destination, using the specified target.

drive_backup
drive_backup

Start a point-in-time copy of a block device to a specificed target.

drive_add
drive_add

Add drive to PCI storage controller.

pcie_aer_inject_error
pcie_aer_inject_error

Inject PCIe AER error

host_net_add
host_net_add

Add host VLAN client.

host_net_remove
host_net_remove

Remove host VLAN client.

netdev_add
netdev_add

Add host network device.

netdev_del
netdev_del

Remove host network device.

object_add
object_add

Create QOM object.

object_del
object_del

Destroy QOM object.

hostfwd_add
hostfwd_add

Redirect TCP or UDP connections from host to guest (requires -net user).

hostfwd_remove
hostfwd_remove

Remove host-to-guest TCP or UDP redirection.

balloon value
balloon

Request VM to change its memory allocation to value (in MB).

set_link name [on|off]
set_link

Switch link name on (i.e. up) or off (i.e. down).

watchdog_action
watchdog_action

Change watchdog action.

acl_show aclname
acl_show

List all the matching rules in the access control list, and the default policy. There are currently two named access control lists, vnc.x509dname and vnc.username matching on the x509 client certificate distinguished name, and SASL username respectively.

acl_policy aclname allow|deny
acl_policy

Set the default access control list policy, used in the event that none of the explicit rules match. The default policy at startup is always deny.

acl_add aclname match allow|deny [index]
acl_add

Add a match rule to the access control list, allowing or denying access. The match will normally be an exact username or x509 distinguished name, but can optionally include wildcard globs. eg *@EXAMPLE.COM to allow all users in the EXAMPLE.COM kerberos realm. The match will normally be appended to the end of the ACL, but can be inserted earlier in the list if the optional index parameter is supplied.

acl_remove aclname match
acl_remove

Remove the specified match rule from the access control list.

acl_reset aclname
acl_reset

Remove all matches from the access control list, and set the default policy back to deny.

nbd_server_start host:port
nbd_server_start

Start an NBD server on the given host and/or port. If the -a option is included, all of the virtual machine’s block devices that have an inserted media on them are automatically exported; in this case, the -w option makes the devices writable too.

nbd_server_add device
nbd_server_add

Export a block device through QEMU’s NBD server, which must be started beforehand with nbd_server_start. The -w option makes the exported device writable too.

nbd_server_stop
nbd_server_stop

Stop the QEMU embedded NBD server.

mce cpu bank status mcgstatus addr misc
mce (x86)

Inject an MCE on the given CPU (x86 only).

getfd fdname
getfd

If a file descriptor is passed alongside this command using the SCM_RIGHTS mechanism on unix sockets, it is stored using the name fdname for later use by other monitor commands.

closefd fdname
closefd

Close the file descriptor previously assigned to fdname using the getfd command. This is only needed if the file descriptor was never used by another monitor command.

block_passwd device password
block_passwd

Set the encrypted device device password to password

block_set_io_throttle device bps bps_rd bps_wr iops iops_rd iops_wr
block_set_io_throttle

Change I/O throttle limits for a block drive to bps bps_rd bps_wr iops iops_rd iops_wr

set_password [ vnc | spice ] password [ action-if-connected ]
set_password

Change spice/vnc password. Use zero to make the password stay valid forever. action-if-connected specifies what should happen in case a connection is established: fail makes the password change fail. disconnect changes the password and disconnects the client. keep changes the password and keeps the connection up. keep is the default.

expire_password [ vnc | spice ] expire-time
expire_password

Specify when a password for spice/vnc becomes invalid. expire-time accepts:

now
Invalidate password instantly.
never
Password stays valid forever.
+nsec
Password stays valid for nsec seconds starting now.
nsec
Password is invalidated at the given time. nsec are the seconds passed since 1970, i.e. unix epoch.
chardev-add args
chardev-add

chardev_add accepts the same parameters as the -chardev command line switch.

chardev-remove id
chardev-remove

Removes the chardev id.

qemu-io device command
qemu-io

Executes a qemu-io command on the given block device.

cpu-add id
cpu-add

Add CPU with id id

qom-list [path]
Print QOM properties of object at location path
qom-set path property value
Set QOM property property of object at location path to value value
info subcommand
info

Show various information about the system state.

info version
version

Show the version of QEMU.

info network
network

Show the network state.

info chardev
chardev

Show the character devices.

info block
block

Show info of one block device or all block devices.

info blockstats
blockstats

Show block device statistics.

info block-jobs
block-jobs

Show progress of ongoing block device operations.

info registers
registers

Show the cpu registers.

info lapic
lapic

Show local APIC state

info ioapic
ioapic

Show io APIC state

info cpus
cpus

Show infos for each CPU.

info history
history

Show the command line history.

info irq
irq

Show the interrupts statistics (if available).

info pic
pic

Show i8259 (PIC) state.

info pci
pci

Show PCI information.

info tlb
tlb

Show virtual to physical memory mappings.

info mem
mem

Show the active virtual memory mappings.

info mtree
mtree

Show memory tree.

info jit
jit

Show dynamic compiler info.

info opcount
opcount

Show dynamic compiler opcode counters

info kvm
kvm

Show KVM information.

info numa
numa

Show NUMA information.

info usb
usb

Show guest USB devices.

info usbhost
usbhost

Show host USB devices.

info profile
profile

Show profiling information.

info capture
capture

Show capture information.

info snapshots
snapshots

Show the currently saved VM snapshots.

info status
status

Show the current VM status (running|paused).

info mice
mice

Show which guest mouse is receiving events.

info vnc
vnc

Show the vnc server status.

info spice
spice

Show the spice server status.

info name
name

Show the current VM name.

info uuid
uuid

Show the current VM UUID.

info cpustats
cpustats

Show CPU statistics.

info usernet
usernet

Show user network stack connection states.

info migrate
migrate

Show migration status.

info migrate_capabilities
migrate_capabilities

Show current migration capabilities.

info migrate_parameters
migrate_parameters

Show current migration parameters.

info migrate_cache_size
migrate_cache_size

Show current migration xbzrle cache size.

info balloon
balloon

Show balloon information.

info qtree
qtree

Show device tree.

info qdm
qdm

Show qdev device model list.

info qom-tree
qom-tree

Show QOM composition tree.

info roms
roms

Show roms.

info trace-events
trace-events

Show available trace-events & their state.

info tpm
tpm

Show the TPM device.

info memdev
memdev

Show memory backends

info memory-devices
memory-devices

Show memory devices.

info iothreads
iothreads

Show iothread’s identifiers.

info rocker name
rocker

Show rocker switch.

info rocker_ports name-ports
ocker-ports

Show rocker ports.

info rocker_of_dpa_flows name [tbl_id]
rocker-of-dpa-flows

Show rocker OF-DPA flow tables.

info rocker-of-dpa-groups name [type]
rocker-of-dpa-groups

Show rocker OF-DPA groups.

info skeys address
skeys

Display the value of a storage key (s390 only)

info dump
dump

Display the latest dump status.

info hotpluggable-cpus
hotpluggable-cpus

Show information about hotpluggable CPUs

Integer expressions

The monitor understands integers expressions for every integer argument. You can use register names to get the value of specifics CPU registers by prefixing them with $.