ret = recvmsg(sockfd, &msgh, 0);
if (ret <= 0) {
- RTE_LOG(ERR, VHOST_CONFIG, "recvmsg failed\n");
+ VHOST_LOG_CONFIG(ERR, "recvmsg failed\n");
return ret;
}
if (msgh.msg_flags & (MSG_TRUNC | MSG_CTRUNC)) {
- RTE_LOG(ERR, VHOST_CONFIG, "truncated msg\n");
+ VHOST_LOG_CONFIG(ERR, "truncated msg\n");
return -1;
}
msgh.msg_controllen = sizeof(control);
cmsg = CMSG_FIRSTHDR(&msgh);
if (cmsg == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG, "cmsg == NULL\n");
+ VHOST_LOG_CONFIG(ERR, "cmsg == NULL\n");
errno = EINVAL;
return -1;
}
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG, "sendmsg error\n");
+ VHOST_LOG_CONFIG(ERR, "sendmsg error\n");
return ret;
}
if (vsocket->linearbuf)
vhost_enable_linearbuf(vid);
- RTE_LOG(INFO, VHOST_CONFIG, "new device, handle is %d\n", vid);
+ VHOST_LOG_CONFIG(INFO, "new device, handle is %d\n", vid);
if (vsocket->notify_ops->new_connection) {
ret = vsocket->notify_ops->new_connection(vid);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to add vhost user connection with fd %d\n",
fd);
goto err_cleanup;
ret = fdset_add(&vhost_user.fdset, fd, vhost_user_read_cb,
NULL, conn);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to add fd %d into vhost server fdset\n",
fd);
if (fd < 0)
return;
- RTE_LOG(INFO, VHOST_CONFIG, "new vhost user connection is %d\n", fd);
+ VHOST_LOG_CONFIG(INFO, "new vhost user connection is %d\n", fd);
vhost_user_add_connection(fd, vsocket);
}
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0)
return -1;
- RTE_LOG(INFO, VHOST_CONFIG, "vhost-user %s: socket created, fd: %d\n",
+ VHOST_LOG_CONFIG(INFO, "vhost-user %s: socket created, fd: %d\n",
vsocket->is_server ? "server" : "client", fd);
if (!vsocket->is_server && fcntl(fd, F_SETFL, O_NONBLOCK)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"vhost-user: can't set nonblocking mode for socket, fd: "
"%d (%s)\n", fd, strerror(errno));
close(fd);
*/
ret = bind(fd, (struct sockaddr *)&vsocket->un, sizeof(vsocket->un));
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to bind to %s: %s; remove it and try again\n",
path, strerror(errno));
goto err;
}
- RTE_LOG(INFO, VHOST_CONFIG, "bind to %s\n", path);
+ VHOST_LOG_CONFIG(INFO, "bind to %s\n", path);
ret = listen(fd, MAX_VIRTIO_BACKLOG);
if (ret < 0)
ret = fdset_add(&vhost_user.fdset, fd, vhost_user_server_new_connection,
NULL, vsocket);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to add listen fd %d to vhost server fdset\n",
fd);
goto err;
flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"can't get flags for connfd %d\n", fd);
return -2;
}
if ((flags & O_NONBLOCK) && fcntl(fd, F_SETFL, flags & ~O_NONBLOCK)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"can't disable nonblocking on fd %d\n", fd);
return -2;
}
sizeof(reconn->un));
if (ret == -2) {
close(reconn->fd);
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"reconnection for fd %d failed\n",
reconn->fd);
goto remove_fd;
if (ret == -1)
continue;
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"%s: connected\n", reconn->vsocket->path);
vhost_user_add_connection(reconn->fd, reconn->vsocket);
remove_fd:
ret = pthread_mutex_init(&reconn_list.mutex, NULL);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG, "failed to initialize mutex");
+ VHOST_LOG_CONFIG(ERR, "failed to initialize mutex");
return ret;
}
TAILQ_INIT(&reconn_list.head);
ret = rte_ctrl_thread_create(&reconn_tid, "vhost_reconn", NULL,
vhost_user_client_reconnect, NULL);
if (ret != 0) {
- RTE_LOG(ERR, VHOST_CONFIG, "failed to create reconnect thread");
+ VHOST_LOG_CONFIG(ERR, "failed to create reconnect thread");
if (pthread_mutex_destroy(&reconn_list.mutex)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to destroy reconnect mutex");
}
}
return 0;
}
- RTE_LOG(WARNING, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(WARNING,
"failed to connect to %s: %s\n",
path, strerror(errno));
return -1;
}
- RTE_LOG(INFO, VHOST_CONFIG, "%s: reconnecting...\n", path);
+ VHOST_LOG_CONFIG(INFO, "%s: reconnecting...\n", path);
reconn = malloc(sizeof(*reconn));
if (reconn == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for reconnect\n");
close(fd);
return -1;
pthread_mutex_lock(&vhost_user.mutex);
vsocket = find_vhost_user_socket(path);
if (!vsocket) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"socket file %s is not registered yet.\n", path);
ret = -1;
goto unlock_exit;
}
if (vdpa_dev->ops->get_features(did, &vdpa_features) < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to get vdpa features "
"for socket file %s.\n", path);
ret = -1;
pthread_mutex_lock(&vhost_user.mutex);
vsocket = find_vhost_user_socket(path);
if (!vsocket) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"socket file %s is not registered yet.\n", path);
ret = -1;
goto unlock_exit;
if (vdpa_dev->ops->get_protocol_features(did,
&vdpa_protocol_features) < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to get vdpa protocol features "
"for socket file %s.\n", path);
ret = -1;
pthread_mutex_lock(&vhost_user.mutex);
vsocket = find_vhost_user_socket(path);
if (!vsocket) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"socket file %s is not registered yet.\n", path);
ret = -1;
goto unlock_exit;
}
if (vdpa_dev->ops->get_queue_num(did, &vdpa_queue_num) < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to get vdpa queue number "
"for socket file %s.\n", path);
ret = -1;
pthread_mutex_lock(&vhost_user.mutex);
if (vhost_user.vsocket_cnt == MAX_VHOST_SOCKET) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"error: the number of vhost sockets reaches maximum\n");
goto out;
}
memset(vsocket, 0, sizeof(struct vhost_user_socket));
vsocket->path = strdup(path);
if (vsocket->path == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"error: failed to copy socket path string\n");
vhost_user_socket_mem_free(vsocket);
goto out;
TAILQ_INIT(&vsocket->conn_list);
ret = pthread_mutex_init(&vsocket->conn_mutex, NULL);
if (ret) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"error: failed to init connection mutex\n");
goto out_free;
}
if (vsocket->dequeue_zero_copy &&
(flags & RTE_VHOST_USER_IOMMU_SUPPORT)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"error: enabling dequeue zero copy and IOMMU features "
"simultaneously is not supported\n");
goto out_mutex;
*/
if (vsocket->dequeue_zero_copy) {
if (vsocket->extbuf) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"error: zero copy is incompatible with external buffers\n");
ret = -1;
goto out_mutex;
}
if (vsocket->linearbuf) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"error: zero copy is incompatible with linear buffers\n");
ret = -1;
goto out_mutex;
vsocket->supported_features &= ~(1ULL << VIRTIO_F_IN_ORDER);
vsocket->features &= ~(1ULL << VIRTIO_F_IN_ORDER);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"Dequeue zero copy requested, disabling postcopy support\n");
vsocket->protocol_features &=
~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT);
(1ULL << VIRTIO_NET_F_HOST_TSO6) |
(1ULL << VIRTIO_NET_F_HOST_UFO);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"Linear buffers requested without external buffers, "
"disabling host segmentation offloading support\n");
vsocket->supported_features &= ~seg_offload_features;
~(1ULL << VHOST_USER_PROTOCOL_F_PAGEFAULT);
} else {
#ifndef RTE_LIBRTE_VHOST_POSTCOPY
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Postcopy requested but not compiled\n");
ret = -1;
goto out_mutex;
out_mutex:
if (pthread_mutex_destroy(&vsocket->conn_mutex)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"error: failed to destroy connection mutex\n");
}
out_free:
goto again;
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"free connfd = %d for device '%s'\n",
conn->connfd, path);
close(conn->connfd);
* rebuild the wait list of poll.
*/
if (fdset_pipe_init(&vhost_user.fdset) < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to create pipe for vhost fdset\n");
return -1;
}
"vhost-events", NULL, fdset_event_dispatch,
&vhost_user.fdset);
if (ret != 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to create fdset handling thread");
fdset_pipe_uninit(&vhost_user.fdset);
if (msg->fd_num == expected_fds)
return 0;
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
" Expect %d FDs for request %s, received %d\n",
expected_fds,
vhost_message_str[msg->request.master],
rte_vhost_driver_get_features(dev->ifname, &vhost_features);
if (features & ~vhost_features) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"(%d) received invalid negotiated features.\n",
dev->vid);
return RTE_VHOST_MSG_RESULT_ERR;
* is enabled when the live-migration starts.
*/
if ((dev->features ^ features) & ~(1ULL << VHOST_F_LOG_ALL)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"(%d) features changed while device is running.\n",
dev->vid);
return RTE_VHOST_MSG_RESULT_ERR;
} else {
dev->vhost_hlen = sizeof(struct virtio_net_hdr);
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"negotiated Virtio features: 0x%" PRIx64 "\n", dev->features);
- VHOST_LOG_DEBUG(VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) mergeable RX buffers %s, virtio 1 %s\n",
dev->vid,
(dev->features & (1 << VIRTIO_NET_F_MRG_RXBUF)) ? "on" : "off",
*/
if (!vq_is_packed(dev)) {
if (vq->size & (vq->size - 1)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"invalid virtqueue size %u\n", vq->size);
return RTE_VHOST_MSG_RESULT_ERR;
}
}
if (vq->size > 32768) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"invalid virtqueue size %u\n", vq->size);
return RTE_VHOST_MSG_RESULT_ERR;
}
vq->zmbufs = rte_zmalloc(NULL, vq->zmbuf_size *
sizeof(struct zcopy_mbuf), 0);
if (vq->zmbufs == NULL) {
- RTE_LOG(WARNING, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(WARNING,
"failed to allocate mem for zero copy; "
"zero copy is force disabled\n");
dev->dequeue_zero_copy = 0;
sizeof(struct vring_used_elem_packed),
RTE_CACHE_LINE_SIZE);
if (!vq->shadow_used_packed) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for shadow used ring.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
vq->size * sizeof(struct vring_used_elem),
RTE_CACHE_LINE_SIZE);
if (!vq->shadow_used_split) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for shadow used ring.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
vq->size * sizeof(struct batch_copy_elem),
RTE_CACHE_LINE_SIZE);
if (!vq->batch_copy_elems) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for batching copy.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
ret |= get_mempolicy(&oldnode, NULL, 0, old_vq,
MPOL_F_NODE | MPOL_F_ADDR);
if (ret) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Unable to get vq numa information.\n");
return dev;
}
if (oldnode != newnode) {
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"reallocate vq from %d to %d node\n", oldnode, newnode);
vq = rte_malloc_socket(NULL, sizeof(*vq), 0, newnode);
if (!vq)
ret = get_mempolicy(&oldnode, NULL, 0, old_dev,
MPOL_F_NODE | MPOL_F_ADDR);
if (ret) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Unable to get dev numa information.\n");
goto out;
}
if (oldnode != newnode) {
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"reallocate dev from %d to %d node\n",
oldnode, newnode);
dev = rte_malloc_socket(NULL, sizeof(*dev), 0, newnode);
gpa = hva_to_gpa(dev, hva, exp_size);
if (!gpa) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"VQ: Failed to find GPA for log_addr: 0x%" PRIx64 " hva: 0x%" PRIx64 "\n",
log_addr, hva);
return 0;
vq->log_guest_addr =
translate_log_addr(dev, vq, addr->log_guest_addr);
if (vq->log_guest_addr == 0) {
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map log_guest_addr.\n",
dev->vid);
return dev;
if (vq->desc_packed == NULL ||
len != sizeof(struct vring_packed_desc) *
vq->size) {
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map desc_packed ring.\n",
dev->vid);
return dev;
vq, addr->avail_user_addr, &len);
if (vq->driver_event == NULL ||
len != sizeof(struct vring_packed_desc_event)) {
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to find driver area address.\n",
dev->vid);
return dev;
vq, addr->used_user_addr, &len);
if (vq->device_event == NULL ||
len != sizeof(struct vring_packed_desc_event)) {
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to find device area address.\n",
dev->vid);
return dev;
vq->desc = (struct vring_desc *)(uintptr_t)ring_addr_to_vva(dev,
vq, addr->desc_user_addr, &len);
if (vq->desc == 0 || len != sizeof(struct vring_desc) * vq->size) {
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map desc ring.\n",
dev->vid);
return dev;
vq->avail = (struct vring_avail *)(uintptr_t)ring_addr_to_vva(dev,
vq, addr->avail_user_addr, &len);
if (vq->avail == 0 || len != expected_len) {
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map avail ring.\n",
dev->vid);
return dev;
vq->used = (struct vring_used *)(uintptr_t)ring_addr_to_vva(dev,
vq, addr->used_user_addr, &len);
if (vq->used == 0 || len != expected_len) {
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"(%d) failed to map used ring.\n",
dev->vid);
return dev;
}
if (vq->last_used_idx != vq->used->idx) {
- RTE_LOG(WARNING, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(WARNING,
"last_used_idx (%u) and vq->used->idx (%u) mismatches; "
"some packets maybe resent for Tx and dropped for Rx\n",
vq->last_used_idx, vq->used->idx);
vq->access_ok = 1;
- VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n",
+ VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address desc: %p\n",
dev->vid, vq->desc);
- VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address avail: %p\n",
+ VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address avail: %p\n",
dev->vid, vq->avail);
- VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address used: %p\n",
+ VHOST_LOG_CONFIG(DEBUG, "(%d) mapped address used: %p\n",
dev->vid, vq->used);
- VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) log_guest_addr: %" PRIx64 "\n",
+ VHOST_LOG_CONFIG(DEBUG, "(%d) log_guest_addr: %" PRIx64 "\n",
dev->vid, vq->log_guest_addr);
return dev;
dev->guest_pages = realloc(dev->guest_pages,
dev->max_guest_pages * sizeof(*page));
if (!dev->guest_pages) {
- RTE_LOG(ERR, VHOST_CONFIG, "cannot realloc guest_pages\n");
+ VHOST_LOG_CONFIG(ERR, "cannot realloc guest_pages\n");
free(old_pages);
return -1;
}
for (i = 0; i < dev->nr_guest_pages; i++) {
page = &dev->guest_pages[i];
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"guest physical page region %u\n"
"\t guest_phys_addr: %" PRIx64 "\n"
"\t host_phys_addr : %" PRIx64 "\n"
return RTE_VHOST_MSG_RESULT_ERR;
if (memory->nregions > VHOST_MEMORY_MAX_NREGIONS) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"too many memory regions (%u)\n", memory->nregions);
return RTE_VHOST_MSG_RESULT_ERR;
}
if (dev->mem && !vhost_memory_changed(memory, dev->mem)) {
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"(%d) memory regions not changed\n", dev->vid);
close_msg_fds(msg);
dev->guest_pages = malloc(dev->max_guest_pages *
sizeof(struct guest_page));
if (dev->guest_pages == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"(%d) failed to allocate memory "
"for dev->guest_pages\n",
dev->vid);
dev->mem = rte_zmalloc("vhost-mem-table", sizeof(struct rte_vhost_memory) +
sizeof(struct rte_vhost_mem_region) * memory->nregions, 0);
if (dev->mem == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"(%d) failed to allocate memory for dev->mem\n",
dev->vid);
return RTE_VHOST_MSG_RESULT_ERR;
/* Check for memory_size + mmap_offset overflow */
if (mmap_offset >= -reg->size) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"mmap_offset (%#"PRIx64") and memory_size "
"(%#"PRIx64") overflow\n",
mmap_offset, reg->size);
*/
alignment = get_blk_size(fd);
if (alignment == (uint64_t)-1) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"couldn't get hugepage size through fstat\n");
goto err_mmap;
}
MAP_SHARED | populate, fd, 0);
if (mmap_addr == MAP_FAILED) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"mmap region %u failed.\n", i);
goto err_mmap;
}
if (dev->dequeue_zero_copy)
if (add_guest_pages(dev, reg, alignment) < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"adding guest pages to region %u failed.\n",
i);
goto err_mmap;
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"guest memory region %u, size: 0x%" PRIx64 "\n"
"\t guest physical addr: 0x%" PRIx64 "\n"
"\t guest virtual addr: 0x%" PRIx64 "\n"
*/
VhostUserMsg ack_msg;
if (read_vhost_message(main_fd, &ack_msg) <= 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Failed to read qemu ack on postcopy set-mem-table\n");
goto err_mmap;
}
goto err_mmap;
if (ack_msg.request.master != VHOST_USER_SET_MEM_TABLE) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Bad qemu ack on postcopy set-mem-table (%d)\n",
ack_msg.request.master);
goto err_mmap;
if (ioctl(dev->postcopy_ufd, UFFDIO_REGISTER,
®_struct)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Failed to register ufd for region %d: (ufd = %d) %s\n",
i, dev->postcopy_ufd,
strerror(errno));
goto err_mmap;
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"\t userfaultfd registered for range : "
"%" PRIx64 " - %" PRIx64 "\n",
(uint64_t)reg_struct.range.start,
return 0;
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"virtio is now ready for processing.\n");
return 1;
}
if (mfd == -1) {
mfd = mkstemp(fname);
if (mfd == -1) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to get inflight buffer fd\n");
return NULL;
}
}
if (ftruncate(mfd, size) == -1) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to alloc inflight buffer\n");
close(mfd);
return NULL;
ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, mfd, 0);
if (ptr == MAP_FAILED) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to mmap inflight buffer\n");
close(mfd);
return NULL;
void *addr;
if (msg->size != sizeof(msg->payload.inflight)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"invalid get_inflight_fd message size is %d\n",
msg->size);
return RTE_VHOST_MSG_RESULT_ERR;
dev->inflight_info = calloc(1,
sizeof(struct inflight_mem_info));
if (!dev->inflight_info) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to alloc dev inflight area\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
num_queues = msg->payload.inflight.num_queues;
queue_size = msg->payload.inflight.queue_size;
- RTE_LOG(INFO, VHOST_CONFIG, "get_inflight_fd num_queues: %u\n",
+ VHOST_LOG_CONFIG(INFO, "get_inflight_fd num_queues: %u\n",
msg->payload.inflight.num_queues);
- RTE_LOG(INFO, VHOST_CONFIG, "get_inflight_fd queue_size: %u\n",
+ VHOST_LOG_CONFIG(INFO, "get_inflight_fd queue_size: %u\n",
msg->payload.inflight.queue_size);
if (vq_is_packed(dev))
mmap_size = num_queues * pervq_inflight_size;
addr = inflight_mem_alloc("vhost-inflight", mmap_size, &fd);
if (!addr) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to alloc vhost inflight area\n");
msg->payload.inflight.mmap_size = 0;
return RTE_VHOST_MSG_RESULT_ERR;
}
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"send inflight mmap_size: %"PRIu64"\n",
msg->payload.inflight.mmap_size);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"send inflight mmap_offset: %"PRIu64"\n",
msg->payload.inflight.mmap_offset);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"send inflight fd: %d\n", msg->fds[0]);
return RTE_VHOST_MSG_RESULT_REPLY;
fd = msg->fds[0];
if (msg->size != sizeof(msg->payload.inflight) || fd < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"invalid set_inflight_fd message size is %d,fd is %d\n",
msg->size, fd);
return RTE_VHOST_MSG_RESULT_ERR;
else
pervq_inflight_size = get_pervq_shm_size_split(queue_size);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"set_inflight_fd mmap_size: %"PRIu64"\n", mmap_size);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"set_inflight_fd mmap_offset: %"PRIu64"\n", mmap_offset);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"set_inflight_fd num_queues: %u\n", num_queues);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"set_inflight_fd queue_size: %u\n", queue_size);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"set_inflight_fd fd: %d\n", fd);
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"set_inflight_fd pervq_inflight_size: %d\n",
pervq_inflight_size);
dev->inflight_info = calloc(1,
sizeof(struct inflight_mem_info));
if (dev->inflight_info == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to alloc dev inflight area\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
addr = mmap(0, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
fd, mmap_offset);
if (addr == MAP_FAILED) {
- RTE_LOG(ERR, VHOST_CONFIG, "failed to mmap share memory.\n");
+ VHOST_LOG_CONFIG(ERR, "failed to mmap share memory.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
file.fd = VIRTIO_INVALID_EVENTFD;
else
file.fd = msg->fds[0];
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"vring call idx:%d file:%d\n", file.index, file.fd);
vq = dev->virtqueue[file.index];
if (!(msg->payload.u64 & VHOST_USER_VRING_NOFD_MASK))
close(msg->fds[0]);
- RTE_LOG(INFO, VHOST_CONFIG, "not implemented\n");
+ VHOST_LOG_CONFIG(INFO, "not implemented\n");
return RTE_VHOST_MSG_RESULT_OK;
}
if (resubmit_num) {
resubmit = calloc(1, sizeof(struct rte_vhost_resubmit_info));
if (!resubmit) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for resubmit info.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
resubmit->resubmit_list = calloc(resubmit_num,
sizeof(struct rte_vhost_resubmit_desc));
if (!resubmit->resubmit_list) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for inflight desc.\n");
free(resubmit);
return RTE_VHOST_MSG_RESULT_ERR;
if (resubmit_num) {
resubmit = calloc(1, sizeof(struct rte_vhost_resubmit_info));
if (resubmit == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for resubmit info.\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
resubmit->resubmit_list = calloc(resubmit_num,
sizeof(struct rte_vhost_resubmit_desc));
if (resubmit->resubmit_list == NULL) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to allocate memory for resubmit desc.\n");
free(resubmit);
return RTE_VHOST_MSG_RESULT_ERR;
file.fd = VIRTIO_INVALID_EVENTFD;
else
file.fd = msg->fds[0];
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"vring kick idx:%d file:%d\n", file.index, file.fd);
/* Interpret ring addresses only when ring is started. */
if (vq_is_packed(dev)) {
if (vhost_check_queue_inflights_packed(dev, vq)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to inflights for vq: %d\n", file.index);
return RTE_VHOST_MSG_RESULT_ERR;
}
} else {
if (vhost_check_queue_inflights_split(dev, vq)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to inflights for vq: %d\n", file.index);
return RTE_VHOST_MSG_RESULT_ERR;
}
msg->payload.state.num = vq->last_avail_idx;
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"vring base idx:%d file:%d\n", msg->payload.state.index,
msg->payload.state.num);
/*
if (validate_msg_fds(msg, 0) != 0)
return RTE_VHOST_MSG_RESULT_ERR;
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"set queue enable: %d to qp idx: %d\n",
enable, index);
rte_vhost_driver_get_protocol_features(dev->ifname,
&slave_protocol_features);
if (protocol_features & ~slave_protocol_features) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"(%d) received invalid protocol features.\n",
dev->vid);
return RTE_VHOST_MSG_RESULT_ERR;
}
dev->protocol_features = protocol_features;
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"negotiated Vhost-user protocol features: 0x%" PRIx64 "\n",
dev->protocol_features);
return RTE_VHOST_MSG_RESULT_ERR;
if (fd < 0) {
- RTE_LOG(ERR, VHOST_CONFIG, "invalid log fd: %d\n", fd);
+ VHOST_LOG_CONFIG(ERR, "invalid log fd: %d\n", fd);
return RTE_VHOST_MSG_RESULT_ERR;
}
if (msg->size != sizeof(VhostUserLog)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"invalid log base msg size: %"PRId32" != %d\n",
msg->size, (int)sizeof(VhostUserLog));
return RTE_VHOST_MSG_RESULT_ERR;
/* Don't allow mmap_offset to point outside the mmap region */
if (off > size) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"log offset %#"PRIx64" exceeds log size %#"PRIx64"\n",
off, size);
return RTE_VHOST_MSG_RESULT_ERR;
}
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"log mmap size: %"PRId64", offset: %"PRId64"\n",
size, off);
addr = mmap(0, size + off, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
close(fd);
if (addr == MAP_FAILED) {
- RTE_LOG(ERR, VHOST_CONFIG, "mmap log base failed!\n");
+ VHOST_LOG_CONFIG(ERR, "mmap log base failed!\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
return RTE_VHOST_MSG_RESULT_ERR;
close(msg->fds[0]);
- RTE_LOG(INFO, VHOST_CONFIG, "not implemented.\n");
+ VHOST_LOG_CONFIG(INFO, "not implemented.\n");
return RTE_VHOST_MSG_RESULT_OK;
}
if (validate_msg_fds(msg, 0) != 0)
return RTE_VHOST_MSG_RESULT_ERR;
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
":: mac: %02x:%02x:%02x:%02x:%02x:%02x\n",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
memcpy(dev->mac.addr_bytes, mac, 6);
if (msg->payload.u64 < VIRTIO_MIN_MTU ||
msg->payload.u64 > VIRTIO_MAX_MTU) {
- RTE_LOG(ERR, VHOST_CONFIG, "Invalid MTU size (%"PRIu64")\n",
+ VHOST_LOG_CONFIG(ERR, "Invalid MTU size (%"PRIu64")\n",
msg->payload.u64);
return RTE_VHOST_MSG_RESULT_ERR;
return RTE_VHOST_MSG_RESULT_ERR;
if (fd < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Invalid file descriptor for slave channel (%d)\n",
fd);
return RTE_VHOST_MSG_RESULT_ERR;
}
break;
default:
- RTE_LOG(ERR, VHOST_CONFIG, "Invalid IOTLB message type (%d)\n",
+ VHOST_LOG_CONFIG(ERR, "Invalid IOTLB message type (%d)\n",
imsg->type);
return RTE_VHOST_MSG_RESULT_ERR;
}
dev->postcopy_ufd = syscall(__NR_userfaultfd, O_CLOEXEC | O_NONBLOCK);
if (dev->postcopy_ufd == -1) {
- RTE_LOG(ERR, VHOST_CONFIG, "Userfaultfd not available: %s\n",
+ VHOST_LOG_CONFIG(ERR, "Userfaultfd not available: %s\n",
strerror(errno));
return RTE_VHOST_MSG_RESULT_ERR;
}
api_struct.api = UFFD_API;
api_struct.features = 0;
if (ioctl(dev->postcopy_ufd, UFFDIO_API, &api_struct)) {
- RTE_LOG(ERR, VHOST_CONFIG, "UFFDIO_API ioctl failure: %s\n",
+ VHOST_LOG_CONFIG(ERR, "UFFDIO_API ioctl failure: %s\n",
strerror(errno));
close(dev->postcopy_ufd);
dev->postcopy_ufd = -1;
return RTE_VHOST_MSG_RESULT_ERR;
if (dev->mem && dev->mem->nregions) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Regions already registered at postcopy-listen\n");
return RTE_VHOST_MSG_RESULT_ERR;
}
if (msg->size) {
if (msg->size > sizeof(msg->payload)) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"invalid msg size: %d\n", msg->size);
return -1;
}
if (ret <= 0)
return ret;
if (ret != (int)msg->size) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"read control message failed\n");
return -1;
}
}
if (vring_idx >= VHOST_MAX_VRING) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"invalid vring index: %u\n", vring_idx);
return -1;
}
if (!dev->notify_ops) {
dev->notify_ops = vhost_driver_callback_get(dev->ifname);
if (!dev->notify_ops) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to get callback ops for driver %s\n",
dev->ifname);
return -1;
ret = read_vhost_message(fd, &msg);
if (ret <= 0) {
if (ret < 0)
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"vhost read message failed\n");
else
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"vhost peer closed\n");
return -1;
if (request > VHOST_USER_NONE && request < VHOST_USER_MAX &&
vhost_message_str[request]) {
if (request != VHOST_USER_IOTLB_MSG)
- RTE_LOG(INFO, VHOST_CONFIG, "read message %s\n",
+ VHOST_LOG_CONFIG(INFO, "read message %s\n",
vhost_message_str[request]);
else
- RTE_LOG(DEBUG, VHOST_CONFIG, "read message %s\n",
+ VHOST_LOG_CONFIG(DEBUG, "read message %s\n",
vhost_message_str[request]);
} else {
- RTE_LOG(DEBUG, VHOST_CONFIG, "External request %d\n", request);
+ VHOST_LOG_CONFIG(DEBUG, "External request %d\n", request);
}
ret = vhost_user_check_and_alloc_queue_pair(dev, &msg);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"failed to alloc queue\n");
return -1;
}
switch (ret) {
case RTE_VHOST_MSG_RESULT_ERR:
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Processing %s failed.\n",
vhost_message_str[request]);
handled = true;
break;
case RTE_VHOST_MSG_RESULT_OK:
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"Processing %s succeeded.\n",
vhost_message_str[request]);
handled = true;
break;
case RTE_VHOST_MSG_RESULT_REPLY:
- RTE_LOG(DEBUG, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(DEBUG,
"Processing %s succeeded and needs reply.\n",
vhost_message_str[request]);
send_vhost_reply(fd, &msg);
/* If message was not handled at this stage, treat it as an error */
if (!handled) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"vhost message (req: %d) was not handled.\n", request);
close_msg_fds(&msg);
ret = RTE_VHOST_MSG_RESULT_ERR;
msg.fd_num = 0;
send_vhost_reply(fd, &msg);
} else if (ret == RTE_VHOST_MSG_RESULT_ERR) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"vhost message handling failed.\n");
return -1;
}
if (!(dev->flags & VIRTIO_DEV_RUNNING)) {
if (dev->dequeue_zero_copy) {
- RTE_LOG(INFO, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(INFO,
"dequeue zero copy is enabled\n");
}
}
if (msg_reply.request.slave != msg->request.slave) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Received unexpected msg type (%u), expected %u\n",
msg_reply.request.slave, msg->request.slave);
ret = -1;
ret = send_vhost_message(dev->slave_req_fd, &msg);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Failed to send IOTLB miss message (%d)\n",
ret);
return ret;
ret = send_vhost_slave_message(dev, &msg);
if (ret < 0) {
- RTE_LOG(ERR, VHOST_CONFIG,
+ VHOST_LOG_CONFIG(ERR,
"Failed to set host notifier (%d)\n", ret);
return ret;
}