diff options
author | Kevin Wolf <kwolf@redhat.com> | 2011-06-01 13:29:11 +0200 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-07-23 11:18:57 -0500 |
commit | 6e1db57b2ac9025c2443c665a0d9e78748637b26 (patch) | |
tree | cb4b73d71dccfc14737c713b07ee3bf89a3c0cf2 /hw | |
parent | 84682834eb8f654da5e03a92930d80b8ae0d3065 (diff) |
qemu-char: Print strerror message on failure
The only way for chardev drivers to communicate an error was to return a NULL
pointer, which resulted in an error message that said _that_ something went
wrong, but not _why_.
This patch changes the interface to return 0/-errno and updates
qemu_chr_open_opts to use strerror to display a more helpful error message.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r-- | hw/baum.c | 7 | ||||
-rw-r--r-- | hw/msmouse.c | 5 | ||||
-rw-r--r-- | hw/msmouse.h | 2 |
3 files changed, 8 insertions, 6 deletions
@@ -576,7 +576,7 @@ static void baum_close(struct CharDriverState *chr) qemu_free(baum); } -CharDriverState *chr_baum_init(QemuOpts *opts) +int chr_baum_init(QemuOpts *opts, CharDriverState **_chr) { BaumDriverState *baum; CharDriverState *chr; @@ -629,7 +629,8 @@ CharDriverState *chr_baum_init(QemuOpts *opts) qemu_chr_generic_open(chr); - return chr; + *_chr = chr; + return 0; fail: qemu_free_timer(baum->cellCount_timer); @@ -638,5 +639,5 @@ fail_handle: qemu_free(handle); qemu_free(chr); qemu_free(baum); - return NULL; + return -EIO; } diff --git a/hw/msmouse.c b/hw/msmouse.c index 05f893ca93..67c6cd43e0 100644 --- a/hw/msmouse.c +++ b/hw/msmouse.c @@ -64,7 +64,7 @@ static void msmouse_chr_close (struct CharDriverState *chr) qemu_free (chr); } -CharDriverState *qemu_chr_open_msmouse(QemuOpts *opts) +int qemu_chr_open_msmouse(QemuOpts *opts, CharDriverState **_chr) { CharDriverState *chr; @@ -74,5 +74,6 @@ CharDriverState *qemu_chr_open_msmouse(QemuOpts *opts) qemu_add_mouse_event_handler(msmouse_event, chr, 0, "QEMU Microsoft Mouse"); - return chr; + *_chr = chr; + return 0; } diff --git a/hw/msmouse.h b/hw/msmouse.h index 456cb21424..8b853b35bf 100644 --- a/hw/msmouse.h +++ b/hw/msmouse.h @@ -1,2 +1,2 @@ /* msmouse.c */ -CharDriverState *qemu_chr_open_msmouse(QemuOpts *opts); +int qemu_chr_open_msmouse(QemuOpts *opts, CharDriverState **_chr); |