@@ -99,6 +99,9 @@ typedef enum VhostUserSlaveRequest {
VHOST_USER_SLAVE_IOTLB_MSG = 1,
VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2,
VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3,
+ VHOST_USER_SLAVE_FS_MAP = 4,
+ VHOST_USER_SLAVE_FS_UNMAP = 5,
+ VHOST_USER_SLAVE_FS_SYNC = 6,
VHOST_USER_SLAVE_MAX
} VhostUserSlaveRequest;
@@ -815,6 +815,41 @@ Slave message types
This request should be sent only when VHOST_USER_PROTOCOL_F_HOST_NOTIFIER
protocol feature has been successfully negotiated.
+ * VHOST_USER_SLAVE_FS_MAP
+
+ Id: 4
+ Equivalent ioctl: N/A
+ Slave payload: fd + n * (offset + address + len)
+ Master payload: N/A
+
+ Requests that the QEMU mmap the given fd into the virtio-fs cache;
+ multiple chunks can be mapped in one command.
+ A reply is generated indicating whether mapping succeeded.
+
+ * VHOST_USER_SLAVE_FS_UNMAP
+
+ Id: 5
+ Equivalent ioctl: N/A
+ Slave payload: n * (address + len)
+ Master payload: N/A
+
+ Requests that the QEMU un-mmap the given range in the virtio-fs cache;
+ multiple chunks can be unmapped in one command.
+ A reply is generated indicating whether unmapping succeeded.
+
+ * VHOST_USER_SLAVE_FS_SYNC
+
+ Id: 6
+ Equivalent ioctl: N/A
+ Slave payload: n * (address + len)
+ Master payload: N/A
+
+ Requests that the QEMU causes any changes to the virtio-fs cache to
+ be synchronised with the backing files. Multiple chunks can be synced
+ in one command.
+ A reply is generated indicating whether syncing succeeded.
+ [Semantic details TBD]
+
VHOST_USER_PROTOCOL_F_REPLY_ACK:
-------------------------------
The original vhost-user specification only demands replies for certain
@@ -21,6 +21,26 @@
#include "hw/virtio/vhost-user-fs.h"
#include "monitor/monitor.h"
+int vhost_user_fs_slave_map(struct vhost_dev *dev, VhostUserFSSlaveMsg *sm,
+ int fd)
+{
+ /* TODO */
+ return -1;
+}
+
+int vhost_user_fs_slave_unmap(struct vhost_dev *dev, VhostUserFSSlaveMsg *sm)
+{
+ /* TODO */
+ return -1;
+}
+
+int vhost_user_fs_slave_sync(struct vhost_dev *dev, VhostUserFSSlaveMsg *sm)
+{
+ /* TODO */
+ return -1;
+}
+
+
static void vuf_get_config(VirtIODevice *vdev, uint8_t *config)
{
VHostUserFS *fs = VHOST_USER_FS(vdev);
@@ -12,6 +12,7 @@
#include "qapi/error.h"
#include "hw/virtio/vhost.h"
#include "hw/virtio/vhost-user.h"
+#include "hw/virtio/vhost-user-fs.h"
#include "hw/virtio/vhost-backend.h"
#include "hw/virtio/virtio.h"
#include "hw/virtio/virtio-net.h"
@@ -97,6 +98,9 @@ typedef enum VhostUserSlaveRequest {
VHOST_USER_SLAVE_IOTLB_MSG = 1,
VHOST_USER_SLAVE_CONFIG_CHANGE_MSG = 2,
VHOST_USER_SLAVE_VRING_HOST_NOTIFIER_MSG = 3,
+ VHOST_USER_SLAVE_FS_MAP = 4,
+ VHOST_USER_SLAVE_FS_UNMAP = 5,
+ VHOST_USER_SLAVE_FS_SYNC = 6,
VHOST_USER_SLAVE_MAX
} VhostUserSlaveRequest;
@@ -169,6 +173,7 @@ typedef union {
VhostUserConfig config;
VhostUserCryptoSession session;
VhostUserVringArea area;
+ VhostUserFSSlaveMsg fs;
} VhostUserPayload;
typedef struct VhostUserMsg {
@@ -1010,6 +1015,17 @@ static void slave_read(void *opaque)
ret = vhost_user_slave_handle_vring_host_notifier(dev, &payload.area,
fd[0]);
break;
+#ifdef CONFIG_VHOST_USER_FS
+ case VHOST_USER_SLAVE_FS_MAP:
+ ret = vhost_user_fs_slave_map(dev, &payload.fs, fd[0]);
+ break;
+ case VHOST_USER_SLAVE_FS_UNMAP:
+ ret = vhost_user_fs_slave_unmap(dev, &payload.fs);
+ break;
+ case VHOST_USER_SLAVE_FS_SYNC:
+ ret = vhost_user_fs_slave_sync(dev, &payload.fs);
+ break;
+#endif
default:
error_report("Received unexpected msg type.");
ret = -EINVAL;
@@ -23,6 +23,24 @@
#define VHOST_USER_FS(obj) \
OBJECT_CHECK(VHostUserFS, (obj), TYPE_VHOST_USER_FS)
+/* Structures carried over the slave channel back to QEMU */
+#define VHOST_USER_FS_SLAVE_ENTRIES 8
+
+/* For the flags field of VhostUserFSSlaveMsg */
+#define VHOST_USER_FS_FLAG_MAP_R (1ull << 0)
+#define VHOST_USER_FS_FLAG_MAP_W (1ull << 1)
+
+typedef struct {
+ /* Offsets within the file being mapped */
+ uint64_t fd_offset[VHOST_USER_FS_SLAVE_ENTRIES];
+ /* Offsets within the cache */
+ uint64_t c_offset[VHOST_USER_FS_SLAVE_ENTRIES];
+ /* Lengths of sections */
+ uint64_t len[VHOST_USER_FS_SLAVE_ENTRIES];
+ /* Flags, from VHOST_USER_FS_FLAG_* */
+ uint64_t flags[VHOST_USER_FS_SLAVE_ENTRIES];
+} VhostUserFSSlaveMsg;
+
typedef struct {
CharBackend chardev;
char *tag;
@@ -44,4 +62,10 @@ typedef struct {
MemoryRegion cache;
} VHostUserFS;
+/* Callbacks from the vhost-user code for slave commands */
+int vhost_user_fs_slave_map(struct vhost_dev *dev, VhostUserFSSlaveMsg *sm,
+ int fd);
+int vhost_user_fs_slave_unmap(struct vhost_dev *dev, VhostUserFSSlaveMsg *sm);
+int vhost_user_fs_slave_sync(struct vhost_dev *dev, VhostUserFSSlaveMsg *sm);
+
#endif /* _QEMU_VHOST_USER_FS_H */