From patchwork Thu Apr 30 18:07:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 466669 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 0A16D14031A for ; Fri, 1 May 2015 04:10:16 +1000 (AEST) Received: from localhost ([::1]:45197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ynsuc-0003Gz-4U for incoming@patchwork.ozlabs.org; Thu, 30 Apr 2015 14:10:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ynss1-0006Mb-02 for qemu-devel@nongnu.org; Thu, 30 Apr 2015 14:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ynss0-0006yw-2D for qemu-devel@nongnu.org; Thu, 30 Apr 2015 14:07:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ynsrw-0006xM-GU; Thu, 30 Apr 2015 14:07:28 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3UI7Pcq000486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 30 Apr 2015 14:07:25 -0400 Received: from scv.usersys.redhat.com (dhcp-17-29.bos.redhat.com [10.18.17.29]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3UI7NQo015406; Thu, 30 Apr 2015 14:07:25 -0400 From: John Snow To: qemu-block@nongnu.org Date: Thu, 30 Apr 2015 14:07:14 -0400 Message-Id: <1430417242-11859-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1430417242-11859-1-git-send-email-jsnow@redhat.com> References: <1430417242-11859-1-git-send-email-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: marc.mari.barcelo@gmail.com, pbonzini@redhat.com, John Snow , qemu-devel@nongnu.org, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v3 1/9] libqos/ahci: Add halted command helpers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sometimes we want a command to halt the VM instead of complete successfully, so it'd be nice to let the libqos/ahci functions cope with such scenarios. Signed-off-by: John Snow --- tests/libqos/ahci.c | 27 +++++++++++++++++++++++++++ tests/libqos/ahci.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c index a18c12b..05dd04d 100644 --- a/tests/libqos/ahci.c +++ b/tests/libqos/ahci.c @@ -566,6 +566,33 @@ inline unsigned size_to_prdtl(unsigned bytes, unsigned bytes_per_prd) return (bytes + bytes_per_prd - 1) / bytes_per_prd; } +/* Issue a command, expecting it to fail and STOP the VM */ +AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8_t port, + uint8_t ide_cmd, uint64_t buffer, + size_t bufsize, uint64_t sector) +{ + AHCICommand *cmd; + + cmd = ahci_command_create(ide_cmd); + ahci_command_adjust(cmd, sector, buffer, bufsize, 0); + ahci_command_commit(ahci, cmd, port); + ahci_command_issue_async(ahci, cmd); + qmp_eventwait("STOP"); + + return cmd; +} + +/* Resume a previously failed command and verify/finalize */ +void ahci_guest_io_resume(AHCIQState *ahci, AHCICommand *cmd) +{ + /* Complete the command */ + qmp_async("{'execute':'cont' }"); + qmp_eventwait("RESUME"); + ahci_command_wait(ahci, cmd); + ahci_command_verify(ahci, cmd); + ahci_command_free(cmd); +} + /* Given a guest buffer address, perform an IO operation */ void ahci_guest_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd, uint64_t buffer, size_t bufsize, uint64_t sector) diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h index 40e8ca4..779e812 100644 --- a/tests/libqos/ahci.h +++ b/tests/libqos/ahci.h @@ -524,6 +524,9 @@ unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port); unsigned size_to_prdtl(unsigned bytes, unsigned bytes_per_prd); void ahci_guest_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd, uint64_t gbuffer, size_t size, uint64_t sector); +AHCICommand *ahci_guest_io_halt(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd, + uint64_t gbuffer, size_t size, uint64_t sector); +void ahci_guest_io_resume(AHCIQState *ahci, AHCICommand *cmd); void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd, void *buffer, size_t bufsize, uint64_t sector);