[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 08/18] vhost-user: add vhost_user to hold the chr
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH 08/18] vhost-user: add vhost_user to hold the chr |
Date: |
Fri, 1 Apr 2016 13:16:18 +0200 |
From: Marc-André Lureau <address@hidden>
Next patches will add more fields to the structure
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/virtio/vhost-user.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 5914e85..02ac1fc 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -108,6 +108,10 @@ static VhostUserMsg m __attribute__ ((unused));
/* The version of the protocol we support */
#define VHOST_USER_VERSION (0x1)
+struct vhost_user {
+ CharDriverState *chr;
+};
+
static bool ioeventfd_enabled(void)
{
return kvm_enabled() && kvm_eventfds_enabled();
@@ -115,7 +119,8 @@ static bool ioeventfd_enabled(void)
static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
{
- CharDriverState *chr = dev->opaque;
+ struct vhost_user *u = dev->opaque;
+ CharDriverState *chr = u->chr;
uint8_t *p = (uint8_t *) msg;
int r, size = VHOST_USER_HDR_SIZE;
@@ -176,7 +181,8 @@ static bool vhost_user_one_time_request(VhostUserRequest
request)
static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
int *fds, int fd_num)
{
- CharDriverState *chr = dev->opaque;
+ struct vhost_user *u = dev->opaque;
+ CharDriverState *chr = u->chr;
int size = VHOST_USER_HDR_SIZE + msg->size;
/*
@@ -510,11 +516,14 @@ static int vhost_user_reset_device(struct vhost_dev *dev)
static int vhost_user_init(struct vhost_dev *dev, void *opaque)
{
uint64_t features;
+ struct vhost_user *u;
int err;
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
- dev->opaque = opaque;
+ u = g_new0(struct vhost_user, 1);
+ u->chr = opaque;
+ dev->opaque = u;
err = vhost_user_get_features(dev, &features);
if (err < 0) {
@@ -559,8 +568,12 @@ static int vhost_user_init(struct vhost_dev *dev, void
*opaque)
static int vhost_user_cleanup(struct vhost_dev *dev)
{
+ struct vhost_user *u;
+
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
+ u = dev->opaque;
+ g_free(u);
dev->opaque = 0;
return 0;
--
2.5.5
- [Qemu-devel] [PATCH 00/18] RFCv2: vhost-user: shutdown and reconnection, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 01/18] tests: append i386 tests, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 02/18] char: lower reconnect error to trace event, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 03/18] char: use a trace for when the char is waiting, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 04/18] char: add wait support for reconnect, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 05/18] vhost-user: check reconnect comes with wait, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 07/18] vhost: add vhost_dev stop callback, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 08/18] vhost-user: add vhost_user to hold the chr,
marcandre . lureau <=
- [Qemu-devel] [PATCH 06/18] vhost-user: add ability to know vhost-user backend disconnection, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 09/18] qemu-char: add qemu_chr_disconnect to close a fd accepted by listen fd, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 10/18] vhost-user: add slave-fd support, marcandre . lureau, 2016/04/01
- [Qemu-devel] [PATCH 11/18] vhost-user: add shutdown support, marcandre . lureau, 2016/04/01