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

vhost-user-scsi: reset the device if supported

If the vhost-user-scsi backend supports the VHOST_USER_F_RESET_DEVICE
protocol feature, then the device can be reset when requested.

If this feature is not supported, do not try a reset as this will send
a VHOST_USER_RESET_OWNER that the backend is not expecting,
potentially putting into an inoperable state.

Signed-off-by: David Vrabel <david.vrabel@nutanix.com>
Signed-off-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Message-Id: <1572385083-5254-3-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
f0472439 d91d57e6

+24
+24
hw/scsi/vhost-user-scsi.c
··· 39 39 VHOST_INVALID_FEATURE_BIT 40 40 }; 41 41 42 + enum VhostUserProtocolFeature { 43 + VHOST_USER_PROTOCOL_F_RESET_DEVICE = 13, 44 + }; 45 + 42 46 static void vhost_user_scsi_set_status(VirtIODevice *vdev, uint8_t status) 43 47 { 44 48 VHostUserSCSI *s = (VHostUserSCSI *)vdev; ··· 59 63 } 60 64 } else { 61 65 vhost_scsi_common_stop(vsc); 66 + } 67 + } 68 + 69 + static void vhost_user_scsi_reset(VirtIODevice *vdev) 70 + { 71 + VHostSCSICommon *vsc = VHOST_SCSI_COMMON(vdev); 72 + struct vhost_dev *dev = &vsc->dev; 73 + 74 + /* 75 + * Historically, reset was not implemented so only reset devices 76 + * that are expecting it. 77 + */ 78 + if (!virtio_has_feature(dev->protocol_features, 79 + VHOST_USER_PROTOCOL_F_RESET_DEVICE)) { 80 + return; 81 + } 82 + 83 + if (dev->vhost_ops->vhost_reset_device) { 84 + dev->vhost_ops->vhost_reset_device(dev); 62 85 } 63 86 } 64 87 ··· 182 205 vdc->get_features = vhost_scsi_common_get_features; 183 206 vdc->set_config = vhost_scsi_common_set_config; 184 207 vdc->set_status = vhost_user_scsi_set_status; 208 + vdc->reset = vhost_user_scsi_reset; 185 209 fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path; 186 210 } 187 211