=head1 NAME

nbdkit-pause-filter - pause NBD requests

=head1 SYNOPSIS

 nbdkit --filter=pause PLUGIN [PLUGIN-ARGS...] pause-control=SOCKET

=head1 DESCRIPTION

C<nbdkit-pause-filter> is a filter for L<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.

=head2 Control socket

The C<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 C<'p'> to the
socket.  Any NBD requests received afterwards will hang until you
resume processing.

To resume processing you send character C<'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
C<'P'> or C<'R'>).  When pausing, the C<'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 C<'X'>.

=head1 EXAMPLE

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

=head1 PARAMETERS

=over 4

=item B<pause-control=>SOCKET

The Unix domain socket for controlling the filter.
See L</Control socket> above.

=back

=head1 NOTES

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.

=head1 FILES

=over 4

=item F<$filterdir/nbdkit-pause-filter.so>

The filter.

Use C<nbdkit --dump-config> to find the location of C<$filterdir>.

=back

=head1 VERSION

C<nbdkit-pause-filter> first appeared in nbdkit 1.22.

=head1 SEE ALSO

L<nbdkit(1)>,
L<nbdkit-filter(3)>,
L<nbdkit-delay-filter(1)>,
L<nbdkit-rate-filter(1)>,
L<nc(1)>.

=head1 AUTHORS

Richard W.M. Jones

=head1 COPYRIGHT

Copyright Red Hat
