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