Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/mst/tags/for_upstream' into sta…
Browse files Browse the repository at this point in the history
…ging

vhost: build fix

Fix build breakages when using older gcc.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

# gpg: Signature made Thu 22 Oct 2015 20:36:07 BST using RSA key ID D28D5469
# gpg: Good signature from "Michael S. Tsirkin <mst@kernel.org>"
# gpg:                 aka "Michael S. Tsirkin <mst@redhat.com>"

* remotes/mst/tags/for_upstream:
  vhost-user: fix up rhel6 build

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
pm215 committed Oct 23, 2015
2 parents 6a6739d + 7f4a930 commit dfbe064
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions hw/virtio/vhost-user.c
Expand Up @@ -89,7 +89,7 @@ typedef struct VhostUserMsg {
struct vhost_vring_state state;
struct vhost_vring_addr addr;
VhostUserMemory memory;
};
} payload;
} QEMU_PACKED VhostUserMsg;

static VhostUserMsg m __attribute__ ((unused));
Expand Down Expand Up @@ -200,8 +200,8 @@ 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,
.u64 = base,
.size = sizeof(m.u64),
.payload.u64 = base,
.size = sizeof(m.payload.u64),
};

if (shmfd && log->fd != -1) {
Expand Down Expand Up @@ -247,26 +247,26 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev,
&ram_addr);
fd = qemu_get_ram_fd(ram_addr);
if (fd > 0) {
msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr;
msg.memory.regions[fd_num].memory_size = reg->memory_size;
msg.memory.regions[fd_num].guest_phys_addr = reg->guest_phys_addr;
msg.memory.regions[fd_num].mmap_offset = reg->userspace_addr -
msg.payload.memory.regions[fd_num].userspace_addr = reg->userspace_addr;
msg.payload.memory.regions[fd_num].memory_size = reg->memory_size;
msg.payload.memory.regions[fd_num].guest_phys_addr = reg->guest_phys_addr;
msg.payload.memory.regions[fd_num].mmap_offset = reg->userspace_addr -
(uintptr_t) qemu_get_ram_block_host_ptr(ram_addr);
assert(fd_num < VHOST_MEMORY_MAX_NREGIONS);
fds[fd_num++] = fd;
}
}

msg.memory.nregions = fd_num;
msg.payload.memory.nregions = fd_num;

if (!fd_num) {
error_report("Failed initializing vhost-user memory map, "
"consider using -object memory-backend-file share=on");
return -1;
}

msg.size = sizeof(m.memory.nregions);
msg.size += sizeof(m.memory.padding);
msg.size = sizeof(m.payload.memory.nregions);
msg.size += sizeof(m.payload.memory.padding);
msg.size += fd_num * sizeof(VhostUserMemoryRegion);

vhost_user_write(dev, &msg, fds, fd_num);
Expand All @@ -280,7 +280,7 @@ static int vhost_user_set_vring_addr(struct vhost_dev *dev,
VhostUserMsg msg = {
.request = VHOST_USER_SET_VRING_ADDR,
.flags = VHOST_USER_VERSION,
.addr = *addr,
.payload.addr = *addr,
.size = sizeof(*addr),
};

Expand All @@ -303,7 +303,7 @@ static int vhost_set_vring(struct vhost_dev *dev,
VhostUserMsg msg = {
.request = request,
.flags = VHOST_USER_VERSION,
.state = *ring,
.payload.state = *ring,
.size = sizeof(*ring),
};

Expand Down Expand Up @@ -345,7 +345,7 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev,
VhostUserMsg msg = {
.request = VHOST_USER_GET_VRING_BASE,
.flags = VHOST_USER_VERSION,
.state = *ring,
.payload.state = *ring,
.size = sizeof(*ring),
};

Expand All @@ -361,12 +361,12 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev,
return -1;
}

if (msg.size != sizeof(m.state)) {
if (msg.size != sizeof(m.payload.state)) {
error_report("Received bad msg size.");
return -1;
}

*ring = msg.state;
*ring = msg.payload.state;

return 0;
}
Expand All @@ -380,14 +380,14 @@ static int vhost_set_vring_file(struct vhost_dev *dev,
VhostUserMsg msg = {
.request = request,
.flags = VHOST_USER_VERSION,
.u64 = file->index & VHOST_USER_VRING_IDX_MASK,
.size = sizeof(m.u64),
.payload.u64 = file->index & VHOST_USER_VRING_IDX_MASK,
.size = sizeof(m.payload.u64),
};

if (ioeventfd_enabled() && file->fd > 0) {
fds[fd_num++] = file->fd;
} else {
msg.u64 |= VHOST_USER_VRING_NOFD_MASK;
msg.payload.u64 |= VHOST_USER_VRING_NOFD_MASK;
}

vhost_user_write(dev, &msg, fds, fd_num);
Expand All @@ -412,8 +412,8 @@ static int vhost_user_set_u64(struct vhost_dev *dev, int request, uint64_t u64)
VhostUserMsg msg = {
.request = request,
.flags = VHOST_USER_VERSION,
.u64 = u64,
.size = sizeof(m.u64),
.payload.u64 = u64,
.size = sizeof(m.payload.u64),
};

vhost_user_write(dev, &msg, NULL, 0);
Expand Down Expand Up @@ -456,12 +456,12 @@ static int vhost_user_get_u64(struct vhost_dev *dev, int request, uint64_t *u64)
return -1;
}

if (msg.size != sizeof(m.u64)) {
if (msg.size != sizeof(m.payload.u64)) {
error_report("Received bad msg size.");
return -1;
}

*u64 = msg.u64;
*u64 = msg.payload.u64;

return 0;
}
Expand Down Expand Up @@ -591,8 +591,8 @@ static int vhost_user_migration_done(struct vhost_dev *dev, char* mac_addr)
VHOST_USER_PROTOCOL_F_RARP)) {
msg.request = VHOST_USER_SEND_RARP;
msg.flags = VHOST_USER_VERSION;
memcpy((char *)&msg.u64, mac_addr, 6);
msg.size = sizeof(m.u64);
memcpy((char *)&msg.payload.u64, mac_addr, 6);
msg.size = sizeof(m.payload.u64);

err = vhost_user_write(dev, &msg, NULL, 0);
return err;
Expand Down

0 comments on commit dfbe064

Please sign in to comment.