|
NAMEqemu-storage-daemon - QEMU storage daemonSYNOPSISqemu-storage-daemon [options]DESCRIPTIONqemu-storage-daemon provides disk image functionality from QEMU, qemu-img, and qemu-nbd in a long-running process controlled via QMP commands without running a virtual machine. It can export disk images, run block job operations, and perform other disk-related operations. The daemon is controlled via a QMP monitor and initial configuration from the command-line.The daemon offers the following subset of QEMU features:
Commands can be sent over a QEMU Monitor Protocol (QMP) connection. See the qemu-storage-daemon-qmp-ref(7) manual page for a description of the commands. The daemon runs until it is stopped using the quit QMP command or SIGINT/SIGHUP/SIGTERM. Warning: Never modify images in use by a running virtual machine or any other process; this may destroy the image. Also, be aware that querying an image that is being modified by another process may encounter inconsistent state. OPTIONSStandard options:
Immediately enable events matching PATTERN (either
event name or a globbing pattern). This option is only available if QEMU has
been compiled with the simple, log or ftrace tracing
backend. To specify multiple events or patterns, specify the -trace
option multiple times.
Use -trace help to print a list of names of trace points. events=FILE Immediately enable events listed in FILE. The file
must contain one event name (as listed in the trace-events-all file)
per line; globbing patterns are accepted too. This option is only available if
QEMU has been compiled with the simple, log or ftrace
tracing backend.
file=FILE Log output traces to FILE. This option is only
available if QEMU has been compiled with the simple tracing
backend.
--chardev socket,id=char1,path=/var/run/qsd-qmp.sock,server=on,wait=off
--monitor chardev=char1
--nbd-server addr.type=unix,addr.path=/var/run/qsd-nbd.sock
$ kill -SIGTERM $(<path/to/qsd.pid) A file lock is applied to the file so only one instance of the daemon can run with a given pid file path. The daemon unlinks its pid file when terminating. The pid file is written after chardevs, exports, and NBD servers have been created but before accepting connections. The daemon has started successfully when the pid file is written and clients may begin connecting. EXAMPLESLaunch the daemon with QMP monitor socket qmp.sock so clients can execute QMP commands:$ qemu-storage-daemon \ --chardev socket,path=qmp.sock,server=on,wait=off,id=char1 \ --monitor chardev=char1 Launch the daemon from Python with a QMP monitor socket using file descriptor passing so there is no need to busy wait for the QMP monitor to become available: #!/usr/bin/env python3 import subprocess import socket sock_path = '/var/run/qmp.sock' with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as listen_sock: listen_sock.bind(sock_path) listen_sock.listen() fd = listen_sock.fileno() subprocess.Popen( ['qemu-storage-daemon', '--chardev', f'socket,fd={fd},server=on,id=char1', '--monitor', 'chardev=char1'], pass_fds=[fd], ) # listen_sock was automatically closed when leaving the 'with' statement # body. If the daemon process terminated early then the following connect() # will fail with "Connection refused" because no process has the listen # socket open anymore. Launch errors can be detected this way. qmp_sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) qmp_sock.connect(sock_path) ...QMP interaction... The same socket spawning approach also works with the --nbd-server addr.type=fd,addr.str=<fd> and --export type=vhost-user-blk,addr.type=fd,addr.str=<fd> options. Export raw image file disk.img over NBD UNIX domain socket nbd.sock: $ qemu-storage-daemon \ --blockdev driver=file,node-name=disk,filename=disk.img \ --nbd-server addr.type=unix,addr.path=nbd.sock \ --export type=nbd,id=export,node-name=disk,writable=on Export a qcow2 image file disk.qcow2 as a vhosts-user-blk device over UNIX domain socket vhost-user-blk.sock: $ qemu-storage-daemon \ --blockdev driver=file,node-name=file,filename=disk.qcow2 \ --blockdev driver=qcow2,node-name=qcow2,file=file \ --export type=vhost-user-blk,id=export,addr.type=unix,addr.path=vhost-user-blk.sock,node-name=qcow2 Export a qcow2 image file disk.qcow2 via FUSE on itself, so the disk image file will then appear as a raw image: $ qemu-storage-daemon \ --blockdev driver=file,node-name=file,filename=disk.qcow2 \ --blockdev driver=qcow2,node-name=qcow2,file=file \ --export type=fuse,id=export,node-name=qcow2,mountpoint=disk.qcow2,writable=on SEE ALSOqemu(1), qemu-block-drivers(7), qemu-storage-daemon-qmp-ref(7)COPYRIGHT2021, The QEMU Project Developers
Visit the GSP FreeBSD Man Page Interface. |