1nbdkit-error-filter(1) NBDKIT nbdkit-error-filter(1)
2
3
4
6 nbdkit-error-filter - inject errors for testing clients
7
9 nbdkit --filter=error PLUGIN
10 [error=EPERM|EIO|ENOMEM|EINVAL|ENOSPC|ESHUTDOWN]
11 [error-rate=10%|0.1]
12 [error-file=/tmp/inject]
13 [error-pread=...] [error-pread-rate=...] [error-pread-file=...]
14 [error-pwrite=...] [error-pwrite-rate=...] [error-pwrite-file=...]
15 [error-trim=...] [error-trim-rate=...] [error-trim-file=...]
16 [error-zero=...] [error-zero-rate=...] [error-zero-file=...]
17 [error-extents=...] [error-extents-rate=...] [error-extents-file=...]
18 [error-cache=...] [error-cache-rate=...] [error-cache-file=...]
19
21 "nbdkit-error-filter" is an nbdkit filter that injects random errors
22 into replies from the server. This is used for testing that NBD
23 clients can handle errors.
24
25 All parameters are optional, but you should usually specify one of the
26 "error-rate" or "error-*-rate" parameters, otherwise this filter will
27 do nothing.
28
30 Inject a low rate of errors randomly into the connection:
31
32 nbdkit --filter=error file disk.img error-rate=1%
33
34 Reading, trimming, cache and extents (block status) requests will be
35 successful, but all writes and zeroing will return "No space left on
36 device":
37
38 nbdkit --filter=error file disk.img \
39 error=ENOSPC \
40 error-pwrite-rate=100% \
41 error-zero-rate=100%
42
43 To make all connections fail hard 60 seconds after the server is
44 started, use:
45
46 rm -f /tmp/inject
47 nbdkit --filter=error file disk.img \
48 error-rate=100% \
49 error-file=/tmp/inject
50 sleep 60; touch /tmp/inject
51
53 error=EPERM|EIO|ENOMEM|EINVAL|ENOSPC|ESHUTDOWN
54 When a random error is injected, you can select which one from the
55 range of possible NBD errors (the NBD protocol only supports a
56 limited range of error codes).
57
58 This parameter is optional and the default is "EIO" ("Input/output
59 error").
60
61 error-rate=N%
62 error-rate=0..1
63 The rate of injected errors per NBD request. This can be expressed
64 as either a percentage between "0%" and "100%" or as a probability
65 between 0 and 1. If "0%" or 0 is used then no errors are ever
66 injected, and if "100%" or 1 is used then all requests return
67 errors.
68
69 This parameter is optional and the default is "0%". Unless you set
70 this, the filter will do nothing.
71
72 error-file=FILENAME
73 Errors will only be injected when FILENAME exists. (Note you must
74 also specify the "error-rate").
75
76 You can use this for fine-grained control over when to inject
77 errors, for example if you want to trigger an error at an exact
78 moment during a test, arrange for this file to be created at the
79 appropriate time. Or conversely to test error recovery in a
80 client, create the file initially, and then delete it to check the
81 client can recover.
82
83 This parameter is optional.
84
85 error-pread, error-pread-rate, error-pread-file.
86 Same as "error", "error-rate" and "error-file" but only apply the
87 settings to NBD pread requests.
88
89 error-pwrite, error-pwrite-rate, error-pwrite-file.
90 Same as "error", "error-rate" and "error-file" but only apply the
91 settings to NBD pwrite requests.
92
93 error-trim, error-trim-rate, error-trim-file.
94 Same as "error", "error-rate" and "error-file" but only apply the
95 settings to NBD trim requests.
96
97 error-zero, error-zero-rate, error-zero-file.
98 Same as "error", "error-rate" and "error-file" but only apply the
99 settings to NBD zero requests.
100
101 error-extents, error-extents-rate, error-extents-file.
102 (nbdkit ≥ 1.12)
103
104 Same as "error", "error-rate" and "error-file" but only apply the
105 settings to NBD block status requests to read extents.
106
107 error-cache, error-cache-rate, error-cache-file.
108 (nbdkit ≥ 1.14)
109
110 Same as "error", "error-rate" and "error-file" but only apply the
111 settings to NBD cache requests.
112
114 Peculiar debug output
115 If you are looking at the debugging output (using "nbdkit -f -v") then
116 you may see peculiar "errors" appearing when using this filter, for
117 example:
118
119 nbdkit: file.9: debug: error: pread count=1024 offset=0 flags=0x0
120
121 In fact these are not errors, nbdkit core is simply printing the name
122 of the filter which happens to be "error". When this filter injects an
123 error you will see something like:
124
125 nbdkit: file.4: error: injecting ENOSPC error into pwrite
126
128 $filterdir/nbdkit-error-filter.so
129 The filter.
130
131 Use "nbdkit --dump-config" to find the location of $filterdir.
132
134 "nbdkit-error-filter" first appeared in nbdkit 1.6.
135
137 nbdkit(1), nbdkit-file-plugin(1), nbdkit-full-plugin(1),
138 nbdkit-filter(3).
139
141 Richard W.M. Jones
142
144 Copyright (C) 2018 Red Hat Inc.
145
147 Redistribution and use in source and binary forms, with or without
148 modification, are permitted provided that the following conditions are
149 met:
150
151 • Redistributions of source code must retain the above copyright
152 notice, this list of conditions and the following disclaimer.
153
154 • Redistributions in binary form must reproduce the above copyright
155 notice, this list of conditions and the following disclaimer in the
156 documentation and/or other materials provided with the
157 distribution.
158
159 • Neither the name of Red Hat nor the names of its contributors may
160 be used to endorse or promote products derived from this software
161 without specific prior written permission.
162
163 THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY
164 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
165 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
166 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE
167 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
168 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
169 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
170 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
171 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
172 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
173 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
174
175
176
177nbdkit-1.28.2 2021-11-09 nbdkit-error-filter(1)