From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoffer Dall Subject: Re: [PATCH 7/9] Add halt() and some error codes Date: Sat, 28 Dec 2013 22:31:03 -0800 Message-ID: <20131229063103.GF13601@cbox> References: <1386175377-23086-1-git-send-email-drjones@redhat.com> <1386175377-23086-8-git-send-email-drjones@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org To: Andrew Jones Return-path: Received: from mail-pa0-f52.google.com ([209.85.220.52]:54318 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751076Ab3L2Gau (ORCPT ); Sun, 29 Dec 2013 01:30:50 -0500 Received: by mail-pa0-f52.google.com with SMTP id ld10so10679581pab.11 for ; Sat, 28 Dec 2013 22:30:50 -0800 (PST) Content-Disposition: inline In-Reply-To: <1386175377-23086-8-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Dec 04, 2013 at 05:42:55PM +0100, Andrew Jones wrote: > 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(). Looks good to me. -Christoffer > > 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 > -- > 1.8.1.4 >