This patch makes vhost_user_write() consistent with
vhost_user_read(), by passing a pointer on the Vhost-user
message instead of a buffer pointer and its length, which
is now calculated in the function.
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
drivers/net/virtio/virtio_user/vhost_user.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
Hi Maxime,
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Monday, December 21, 2020 5:14 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; olivier.matz@6wind.com;
> amorenoz@redhat.com; david.marchand@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH 23/40] net/virtio: make Vhost-user req sender consistent
>
> This patch makes vhost_user_write() consistent with
> vhost_user_read(), by passing a pointer on the Vhost-user
You mean a pointer 'to' the vhost-user msg? :P
Thanks,
Chenbo
> message instead of a buffer pointer and its length, which
> is now calculated in the function.
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
On 1/6/21 12:50 PM, Xia, Chenbo wrote:
> Hi Maxime,
>
>> -----Original Message-----
>> From: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Sent: Monday, December 21, 2020 5:14 AM
>> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; olivier.matz@6wind.com;
>> amorenoz@redhat.com; david.marchand@redhat.com
>> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Subject: [PATCH 23/40] net/virtio: make Vhost-user req sender consistent
>>
>> This patch makes vhost_user_write() consistent with
>> vhost_user_read(), by passing a pointer on the Vhost-user
>
> You mean a pointer 'to' the vhost-user msg? :P
Changed to:
"by passing a Vhost-user message pointer instead of a buffer pointer and
its length"
Thanks,
Maxime
> Thanks,
> Chenbo
>
>> message instead of a buffer pointer and its length, which
>> is now calculated in the function.
>>
>> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>
@@ -51,7 +51,7 @@ struct vhost_user_msg {
(sizeof(struct vhost_user_msg) - VHOST_USER_HDR_SIZE)
static int
-vhost_user_write(int fd, void *buf, int len, int *fds, int fd_num)
+vhost_user_write(int fd, struct vhost_user_msg *msg, int *fds, int fd_num)
{
int r;
struct msghdr msgh;
@@ -63,8 +63,8 @@ vhost_user_write(int fd, void *buf, int len, int *fds, int fd_num)
memset(&msgh, 0, sizeof(msgh));
memset(control, 0, sizeof(control));
- iov.iov_base = (uint8_t *)buf;
- iov.iov_len = len;
+ iov.iov_base = (uint8_t *)msg;
+ iov.iov_len = VHOST_USER_HDR_SIZE + msg->size;
msgh.msg_iov = &iov;
msgh.msg_iovlen = 1;
@@ -259,7 +259,6 @@ vhost_user_sock(struct virtio_user_dev *dev,
int has_reply_ack = 0;
int fds[VHOST_MEMORY_MAX_NREGIONS];
int fd_num = 0;
- int len;
int vhostfd = dev->vhostfd;
RTE_SET_USED(m);
@@ -359,8 +358,7 @@ vhost_user_sock(struct virtio_user_dev *dev,
return -1;
}
- len = VHOST_USER_HDR_SIZE + msg.size;
- if (vhost_user_write(vhostfd, &msg, len, fds, fd_num) < 0) {
+ if (vhost_user_write(vhostfd, &msg, fds, fd_num) < 0) {
PMD_DRV_LOG(ERR, "%s failed: %s",
vhost_msg_strings[req], strerror(errno));
return -1;