aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi/vhost-scsi.c
diff options
context:
space:
mode:
authorNir Weiner <nir.weiner@oracle.com>2019-04-16 15:59:10 +0300
committerMichael S. Tsirkin <mst@redhat.com>2019-06-02 21:32:06 -0400
commitc6d369fd78c654fa618e382b39da850393b8a0da (patch)
treee87bf66c4636c6520439ac14a96d8a42fe62cb8a /hw/scsi/vhost-scsi.c
parentab50f22309a17c772c51931940596e707c200739 (diff)
downloadqemu-c6d369fd78c654fa618e382b39da850393b8a0da.zip
qemu-c6d369fd78c654fa618e382b39da850393b8a0da.tar.gz
qemu-c6d369fd78c654fa618e382b39da850393b8a0da.tar.bz2
vhost-scsi: The vhost backend should be stopped when the VM is not running
vhost-scsi doesn’t takes into account whether the VM is running or not in order to decide if it should start/stop vhost backend. This would lead to vhost backend still being active when VM's RunState suddenly change to stopped. An example of when this issue is encountered is when Live-Migration Pre-Copy phase completes. As in this case, VM state will be changed to stopped (while vhost backend is still active), which will result in virtio_vmstate_change() -> virtio_set_status() -> vhost_scsi_set_status() executed but vhost_scsi_set_status() will just return without stopping vhost backend. To handle this, change code to consider that vhost processing should be stopped when VM is not running. Similar to how it is done in vhost-vsock device at vhost_vsock_set_status(). Fixes: 5e9be92d7752 ("vhost-scsi: new device supporting the tcm_vhost Linux kernel module”) 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-2-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>
Diffstat (limited to 'hw/scsi/vhost-scsi.c')
-rw-r--r--hw/scsi/vhost-scsi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 61e2e57..ca42cff 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -114,6 +114,10 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val)
VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
bool start = (val & VIRTIO_CONFIG_S_DRIVER_OK);
+ if (!vdev->vm_running) {
+ start = false;
+ }
+
if (vsc->dev.started == start) {
return;
}