[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string()
From: |
Luiz Capitulino |
Subject: |
[Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string() |
Date: |
Tue, 20 Apr 2010 18:09:37 -0300 |
There are error handling functions in QEMU which print errno codes
to the user. While it's debatable if this is good from a user
perspective, sometimes it's the best you can do because it's what
system calls return and this is also useful for debugging.
So, we need a way to expose those codes in QMP. We can't use the
codes themselfs because they may vary between systems.
The best solution I can think of is returning the string
representation of the name. For example, EIO becomes "EIO".
This is what get_errno_string() does.
Signed-off-by: Luiz Capitulino <address@hidden>
---
qemu-error.c | 25 +++++++++++++++++++++++++
qemu-error.h | 1 +
2 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/qemu-error.c b/qemu-error.c
index 5a35e7c..55ce133 100644
--- a/qemu-error.c
+++ b/qemu-error.c
@@ -207,3 +207,28 @@ void error_report(const char *fmt, ...)
va_end(ap);
error_printf("\n");
}
+
+/*
+ * This is probably only useful for QMP
+ */
+const char *get_errno_string(int err)
+{
+ assert(err < 0);
+
+ switch (err) {
+ case -EINVAL:
+ return "EINVAL";
+ case -EIO:
+ return "EIO";
+ case -ENOENT:
+ return "ENOENT";
+ case -ENOMEDIUM:
+ return "ENOMEDIUM";
+ case -ENOTSUP:
+ return "ENOTSUP";
+ default:
+ return "unknown";
+ }
+
+ abort();
+}
diff --git a/qemu-error.h b/qemu-error.h
index a45609f..bf2b890 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_string(int err);
#endif
--
1.7.1.rc1.12.ga6018
- [Qemu-devel] [RFC 00/22]: QMP: Convert savevm/loadvm/delvm, Luiz Capitulino, 2010/04/20
- [Qemu-devel] [PATCH 01/22] QMP: Introduce RESUME event, Luiz Capitulino, 2010/04/20
- [Qemu-devel] [PATCH 02/22] savevm: Don't check the return of qemu_fopen_bdrv(), Luiz Capitulino, 2010/04/20
- [Qemu-devel] [PATCH 03/22] savevm: Introduce delete_snapshot() and use it, Luiz Capitulino, 2010/04/20
- [Qemu-devel] [PATCH 05/22] savevm: load_vmstate(): Return 'ret' on error, Luiz Capitulino, 2010/04/20
- [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(),
Luiz Capitulino <=
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), Daniel P. Berrange, 2010/04/21
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), Kevin Wolf, 2010/04/21
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), malc, 2010/04/21
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), Luiz Capitulino, 2010/04/21
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), Daniel P. Berrange, 2010/04/21
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), Luiz Capitulino, 2010/04/21
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), Markus Armbruster, 2010/04/21
- Re: [Qemu-devel] [PATCH 07/22] qemu-error: Introduce get_errno_string(), Luiz Capitulino, 2010/04/22
[Qemu-devel] [PATCH 06/22] savevm: load_vmstate(): Improve error check, Luiz Capitulino, 2010/04/20
[Qemu-devel] [PATCH 04/22] savevm: do_loadvm(): Always resume the VM, Luiz Capitulino, 2010/04/20