From e4898ec4c5963749b633fba75561736de0ce65d1 Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Mon, 8 Jul 2024 13:36:56 +0800 Subject: [PATCH 1/9] vhsot-user: Do not wait for replay for not sent VHOST_USER_SET_LOG_BASE Signed-off-by: BillXiang <1373760142@qq.com> --- hw/virtio/vhost-user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index c97ea2544d..8dfd728069 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -519,7 +519,7 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_SET_LOG_BASE, - .hdr.flags = VHOST_USER_VERSION, + .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK, .payload.log.mmap_size = log->size * sizeof(*(log->log)), .payload.log.mmap_offset = 0, .hdr.size = sizeof(msg.payload.log), @@ -534,7 +534,7 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, return ret; } - if (shmfd) { + if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { msg.hdr.size = 0; ret = vhost_user_read(dev, &msg); if (ret < 0) { -- Gitee From ffd04d7d8a9f64f5b68e9e5a975860ef88b31891 Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Mon, 8 Jul 2024 20:42:42 +0800 Subject: [PATCH 2/9] vhsot-user: Ask for replay when supported Signed-off-by: BillXiang <1373760142@qq.com> --- hw/virtio/vhost-user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 8dfd728069..4978280189 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -516,15 +516,21 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, size_t fd_num = 0; bool shmfd = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_LOG_SHMFD); + bool reply_supported = virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_REPLY_ACK); int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_SET_LOG_BASE, - .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK, + .hdr.flags = VHOST_USER_VERSION, .payload.log.mmap_size = log->size * sizeof(*(log->log)), .payload.log.mmap_offset = 0, .hdr.size = sizeof(msg.payload.log), }; + if (shmfd && reply_supported) { + msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; + } + if (shmfd && log->fd != -1) { fds[fd_num++] = log->fd; } -- Gitee From 13caee05d3ed94166e370f272c3175332ca1bcb1 Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Wed, 10 Jul 2024 18:00:34 +0800 Subject: [PATCH 3/9] vhsot-user: Clear flag after use for ci Signed-off-by: BillXiang <1373760142@qq.com> --- hw/virtio/vhost-user.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 4978280189..af00328bdb 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -541,6 +541,7 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, } if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { + msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; msg.hdr.size = 0; ret = vhost_user_read(dev, &msg); if (ret < 0) { -- Gitee From 5db5ab03dd3ec1e0e7eb3140f327fad75bbb0dae Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Wed, 10 Jul 2024 19:12:07 +0800 Subject: [PATCH 4/9] vhsot-user: test for ci Signed-off-by: BillXiang <1373760142@qq.com> --- hw/virtio/vhost-user.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index af00328bdb..8600799151 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -516,8 +516,8 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, size_t fd_num = 0; bool shmfd = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_LOG_SHMFD); - bool reply_supported = virtio_has_feature(dev->protocol_features, - VHOST_USER_PROTOCOL_F_REPLY_ACK); + // bool reply_supported = virtio_has_feature(dev->protocol_features, + // VHOST_USER_PROTOCOL_F_REPLY_ACK); int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_SET_LOG_BASE, @@ -527,9 +527,9 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, .hdr.size = sizeof(msg.payload.log), }; - if (shmfd && reply_supported) { - msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; - } + // if (shmfd && reply_supported) { + // msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; + // } if (shmfd && log->fd != -1) { fds[fd_num++] = log->fd; @@ -540,8 +540,9 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, return ret; } - if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { - msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; + // if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { + // msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; + if (shmfd) { msg.hdr.size = 0; ret = vhost_user_read(dev, &msg); if (ret < 0) { -- Gitee From f80e90c4c055a7ae822fbf913dba471f240f6602 Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Wed, 10 Jul 2024 19:44:36 +0800 Subject: [PATCH 5/9] vhsot-user: test for ci Signed-off-by: BillXiang <1373760142@qq.com> --- hw/virtio/vhost-user.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 8600799151..afeeefa1c7 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -496,6 +496,9 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, trace_vhost_user_write(msg->hdr.request, msg->hdr.flags); + if (msg->hdr.request == VHOST_USER_SET_LOG_BASE) { + msg->hdr.flags |= VHOST_USER_NEED_REPLY_MASK; + } return 0; } @@ -540,9 +543,10 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, return ret; } - // if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { - // msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; - if (shmfd) { + if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { + msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; + // msg.hdr.flags = (VHOST_USER_REPLY_MASK | VHOST_USER_VERSION); + // if (shmfd) { msg.hdr.size = 0; ret = vhost_user_read(dev, &msg); if (ret < 0) { -- Gitee From 2c5f61ad81c082cdcd02859a3f800576ebb9a868 Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Wed, 17 Jul 2024 11:38:27 +0800 Subject: [PATCH 6/9] Revert "vhsot-user: test for ci" This reverts commit f80e90c4c055a7ae822fbf913dba471f240f6602. --- hw/virtio/vhost-user.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index afeeefa1c7..8600799151 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -496,9 +496,6 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, trace_vhost_user_write(msg->hdr.request, msg->hdr.flags); - if (msg->hdr.request == VHOST_USER_SET_LOG_BASE) { - msg->hdr.flags |= VHOST_USER_NEED_REPLY_MASK; - } return 0; } @@ -543,10 +540,9 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, return ret; } - if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { - msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; - // msg.hdr.flags = (VHOST_USER_REPLY_MASK | VHOST_USER_VERSION); - // if (shmfd) { + // if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { + // msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; + if (shmfd) { msg.hdr.size = 0; ret = vhost_user_read(dev, &msg); if (ret < 0) { -- Gitee From f217d85433ba0da3297033fa77ac4c1f8a3aff33 Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Wed, 17 Jul 2024 11:38:38 +0800 Subject: [PATCH 7/9] Revert "vhsot-user: test for ci" This reverts commit 5db5ab03dd3ec1e0e7eb3140f327fad75bbb0dae. --- hw/virtio/vhost-user.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 8600799151..af00328bdb 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -516,8 +516,8 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, size_t fd_num = 0; bool shmfd = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_LOG_SHMFD); - // bool reply_supported = virtio_has_feature(dev->protocol_features, - // VHOST_USER_PROTOCOL_F_REPLY_ACK); + bool reply_supported = virtio_has_feature(dev->protocol_features, + VHOST_USER_PROTOCOL_F_REPLY_ACK); int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_SET_LOG_BASE, @@ -527,9 +527,9 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, .hdr.size = sizeof(msg.payload.log), }; - // if (shmfd && reply_supported) { - // msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; - // } + if (shmfd && reply_supported) { + msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; + } if (shmfd && log->fd != -1) { fds[fd_num++] = log->fd; @@ -540,9 +540,8 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, return ret; } - // if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { - // msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; - if (shmfd) { + if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { + msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; msg.hdr.size = 0; ret = vhost_user_read(dev, &msg); if (ret < 0) { -- Gitee From a5ef1ee93c36b73a49a9866f2698b3b50ed363cc Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Wed, 17 Jul 2024 11:38:56 +0800 Subject: [PATCH 8/9] Revert "vhsot-user: Clear flag after use for ci" This reverts commit 13caee05d3ed94166e370f272c3175332ca1bcb1. --- hw/virtio/vhost-user.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index af00328bdb..4978280189 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -541,7 +541,6 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, } if (shmfd && (msg.hdr.flags & VHOST_USER_NEED_REPLY_MASK)) { - msg.hdr.flags &= ~VHOST_USER_NEED_REPLY_MASK; msg.hdr.size = 0; ret = vhost_user_read(dev, &msg); if (ret < 0) { -- Gitee From cf2353fb5d6aebe3888574e381b6ee219c633266 Mon Sep 17 00:00:00 2001 From: BillXiang <1373760142@qq.com> Date: Wed, 17 Jul 2024 11:40:30 +0800 Subject: [PATCH 9/9] Revert "vhsot-user: Ask for replay when supported" This reverts commit ffd04d7d8a9f64f5b68e9e5a975860ef88b31891. --- hw/virtio/vhost-user.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 4978280189..8dfd728069 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -516,21 +516,15 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, size_t fd_num = 0; bool shmfd = virtio_has_feature(dev->protocol_features, VHOST_USER_PROTOCOL_F_LOG_SHMFD); - bool reply_supported = virtio_has_feature(dev->protocol_features, - VHOST_USER_PROTOCOL_F_REPLY_ACK); int ret; VhostUserMsg msg = { .hdr.request = VHOST_USER_SET_LOG_BASE, - .hdr.flags = VHOST_USER_VERSION, + .hdr.flags = VHOST_USER_VERSION | VHOST_USER_NEED_REPLY_MASK, .payload.log.mmap_size = log->size * sizeof(*(log->log)), .payload.log.mmap_offset = 0, .hdr.size = sizeof(msg.payload.log), }; - if (shmfd && reply_supported) { - msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK; - } - if (shmfd && log->fd != -1) { fds[fd_num++] = log->fd; } -- Gitee