From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyUAo-0000C2-5e for qemu-devel@nongnu.org; Mon, 06 Aug 2012 16:45:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SyUAm-0004dc-LV for qemu-devel@nongnu.org; Mon, 06 Aug 2012 16:45:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SyUAm-0004dH-Ce for qemu-devel@nongnu.org; Mon, 06 Aug 2012 16:45:08 -0400 From: Kevin Wolf Date: Mon, 6 Aug 2012 22:44:48 +0200 Message-Id: <1344285891-6578-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1344285891-6578-1-git-send-email-kwolf@redhat.com> References: <1344285891-6578-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 09/12] qemu-io: add "abort" command to simulate program crash List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Stefan Hajnoczi Avoiding data loss and corruption is the top requirement for image file formats. The qemu-io "abort" command makes it possible to simulate program crashes and does not give the image format a chance to cleanly shut down. This command is useful for data integrity test cases. Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- qemu-io.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-) diff --git a/qemu-io.c b/qemu-io.c index 8f3b94b..d0f4fb7 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -1652,6 +1652,17 @@ static const cmdinfo_t map_cmd = { .oneline = "prints the allocated areas of a file", }; +static int abort_f(int argc, char **argv) +{ + abort(); +} + +static const cmdinfo_t abort_cmd = { + .name = "abort", + .cfunc = abort_f, + .flags = CMD_NOFILE_OK, + .oneline = "simulate a program crash using abort(3)", +}; static int close_f(int argc, char **argv) { @@ -1905,6 +1916,7 @@ int main(int argc, char **argv) add_command(&discard_cmd); add_command(&alloc_cmd); add_command(&map_cmd); + add_command(&abort_cmd); add_args_command(init_args_command); add_check_command(init_check_command); -- 1.7.6.5