vhost-user: pass message as a pointer to process_message_reply()
PATCH 1/1 vhost-user: pass message as a pointer to process_message_reply()
process_message_reply() was recently updated to get full message content instead of only its request field.
There is no need to copy all the struct content into the stack, so just pass its pointer.
--- hw/virtio/vhost-user.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/virtio/vhost-user.c +6 -6
@@ -162,11 +162,11 @@ fail: }static int process_message_reply (struct vhost_dev *dev, -VhostUserMsg msg) +VhostUserMsg *msg) {VhostUserMsg msg_reply; -if ((msg.flags &VHOST_USER_NEED_REPLY_MASK ) ==0 ) { +if ((msg->flags &VHOST_USER_NEED_REPLY_MASK ) ==0 ) {return 0 ; }
@@ -174,10 +174,10 @@ static int process_message_reply(struct vhost_dev *dev,return -1 ; } -if (msg_reply.request != msg.request) { +if (msg_reply.request != msg->request) {error_report ("Received unexpected msg type." "Expected %d received %d" , - msg.request, msg_reply.request); + msg->request, msg_reply.request);return -1 ; }
@@ -324,7 +324,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, }if (reply_supported) { -return process_message_reply (dev, msg); +return process_message_reply (dev, &msg); }return 0 ;
@@ -716,7 +716,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)/* If reply_ack supported, slave has to ack specified MTU is valid */ if (reply_supported) { -return process_message_reply (dev, msg); +return process_message_reply (dev, &msg); }return 0 ;
Signature · 1 line
2.9.4
Quoted 18 lines · Maxime Coquelin
process_message_reply()was recently updated to get full message content instead of only its request field.There is no need to copy all the struct content into the stack, so just pass its pointer.
Cc Zhiyong Yang <[email protected]>Fixes 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ")Signed-off-by Maxime Coquelin <[email protected]>--- hw/virtio/vhost-user.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)hw/virtio/vhost-user.c +0
-0
hw/virtio/vhost-user.c fail: · line 166
Quoted 6 lines
hw/virtio/vhost-user.c +1
-1@@ -162,11 +162,11 @@ fail: }static int process_message_reply (struct vhost_dev *dev, -VhostUserMsg msg) +VhostUserMsg *msg)
Can you make it const?
Quoted 42 lines
hw/virtio/vhost-user.c +4
-4{VhostUserMsg msg_reply; -if ((msg.flags &VHOST_USER_NEED_REPLY_MASK ) ==0 ) { +if ((msg->flags &VHOST_USER_NEED_REPLY_MASK ) ==0 ) {return 0 ; }@@ -174,10 +174,10 @@ static int process_message_reply(struct vhost_dev *dev, return -1 ; } -if (msg_reply.request != msg.request) { +if (msg_reply.request != msg->request) {error_report ("Received unexpected msg type." "Expected %d received %d" , - msg.request, msg_reply.request); + msg->request, msg_reply.request);return -1 ; }@@ -324,7 +324,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, }if (reply_supported) { -return process_message_reply (dev, msg); +return process_message_reply (dev, &msg); }return 0;hw/virtio/vhost-user.c +1
-1@@ -716,7 +716,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)/* If reply_ack supported, slave has to ack specified MTU is valid */ if (reply_supported) { -return process_message_reply (dev, msg); +return process_message_reply (dev, &msg); }return 0;
Quoted 5 lines
--
2.9.4--
Marc-André Lureau
Quoted 27 lines · Marc-André Lureau
On Wed, May 24, 2017 at 11:35 AM Maxime Coquelin <[email protected] <mailto:[email protected]>> wrote:
process_message_reply()was recently updated to get full message content instead of only its request field.There is no need to copy all the struct content into the stack, so just pass its pointer.
Cc: Zhiyong Yang <[email protected]
<mailto:[email protected]>>Fixes 60cd11024f41 ("hw/virtio: fix vhost user fails to startupwhen MQ")
Signed-off-by Maxime Coquelin <[email protected]<mailto:[email protected]>>
---
hw/virtio/vhost-user.c| 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)diff --git
a/hw/virtio/vhost-user.cb/hw/virtio/vhost-user.cindex b87a176..baf2487 100644
---a/hw/virtio/vhost-user.c
+++b/hw/virtio/vhost-user.c
@@ -162,11 +162,11 @@ fail:
}
Quoted 6 lines
static int process_message_reply(struct
vhost_dev*dev,
- VhostUserMsg msg)
+ VhostUserMsg *msg)Can you make it const?
Sure!
Thanks,
Maxime
Jens Freimann
Reviewed-byQuoted 31 lines · Maxime Coquelin
Quoted 28 lines · Marc-André Lureau
On Wed, May 24, 2017 at 11:35 AM Maxime Coquelin <[email protected] <mailto:[email protected]>> wrote:
process_message_reply()was recently updated to get full message content instead of only its request field.There is no need to copy all the struct content into the stack, so just pass its pointer.
Cc: Zhiyong Yang <[email protected]
<mailto:[email protected]>>Fixes 60cd11024f41 ("hw/virtio: fix vhost user fails to startupwhen MQ")
Signed-off-by Maxime Coquelin <[email protected]<mailto:[email protected]>>
---
hw/virtio/vhost-user.c| 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)diff --git
a/hw/virtio/vhost-user.cb/hw/virtio/vhost-user.cindex b87a176..baf2487 100644
---a/hw/virtio/vhost-user.c
+++b/hw/virtio/vhost-user.c
@@ -162,11 +162,11 @@ fail:
}
Quoted 7 lines
Quoted 6 lines
static int process_message_reply(struct
vhost_dev*dev,
- VhostUserMsg msg)
+ VhostUserMsg *msg)Can you make it const?
Sure!
with that:
Hi, Maxime:
Quoted 12 lines
-----Original Message-----
From: Maxime Coquelin [mailto:[email protected]]
Sent: Wednesday, May 24, 2017 4:35 PM
To: Yang, Zhiyong <[email protected]>; [email protected]; qemu- [email protected]; [email protected]; [email protected]
Cc: Maxime Coquelin <[email protected]>
Subject: [PATCH] vhost-user: pass message as a pointer toprocess_message_reply()
process_message_reply()was recently updated to get full message content instead of only its request field.
Quoted 6 lines
There is no need to copy all the struct content into the stack, so just pass its pointer.
Cc Zhiyong Yang <[email protected]>Fixes 60cd11024f41 ("hw/virtio: fix vhost user fails to startup when MQ")Signed-off-by Maxime Coquelin <[email protected]>
Good modification. Thanks.
Quoted 58 lines
--- hw/virtio/vhost-user.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)hw/virtio/vhost-user.c index renamed from hw/virtio/vhost-user.c +0
-0b87a176..baf2487 100644
hw/virtio/vhost-user.c +5
-5@@ -162,11 +162,11 @@ fail: }static int process_message_reply (struct vhost_dev *dev, -VhostUserMsg msg) +VhostUserMsg *msg) {VhostUserMsg msg_reply; -if ((msg.flags &VHOST_USER_NEED_REPLY_MASK ) ==0 ) { +if ((msg->flags &VHOST_USER_NEED_REPLY_MASK ) ==0 ) {return 0 ; }@@ -174,10 +174,10 @@ static int process_message_reply(struct vhost_dev *dev, return -1 ; } -if (msg_reply.request != msg.request) { +if (msg_reply.request != msg->request) {error_report ("Received unexpected msg type." "Expected %d received %d" , - msg.request, msg_reply.request); + msg->request, msg_reply.request);return -1 ; }@@ -324,7 +324,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, }if (reply_supported) { -return process_message_reply (dev, msg); +return process_message_reply (dev, &msg); }return 0;hw/virtio/vhost-user.c +1
-1@@ -716,7 +716,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu)/* If reply_ack supported, slave has to ack specified MTU is valid */ if (reply_supported) { -return process_message_reply (dev, msg); +return process_message_reply (dev, &msg); }return 0;--
2.9.4