[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name()
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name() |
Date: |
Mon, 03 May 2010 15:06:01 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
Luiz Capitulino <address@hidden> writes:
> We need to expose errno in QMP, for three reasons:
>
> 1. Some error handling functions print errno codes to the user,
> while it's debatable whether this is good or not from a user
> perspective, sometimes it's the best we can do because it's
> what system calls and libraries return
>
> 2. Some events (eg. BLOCK_IO_ERROR) will be made even more
> complete with errno information
>
> 3. It's very good for debugging
>
> So, we need a way to expose those codes in QMP. We can't just use
> the codes themselfs because they may vary between systems.
>
> The best solution I can think of is to return the string
> representation of the name. For example, EIO becomes "EIO".
>
> This is what get_errno_name() does.
>
> Signed-off-by: Luiz Capitulino <address@hidden>
> ---
> qemu-error.c | 85
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> qemu-error.h | 1 +
> 2 files changed, 86 insertions(+), 0 deletions(-)
>
> diff --git a/qemu-error.c b/qemu-error.c
> index 5a35e7c..7035417 100644
> --- a/qemu-error.c
> +++ b/qemu-error.c
> @@ -207,3 +207,88 @@ void error_report(const char *fmt, ...)
> va_end(ap);
> error_printf("\n");
> }
> +
> +/*
> + * Probably only useful for QMP
> + */
> +const char *get_errno_name(int err)
> +{
> + switch (abs(err)) {
> + case EPERM:
> + return "EPERM";
> + case ENOENT:
> + return "ENOENT";
[...]
> + case EDOM:
> + return "EDOM";
> + case ERANGE:
> + return "ERANGE";
> + case ENOMEDIUM:
> + return "ENOMEDIUM";
> + case ENOTSUP:
> + return "ENOTSUP";
> + default:
> + return "unknown";
How did you choose the codes to implement? POSIX has many more...
> + }
> +
> + abort();
> +}
> diff --git a/qemu-error.h b/qemu-error.h
> index a45609f..c5e39b5 100644
> --- a/qemu-error.h
> +++ b/qemu-error.h
> @@ -38,4 +38,5 @@ void error_print_loc(void);
> void error_set_progname(const char *argv0);
> void error_report(const char *fmt, ...) __attribute__ ((format(printf, 1,
> 2)));
>
> +const char *get_errno_name(int err);
> #endif
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(),
Markus Armbruster <=
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Anthony Liguori, 2010/05/03
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Luiz Capitulino, 2010/05/04
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Anthony Liguori, 2010/05/04
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Luiz Capitulino, 2010/05/04
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Anthony Liguori, 2010/05/04
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Luiz Capitulino, 2010/05/05
- Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Markus Armbruster, 2010/05/10
Re: [Qemu-devel] [PATCH 1/2] qemu-error: Introduce get_errno_name(), Markus Armbruster, 2010/05/10