libvhost-user: add vmsg_set_reply_u64() helper
commitdb68f4ff06cbe0517ed0d9b5634f6cddaed2547c
authorStefan Hajnoczi <stefanha@redhat.com>
Wed, 26 Jun 2019 07:48:12 +0000 (26 08:48 +0100)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 4 Jul 2019 21:00:32 +0000 (4 17:00 -0400)
tree09127383fdd8160bb275cd2594fb8e6e17bdfb34
parent457cfcccdd107a968d106934df63b836b5dd743e
libvhost-user: add vmsg_set_reply_u64() helper

The VhostUserMsg request is reused as the reply by message processing
functions.  This is risky since request fields may corrupt the reply if
the vhost-user message handler function forgets to re-initialize them.

Changing this practice would be very invasive but we can introduce a
helper function to make u64 payload replies safe.  This also eliminates
code duplication in message processing functions.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20190626074815.19994-2-stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
contrib/libvhost-user/libvhost-user.c