From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50394) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn0j3-0004Gh-7J for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:50:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zn0j1-0007BU-RD for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:50:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35483) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zn0j1-0007BP-Iw for qemu-devel@nongnu.org; Fri, 16 Oct 2015 04:50:55 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 38B592653 for ; Fri, 16 Oct 2015 08:50:55 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-80.ams2.redhat.com [10.36.112.80]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9G8oCaj010200 for ; Fri, 16 Oct 2015 04:50:54 -0400 From: Paolo Bonzini Date: Fri, 16 Oct 2015 10:49:46 +0200 Message-Id: <1444985411-17803-25-git-send-email-pbonzini@redhat.com> In-Reply-To: <1444985411-17803-1-git-send-email-pbonzini@redhat.com> References: <1444985411-17803-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 24/49] qemu-char: cleanup HAVE_CHARDEV_* List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Move the #ifdef up into qmp_chardev_add, and avoid duplicating the code that reports unavailable backends. Split HAVE_CHARDEV_TTY into HAVE_CHARDEV_SERIAL and HAVE_CHARDEV_PTY. Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini --- qemu-char.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/qemu-char.c b/qemu-char.c index f51c0aa..7219d56 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -1196,7 +1196,8 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \ || defined(__GLIBC__) -#define HAVE_CHARDEV_TTY 1 +#define HAVE_CHARDEV_SERIAL 1 +#define HAVE_CHARDEV_PTY 1 typedef struct { GIOChannel *fd; @@ -1832,6 +1833,8 @@ static CharDriverState *qemu_chr_open_pp_fd(int fd) #else /* _WIN32 */ +#define HAVE_CHARDEV_SERIAL 1 + typedef struct { int max_size; HANDLE hcom, hrecv, hsend; @@ -4069,10 +4072,10 @@ static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp) return qemu_chr_open_fd(in, out); } +#ifdef HAVE_CHARDEV_SERIAL static CharDriverState *qmp_chardev_open_serial(ChardevHostdev *serial, Error **errp) { -#ifdef HAVE_CHARDEV_TTY int fd; fd = qmp_chardev_open_file_source(serial->device, O_RDWR, errp); @@ -4081,16 +4084,12 @@ static CharDriverState *qmp_chardev_open_serial(ChardevHostdev *serial, } qemu_set_nonblock(fd); return qemu_chr_open_tty_fd(fd); -#else - error_setg(errp, "character device backend type 'serial' not supported"); - return NULL; -#endif } +#ifdef HAVE_CHARDEV_PARPORT static CharDriverState *qmp_chardev_open_parallel(ChardevHostdev *parallel, Error **errp) { -#ifdef HAVE_CHARDEV_PARPORT int fd; fd = qmp_chardev_open_file_source(parallel->device, O_RDWR, errp); @@ -4098,11 +4097,8 @@ static CharDriverState *qmp_chardev_open_parallel(ChardevHostdev *parallel, return NULL; } return qemu_chr_open_pp_fd(fd); -#else - error_setg(errp, "character device backend type 'parallel' not supported"); - return NULL; -#endif } +#endif #endif /* WIN32 */ @@ -4227,12 +4223,16 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, case CHARDEV_BACKEND_KIND_FILE: chr = qmp_chardev_open_file(backend->file, &local_err); break; +#ifdef HAVE_CHARDEV_SERIAL case CHARDEV_BACKEND_KIND_SERIAL: chr = qmp_chardev_open_serial(backend->serial, &local_err); break; +#endif +#ifdef HAVE_CHARDEV_PARPORT case CHARDEV_BACKEND_KIND_PARALLEL: chr = qmp_chardev_open_parallel(backend->parallel, &local_err); break; +#endif case CHARDEV_BACKEND_KIND_PIPE: chr = qemu_chr_open_pipe(backend->pipe); break; @@ -4242,7 +4242,7 @@ ChardevReturn *qmp_chardev_add(const char *id, ChardevBackend *backend, case CHARDEV_BACKEND_KIND_UDP: chr = qmp_chardev_open_udp(backend->udp, &local_err); break; -#ifdef HAVE_CHARDEV_TTY +#ifdef HAVE_CHARDEV_PTY case CHARDEV_BACKEND_KIND_PTY: chr = qemu_chr_open_pty(id, ret); break; -- 2.5.0