docs: Add VERSION section giving first version a plugin/filter appeared.
[nbdkit/ericb.git] / plugins / reflection / nbdkit-reflection-plugin.pod
blobbeebae4084ead44484c32023440ae5a033fc3316
1 =head1 NAME
3 nbdkit-reflection-plugin - reflect client info back to the client
5 =head1 SYNOPSIS
7  nbdkit reflection [mode=]exportname|base64exportname|address
9 =head1 DESCRIPTION
11 C<nbdkit-reflection-plugin> is a test plugin which reflects
12 information sent by the client back to the client.
14 In its default mode (C<mode=exportname>) it converts the export name
15 passed from the client into a disk image.  C<mode=base64exportname> is
16 similar except the client must base64-encode the data in the export
17 name, allowing arbitrary binary data to be sent (see L</EXAMPLES>
18 below to make this clearer).  Export names are limited to 4096 bytes
19 by the NBD protocol, and nbdkit limits them to a few bytes smaller
20 than this.
22 C<mode=address> creates a disk which contains the client's IP address
23 and port number as a string.
25 The plugin only supports read-only access.  To make the disk writable,
26 add L<nbdkit-cow-filter(1)> on top.
28 =head1 EXAMPLES
30 Create a reflection disk.  By setting the export name to C<"hello">
31 when we open it, a virtual disk of only 5 bytes containing these
32 characters is created.  We then display the contents:
34  $ nbdkit --exit-with-parent reflection mode=exportname &
35  $ nbdsh -u 'nbd://localhost/hello' -c - <<'EOF'
36  size = h.get_size()
37  print("size = %d" % size)
38  buf = h.pread(size, 0)
39  print("buf = %r" % buf)
40  EOF
42  size = 5
43  buf = b"hello"
45 By running a reflection plugin, you can pass whole bootable VMs on the
46 qemu command line:
48  $ nbdkit reflection mode=base64exportname
49  $ qemu-system-x86_64 \
50    -drive 'snapshot=on,file.driver=nbd,file.host=localhost,file.port=10809,file.export=
51  tACwA80QtBOzCrABuRwAtgCyAL0ZfM0Q9CoqKiBIZWxsbyBmcm9tIG5iZGtp
52  dCEgKioqDQoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
53  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
54  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
55  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
56  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
57  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
58  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
59  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
60  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
61  AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
62  AAAAAAAAAAAAAAAAAAAAVao=
63  '
65 Another use for the reflection plugin is to send back the client's IP
66 address:
68  $ nbdkit reflection mode=address
69  $ nbdsh -u 'nbd://localhost' -c 'print(h.pread(h.get_size(), 0))'
71 which will print something like:
73  b'[::1]:58912'
75 =head1 PARAMETERS
77 =over 4
79 =item [B<mode=>]B<address>
81 Reflect the client's IP address and client port number as a string in
82 the usual format.  For Unix sockets this sets the disk to the string
83 C<"unix"> to avoid leaking host paths.
85 =item [B<mode=>]B<base64exportname>
87 Reflect the export name passed by the client, assuming the client
88 string is base64 encoded.
90 This mode is only supported if nbdkit was compiled with GnuTLS E<ge>
91 3.6.0.  You can find out by checking if:
93  $ nbdkit reflection --dump-plugin
95 contains:
97  reflection_base64=yes
99 =item [B<mode=>]B<exportname>
101 Reflect the raw export name passed by the client.  Note the export
102 name cannot contain ASCII NUL characters.
104 This is the default mode.
106 C<mode=> is a magic config key and may be omitted in most cases.
107 See L<nbdkit(1)/Magic parameters>.
109 =back
111 =head1 FILES
113 =over 4
115 =item F<$plugindir/nbdkit-reflection-plugin.so>
117 The plugin.
119 Use C<nbdkit --dump-config> to find the location of C<$plugindir>.
121 =back
123 =head1 VERSION
125 C<nbdkit-reflection-plugin> first appeared in nbdkit 1.16.
127 =head1 SEE ALSO
129 L<nbdkit(1)>,
130 L<nbdkit-plugin(3)>,
131 L<nbdkit-cow-filter(1)>,
132 L<nbdkit-data-plugin(1)>.
134 =head1 AUTHORS
136 Richard W.M. Jones
138 =head1 COPYRIGHT
140 Copyright (C) 2019 Red Hat Inc.