From patchwork Wed Dec 4 16:42:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 3283691 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 706E19F3AE for ; Wed, 4 Dec 2013 16:43:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5A40A2045A for ; Wed, 4 Dec 2013 16:43:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 254F920254 for ; Wed, 4 Dec 2013 16:43:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932944Ab3LDQni (ORCPT ); Wed, 4 Dec 2013 11:43:38 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28191 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932920Ab3LDQn3 (ORCPT ); Wed, 4 Dec 2013 11:43:29 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB4GhEFt021624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 4 Dec 2013 11:43:14 -0500 Received: from hawk.usersys.redhat.com.com (dhcp-1-158.brq.redhat.com [10.34.1.158]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rB4Gh3G1015485; Wed, 4 Dec 2013 11:43:13 -0500 From: Andrew Jones To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH 7/9] Add halt() and some error codes Date: Wed, 4 Dec 2013 17:42:55 +0100 Message-Id: <1386175377-23086-8-git-send-email-drjones@redhat.com> In-Reply-To: <1386175377-23086-1-git-send-email-drjones@redhat.com> References: <1386175377-23086-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define a halt function that can be implemented by the test framework for use on error paths before exit() works. Also add some error codes that can be passed to halt() in case the serial isn't working either. Then, on register inspection of the halted guest we may be able to quickly determine the problem without having to find the halt() call-site. The error codes may of course also be used with exit(). Signed-off-by: Andrew Jones --- v2: - keep the error numbers more consistent with the standard numbers --- lib/errno.h | 22 ++++++++++++++++++++++ lib/libcflat.h | 2 ++ 2 files changed, 24 insertions(+) create mode 100644 lib/errno.h diff --git a/lib/errno.h b/lib/errno.h new file mode 100644 index 0000000000000..f60845cdc61f6 --- /dev/null +++ b/lib/errno.h @@ -0,0 +1,22 @@ +#ifndef _ERRNO_H_ +#define _ERRNO_H_ +/* + * Define some error codes for the test framework's use. qemu + * exits with ((code << 1) | 1) when this framework calls + * exit(code), so we reserve codes 64 to 126. 127 is left + * for exit(-1). + * + * (Ab)use the standard E* names for syntax highlighting... + * The errno descriptions in [] are for non-standard semantics. + */ +#define EINTR (64 + 4) /* [unhandled exception] */ +#define EIO (64 + 5) /* I/O error */ +#define ENXIO (64 + 6) /* No such device or address [no serial] */ +#define ENOEXEC (64 + 8) /* Exec format error [bad flat file] */ +#define ENOMEM (64 + 12) /* Out of memory */ +#define ENODEV (64 + 19) /* No such device */ +#define EINVAL (64 + 22) /* Invalid argument */ +#define ENOSPC (64 + 28) /* No space left on device */ +#define ERANGE (64 + 34) /* Math result not representable + [divide by zero] */ +#endif diff --git a/lib/libcflat.h b/lib/libcflat.h index 140c172e77d54..a1be635ab4ee9 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -37,6 +37,7 @@ typedef _Bool bool; #define true 1 #define false 0 +extern void halt(int code); extern void exit(int code); extern unsigned long strlen(const char *buf); @@ -57,4 +58,5 @@ extern long atol(const char *ptr); #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) #define NULL ((void *)0UL) +#include "errno.h" #endif