From 229a1ea318a6604c46f8404d3c61802b3421421c Mon Sep 17 00:00:00 2001
From: Thanos Makatos <thanos.makatos@nutanix.com>
Date: Tue, 22 Nov 2022 14:23:34 +0000
Subject: add debugging to handle_device_get_region_io_fds (#723)

Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Reviewed-by: John Levon <john.levon@nutanix.com>
---
 lib/libvfio-user.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 219b527..be4be95 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -582,12 +582,14 @@ handle_device_get_region_io_fds(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
     assert(msg->out.fds == NULL);
 
     if (msg->in.iov.iov_len < sizeof(vfio_user_region_io_fds_request_t)) {
+        vfu_log(vfu_ctx, LOG_DEBUG, "input message too small");
         return ERROR_INT(EINVAL);
     }
 
     req = msg->in.iov.iov_base;
 
     if (req->flags != 0 || req->count != 0) {
+        vfu_log(vfu_ctx, LOG_DEBUG, "bad flags or bad count");
         return ERROR_INT(EINVAL);
     }
 
@@ -601,6 +603,7 @@ handle_device_get_region_io_fds(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
 
     // At least one flag must be set for a valid region.
     if (!(vfu_reg->flags & VFU_REGION_FLAG_MASK)) {
+        vfu_log(vfu_ctx, LOG_DEBUG, "bad region flags");
         return ERROR_INT(EINVAL);
     }
 
@@ -613,6 +616,7 @@ handle_device_get_region_io_fds(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
 
     if (req->argsz < sizeof(vfio_user_region_io_fds_reply_t) ||
         req->argsz > SERVER_MAX_DATA_XFER_SIZE) {
+        vfu_log(vfu_ctx, LOG_DEBUG, "bad argsz");
         return ERROR_INT(EINVAL);
     }
 
-- 
cgit v1.1