All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
To: laurent@vivier.eu, pbonzini@redhat.com, fam@euphon.net,
	qemu-devel@nongnu.org
Subject: [PATCH v3 10/10] esp: recreate ESPState current_req after migration
Date: Sat,  5 Mar 2022 15:55:30 +0000	[thread overview]
Message-ID: <20220305155530.9265-11-mark.cave-ayland@ilande.co.uk> (raw)
In-Reply-To: <20220305155530.9265-1-mark.cave-ayland@ilande.co.uk>

Since PDMA reads/writes are driven by the guest, it is possible that migration
can occur whilst a SCSIRequest is still active. Fortunately active SCSIRequests
are already included in the migration stream and restarted post migration but
this still leaves the reference in ESPState uninitialised.

Implement the SCSIBusInfo .load_request callback to obtain a reference to the
currently active SCSIRequest and use it to recreate ESPState current_req
after migration.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
---
 hw/scsi/esp.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c
index 3f7cf30fa7..2d3c649567 100644
--- a/hw/scsi/esp.c
+++ b/hw/scsi/esp.c
@@ -1349,6 +1349,15 @@ static uint64_t sysbus_esp_pdma_read(void *opaque, hwaddr addr,
     return val;
 }
 
+static void *esp_load_request(QEMUFile *f, SCSIRequest *req)
+{
+    ESPState *s = container_of(req->bus, ESPState, bus);
+
+    scsi_req_ref(req);
+    s->current_req = req;
+    return s;
+}
+
 static const MemoryRegionOps sysbus_esp_pdma_ops = {
     .read = sysbus_esp_pdma_read,
     .write = sysbus_esp_pdma_write,
@@ -1364,6 +1373,7 @@ static const struct SCSIBusInfo esp_scsi_info = {
     .max_target = ESP_MAX_DEVS,
     .max_lun = 7,
 
+    .load_request = esp_load_request,
     .transfer_data = esp_transfer_data,
     .complete = esp_command_complete,
     .cancel = esp_request_cancelled
-- 
2.20.1



      parent reply	other threads:[~2022-03-05 16:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-05 15:55 [PATCH v3 00/10] q800: migration fixes Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 01/10] macfb: add VMStateDescription for MacfbNubusState and MacfbSysBusState Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 02/10] macfb: don't use special irq_state and irq_mask variables in MacfbState Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 03/10] macfb: increase number of registers saved " Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 04/10] macfb: add VMStateDescription fields for display type and VBL timer Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 05/10] macfb: set initial value of mode control registers in macfb_common_realize() Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 06/10] esp: introduce esp_set_pdma_cb() function Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 07/10] esp: introduce esp_pdma_cb() function Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 08/10] esp: convert ESPState pdma_cb from a function pointer to an integer Mark Cave-Ayland
2022-03-05 15:55 ` [PATCH v3 09/10] esp: include the current PDMA callback in the migration stream Mark Cave-Ayland
2022-03-05 15:55 ` Mark Cave-Ayland [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220305155530.9265-11-mark.cave-ayland@ilande.co.uk \
    --to=mark.cave-ayland@ilande.co.uk \
    --cc=fam@euphon.net \
    --cc=laurent@vivier.eu \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.