[Libguestfs] [nbdkit PATCH v2 3/6] protocol: Support ESHUTDOWN error

Eric Blake eblake at redhat.com
Thu Jan 26 02:42:33 UTC 2017


The NBD specification was clarified to state that the server can
send ESHUTDOWN at any time that it wants to inform the client
that the server is about to close the connection and that all
further commands will fail, to give the client a chance to first
send NBD_CMD_DISC for a clean shutdown.  While nbdkit does not
(yet) directly send this errno, it is feasible that a plugin may
want this error value preserved across the wire rather than
converted to EINVAL.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 src/connections.c | 4 ++++
 src/protocol.h    | 1 +
 2 files changed, 5 insertions(+)

diff --git a/src/connections.c b/src/connections.c
index e15a777..c0f0567 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -737,6 +737,10 @@ nbd_errno (int error)
   case EFBIG:
   case ENOSPC:
     return NBD_ENOSPC;
+#ifdef ESHUTDOWN
+  case ESHUTDOWN:
+    return NBD_ESHUTDOWN;
+#endif
   case EINVAL:
   default:
     return NBD_EINVAL;
diff --git a/src/protocol.h b/src/protocol.h
index 4571a3a..74c4527 100644
--- a/src/protocol.h
+++ b/src/protocol.h
@@ -145,5 +145,6 @@ struct reply {
 #define NBD_ENOMEM     12
 #define NBD_EINVAL     22
 #define NBD_ENOSPC     28
+#define NBD_ESHUTDOWN 108

 #endif /* NBDKIT_PROTOCOL_H */
-- 
2.9.3




More information about the Libguestfs mailing list