From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPviK-0000CV-NZ for qemu-devel@nongnu.org; Mon, 23 Feb 2015 11:18:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YPviG-00058m-03 for qemu-devel@nongnu.org; Mon, 23 Feb 2015 11:18:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YPviF-00058R-H4 for qemu-devel@nongnu.org; Mon, 23 Feb 2015 11:18:27 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1NGIP3s021692 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 23 Feb 2015 11:18:26 -0500 From: John Snow Date: Mon, 23 Feb 2015 11:18:05 -0500 Message-Id: <1424708286-16483-17-git-send-email-jsnow@redhat.com> In-Reply-To: <1424708286-16483-1-git-send-email-jsnow@redhat.com> References: <1424708286-16483-1-git-send-email-jsnow@redhat.com> Subject: [Qemu-devel] [PATCH v4 16/17] ahci: Recompute cur_cmd on migrate post load List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, mst@redhat.com, armbru@redhat.com, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, John Snow 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 --- hw/ide/ahci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 56a4867..e1ae36f 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -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]; } } -- 1.9.3