]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
ahci: Recompute cur_cmd on migrate post load
authorJohn Snow <jsnow@redhat.com>
Mon, 23 Feb 2015 16:18:05 +0000 (11:18 -0500)
committerKevin Wolf <kwolf@redhat.com>
Tue, 10 Mar 2015 13:02:23 +0000 (14:02 +0100)
When the AHCI HBA device is migrated, all of the information that
led to the request being created is stored in the AHCIDevice
structures, except for pointers into guest data where return
information needs to be stored.

The "cur_cmd" field is usually responsible for this.

To rebuild the cur_cmd pointer post-migration, we can utilize
the busy_slot index to figure out where the command header
we are still processing is.

This allows a machine in a halted state from rerror=stop or
werror=stop to be migrated and resume operations without issue.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1424708286-16483-17-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/ide/ahci.c

index 56a4867cd09ccf8679c56b0a8b0ef2948c928644..e1ae36f7cd51f6a252c4afe272a336a6a9602d04 100644 (file)
@@ -1376,6 +1376,13 @@ static int ahci_state_post_load(void *opaque, int version_id)
          */
         if (ad->busy_slot == -1) {
             check_cmd(s, i);
+        } else {
+            /* We are in the middle of a command, and may need to access
+             * the command header in guest memory again. */
+            if (ad->busy_slot < 0 || ad->busy_slot >= AHCI_MAX_CMDS) {
+                return -1;
+            }
+            ad->cur_cmd = &((AHCICmdHdr *)ad->lst)[ad->busy_slot];
         }
     }