Unlike many other backends, these leave open error reporting to their caller. Because the caller doesn't know what went wrong, this results in a pretty useless error message.
Change them to report their errors themselves. Improves user-hostile messages like this one for "-chardev tty,id=foo,path=/dev/parport0" chardev: opening backend "parport" failed to qemu-system-x86_64: -chardev parport,id=foo,path=/dev/parport0: Can't open '/dev/parport0': Permission denied chardev: opening backend "parport" failed The useless "opening backend failed" message will be cleaned up shortly. Signed-off-by: Markus Armbruster <arm...@redhat.com> --- qemu-char.c | 21 ++++++++++++++++++--- 1 files changed, 18 insertions(+), 3 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index 1ff7f4b..ecbb595 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1371,14 +1371,18 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) ParallelCharDriver *drv; int fd; + if (!filename) { + error_report("parport character device requires parameter path"); + return NULL; + } + TFR(fd = qemu_open(filename, O_RDWR)); if (fd < 0) { - return NULL; + goto err; } if (ioctl(fd, PPCLAIM) < 0) { - close(fd); - return NULL; + goto err; } drv = g_malloc0(sizeof(ParallelCharDriver)); @@ -1394,6 +1398,11 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) qemu_chr_generic_open(chr); return chr; + +err: + error_report("Can't open '%s': %s", filename, strerror(errno)); + close(fd); + return NULL; } #endif /* __linux__ */ @@ -1441,8 +1450,14 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts) CharDriverState *chr; int fd; + if (!filename) { + error_report("parport character device requires parameter path"); + return NULL; + } + fd = qemu_open(filename, O_RDWR); if (fd < 0) { + error_report("Can't open '%s': %s", filename, strerror(errno)); return NULL; } -- 1.7.6.5