[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 079/108] virtio-scsi: define dummy handle_output fo
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 079/108] virtio-scsi: define dummy handle_output for vhost-scsi vqs |
Date: |
Wed, 6 Aug 2014 15:39:29 -0500 |
From: Ming Lei <address@hidden>
vhost userspace needn't to handle vq's notification from guest,
so define dummy handle_output callback for all vqs of vhost-scsi.
In some corner cases(such as when handling vq's reset from VM), virtio-pci
still trys to handle pending virtio-scsi events, then object check failure
inside virtio_scsi_handle_event() for vhost-scsi can be triggered.
The issue can be reproduced by 'rmmod virtio-scsi', 'system sleep' or reboot
inside VM.
Cc: address@hidden
Cc: Anthony Liguori <address@hidden>
Cc: "Michael S. Tsirkin" <address@hidden>
Cc: Paolo Bonzini <address@hidden>
Signed-off-by: Ming Lei <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
(cherry picked from commit 91d670fbf9945ca4ecbd123affb36889e7fe8a5d)
Signed-off-by: Michael Roth <address@hidden>
---
hw/scsi/vhost-scsi.c | 8 +++++++-
hw/scsi/virtio-scsi.c | 14 +++++++++-----
include/hw/virtio/virtio-scsi.h | 7 ++++++-
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 3983a5b..9099192 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -196,6 +196,10 @@ static void vhost_scsi_set_status(VirtIODevice *vdev,
uint8_t val)
}
}
+static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
+{
+}
+
static void vhost_scsi_realize(DeviceState *dev, Error **errp)
{
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
@@ -217,7 +221,9 @@ static void vhost_scsi_realize(DeviceState *dev, Error
**errp)
}
}
- virtio_scsi_common_realize(dev, &err);
+ virtio_scsi_common_realize(dev, &err, vhost_dummy_handle_output,
+ vhost_dummy_handle_output,
+ vhost_dummy_handle_output);
if (err != NULL) {
error_propagate(errp, err);
return;
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 14261fb..d183cd0 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -605,7 +605,9 @@ static struct SCSIBusInfo virtio_scsi_scsi_info = {
.load_request = virtio_scsi_load_request,
};
-void virtio_scsi_common_realize(DeviceState *dev, Error **errp)
+void virtio_scsi_common_realize(DeviceState *dev, Error **errp,
+ HandleOutput ctrl, HandleOutput evt,
+ HandleOutput cmd)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev);
@@ -619,12 +621,12 @@ void virtio_scsi_common_realize(DeviceState *dev, Error
**errp)
s->cdb_size = VIRTIO_SCSI_CDB_SIZE;
s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
- virtio_scsi_handle_ctrl);
+ ctrl);
s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
- virtio_scsi_handle_event);
+ evt);
for (i = 0; i < s->conf.num_queues; i++) {
s->cmd_vqs[i] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE,
- virtio_scsi_handle_cmd);
+ cmd);
}
}
@@ -635,7 +637,9 @@ static void virtio_scsi_device_realize(DeviceState *dev,
Error **errp)
static int virtio_scsi_id;
Error *err = NULL;
- virtio_scsi_common_realize(dev, &err);
+ virtio_scsi_common_realize(dev, &err, virtio_scsi_handle_ctrl,
+ virtio_scsi_handle_event,
+ virtio_scsi_handle_cmd);
if (err != NULL) {
error_propagate(errp, err);
return;
diff --git a/include/hw/virtio/virtio-scsi.h b/include/hw/virtio/virtio-scsi.h
index 42b1024..e81a643 100644
--- a/include/hw/virtio/virtio-scsi.h
+++ b/include/hw/virtio/virtio-scsi.h
@@ -186,7 +186,12 @@ typedef struct {
DEFINE_PROP_BIT("param_change", _state, _feature_field,
\
VIRTIO_SCSI_F_CHANGE, true)
-void virtio_scsi_common_realize(DeviceState *dev, Error **errp);
+typedef void (*HandleOutput)(VirtIODevice *, VirtQueue *);
+
+void virtio_scsi_common_realize(DeviceState *dev, Error **errp,
+ HandleOutput ctrl, HandleOutput evt,
+ HandleOutput cmd);
+
void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp);
#endif /* _QEMU_VIRTIO_SCSI_H */
--
1.9.1
- [Qemu-stable] [PATCH 068/108] aio: fix qemu_bh_schedule() bh->ctx race condition, (continued)
- [Qemu-stable] [PATCH 068/108] aio: fix qemu_bh_schedule() bh->ctx race condition, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 069/108] qga: Fix handle fd leak in acquire_privilege(), Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 071/108] arch_init: Be sure of only one exit entry with DPRINTF() for ram_load(), Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 073/108] rdma: bug fixes, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 072/108] migration: catch unknown flags in ram_load, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 075/108] qdev: reorganize error reporting in bus_set_realized, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 076/108] qdev: recursively unrealize devices when unrealizing bus, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 077/108] scsi-disk: fix bug in scsi_block_new_request() introduced by commit 137745c, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 078/108] vhost: fix resource leak in error handling, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 080/108] usb: Fix usb-bt-dongle initialization., Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 079/108] virtio-scsi: define dummy handle_output for vhost-scsi vqs,
Michael Roth <=
- [Qemu-stable] [PATCH 083/108] coroutine-win32.c: Add noinline attribute to work around gcc bug, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 086/108] target-i386: Filter FEAT_7_0_EBX TCG features too, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 082/108] q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 084/108] hw/xtensa/xtfpga: fix FLASH mapping to boot region for KC705, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 085/108] target-i386: Make TCG feature filtering more readable, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 088/108] virtio-serial: don't migrate the config space, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 087/108] virtio-net: byteswap virtio-net header, Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 090/108] nbd: Don't validate from and len in NBD_CMD_DISC., Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 089/108] nbd: Don't export a block device with no medium., Michael Roth, 2014/08/06
- [Qemu-stable] [PATCH 074/108] hw: Consistently name Error ** objects errp, and not err, Michael Roth, 2014/08/06