aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-06-14 07:51:45 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-06-14 07:51:45 -0500
commit301255e6303457e10b9a42dc208f80c058004c1c (patch)
treebd9052fb0bf7e87f6e4913c9646ffcc18413fd93 /qemu-char.c
parent5f13731f8cb6aadecf214513ec810d61dc1f71dc (diff)
parentba275adba09adfc0f7ec533f1fddba678d9ba826 (diff)
downloadqemu-301255e6303457e10b9a42dc208f80c058004c1c.zip
qemu-301255e6303457e10b9a42dc208f80c058004c1c.tar.gz
qemu-301255e6303457e10b9a42dc208f80c058004c1c.tar.bz2
Merge remote-tracking branch 'mjt/trivial-patches-next' into staging
# By Michael Tokarev (4) and others # Via Michael Tokarev * mjt/trivial-patches-next: (26 commits) piix: fix some printf errors when debug is enabled cputlb: fix debug logs create qemu_openpty_raw() helper function and move it to a separate file main-loop: do not include slirp/slirp.h, use libslirp.h instead libcacard/vscclient: fix leakage of socket on error paths linux-headers: Update to v3.10-rc5 KVM: PPC: Add dummy kvm_arch_init_irq_routing() KVM: S390: Add dummy kvm_arch_init_irq_routing() KVM: ARM: Add dummy kvm_arch_init_irq_routing() ivshmem: add missing error exit(2) hw/xen: Use g_free instead of free and fix potential memory leaks target-sparc: Replace free by g_free hw/scsi: Don't increment a boolean value device tree: Fix cppcheck warning Makefile: Install qemu-img and qemu-nbd man pages only if built Unbreak -no-quit for GTK, validate SDL options gtk: implement -full-screen char/serial: serial_ioport_write: Factor out common code char/serial: Use generic Fifo8 char/serial: cosmetic fixes. ... Message-id: 1371207042-17980-1-git-send-email-mjt@msgid.tls.msk.ru Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c79
1 files changed, 5 insertions, 74 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 0b6ae95..2c3cfe6 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -76,8 +76,6 @@
#include <netinet/ip_icmp.h> // must come after ip.h
#include <netinet/udp.h>
#include <netinet/tcp.h>
-#include <net/if.h>
-#include <syslog.h>
#endif
#endif
#endif
@@ -966,63 +964,6 @@ static CharDriverState *qemu_chr_open_stdio(ChardevStdio *opts)
return chr;
}
-#ifdef __sun__
-/* Once Solaris has openpty(), this is going to be removed. */
-static int openpty(int *amaster, int *aslave, char *name,
- struct termios *termp, struct winsize *winp)
-{
- const char *slave;
- int mfd = -1, sfd = -1;
-
- *amaster = *aslave = -1;
-
- mfd = open("/dev/ptmx", O_RDWR | O_NOCTTY);
- if (mfd < 0)
- goto err;
-
- if (grantpt(mfd) == -1 || unlockpt(mfd) == -1)
- goto err;
-
- if ((slave = ptsname(mfd)) == NULL)
- goto err;
-
- if ((sfd = open(slave, O_RDONLY | O_NOCTTY)) == -1)
- goto err;
-
- if (ioctl(sfd, I_PUSH, "ptem") == -1 ||
- (termp != NULL && tcgetattr(sfd, termp) < 0))
- goto err;
-
- if (amaster)
- *amaster = mfd;
- if (aslave)
- *aslave = sfd;
- if (winp)
- ioctl(sfd, TIOCSWINSZ, winp);
-
- return 0;
-
-err:
- if (sfd != -1)
- close(sfd);
- close(mfd);
- return -1;
-}
-
-static void cfmakeraw (struct termios *termios_p)
-{
- termios_p->c_iflag &=
- ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
- termios_p->c_oflag &= ~OPOST;
- termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
- termios_p->c_cflag &= ~(CSIZE|PARENB);
- termios_p->c_cflag |= CS8;
-
- termios_p->c_cc[VMIN] = 0;
- termios_p->c_cc[VTIME] = 0;
-}
-#endif
-
#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
|| defined(__GLIBC__)
@@ -1194,34 +1135,24 @@ static CharDriverState *qemu_chr_open_pty(const char *id,
{
CharDriverState *chr;
PtyCharDriver *s;
- struct termios tty;
int master_fd, slave_fd;
-#if defined(__OpenBSD__) || defined(__DragonFly__)
char pty_name[PATH_MAX];
-#define q_ptsname(x) pty_name
-#else
- char *pty_name = NULL;
-#define q_ptsname(x) ptsname(x)
-#endif
- if (openpty(&master_fd, &slave_fd, pty_name, NULL, NULL) < 0) {
+ master_fd = qemu_openpty_raw(&slave_fd, pty_name);
+ if (master_fd < 0) {
return NULL;
}
- /* Set raw attributes on the pty. */
- tcgetattr(slave_fd, &tty);
- cfmakeraw(&tty);
- tcsetattr(slave_fd, TCSAFLUSH, &tty);
close(slave_fd);
chr = g_malloc0(sizeof(CharDriverState));
- chr->filename = g_strdup_printf("pty:%s", q_ptsname(master_fd));
- ret->pty = g_strdup(q_ptsname(master_fd));
+ chr->filename = g_strdup_printf("pty:%s", pty_name);
+ ret->pty = g_strdup(pty_name);
ret->has_pty = true;
fprintf(stderr, "char device redirected to %s (label %s)\n",
- q_ptsname(master_fd), id);
+ pty_name, id);
s = g_malloc0(sizeof(PtyCharDriver));
chr->opaque = s;