mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
Add vhost-backend and VhostBackendType
Use vhost_set_backend_type to initialise a proper vhost_ops structure. In vhost_net_init and vhost_net_start_one call conditionally TAP related initialisation depending on the vhost backend type. Signed-off-by: Antonios Motakis <a.motakis@virtualopensystems.com> Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
24d1eb33eb
commit
1a1bfac9ee
9 changed files with 135 additions and 34 deletions
|
@ -11,6 +11,13 @@
|
|||
#ifndef VHOST_BACKEND_H_
|
||||
#define VHOST_BACKEND_H_
|
||||
|
||||
typedef enum VhostBackendType {
|
||||
VHOST_BACKEND_TYPE_NONE = 0,
|
||||
VHOST_BACKEND_TYPE_KERNEL = 1,
|
||||
VHOST_BACKEND_TYPE_USER = 2,
|
||||
VHOST_BACKEND_TYPE_MAX = 3,
|
||||
} VhostBackendType;
|
||||
|
||||
struct vhost_dev;
|
||||
|
||||
typedef int (*vhost_call)(struct vhost_dev *dev, unsigned long int request,
|
||||
|
@ -19,9 +26,13 @@ typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque);
|
|||
typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev);
|
||||
|
||||
typedef struct VhostOps {
|
||||
VhostBackendType backend_type;
|
||||
vhost_call vhost_call;
|
||||
vhost_backend_init vhost_backend_init;
|
||||
vhost_backend_cleanup vhost_backend_cleanup;
|
||||
} VhostOps;
|
||||
|
||||
int vhost_set_backend_type(struct vhost_dev *dev,
|
||||
VhostBackendType backend_type);
|
||||
|
||||
#endif /* VHOST_BACKEND_H_ */
|
||||
|
|
|
@ -31,7 +31,6 @@ typedef unsigned long vhost_log_chunk_t;
|
|||
struct vhost_memory;
|
||||
struct vhost_dev {
|
||||
MemoryListener memory_listener;
|
||||
int control;
|
||||
struct vhost_memory *mem;
|
||||
int n_mem_sections;
|
||||
MemoryRegionSection *mem_sections;
|
||||
|
@ -51,10 +50,11 @@ struct vhost_dev {
|
|||
hwaddr mem_changed_start_addr;
|
||||
hwaddr mem_changed_end_addr;
|
||||
const VhostOps *vhost_ops;
|
||||
void *opaque;
|
||||
};
|
||||
|
||||
int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
|
||||
bool force);
|
||||
VhostBackendType backend_type, bool force);
|
||||
void vhost_dev_cleanup(struct vhost_dev *hdev);
|
||||
bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev);
|
||||
int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev);
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
#define VHOST_NET_H
|
||||
|
||||
#include "net/net.h"
|
||||
#include "hw/virtio/vhost-backend.h"
|
||||
|
||||
struct vhost_net;
|
||||
typedef struct vhost_net VHostNetState;
|
||||
|
||||
typedef struct VhostNetOptions {
|
||||
VhostBackendType backend_type;
|
||||
NetClientState *net_backend;
|
||||
void *opaque;
|
||||
bool force;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue