Skip to content

Commit

Permalink
vhost-user: modify SET_LOG_BASE to pass mmap size and offset
Browse files Browse the repository at this point in the history
Unlike the kernel, vhost-user application accesses log table by
mmaping it to its user space. This change adds two new fields to
VhostUserMsg payload: mmap_size, and mmap_offset and make QEMU to
pass the to vhost-user application in VHOST_USER_SET_LOG_BASE
request.

Signed-off-by: Victor Kaplansky <victork@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
vkaplans authored and mstsirkin committed Nov 12, 2015
1 parent 393f04d commit 2b8819c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
8 changes: 7 additions & 1 deletion docs/specs/vhost-user.txt
Expand Up @@ -98,6 +98,7 @@ typedef struct VhostUserMsg {
struct vhost_vring_state state;
struct vhost_vring_addr addr;
VhostUserMemory memory;
VhostUserLog log;
};
} QEMU_PACKED VhostUserMsg;

Expand Down Expand Up @@ -282,7 +283,12 @@ Message types
Master payload: u64
Slave payload: N/A

Sets the logging base address.
Sets logging shared memory space.
When slave has VHOST_USER_PROTOCOL_F_LOG_SHMFD protocol
feature, the log memory fd is provided in the ancillary data of
VHOST_USER_SET_LOG_BASE message, the size and offset of shared
memory area provided in the message.


* VHOST_USER_SET_LOG_FD

Expand Down
11 changes: 9 additions & 2 deletions hw/virtio/vhost-user.c
Expand Up @@ -75,6 +75,11 @@ typedef struct VhostUserMemory {
VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS];
} VhostUserMemory;

typedef struct VhostUserLog {
uint64_t mmap_size;
uint64_t mmap_offset;
} VhostUserLog;

typedef struct VhostUserMsg {
VhostUserRequest request;

Expand All @@ -89,6 +94,7 @@ typedef struct VhostUserMsg {
struct vhost_vring_state state;
struct vhost_vring_addr addr;
VhostUserMemory memory;
VhostUserLog log;
} payload;
} QEMU_PACKED VhostUserMsg;

Expand Down Expand Up @@ -200,8 +206,9 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base,
VhostUserMsg msg = {
.request = VHOST_USER_SET_LOG_BASE,
.flags = VHOST_USER_VERSION,
.payload.u64 = base,
.size = sizeof(msg.payload.u64),
.payload.log.mmap_size = log->size,
.payload.log.mmap_offset = 0,
.size = sizeof(msg.payload.log),
};

if (shmfd && log->fd != -1) {
Expand Down
8 changes: 8 additions & 0 deletions tests/vhost-user-test.c
Expand Up @@ -86,6 +86,11 @@ typedef struct VhostUserMemory {
VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS];
} VhostUserMemory;

typedef struct VhostUserLog {
uint64_t mmap_size;
uint64_t mmap_offset;
} VhostUserLog;

typedef struct VhostUserMsg {
VhostUserRequest request;

Expand All @@ -94,10 +99,13 @@ typedef struct VhostUserMsg {
uint32_t flags;
uint32_t size; /* the following payload size */
union {
#define VHOST_USER_VRING_IDX_MASK (0xff)
#define VHOST_USER_VRING_NOFD_MASK (0x1<<8)
uint64_t u64;
struct vhost_vring_state state;
struct vhost_vring_addr addr;
VhostUserMemory memory;
VhostUserLog log;
} payload;
} QEMU_PACKED VhostUserMsg;

Expand Down

0 comments on commit 2b8819c

Please sign in to comment.