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

vhost-scsi: Add VMState descriptor

As preparation of enabling migration of vhost-scsi device,
define it’s VMState. Note, we keep the convention of
verifying in the pre_save() method that the vhost backend
must be stopped before attempting to save the device
state. Similar to how it is done for vhost-vsock.

Reviewed-by: Bijan Mottahedeh <bijan.mottahedeh@oracle.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Signed-off-by: Nir Weiner <nir.weiner@oracle.com>
Message-Id: <20190416125912.44001-3-liran.alon@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

authored by

Nir Weiner and committed by
Michael S. Tsirkin
4ea57425 c6d369fd

+23
+23
hw/scsi/vhost-scsi.c
··· 139 139 { 140 140 } 141 141 142 + static int vhost_scsi_pre_save(void *opaque) 143 + { 144 + VHostSCSICommon *vsc = opaque; 145 + 146 + /* At this point, backend must be stopped, otherwise 147 + * it might keep writing to memory. */ 148 + assert(!vsc->dev.started); 149 + 150 + return 0; 151 + } 152 + 153 + static const VMStateDescription vmstate_virtio_vhost_scsi = { 154 + .name = "virtio-vhost_scsi", 155 + .minimum_version_id = 1, 156 + .version_id = 1, 157 + .fields = (VMStateField[]) { 158 + VMSTATE_VIRTIO_DEVICE, 159 + VMSTATE_END_OF_LIST() 160 + }, 161 + .pre_save = vhost_scsi_pre_save, 162 + }; 163 + 142 164 static void vhost_scsi_realize(DeviceState *dev, Error **errp) 143 165 { 144 166 VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev); ··· 256 278 FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(klass); 257 279 258 280 dc->props = vhost_scsi_properties; 281 + dc->vmsd = &vmstate_virtio_vhost_scsi; 259 282 set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); 260 283 vdc->realize = vhost_scsi_realize; 261 284 vdc->unrealize = vhost_scsi_unrealize;