From: Mark Cave-Ayland Date: Sat, 5 Mar 2022 15:55:30 +0000 (+0000) Subject: esp: recreate ESPState current_req after migration X-Git-Tag: qemu-xen-4.17.0-rc4~55^2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a7a2208862bee2bc4fe55adfd947dc4a15ad0216;p=qemu-xen.git esp: recreate ESPState current_req after migration 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 Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier Message-Id: <20220305155530.9265-11-mark.cave-ayland@ilande.co.uk> Signed-off-by: Mark Cave-Ayland --- 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