[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v3 54/62] vhost-user-scsi: start vhost when guest kicks
From: |
Michael S. Tsirkin |
Subject: |
[PULL v3 54/62] vhost-user-scsi: start vhost when guest kicks |
Date: |
Sun, 22 Oct 2023 05:25:54 -0400 |
From: Li Feng <fengli@smartx.com>
Let's keep the same behavior as vhost-user-blk.
Some old guests kick virtqueue before setting VIRTIO_CONFIG_S_DRIVER_OK.
Signed-off-by: Li Feng <fengli@smartx.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Message-Id: <20231009044735.941655-5-fengli@smartx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/scsi/vhost-user-scsi.c | 48 +++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 24c250d3f8..258fba5c69 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -92,8 +92,48 @@ static void vhost_user_scsi_set_status(VirtIODevice *vdev,
uint8_t status)
}
}
-static void vhost_dummy_handle_output(VirtIODevice *vdev, VirtQueue *vq)
+static void vhost_user_scsi_handle_output(VirtIODevice *vdev, VirtQueue *vq)
{
+ VHostUserSCSI *s = (VHostUserSCSI *)vdev;
+ DeviceState *dev = DEVICE(vdev);
+ VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
+ VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
+
+ Error *local_err = NULL;
+ int i, ret;
+
+ if (!vdev->start_on_kick) {
+ return;
+ }
+
+ if (!s->connected) {
+ return;
+ }
+
+ if (vhost_dev_is_started(&vsc->dev)) {
+ return;
+ }
+
+ /*
+ * Some guests kick before setting VIRTIO_CONFIG_S_DRIVER_OK so start
+ * vhost here instead of waiting for .set_status().
+ */
+ ret = vhost_user_scsi_start(s, &local_err);
+ if (ret < 0) {
+ error_reportf_err(local_err, "vhost-user-scsi: vhost start failed: ");
+ qemu_chr_fe_disconnect(&vs->conf.chardev);
+ return;
+ }
+
+ /* Kick right away to begin processing requests already in vring */
+ for (i = 0; i < vsc->dev.nvqs; i++) {
+ VirtQueue *kick_vq = virtio_get_queue(vdev, i);
+
+ if (!virtio_queue_get_desc_addr(vdev, i)) {
+ continue;
+ }
+ event_notifier_set(virtio_queue_get_host_notifier(kick_vq));
+ }
}
static int vhost_user_scsi_connect(DeviceState *dev, Error **errp)
@@ -220,9 +260,9 @@ static void vhost_user_scsi_realize(DeviceState *dev, Error
**errp)
return;
}
- virtio_scsi_common_realize(dev, vhost_dummy_handle_output,
- vhost_dummy_handle_output,
- vhost_dummy_handle_output, &err);
+ virtio_scsi_common_realize(dev, vhost_user_scsi_handle_output,
+ vhost_user_scsi_handle_output,
+ vhost_user_scsi_handle_output, &err);
if (err != NULL) {
error_propagate(errp, err);
return;
--
MST
- [PULL v3 44/62] hw/isa/piix: Share PIIX3's base class with PIIX4, (continued)
- [PULL v3 44/62] hw/isa/piix: Share PIIX3's base class with PIIX4, Michael S. Tsirkin, 2023/10/22
- [PULL v3 45/62] hw/isa/piix: Reuse PIIX3 base class' realize method in PIIX4, Michael S. Tsirkin, 2023/10/22
- [PULL v3 46/62] hw/isa/piix: Rename functions to be shared for PCI interrupt triggering, Michael S. Tsirkin, 2023/10/22
- [PULL v3 47/62] hw/isa/piix: Reuse PIIX3's PCI interrupt triggering in PIIX4, Michael S. Tsirkin, 2023/10/22
- [PULL v3 50/62] hw/i386/pc_piix: Make PIIX4 south bridge usable in PC machine, Michael S. Tsirkin, 2023/10/22
- [PULL v3 48/62] hw/isa/piix: Resolve duplicate code regarding PCI interrupt wiring, Michael S. Tsirkin, 2023/10/22
- [PULL v3 51/62] vhost-user-common: send get_inflight_fd once, Michael S. Tsirkin, 2023/10/22
- [PULL v3 49/62] hw/isa/piix: Implement multi-process QEMU support also for PIIX4, Michael S. Tsirkin, 2023/10/22
- [PULL v3 53/62] vhost-user-scsi: support reconnect to backend, Michael S. Tsirkin, 2023/10/22
- [PULL v3 52/62] vhost: move and rename the conn retry times, Michael S. Tsirkin, 2023/10/22
- [PULL v3 54/62] vhost-user-scsi: start vhost when guest kicks,
Michael S. Tsirkin <=
- [PULL v3 55/62] vhost-user: fix lost reconnect, Michael S. Tsirkin, 2023/10/22
- [PULL v3 56/62] hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range, Michael S. Tsirkin, 2023/10/22
- [PULL v3 57/62] tests/acpi: Allow update of DSDT.cxl, Michael S. Tsirkin, 2023/10/22
- [PULL v3 58/62] hw/cxl: Add QTG _DSM support for ACPI0017 device, Michael S. Tsirkin, 2023/10/22
- [PULL v3 60/62] vhost-user: Fix protocol feature bit conflict, Michael S. Tsirkin, 2023/10/22
- [PULL v3 59/62] tests/acpi: Update DSDT.cxl with QTG DSM, Michael S. Tsirkin, 2023/10/22
- [PULL v3 61/62] MAINTAINERS: Add include/hw/intc/i8259.h to the PC chip section, Michael S. Tsirkin, 2023/10/22
- [PULL v3 62/62] intel-iommu: Report interrupt remapping faults, fix return value, Michael S. Tsirkin, 2023/10/22
- Re: [PULL v3 00/62] virtio,pc,pci: features, cleanups, Stefan Hajnoczi, 2023/10/23