[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/7] libvhost-user: rename struct VuDev fields from "slave" to "b
From: |
Paolo Bonzini |
Subject: |
[PATCH 7/7] libvhost-user: rename struct VuDev fields from "slave" to "backend" |
Date: |
Thu, 11 Mar 2021 05:32:50 -0500 |
Technically these are parts of the API, but the file descriptor seems
to be managed by libvhost-user itself only.
Nevertheless, I am keeping this as a separate change.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
subprojects/libvhost-user/libvhost-user.c | 46 +++++++++++------------
subprojects/libvhost-user/libvhost-user.h | 6 +--
2 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/subprojects/libvhost-user/libvhost-user.c
b/subprojects/libvhost-user/libvhost-user.c
index b7aef17e4e..53fa8b8f38 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -400,8 +400,8 @@ vu_send_reply(VuDev *dev, int conn_fd, VhostUserMsg *vmsg)
}
/*
- * Processes a reply on the slave channel.
- * Entered with slave_mutex held and releases it before exit.
+ * Processes a reply from the frontend on the backend channel.
+ * Entered with backend_mutex held and releases it before exit.
* Returns true on success.
*/
static bool
@@ -415,7 +415,7 @@ vu_process_message_reply(VuDev *dev, const VhostUserMsg
*vmsg)
goto out;
}
- if (!vu_message_read_default(dev, dev->slave_fd, &msg_reply)) {
+ if (!vu_message_read_default(dev, dev->backend_fd, &msg_reply)) {
goto out;
}
@@ -428,7 +428,7 @@ vu_process_message_reply(VuDev *dev, const VhostUserMsg
*vmsg)
result = msg_reply.payload.u64 == 0;
out:
- pthread_mutex_unlock(&dev->slave_mutex);
+ pthread_mutex_unlock(&dev->backend_mutex);
return result;
}
@@ -1335,13 +1335,13 @@ bool vu_set_queue_host_notifier(VuDev *dev, VuVirtq
*vq, int fd,
return false;
}
- pthread_mutex_lock(&dev->slave_mutex);
- if (!vu_message_write(dev, dev->slave_fd, &vmsg)) {
- pthread_mutex_unlock(&dev->slave_mutex);
+ pthread_mutex_lock(&dev->backend_mutex);
+ if (!vu_message_write(dev, dev->backend_fd, &vmsg)) {
+ pthread_mutex_unlock(&dev->backend_mutex);
return false;
}
- /* Also unlocks the slave_mutex */
+ /* Also unlocks the backend_mutex */
return vu_process_message_reply(dev, &vmsg);
}
@@ -1492,18 +1492,18 @@ vu_set_vring_enable_exec(VuDev *dev, VhostUserMsg *vmsg)
}
static bool
-vu_set_slave_req_fd(VuDev *dev, VhostUserMsg *vmsg)
+vu_set_backend_req_fd(VuDev *dev, VhostUserMsg *vmsg)
{
if (vmsg->fd_num != 1) {
- vu_panic(dev, "Invalid slave_req_fd message (%d fd's)", vmsg->fd_num);
+ vu_panic(dev, "Invalid backend_req_fd message (%d fd's)",
vmsg->fd_num);
return false;
}
- if (dev->slave_fd != -1) {
- close(dev->slave_fd);
+ if (dev->backend_fd != -1) {
+ close(dev->backend_fd);
}
- dev->slave_fd = vmsg->fds[0];
- DPRINT("Got slave_fd: %d\n", vmsg->fds[0]);
+ dev->backend_fd = vmsg->fds[0];
+ DPRINT("Got backend_fd: %d\n", vmsg->fds[0]);
return false;
}
@@ -1865,7 +1865,7 @@ vu_process_message(VuDev *dev, VhostUserMsg *vmsg)
case VHOST_USER_SET_VRING_ENABLE:
return vu_set_vring_enable_exec(dev, vmsg);
case VHOST_USER_SET_BACKEND_REQ_FD:
- return vu_set_slave_req_fd(dev, vmsg);
+ return vu_set_backend_req_fd(dev, vmsg);
case VHOST_USER_GET_CONFIG:
return vu_get_config(dev, vmsg);
case VHOST_USER_SET_CONFIG:
@@ -1986,11 +1986,11 @@ vu_deinit(VuDev *dev)
}
vu_close_log(dev);
- if (dev->slave_fd != -1) {
- close(dev->slave_fd);
- dev->slave_fd = -1;
+ if (dev->backend_fd != -1) {
+ close(dev->backend_fd);
+ dev->backend_fd = -1;
}
- pthread_mutex_destroy(&dev->slave_mutex);
+ pthread_mutex_destroy(&dev->backend_mutex);
if (dev->sock != -1) {
close(dev->sock);
@@ -2028,8 +2028,8 @@ vu_init(VuDev *dev,
dev->remove_watch = remove_watch;
dev->iface = iface;
dev->log_call_fd = -1;
- pthread_mutex_init(&dev->slave_mutex, NULL);
- dev->slave_fd = -1;
+ pthread_mutex_init(&dev->backend_mutex, NULL);
+ dev->backend_fd = -1;
dev->max_queues = max_queues;
dev->vq = malloc(max_queues * sizeof(dev->vq[0]));
@@ -2387,9 +2387,9 @@ static void _vu_queue_notify(VuDev *dev, VuVirtq *vq,
bool sync)
vmsg.flags |= VHOST_USER_NEED_REPLY_MASK;
}
- vu_message_write(dev, dev->slave_fd, &vmsg);
+ vu_message_write(dev, dev->backend_fd, &vmsg);
if (ack) {
- vu_message_read_default(dev, dev->slave_fd, &vmsg);
+ vu_message_read_default(dev, dev->backend_fd, &vmsg);
}
return;
}
diff --git a/subprojects/libvhost-user/libvhost-user.h
b/subprojects/libvhost-user/libvhost-user.h
index eba3e1fc05..f29cbf4754 100644
--- a/subprojects/libvhost-user/libvhost-user.h
+++ b/subprojects/libvhost-user/libvhost-user.h
@@ -397,9 +397,9 @@ struct VuDev {
VuVirtq *vq;
VuDevInflightInfo inflight_info;
int log_call_fd;
- /* Must be held while using slave_fd */
- pthread_mutex_t slave_mutex;
- int slave_fd;
+ /* Must be held while using backend */
+ pthread_mutex_t backend_mutex;
+ int backend_fd;
uint64_t log_size;
uint8_t *log_table;
uint64_t features;
--
2.26.2
- [PATCH v2 0/7] vhost: replace master/slave with more accurate wording, Paolo Bonzini, 2021/03/11
- [PATCH 2/7] docs: vhost-user: rewrite section on ring state machine, Paolo Bonzini, 2021/03/11
- [PATCH 1/7] docs: vhost-user: clean up request/reply description, Paolo Bonzini, 2021/03/11
- [PATCH 4/7] docs: vhost-user: rename message names from "SLAVE" to "BACKEND", Paolo Bonzini, 2021/03/11
- [PATCH 3/7] docs: vhost-user: replace master/slave with frontend/backend, Paolo Bonzini, 2021/03/11
- [PATCH 5/7] vhost-user: rename message names from "SLAVE" to "BACKEND", Paolo Bonzini, 2021/03/11
- [PATCH 7/7] libvhost-user: rename struct VuDev fields from "slave" to "backend",
Paolo Bonzini <=
- [PATCH 6/7] libvhost-user: rename message names from "SLAVE" to "BACKEND", Paolo Bonzini, 2021/03/11
- Re: [PATCH v2 0/7] vhost: replace master/slave with more accurate wording, no-reply, 2021/03/11
- Re: [PATCH v2 0/7] vhost: replace master/slave with more accurate wording, Marc-André Lureau, 2021/03/11
- Re: [PATCH v2 0/7] vhost: replace master/slave with more accurate wording, Stefano Garzarella, 2021/03/12