[Libguestfs] [libnbd PATCH 7/7] states: Capture NBD_REP_ERR message
Eric Blake
eblake at redhat.com
Fri Jun 14 22:00:08 UTC 2019
On 6/14/19 4:54 PM, Eric Blake wrote:
> Similar to the earlier patch for structured reply errors, it's worth
> logging (at least through debug) any error messages that the server
> sends alongside NBD_REP_ERR. And given our earlier changes, it
> doesn't really impact the size of struct nbd_handle.
> ---
> +++ b/generator/states-newstyle.c
> @@ -77,6 +77,35 @@ prepare_for_reply_payload (struct nbd_handle *h, uint32_t opt)
> return 0;
> }
>
> +/* Check an unexpected server reply. If it is an error, log any
> + * message from the server and return 0; otherwise, return -1.
> + */
> +static int
> +handle_reply_error (struct nbd_handle *h)
> +{
> + uint32_t len;
> + uint32_t reply;
> +
> + len = be32toh (h->sbuf.or.option_reply.replylen);
> + reply = be32toh (h->sbuf.or.option_reply.reply);
> + if (!NBD_REP_IS_ERR (reply)) {
> + set_error (0, "handshake: unexpected option reply type %d", reply);
> + return -1;
> + }
> +
> + assert (NBD_MAX_STRING < sizeof h->sbuf.or.payload);
Missing an addition of #include <assert.h>.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190614/e9fea6a8/attachment.sig>
More information about the Libguestfs
mailing list