From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KXCvP-0006U3-Ip for qemu-devel@nongnu.org; Sun, 24 Aug 2008 06:34:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KXCvO-0006Tf-UF for qemu-devel@nongnu.org; Sun, 24 Aug 2008 06:34:23 -0400 Received: from [199.232.76.173] (port=57888 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXCvO-0006Tc-GA for qemu-devel@nongnu.org; Sun, 24 Aug 2008 06:34:22 -0400 Received: from savannah.gnu.org ([199.232.41.3]:37066 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KXCvO-0005eX-6O for qemu-devel@nongnu.org; Sun, 24 Aug 2008 06:34:22 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KXCvM-0001Tm-P5 for qemu-devel@nongnu.org; Sun, 24 Aug 2008 10:34:20 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KXCvM-0001Th-E7 for qemu-devel@nongnu.org; Sun, 24 Aug 2008 10:34:20 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Sun, 24 Aug 2008 10:34:20 +0000 Subject: [Qemu-devel] [5079] Enable pty/tty functions for BSDs too (initial patch from Xen) Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5079 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5079 Author: blueswir1 Date: 2008-08-24 10:34:20 +0000 (Sun, 24 Aug 2008) Log Message: ----------- Enable pty/tty functions for BSDs too (initial patch from Xen) Modified Paths: -------------- trunk/vl.c Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-08-24 10:30:33 UTC (rev 5078) +++ trunk/vl.c 2008-08-24 10:34:20 UTC (rev 5079) @@ -109,6 +109,10 @@ #include "libslirp.h" #endif +#if defined(__OpenBSD__) +#include +#endif + #if defined(CONFIG_VDE) #include #endif @@ -2465,7 +2469,8 @@ } #endif -#if defined(__linux__) || defined(__sun__) +#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ + || defined(__NetBSD__) || defined(__OpenBSD__) typedef struct { int fd; @@ -2593,6 +2598,13 @@ PtyCharDriver *s; struct termios tty; int slave_fd; +#if defined(__OpenBSD__) + char pty_name[PATH_MAX]; +#define q_ptsname(x) pty_name +#else + char *pty_name = NULL; +#define q_ptsname(x) ptsname(x) +#endif chr = qemu_mallocz(sizeof(CharDriverState)); if (!chr) @@ -2603,7 +2615,7 @@ return NULL; } - if (openpty(&s->fd, &slave_fd, NULL, NULL, NULL) < 0) { + if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) { return NULL; } @@ -2612,7 +2624,7 @@ tcsetattr(slave_fd, TCSAFLUSH, &tty); close(slave_fd); - fprintf(stderr, "char device redirected to %s\n", ptsname(s->fd)); + fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd)); chr->opaque = s; chr->chr_write = pty_chr_write; @@ -3819,7 +3831,8 @@ return qemu_chr_open_pp(filename); } else #endif -#if defined(__linux__) || defined(__sun__) +#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ + || defined(__NetBSD__) || defined(__OpenBSD__) if (strstart(filename, "/dev/", NULL)) { return qemu_chr_open_tty(filename); } else