qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

vhost-user: add VHOST_USER_RESET_DEVICE to reset devices

Add a VHOST_USER_RESET_DEVICE message which will reset the vhost user
backend. Disabling all rings, and resetting all internal state, ready
for the backend to be reinitialized.

A backend has to report it supports this features with the
VHOST_USER_PROTOCOL_F_RESET_DEVICE protocol feature bit. If it does
so, the new message is used instead of sending a RESET_OWNER which has
had inconsistent implementations.

Signed-off-by: David Vrabel <david.vrabel@nutanix.com>
Signed-off-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Message-Id: <1572385083-5254-2-git-send-email-raphael.norwitz@nutanix.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

Raphael Norwitz and committed by
Michael S. Tsirkin
d91d57e6 f2a7e8f1

+22 -1
+15
docs/interop/vhost-user.rst
··· 785 785 #define VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD 10 786 786 #define VHOST_USER_PROTOCOL_F_HOST_NOTIFIER 11 787 787 #define VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD 12 788 + #define VHOST_USER_PROTOCOL_F_RESET_DEVICE 13 788 789 789 790 Master message types 790 791 -------------------- ··· 1189 1190 Sets the GPU protocol socket file descriptor, which is passed as 1190 1191 ancillary data. The GPU protocol is used to inform the master of 1191 1192 rendering state and updates. See vhost-user-gpu.rst for details. 1193 + 1194 + ``VHOST_USER_RESET_DEVICE`` 1195 + :id: 34 1196 + :equivalent ioctl: N/A 1197 + :master payload: N/A 1198 + :slave payload: N/A 1199 + 1200 + Ask the vhost user backend to disable all rings and reset all 1201 + internal device state to the initial state, ready to be 1202 + reinitialized. The backend retains ownership of the device 1203 + throughout the reset operation. 1204 + 1205 + Only valid if the ``VHOST_USER_PROTOCOL_F_RESET_DEVICE`` protocol 1206 + feature is set by the backend. 1192 1207 1193 1208 Slave message types 1194 1209 -------------------
+7 -1
hw/virtio/vhost-user.c
··· 58 58 VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD = 10, 59 59 VHOST_USER_PROTOCOL_F_HOST_NOTIFIER = 11, 60 60 VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD = 12, 61 + VHOST_USER_PROTOCOL_F_RESET_DEVICE = 13, 61 62 VHOST_USER_PROTOCOL_F_MAX 62 63 }; 63 64 ··· 98 99 VHOST_USER_GET_INFLIGHT_FD = 31, 99 100 VHOST_USER_SET_INFLIGHT_FD = 32, 100 101 VHOST_USER_GPU_SET_SOCKET = 33, 102 + VHOST_USER_RESET_DEVICE = 34, 101 103 VHOST_USER_MAX 102 104 } VhostUserRequest; 103 105 ··· 890 892 static int vhost_user_reset_device(struct vhost_dev *dev) 891 893 { 892 894 VhostUserMsg msg = { 893 - .hdr.request = VHOST_USER_RESET_OWNER, 894 895 .hdr.flags = VHOST_USER_VERSION, 895 896 }; 897 + 898 + msg.hdr.request = virtio_has_feature(dev->protocol_features, 899 + VHOST_USER_PROTOCOL_F_RESET_DEVICE) 900 + ? VHOST_USER_RESET_DEVICE 901 + : VHOST_USER_RESET_OWNER; 896 902 897 903 if (vhost_user_write(dev, &msg, NULL, 0) < 0) { 898 904 return -1;