mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
vhost-user: send log shm fd along with log_base
Send the shm for the dirty pages logging if the backend supports VHOST_USER_PROTOCOL_F_LOG_SHMFD. Wait for a reply to make sure the old log is no longer used. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Thibaut Collet <thibaut.collet@6wind.com>
This commit is contained in:
parent
15324404f6
commit
9a78a5dd27
4 changed files with 33 additions and 6 deletions
|
@ -367,8 +367,13 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base)
|
||||
static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base,
|
||||
struct vhost_log *log)
|
||||
{
|
||||
int fds[VHOST_MEMORY_MAX_NREGIONS];
|
||||
size_t fd_num = 0;
|
||||
bool shmfd = virtio_has_feature(dev->protocol_features,
|
||||
VHOST_USER_PROTOCOL_F_LOG_SHMFD);
|
||||
VhostUserMsg msg = {
|
||||
.request = VHOST_USER_SET_LOG_BASE,
|
||||
.flags = VHOST_USER_VERSION,
|
||||
|
@ -376,7 +381,25 @@ static int vhost_set_log_base(struct vhost_dev *dev, uint64_t base)
|
|||
.size = sizeof(m.u64),
|
||||
};
|
||||
|
||||
vhost_user_write(dev, &msg, NULL, 0);
|
||||
if (shmfd && log->fd != -1) {
|
||||
fds[fd_num++] = log->fd;
|
||||
}
|
||||
|
||||
vhost_user_write(dev, &msg, fds, fd_num);
|
||||
|
||||
if (shmfd) {
|
||||
msg.size = 0;
|
||||
if (vhost_user_read(dev, &msg) < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (msg.request != VHOST_USER_SET_LOG_BASE) {
|
||||
error_report("Received unexpected msg type. "
|
||||
"Expected %d received %d",
|
||||
VHOST_USER_SET_LOG_BASE, msg.request);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue