qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/3] vhost-scsi: The vhost device should be stopped


From: Nir Weiner
Subject: [Qemu-devel] [PATCH 1/3] vhost-scsi: The vhost device should be stopped when the VM is not running
Date: Thu, 21 Mar 2019 09:55:43 +0200

vhost-scsi doesn’t takes into account whether the vm is running or not in
order to decide if it should start/stop vhost processing.
This would lead to vhost processing still being active when VM the 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 processing 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 processing.

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 <address@hidden>
Reviewed-by: Liran Alon <address@hidden>
Signed-off-by: Nir Weiner <address@hidden>
---
 hw/scsi/vhost-scsi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 61e2e57da9d5..ca42cff1b907 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;
     }
-- 
2.17.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]