4 * Copyright (c) 2013 Virtual Open Systems Sarl.
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
11 #ifndef VHOST_BACKEND_H_
12 #define VHOST_BACKEND_H_
14 typedef enum VhostBackendType
{
15 VHOST_BACKEND_TYPE_NONE
= 0,
16 VHOST_BACKEND_TYPE_KERNEL
= 1,
17 VHOST_BACKEND_TYPE_USER
= 2,
18 VHOST_BACKEND_TYPE_MAX
= 3,
23 typedef int (*vhost_call
)(struct vhost_dev
*dev
, unsigned long int request
,
25 typedef int (*vhost_backend_init
)(struct vhost_dev
*dev
, void *opaque
);
26 typedef int (*vhost_backend_cleanup
)(struct vhost_dev
*dev
);
27 typedef int (*vhost_backend_get_vq_index
)(struct vhost_dev
*dev
, int idx
);
28 typedef int (*vhost_backend_set_vring_enable
)(struct vhost_dev
*dev
, int enable
);
29 typedef int (*vhost_backend_memslots_limit
)(struct vhost_dev
*dev
);
31 typedef int (*vhost_set_log_base_op
)(struct vhost_dev
*dev
, uint64_t base
);
33 typedef struct VhostOps
{
34 VhostBackendType backend_type
;
35 vhost_call vhost_call
;
36 vhost_backend_init vhost_backend_init
;
37 vhost_backend_cleanup vhost_backend_cleanup
;
38 vhost_backend_get_vq_index vhost_backend_get_vq_index
;
39 vhost_backend_set_vring_enable vhost_backend_set_vring_enable
;
40 vhost_backend_memslots_limit vhost_backend_memslots_limit
;
41 vhost_set_log_base_op vhost_set_log_base
;
44 extern const VhostOps user_ops
;
46 int vhost_set_backend_type(struct vhost_dev
*dev
,
47 VhostBackendType backend_type
);
49 #endif /* VHOST_BACKEND_H_ */