From d0e6d83c083e74af05f10ed3dcee6dc3b757d933 Mon Sep 17 00:00:00 2001 From: John Levon Date: Thu, 21 Jul 2022 11:31:10 +0100 Subject: [PATCH] fix x-no-posted-writes VFIO_USER_NO_REPLY should not be set if we've globally disabled posted writes. Signed-off-by: John Levon --- hw/vfio/user.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/vfio/user.c b/hw/vfio/user.c index edc59bd7c18..361975df980 100644 --- a/hw/vfio/user.c +++ b/hw/vfio/user.c @@ -1451,14 +1451,20 @@ static int vfio_user_region_write(VFIOProxy *proxy, uint8_t index, off_t offset, uint32_t count, void *data, bool post) { VFIOUserRegionRW *msgp = NULL; - int flags = post ? VFIO_USER_NO_REPLY : 0; int size = sizeof(*msgp) + count; + int flags; int ret; if (count > max_xfer_size) { return -EINVAL; } + if (proxy->flags & VFIO_PROXY_NO_POST) { + post = false; + } + + flags = post ? VFIO_USER_NO_REPLY : 0; + msgp = g_malloc0(size); vfio_user_request_msg(&msgp->hdr, VFIO_USER_REGION_WRITE, size, flags); msgp->offset = offset; @@ -1467,7 +1473,7 @@ static int vfio_user_region_write(VFIOProxy *proxy, uint8_t index, off_t offset, memcpy(&msgp->data, data, count); /* async send will free msg after it's sent */ - if (post && !(proxy->flags & VFIO_PROXY_NO_POST)) { + if (post) { vfio_user_send_async(proxy, &msgp->hdr, NULL); return count; }