On 23/03/2016 11:26, Denis V. Lunev wrote: > If the migration occurs after the IDE DMA has been set up but before it > has been initiated, the state gets lost upon save/restore. Specifically, > ->dma_cb callback gets cleared, so, when the guest eventually starts bus > mastering, the DMA never completes, causing the guest to time out the > operation. > > OTOH all the infrastructure is already in place to restart the DMA if > the migration happens while the DMA is in progress. > > So reuse that infrastructure, by calling the DMA callback with an > artificial error code in pre_save if the callback is already set but > DMAING is clear. The callback then sets bus->error_status to indicate > the need for restart; however since DMAING is clear the state upon > restore will be exactly "ready forDMA" as before the save.
Could you just use the dma_cmd field to build the error_status? For extra points, make ide_handle_rw_error convert IDE_DMA_* to IDE_RETRY_* so that the callers only need to pass in IDE_RETRY_DMA (like they only need to pass in IDE_RETRY_PIO). Paolo