On Tue, Oct 06, 2020 at 01:01:49PM -0500, Eric Blake wrote: > On 10/6/20 11:54 AM, Richard W.M. Jones wrote: > > If the server fails, nbdinfo can write partial output before the error > > message (albeit on different channels). Here is an example: > > > > $ nbdkit eval open='echo EIO fail >&2; exit 1' --run 'nbdinfo --json > > "$uri"' > > { > > "protocol": "newstyle-fixed", > > "TLS": false, > > nbdkit: eval[1]: error: /tmp/nbdkitii3pZW/open: fail > > nbdkit: eval[1]: error: /tmp/nbdkitii3pZW/open: fail > > nbdinfo: nbd_opt_go: server replied with error to opt_go request: No such > > file or directory > > > > Notice the partial JSON document, and the error message from nbdinfo. > > > > With this commit nbdinfo tries to produce either the complete output > > or the error message. > > --- > > info/Makefile.am | 1 + > > info/info-atomic-output.sh | 32 ++++++ > > info/nbdinfo.c | 194 ++++++++++++++++++++++--------------- > > 3 files changed, 147 insertions(+), 80 deletions(-) > > ACK. Mostly mechanical, and memstreams make this nice. > > > > +++ b/info/info-atomic-output.sh > > @@ -0,0 +1,32 @@ > > > +. ../tests/functions.sh > > + > > +set -e > > +set -x > > + > > +requires nbdkit --version > > +requires nbdkit eval --version > > You could simplify this: if the second line passes, the first line is > implied, therefore, only the second is needed. > > > + > > +out=info-atomic-output.out > > +cleanup_fn rm -f $out > > + > > +nbdkit -U - eval open='echo EIO fail >&2; exit 1' \ > > + --run '$VG nbdinfo --size "nbd+unix:///?socket=$unixsocket"' > $out > > ||: > > nbdkit added $uri in 1.14, and the eval plugin in 1.18. You could > shorten this to --run '$VG nbdino --size "$uri"'. (We still use the > longhand elsewhere because of older RHEL having older nbdkit, but this > will already be skipped on those setups).
Yes, good point. For the record RHEL 7 has nbdkit 1.8 (forever now), but of course no eval plugin. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs