Re: [Libguestfs] [PATCH nbdkit v2 5/6] New plugin: ones

2023-05-17 Thread Eric Blake
On Wed, May 17, 2023 at 11:06:58AM +0100, Richard W.M. Jones wrote: > Returns a fully allocated disk containing all 0xff (all ones), or > another byte of your choice. > --- > + > +=item BN > + > +Set the repeating byte to C. The default is C<0xff> (all ones). > + > +Instead of C it is more

Re: [Libguestfs] [PATCH nbdkit v2 6/6] New filter: evil

2023-05-17 Thread Eric Blake
On Wed, May 17, 2023 at 11:06:59AM +0100, Richard W.M. Jones wrote: > This filter adds random data corruption when reading from the > underlying plugin. > --- > +=head1 VERSION > + > +C first appeared in nbdkit 1.36. Missed touching up this part of your copy-paste. > +static enum mode evil_mode

Re: [Libguestfs] [PATCH nbdkit v2 4/6] common/include: Make log_2_bits work on 64 bit ints

2023-05-17 Thread Eric Blake
On Wed, May 17, 2023 at 11:06:57AM +0100, Richard W.M. Jones wrote: > Previously it only worked for 64 bit ints on 64 bit platforms, but we > can easily adjust the function to work on any platform. > --- > common/include/ispowerof2.h | 4 ++-- > common/include/test-ispowerof2.c | 6 ++ >

Re: [Libguestfs] [PATCH nbdkit v2 4/6] common/include: Make log_2_bits work on 64 bit ints

2023-05-17 Thread Eric Blake
On Wed, May 17, 2023 at 11:06:57AM +0100, Richard W.M. Jones wrote: > Previously it only worked for 64 bit ints on 64 bit platforms, but we > can easily adjust the function to work on any platform. > --- > common/include/ispowerof2.h | 4 ++-- > common/include/test-ispowerof2.c | 6 ++ >

Re: [Libguestfs] [PATCH nbdkit v2 2/6] error: Use new nbdkit_parse_probability

2023-05-17 Thread Eric Blake
On Wed, May 17, 2023 at 11:06:55AM +0100, Richard W.M. Jones wrote: > This replaces the existing ad hoc parsing with the new public function. > --- > filters/error/nbdkit-error-filter.pod | 12 +++- > filters/error/error.c | 14 +- > 2 files changed, 8

Re: [Libguestfs] [PATCH nbdkit v2 1/6] Add new public nbdkit_parse_probability function

2023-05-17 Thread Eric Blake
On Wed, May 17, 2023 at 11:06:54AM +0100, Richard W.M. Jones wrote: > In nbdkit-error-filter we need to parse parameters as probabilities. > This is useful enough to add to nbdkit, since we will use it in > another filter in future. > --- > docs/nbdkit-plugin.pod | 19 +++ >

Re: [Libguestfs] [PATCH nbdkit v2 3/6] common/include: Add next_power_of_2 function

2023-05-17 Thread Eric Blake
On Wed, May 17, 2023 at 11:06:56AM +0100, Richard W.M. Jones wrote: > It takes a 64 bit integer and finds the next power of 2, > eg. next_power_of_2 (510) => 512 (2^9) > > Taken from https://jameshfisher.com/2018/03/30/round-up-power-2/ > with some fixes. > > Thanks: Eric Blake > --- >

Re: [Libguestfs] [PATCH nbdkit 1/5] Add new public nbdkit_parse_probability function

2023-05-17 Thread Richard W.M. Jones
On Tue, May 16, 2023 at 09:22:31PM +0100, Richard W.M. Jones wrote: > I'm not really sure we reached a conclusion so far, but I did want to > say that I changed the evil filter impl so that it now treats any > 0 <= P < 1e-12 as effectively 0. (P == evil-probability; P < 0 and P > 1 > are still

[Libguestfs] [PATCH nbdkit v2 0/6] New ones plugin and evil filter

2023-05-17 Thread Richard W.M. Jones
This addresses most of the issues from the review of v1 here: https://listman.redhat.com/archives/libguestfs/2023-May/031520.html * The filter now only handles 1e-12 <= P <= 1/8. Probabilities outside this range are treated as 0% or 100% respectively. The reasons are given in the code and

[Libguestfs] [PATCH nbdkit v2 1/6] Add new public nbdkit_parse_probability function

2023-05-17 Thread Richard W.M. Jones
In nbdkit-error-filter we need to parse parameters as probabilities. This is useful enough to add to nbdkit, since we will use it in another filter in future. --- docs/nbdkit-plugin.pod | 19 +++ plugins/python/nbdkit-python-plugin.pod | 6 ++ include/nbdkit-common.h

[Libguestfs] [PATCH nbdkit v2 3/6] common/include: Add next_power_of_2 function

2023-05-17 Thread Richard W.M. Jones
It takes a 64 bit integer and finds the next power of 2, eg. next_power_of_2 (510) => 512 (2^9) Taken from https://jameshfisher.com/2018/03/30/round-up-power-2/ with some fixes. Thanks: Eric Blake --- common/include/ispowerof2.h | 9 + common/include/test-ispowerof2.c | 15

[Libguestfs] [PATCH nbdkit v2 6/6] New filter: evil

2023-05-17 Thread Richard W.M. Jones
This filter adds random data corruption when reading from the underlying plugin. --- filters/error/nbdkit-error-filter.pod | 4 + filters/evil/nbdkit-evil-filter.pod | 167 ++ configure.ac | 2 + filters/evil/Makefile.am | 77 +

[Libguestfs] [PATCH nbdkit v2 2/6] error: Use new nbdkit_parse_probability

2023-05-17 Thread Richard W.M. Jones
This replaces the existing ad hoc parsing with the new public function. --- filters/error/nbdkit-error-filter.pod | 12 +++- filters/error/error.c | 14 +- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/filters/error/nbdkit-error-filter.pod

[Libguestfs] [PATCH nbdkit v2 5/6] New plugin: ones

2023-05-17 Thread Richard W.M. Jones
Returns a fully allocated disk containing all 0xff (all ones), or another byte of your choice. --- plugins/data/nbdkit-data-plugin.pod | 1 + plugins/full/nbdkit-full-plugin.pod | 1 + plugins/null/nbdkit-null-plugin.pod | 1 +

[Libguestfs] [PATCH nbdkit v2 4/6] common/include: Make log_2_bits work on 64 bit ints

2023-05-17 Thread Richard W.M. Jones
Previously it only worked for 64 bit ints on 64 bit platforms, but we can easily adjust the function to work on any platform. --- common/include/ispowerof2.h | 4 ++-- common/include/test-ispowerof2.c | 6 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git

Re: [Libguestfs] [PATCH nbdkit 5/5] New filter: evil

2023-05-17 Thread Richard W.M. Jones
On Wed, May 17, 2023 at 03:28:11PM +0200, Laszlo Ersek wrote: > On 5/16/23 14:12, Richard W.M. Jones wrote: > > > +/* This is the heart of the algorithm, the function which corrupts > > + * the buffer after reading it from the plugin. > > + * > > + * The observation is that if we have a block of

Re: [Libguestfs] [PATCH nbdkit 1/5] Add new public nbdkit_parse_probability function

2023-05-17 Thread Laszlo Ersek
On 5/16/23 22:22, Richard W.M. Jones wrote: > On Tue, May 16, 2023 at 02:35:38PM -0500, Eric Blake wrote: >> Our pre-existing error filter is already doing percentage calculations >> via floating point, so on the grounds that this patch is consolidating >> common code patterns to avoid

Re: [Libguestfs] [PATCH nbdkit 1/5] Add new public nbdkit_parse_probability function

2023-05-17 Thread Laszlo Ersek
On 5/16/23 21:35, Eric Blake wrote: > On Tue, May 16, 2023 at 07:20:16PM +0200, Laszlo Ersek wrote: >> On 5/16/23 14:12, Richard W.M. Jones wrote: >>> +else if (d2 == 0) /* N/0 is bad */ >>> + goto bad_parse; >>> +else >>> + d /= d2; >> >> I don't want to be a

Re: [Libguestfs] [PATCH nbdkit 5/5] New filter: evil

2023-05-17 Thread Laszlo Ersek
On 5/16/23 14:12, Richard W.M. Jones wrote: > +/* This is the heart of the algorithm, the function which corrupts > + * the buffer after reading it from the plugin. > + * > + * The observation is that if we have a block of (eg) size 10^6 bits > + * and our probability of finding a corrupt bit is