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). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs