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 Same as "error", "error-rate" and "error-file" but only apply the
103 settings to NBD block status requests to read extents.
104
105 error-cache, error-cache-rate, error-cache-file.
106 Same as "error", "error-rate" and "error-file" but only apply the
107 settings to NBD cache requests.
108
110 Peculiar debug output
111 If you are looking at the debugging output (using "nbdkit -f -v") then
112 you may see peculiar "errors" appearing when using this filter, for
113 example:
114
115 nbdkit: file.9: debug: error: pread count=1024 offset=0 flags=0x0
116
117 In fact these are not errors, nbdkit core is simply printing the name
118 of the filter which happens to be "error". When this filter injects an
119 error you will see something like:
120
121 nbdkit: file.4: error: injecting ENOSPC error into pwrite
122
124 $filterdir/nbdkit-error-filter.so
125 The filter.
126
127 Use "nbdkit --dump-config" to find the location of $filterdir.
128
130 "nbdkit-error-filter" first appeared in nbdkit 1.6.
131
133 nbdkit(1), nbdkit-file-plugin(1), nbdkit-full-plugin(1),
134 nbdkit-filter(3).
135
137 Richard W.M. Jones
138
140 Copyright (C) 2018 Red Hat Inc.
141
143 Redistribution and use in source and binary forms, with or without
144 modification, are permitted provided that the following conditions are
145 met:
146
147 · Redistributions of source code must retain the above copyright
148 notice, this list of conditions and the following disclaimer.
149
150 · Redistributions in binary form must reproduce the above copyright
151 notice, this list of conditions and the following disclaimer in the
152 documentation and/or other materials provided with the
153 distribution.
154
155 · Neither the name of Red Hat nor the names of its contributors may
156 be used to endorse or promote products derived from this software
157 without specific prior written permission.
158
159 THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY
160 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
162 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE
163 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
164 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
165 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
166 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
167 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
168 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
169 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
170
171
172
173nbdkit-1.16.1 2019-12-03 nbdkit-error-filter(1)