if (unlikely(!dev->log_base))
return;
+ /* No cache, nothing to sync */
+ if (unlikely(!vq->log_cache))
+ return;
+
rte_atomic_thread_fence(__ATOMIC_RELEASE);
log_base = (unsigned long *)(uintptr_t)dev->log_base;
uint32_t offset = page / (sizeof(unsigned long) << 3);
int i;
+ if (unlikely(!vq->log_cache)) {
+ /* No logging cache allocated, write dirty log map directly */
+ rte_atomic_thread_fence(__ATOMIC_RELEASE);
+ vhost_log_page((uint8_t *)(uintptr_t)dev->log_base, page);
+
+ return;
+ }
+
for (i = 0; i < vq->log_cache_nb_elem; i++) {
struct log_cache_entry *elem = vq->log_cache + i;
}
rte_free(vq->batch_copy_elems);
rte_mempool_free(vq->iotlb_pool);
+ rte_free(vq->log_cache);
rte_free(vq);
}
rte_free(vq->batch_copy_elems);
vq->batch_copy_elems = NULL;
+ rte_free(vq->log_cache);
+ vq->log_cache = NULL;
+
msg->size = sizeof(msg->payload.state);
msg->fd_num = 0;
int fd = msg->fds[0];
uint64_t size, off;
void *addr;
+ uint32_t i;
if (validate_msg_fds(msg, 1) != 0)
return RTE_VHOST_MSG_RESULT_ERR;
dev->log_base = dev->log_addr + off;
dev->log_size = size;
+ for (i = 0; i < dev->nr_vring; i++) {
+ struct vhost_virtqueue *vq = dev->virtqueue[i];
+
+ rte_free(vq->log_cache);
+ vq->log_cache = NULL;
+ vq->log_cache_nb_elem = 0;
+ vq->log_cache = rte_zmalloc("vq log cache",
+ sizeof(struct log_cache_entry) * VHOST_LOG_CACHE_NR,
+ 0);
+ /*
+ * If log cache alloc fail, don't fail migration, but no
+ * caching will be done, which will impact performance
+ */
+ if (!vq->log_cache)
+ VHOST_LOG_CONFIG(ERR, "Failed to allocate VQ logging cache\n");
+ }
+
/*
* The spec is not clear about it (yet), but QEMU doesn't expect
* any payload in the reply.