$filterdir/nbdkit-pause-filter.so
The filter.
Use "nbdkit --dump-config" to find the location of $filterdir.
Pause nbd requests
nbdkit --filter=pause
PLUGIN
[PLUGIN-ARGS ...]
pause-control=SOCKET
"nbdkit-pause-filter" is a filter for nbdkit(1) which can temporarily stop NBD requests from being handled by nbdkit, and later resume them. This filter can be used if you need to take a snapshot of the underlying storage.
The "pause-control" parameter is the name of a Unix domain socket which the filter listens for commands on.
To pause NBD request processing you send character 'p' to the socket. Any NBD requests received afterwards will hang until you resume processing.
To resume processing you send character 'r' to the socket.
So you can know when pausing/resuming has taken effect, the filter echos back the character over the socket in uppercase (ie. either 'P' or 'R'). When pausing, the 'P' response is not sent until all outstanding NBD requests (received before the pause) have been completed. This usually means the plugin is idle, although be aware that it is possible for plugins to create background threads and do work that the filter cannot "see".
Any unknown commands are ignored. The filter responds with 'X'.
Pick a large file, disk image or ISO, serve it over NBD, and start copying it:
nbdkit --filter=pause --filter=rate \file BIG_FILE.ISO rate=10M pause-control=sock \--run 'qemu-img convert -p "$uri" /var/tmp/out'
To cause the copy to appear to hang, do:
echo p | nc -U sock
To resume activity:
echo r | nc -U sock
pause-control=SOCKETThe Unix domain socket for controlling the filter. See "Control socket" above.
If you are connecting a kernel client, virtual machine or similar to nbdkit then only short pauses are tolerated, and you will soon get timeout errors. The timeouts are not generated by nbdkit, but by the client itself.
The pause filter does not flush requests to disk, although this is a possible future enhancement.
A virtual machine with multiple disks connected through multiple nbdkit instances cannot get a consistent snapshot using this filter, since even if you send the pause commands to all instances at the same time they will be processed at slightly different times (and this can matter if a virtual machine is doing something like RAID across the disks). This is not something that can be solved at the level of individual devices, the only way to solve this is at the hypervisor level.
$filterdir/nbdkit-pause-filter.so
The filter.
Use "nbdkit --dump-config" to find the location of $filterdir.
"nbdkit-pause-filter" first appeared in nbdkit 1.22.
3 releases since Debian 11 (Bullseye); the text changed 2 times.