aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2011-06-01 13:29:11 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2011-07-23 11:18:57 -0500
commit6e1db57b2ac9025c2443c665a0d9e78748637b26 (patch)
treecb4b73d71dccfc14737c713b07ee3bf89a3c0cf2 /spice-qemu-char.c
parentqemu-timer: change unix timer to dynticks (diff)
downloadqemu-kvm-6e1db57b2ac9025c2443c665a0d9e78748637b26.tar.gz
qemu-kvm-6e1db57b2ac9025c2443c665a0d9e78748637b26.tar.bz2
qemu-kvm-6e1db57b2ac9025c2443c665a0d9e78748637b26.zip
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 'spice-qemu-char.c')
-rw-r--r--spice-qemu-char.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
index 605c24123..95bf6b65d 100644
--- a/spice-qemu-char.c
+++ b/spice-qemu-char.c
@@ -159,7 +159,7 @@ static void print_allowed_subtypes(void)
fprintf(stderr, "\n");
}
-CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
+int qemu_chr_open_spice(QemuOpts *opts, CharDriverState **_chr)
{
CharDriverState *chr;
SpiceCharDriver *s;
@@ -171,7 +171,7 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
if (name == NULL) {
fprintf(stderr, "spice-qemu-char: missing name parameter\n");
print_allowed_subtypes();
- return NULL;
+ return -EINVAL;
}
for(;*psubtype != NULL; ++psubtype) {
if (strcmp(name, *psubtype) == 0) {
@@ -182,7 +182,7 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
if (subtype == NULL) {
fprintf(stderr, "spice-qemu-char: unsupported name\n");
print_allowed_subtypes();
- return NULL;
+ return -EINVAL;
}
chr = qemu_mallocz(sizeof(CharDriverState));
@@ -199,5 +199,6 @@ CharDriverState *qemu_chr_open_spice(QemuOpts *opts)
qemu_chr_generic_open(chr);
- return chr;
+ *_chr = chr;
+ return 0;
}