[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 72/83] vhost-user-common: send get_inflight_fd once
|
From: |
Michael S. Tsirkin |
|
Subject: |
[PULL 72/83] vhost-user-common: send get_inflight_fd once |
|
Date: |
Wed, 18 Oct 2023 11:58:51 -0400 |
From: Li Feng <fengli@smartx.com>
Currently the get_inflight_fd will be sent every time the device is started, and
the backend will allocate shared memory to save the inflight state. If the
backend finds that it receives the second get_inflight_fd, it will release the
previous shared memory, which breaks inflight working logic.
This patch is a preparation for the following patches.
Signed-off-by: Li Feng <fengli@smartx.com>
Reviewed-by: Raphael Norwitz <raphael.norwitz@nutanix.com>
Message-Id: <20231009044735.941655-2-fengli@smartx.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/scsi/vhost-scsi-common.c | 37 ++++++++++++++++++-------------------
1 file changed, 18 insertions(+), 19 deletions(-)
diff --git a/hw/scsi/vhost-scsi-common.c b/hw/scsi/vhost-scsi-common.c
index a06f01af26..a61cd0e907 100644
--- a/hw/scsi/vhost-scsi-common.c
+++ b/hw/scsi/vhost-scsi-common.c
@@ -52,20 +52,28 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc)
vsc->dev.acked_features = vdev->guest_features;
- assert(vsc->inflight == NULL);
- vsc->inflight = g_new0(struct vhost_inflight, 1);
- ret = vhost_dev_get_inflight(&vsc->dev,
- vs->conf.virtqueue_size,
- vsc->inflight);
+ ret = vhost_dev_prepare_inflight(&vsc->dev, vdev);
if (ret < 0) {
- error_report("Error get inflight: %d", -ret);
+ error_report("Error setting inflight format: %d", -ret);
goto err_guest_notifiers;
}
- ret = vhost_dev_set_inflight(&vsc->dev, vsc->inflight);
- if (ret < 0) {
- error_report("Error set inflight: %d", -ret);
- goto err_guest_notifiers;
+ if (vsc->inflight) {
+ if (!vsc->inflight->addr) {
+ ret = vhost_dev_get_inflight(&vsc->dev,
+ vs->conf.virtqueue_size,
+ vsc->inflight);
+ if (ret < 0) {
+ error_report("Error getting inflight: %d", -ret);
+ goto err_guest_notifiers;
+ }
+ }
+
+ ret = vhost_dev_set_inflight(&vsc->dev, vsc->inflight);
+ if (ret < 0) {
+ error_report("Error setting inflight: %d", -ret);
+ goto err_guest_notifiers;
+ }
}
ret = vhost_dev_start(&vsc->dev, vdev, true);
@@ -85,9 +93,6 @@ int vhost_scsi_common_start(VHostSCSICommon *vsc)
return ret;
err_guest_notifiers:
- g_free(vsc->inflight);
- vsc->inflight = NULL;
-
k->set_guest_notifiers(qbus->parent, vsc->dev.nvqs, false);
err_host_notifiers:
vhost_dev_disable_notifiers(&vsc->dev, vdev);
@@ -111,12 +116,6 @@ void vhost_scsi_common_stop(VHostSCSICommon *vsc)
}
assert(ret >= 0);
- if (vsc->inflight) {
- vhost_dev_free_inflight(vsc->inflight);
- g_free(vsc->inflight);
- vsc->inflight = NULL;
- }
-
vhost_dev_disable_notifiers(&vsc->dev, vdev);
}
--
MST
- [PULL 55/83] hw/isa/piix3: Create power management controller in host device, (continued)
- [PULL 55/83] hw/isa/piix3: Create power management controller in host device, Michael S. Tsirkin, 2023/10/18
- [PULL 64/83] hw/isa/piix: Harmonize names of reset control memory regions, Michael S. Tsirkin, 2023/10/18
- [PULL 66/83] hw/isa/piix: Reuse PIIX3 base class' realize method in PIIX4, Michael S. Tsirkin, 2023/10/18
- [PULL 67/83] hw/isa/piix: Rename functions to be shared for PCI interrupt triggering, Michael S. Tsirkin, 2023/10/18
- [PULL 65/83] hw/isa/piix: Share PIIX3's base class with PIIX4, Michael S. Tsirkin, 2023/10/18
- [PULL 69/83] hw/isa/piix: Resolve duplicate code regarding PCI interrupt wiring, Michael S. Tsirkin, 2023/10/18
- [PULL 63/83] hw/isa/piix: Allow for optional PIT creation in PIIX3, Michael S. Tsirkin, 2023/10/18
- [PULL 71/83] hw/i386/pc_piix: Make PIIX4 south bridge usable in PC machine, Michael S. Tsirkin, 2023/10/18
- [PULL 60/83] hw/isa/piix4: Reuse struct PIIXState from PIIX3, Michael S. Tsirkin, 2023/10/18
- [PULL 68/83] hw/isa/piix: Reuse PIIX3's PCI interrupt triggering in PIIX4, Michael S. Tsirkin, 2023/10/18
- [PULL 72/83] vhost-user-common: send get_inflight_fd once,
Michael S. Tsirkin <=
- [PULL 74/83] vhost-user-scsi: support reconnect to backend, Michael S. Tsirkin, 2023/10/18
- [PULL 73/83] vhost: move and rename the conn retry times, Michael S. Tsirkin, 2023/10/18
- [PULL 75/83] vhost-user-scsi: start vhost when guest kicks, Michael S. Tsirkin, 2023/10/18
- [PULL 76/83] vhost-user: fix lost reconnect, Michael S. Tsirkin, 2023/10/18
- [PULL 77/83] hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range, Michael S. Tsirkin, 2023/10/18
- [PULL 70/83] hw/isa/piix: Implement multi-process QEMU support also for PIIX4, Michael S. Tsirkin, 2023/10/18
- [PULL 79/83] hw/cxl: Add QTG _DSM support for ACPI0017 device, Michael S. Tsirkin, 2023/10/18
- [PULL 78/83] tests/acpi: Allow update of DSDT.cxl, Michael S. Tsirkin, 2023/10/18
- [PULL 80/83] tests/acpi: Update DSDT.cxl with QTG DSM, Michael S. Tsirkin, 2023/10/18
- [PULL 82/83] MAINTAINERS: Add include/hw/intc/i8259.h to the PC chip section, Michael S. Tsirkin, 2023/10/18