summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorHaiyang Tan <haiyang.tan.dev@gmail.com>2018-01-20 04:48:53 -0500
committerDamjan Marion <dmarion.lists@gmail.com>2018-02-05 12:13:35 +0000
commit7b0933a97d8830e288ab3e350b07656196599847 (patch)
treeb0143a79afbf9f704df6bb14194650eaf35dd1e3 /src/vnet
parent56e6f095e35799cb1fe2080f5242e3d9876baa22 (diff)
vhost_user: code cleanup
1. Replace the magic number '-1' with MAP_FAILED 2. On x86 platform, QEMU uses vhostuser required the memory back-end is file based, the file could be tmpfs(4K page size) or hugetlbfs(2M or 1G page size) Change-Id: If1818cb6833728d641f68e4d4a3bc645e70f2ee6 Signed-off-by: Haiyang Tan <haiyang.tan.dev@gmail.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/devices/virtio/vhost-user.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index 874a97dbd77..9c93ef4ebfb 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -306,7 +306,7 @@ unmap_all_mem_regions (vhost_user_intf_t * vui)
int i, r;
for (i = 0; i < vui->nregions; i++)
{
- if (vui->region_mmap_addr[i] != (void *) -1)
+ if (vui->region_mmap_addr[i] != MAP_FAILED)
{
long page_sz = get_huge_page_size (vui->region_mmap_fd[i]);
@@ -323,7 +323,7 @@ unmap_all_mem_regions (vhost_user_intf_t * vui)
("unmap memory region %d addr 0x%lx len 0x%lx page_sz 0x%x", i,
vui->region_mmap_addr[i], map_sz, page_sz);
- vui->region_mmap_addr[i] = (void *) -1;
+ vui->region_mmap_addr[i] = MAP_FAILED;
if (r == -1)
{
@@ -829,7 +829,7 @@ vhost_user_socket_read (clib_file_t * uf)
long page_sz = get_huge_page_size (fds[i]);
- /* align size to 2M page */
+ /* align size to page */
ssize_t map_sz = (vui->regions[i].memory_size +
vui->regions[i].mmap_offset +
page_sz - 1) & ~(page_sz - 1);
@@ -1076,7 +1076,7 @@ vhost_user_socket_read (clib_file_t * uf)
}
fd = fds[0];
- /* align size to 2M page */
+ /* align size to page */
long page_sz = get_huge_page_size (fd);
ssize_t map_sz =
(msg.log.size + msg.log.offset + page_sz - 1) & ~(page_sz - 1);