summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-08-24 10:34:20 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2008-08-24 10:34:20 +0000
commit9892fbfb24009f98c60ce50155e7e6c5d7aa6b7b (patch)
tree3acdbba32874c48a0ff1a418e22bcf929bdb9186
parenta10ea30b11e672abf676b4fbaabe29e95589c07d (diff)
downloadqemu-9892fbfb24009f98c60ce50155e7e6c5d7aa6b7b.tar.gz
qemu-9892fbfb24009f98c60ce50155e7e6c5d7aa6b7b.tar.bz2
qemu-9892fbfb24009f98c60ce50155e7e6c5d7aa6b7b.zip
Enable pty/tty functions for BSDs too (initial patch from Xen)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5079 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--vl.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/vl.c b/vl.c
index 7ca8420f04..245177a52c 100644
--- a/vl.c
+++ b/vl.c
@@ -109,6 +109,10 @@ int inet_aton(const char *cp, struct in_addr *ia);
#include "libslirp.h"
#endif
+#if defined(__OpenBSD__)
+#include <util.h>
+#endif
+
#if defined(CONFIG_VDE)
#include <libvdeplug.h>
#endif
@@ -2465,7 +2469,8 @@ void cfmakeraw (struct termios *termios_p)
}
#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 @@ static CharDriverState *qemu_chr_open_pty(void)
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 @@ static CharDriverState *qemu_chr_open_pty(void)
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 @@ static CharDriverState *qemu_chr_open_pty(void)
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 @@ CharDriverState *qemu_chr_open(const char *filename)
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