}
void qemu_chr_add_handlers(CharDriverState *s,
- IOCanRWHandler *fd_can_read,
+ IOCanReadHandler *fd_can_read,
IOReadHandler *fd_read,
IOEventHandler *fd_event,
void *opaque)
#define MUX_BUFFER_SIZE 32 /* Must be a power of 2. */
#define MUX_BUFFER_MASK (MUX_BUFFER_SIZE - 1)
typedef struct {
- IOCanRWHandler *chr_can_read[MAX_MUX];
+ IOCanReadHandler *chr_can_read[MAX_MUX];
IOReadHandler *chr_read[MAX_MUX];
IOEventHandler *chr_event[MAX_MUX];
void *ext_opaque[MAX_MUX];
speed, parity, data_bits, stop_bits);
#endif
tcgetattr (fd, &tty);
+ if (!term_atexit_done) {
+ oldtty = tty;
+ }
#define check_speed(val) if (speed <= val) { spd = B##val; break; }
speed = speed * 10 / 11;
return 0;
}
+static void tty_exit(void)
+{
+ tcsetattr(0, TCSANOW, &oldtty);
+}
+
+static void qemu_chr_close_tty(CharDriverState *chr)
+{
+ FDCharDriver *s = chr->opaque;
+ int fd = -1;
+
+ if (s) {
+ fd = s->fd_in;
+ }
+
+ fd_chr_close(chr);
+
+ if (fd >= 0) {
+ close(fd);
+ }
+}
+
static CharDriverState *qemu_chr_open_tty(QemuOpts *opts)
{
const char *filename = qemu_opt_get(opts, "path");
return NULL;
}
chr->chr_ioctl = tty_serial_ioctl;
+ chr->chr_close = qemu_chr_close_tty;
+ if (!term_atexit_done++)
+ atexit(tty_exit);
return chr;
}
#else /* ! __linux__ && ! __sun__ */
-static CharDriverState *qemu_chr_open_pty(void)
+static CharDriverState *qemu_chr_open_pty(QemuOpts *opts)
{
return NULL;
}
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
{
- int fd = (int)chr->opaque;
+ int fd = (int)(long)chr->opaque;
uint8_t b;
switch(cmd) {
return NULL;
chr = qemu_mallocz(sizeof(CharDriverState));
- chr->opaque = (void *)fd;
+ chr->opaque = (void *)(long)fd;
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
return chr;
qemu_opt_set(opts, "backend", "udp");
if (sscanf(p, "%64[^:]:%32[^@,]%n", host, port, &pos) < 2) {
host[0] = 0;
- if (sscanf(p, ":%32[^,]%n", port, &pos) < 1) {
- fprintf(stderr, "udp #1\n");
+ if (sscanf(p, ":%32[^@,]%n", port, &pos) < 1) {
goto fail;
}
}
if (sscanf(p, "%64[^:]:%32[^,]%n", host, port, &pos) < 2) {
host[0] = 0;
if (sscanf(p, ":%32[^,]%n", port, &pos) < 1) {
- fprintf(stderr, "udp #2\n");
goto fail;
}
}
}
fail:
- fprintf(stderr, "%s: fail on \"%s\"\n", __FUNCTION__, filename);
qemu_opts_del(opts);
return NULL;
}