Commit 9892fbfb24009f98c60ce50155e7e6c5d7aa6b7b
1 parent
a10ea30b
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
Showing
1 changed file
with
17 additions
and
4 deletions
vl.c
| @@ -109,6 +109,10 @@ int inet_aton(const char *cp, struct in_addr *ia); | @@ -109,6 +109,10 @@ int inet_aton(const char *cp, struct in_addr *ia); | ||
| 109 | #include "libslirp.h" | 109 | #include "libslirp.h" |
| 110 | #endif | 110 | #endif |
| 111 | 111 | ||
| 112 | +#if defined(__OpenBSD__) | ||
| 113 | +#include <util.h> | ||
| 114 | +#endif | ||
| 115 | + | ||
| 112 | #if defined(CONFIG_VDE) | 116 | #if defined(CONFIG_VDE) |
| 113 | #include <libvdeplug.h> | 117 | #include <libvdeplug.h> |
| 114 | #endif | 118 | #endif |
| @@ -2465,7 +2469,8 @@ void cfmakeraw (struct termios *termios_p) | @@ -2465,7 +2469,8 @@ void cfmakeraw (struct termios *termios_p) | ||
| 2465 | } | 2469 | } |
| 2466 | #endif | 2470 | #endif |
| 2467 | 2471 | ||
| 2468 | -#if defined(__linux__) || defined(__sun__) | 2472 | +#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ |
| 2473 | + || defined(__NetBSD__) || defined(__OpenBSD__) | ||
| 2469 | 2474 | ||
| 2470 | typedef struct { | 2475 | typedef struct { |
| 2471 | int fd; | 2476 | int fd; |
| @@ -2593,6 +2598,13 @@ static CharDriverState *qemu_chr_open_pty(void) | @@ -2593,6 +2598,13 @@ static CharDriverState *qemu_chr_open_pty(void) | ||
| 2593 | PtyCharDriver *s; | 2598 | PtyCharDriver *s; |
| 2594 | struct termios tty; | 2599 | struct termios tty; |
| 2595 | int slave_fd; | 2600 | int slave_fd; |
| 2601 | +#if defined(__OpenBSD__) | ||
| 2602 | + char pty_name[PATH_MAX]; | ||
| 2603 | +#define q_ptsname(x) pty_name | ||
| 2604 | +#else | ||
| 2605 | + char *pty_name = NULL; | ||
| 2606 | +#define q_ptsname(x) ptsname(x) | ||
| 2607 | +#endif | ||
| 2596 | 2608 | ||
| 2597 | chr = qemu_mallocz(sizeof(CharDriverState)); | 2609 | chr = qemu_mallocz(sizeof(CharDriverState)); |
| 2598 | if (!chr) | 2610 | if (!chr) |
| @@ -2603,7 +2615,7 @@ static CharDriverState *qemu_chr_open_pty(void) | @@ -2603,7 +2615,7 @@ static CharDriverState *qemu_chr_open_pty(void) | ||
| 2603 | return NULL; | 2615 | return NULL; |
| 2604 | } | 2616 | } |
| 2605 | 2617 | ||
| 2606 | - if (openpty(&s->fd, &slave_fd, NULL, NULL, NULL) < 0) { | 2618 | + if (openpty(&s->fd, &slave_fd, pty_name, NULL, NULL) < 0) { |
| 2607 | return NULL; | 2619 | return NULL; |
| 2608 | } | 2620 | } |
| 2609 | 2621 | ||
| @@ -2612,7 +2624,7 @@ static CharDriverState *qemu_chr_open_pty(void) | @@ -2612,7 +2624,7 @@ static CharDriverState *qemu_chr_open_pty(void) | ||
| 2612 | tcsetattr(slave_fd, TCSAFLUSH, &tty); | 2624 | tcsetattr(slave_fd, TCSAFLUSH, &tty); |
| 2613 | close(slave_fd); | 2625 | close(slave_fd); |
| 2614 | 2626 | ||
| 2615 | - fprintf(stderr, "char device redirected to %s\n", ptsname(s->fd)); | 2627 | + fprintf(stderr, "char device redirected to %s\n", q_ptsname(s->fd)); |
| 2616 | 2628 | ||
| 2617 | chr->opaque = s; | 2629 | chr->opaque = s; |
| 2618 | chr->chr_write = pty_chr_write; | 2630 | chr->chr_write = pty_chr_write; |
| @@ -3819,7 +3831,8 @@ CharDriverState *qemu_chr_open(const char *filename) | @@ -3819,7 +3831,8 @@ CharDriverState *qemu_chr_open(const char *filename) | ||
| 3819 | return qemu_chr_open_pp(filename); | 3831 | return qemu_chr_open_pp(filename); |
| 3820 | } else | 3832 | } else |
| 3821 | #endif | 3833 | #endif |
| 3822 | -#if defined(__linux__) || defined(__sun__) | 3834 | +#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ |
| 3835 | + || defined(__NetBSD__) || defined(__OpenBSD__) | ||
| 3823 | if (strstart(filename, "/dev/", NULL)) { | 3836 | if (strstart(filename, "/dev/", NULL)) { |
| 3824 | return qemu_chr_open_tty(filename); | 3837 | return qemu_chr_open_tty(filename); |
| 3825 | } else | 3838 | } else |