[Libguestfs] [nbdkit PATCH 2/7] protocol: Support EOVERFLOW

Eric Blake eblake at redhat.com
Tue Apr 23 00:50:21 UTC 2019


When the NBD spec added structured replies, it also added the
EOVERFLOW error as valid for an NBD_CMD_FLAG_DF request larger than
64k if the server can't support that without fragmentation. Once the
nbd plugin supports structured replies, we will need to properly pass
that error through to the end client (even though our current .pread
interface implies we are unlikely to ever generate the error locally).

The protocol says that EOVERFLOW is only valid if the client actually
sent NBD_CMD_FLAG_DF (which in turn requires that the client
negotiated NBD_OPT_STRUCTURED_REPLY), so if we wanted, we could add
some logic to continue to squash all other cases of EOVERFLOW to
EINVAL to remain protcol-compliant; but I figured it was not worth the
complications of ensuring that plugins are not setting that particular
error when it is not appropriate.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 common/protocol/protocol.h | 1 +
 plugins/nbd/nbd.c          | 2 ++
 server/protocol.c          | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/common/protocol/protocol.h b/common/protocol/protocol.h
index 57ce3d8..94dd6c5 100644
--- a/common/protocol/protocol.h
+++ b/common/protocol/protocol.h
@@ -230,6 +230,7 @@ extern const char *name_of_nbd_error (int);
 #define NBD_ENOMEM     12
 #define NBD_EINVAL     22
 #define NBD_ENOSPC     28
+#define NBD_EOVERFLOW  75
 #define NBD_ESHUTDOWN 108

 #endif /* NBDKIT_PROTOCOL_H */
diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c
index ae15eb7..72e833c 100644
--- a/plugins/nbd/nbd.c
+++ b/plugins/nbd/nbd.c
@@ -385,6 +385,8 @@ nbd_reply_raw (struct handle *h, int *fd)
     return EINVAL;
   case NBD_ENOSPC:
     return ENOSPC;
+  case NBD_EOVERFLOW:
+    return EOVERFLOW;
   case NBD_ESHUTDOWN:
     return ESHUTDOWN;
   }
diff --git a/server/protocol.c b/server/protocol.c
index 212bed0..a52bb56 100644
--- a/server/protocol.c
+++ b/server/protocol.c
@@ -348,6 +348,8 @@ nbd_errno (int error)
   case ESHUTDOWN:
     return NBD_ESHUTDOWN;
 #endif
+  case EOVERFLOW:
+    return NBD_EOVERFLOW;
   case EINVAL:
   default:
     return NBD_EINVAL;
-- 
2.20.1




More information about the Libguestfs mailing list