mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-30 13:53:54 -06:00
libvhost-user: Allow vu_message_read to be replaced
Allow vu_message_read to be replaced by one which will make use of the QIOChannel functions. Thus reading vhost-user message won't stall the guest. For slave channel, we still use the default vu_message_read. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Coiby Xu <coiby.xu@gmail.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20200918080912.321299-2-coiby.xu@gmail.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
f25e7ab2b0
commit
049f55502a
5 changed files with 33 additions and 10 deletions
|
@ -36,6 +36,8 @@
|
|||
*/
|
||||
#define VHOST_USER_MAX_RAM_SLOTS 32
|
||||
|
||||
#define VHOST_USER_HDR_SIZE offsetof(VhostUserMsg, payload.u64)
|
||||
|
||||
typedef enum VhostSetConfigType {
|
||||
VHOST_SET_CONFIG_TYPE_MASTER = 0,
|
||||
VHOST_SET_CONFIG_TYPE_MIGRATION = 1,
|
||||
|
@ -221,6 +223,7 @@ typedef uint64_t (*vu_get_features_cb) (VuDev *dev);
|
|||
typedef void (*vu_set_features_cb) (VuDev *dev, uint64_t features);
|
||||
typedef int (*vu_process_msg_cb) (VuDev *dev, VhostUserMsg *vmsg,
|
||||
int *do_reply);
|
||||
typedef bool (*vu_read_msg_cb) (VuDev *dev, int sock, VhostUserMsg *vmsg);
|
||||
typedef void (*vu_queue_set_started_cb) (VuDev *dev, int qidx, bool started);
|
||||
typedef bool (*vu_queue_is_processed_in_order_cb) (VuDev *dev, int qidx);
|
||||
typedef int (*vu_get_config_cb) (VuDev *dev, uint8_t *config, uint32_t len);
|
||||
|
@ -389,6 +392,23 @@ struct VuDev {
|
|||
bool broken;
|
||||
uint16_t max_queues;
|
||||
|
||||
/* @read_msg: custom method to read vhost-user message
|
||||
*
|
||||
* Read data from vhost_user socket fd and fill up
|
||||
* the passed VhostUserMsg *vmsg struct.
|
||||
*
|
||||
* If reading fails, it should close the received set of file
|
||||
* descriptors as socket message's auxiliary data.
|
||||
*
|
||||
* For the details, please refer to vu_message_read in libvhost-user.c
|
||||
* which will be used by default if not custom method is provided when
|
||||
* calling vu_init
|
||||
*
|
||||
* Returns: true if vhost-user message successfully received,
|
||||
* otherwise return false.
|
||||
*
|
||||
*/
|
||||
vu_read_msg_cb read_msg;
|
||||
/* @set_watch: add or update the given fd to the watch set,
|
||||
* call cb when condition is met */
|
||||
vu_set_watch_cb set_watch;
|
||||
|
@ -432,6 +452,7 @@ bool vu_init(VuDev *dev,
|
|||
uint16_t max_queues,
|
||||
int socket,
|
||||
vu_panic_cb panic,
|
||||
vu_read_msg_cb read_msg,
|
||||
vu_set_watch_cb set_watch,
|
||||
vu_remove_watch_cb remove_watch,
|
||||
const VuDevIface *iface);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue