diff options
author | kraxel <kraxel> | 2008-11-04 14:22:31 +0000 |
---|---|---|
committer | kraxel <kraxel> | 2008-11-04 14:22:31 +0000 |
commit | 08b3fdf47379a3309daa8f33c501079f07de4571 (patch) | |
tree | 9ac7f659a123d0b8774664a754d6391835786982 | |
parent | 5c906e533c9673d57b66f7c7ff4a40621fcaa9ab (diff) | |
download | qemu-gtk-08b3fdf47379a3309daa8f33c501079f07de4571.tar.gz |
- handle chardevs.
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | devices.c | 10 | ||||
-rw-r--r-- | qemu-gtk.c | 4 | ||||
-rw-r--r-- | tcp.c | 26 | ||||
-rw-r--r-- | tcp.h | 1 |
5 files changed, 37 insertions, 6 deletions
@@ -1 +1 @@ -0.6 +0.7 @@ -422,7 +422,11 @@ void devices_parse_info_chardev(struct qemu_window *win, char *str) while (str[pos+len] == '\r' || str[pos+len] == '\n') len++; - /* filter out */ + if (debug) + fprintf(stderr, "%s: %s -- \"%s\"\n", + __FUNCTION__, name, file); + + /* filter out stuff */ if (strcmp(name, "monitor") == 0) continue; if (strcmp(name, "gdb") == 0) @@ -438,10 +442,6 @@ void devices_parse_info_chardev(struct qemu_window *win, char *str) win->sercon = strdup(file); } - if (1 || debug) - fprintf(stderr, "%s: %s -- \"%s\"\n", - __FUNCTION__, name, file); - snprintf(label, sizeof(label), "%s", name); snprintf(action, sizeof(action), "%s_%s", name, file); add_entry(win, win->chardev.ag, menu_cb_open_term, &i_xml, &i_pos, @@ -519,6 +519,10 @@ int conn_init(struct qemu_conn *conn, char *name, char *dest) conn->handle = unix_connect(path); } else if (1 == sscanf(dest, "pipe:%255s", path)) { conn->handle = pipe_connect(path); + } else if (1 == sscanf(dest, "pty:%255s", path)) { + conn->handle = cdev_connect(path); + } else if (1 == sscanf(dest, "pts:%255s", path)) { + conn->handle = cdev_connect(path); } else { fprintf(stderr, "can't parse \"%s\"\n", dest); conn->handle = -1; @@ -179,6 +179,32 @@ int unix_connect(char *path) return sock; } +int cdev_connect(char *path) +{ + struct stat st; + char *opts; + int fd; + + opts = strchr(path,','); + if (opts) { + *opts = 0; + opts++; + } + + fd = open(path, O_RDWR); + if (fd == -1) { + fprintf(stderr, "open %s: %s\n", path, strerror(errno)); + return -1; + } + fstat(fd, &st); + if (!S_ISCHR(st.st_mode)) { + fprintf(stderr, "not a character device: %s\n", path); + close(fd); + return -1; + } + return fd; +} + int pipe_connect(char *path) { struct stat st; @@ -13,3 +13,4 @@ int tcp_listen(struct addrinfo *ai, char *addr, char *port); int unix_connect(char *path); int pipe_connect(char *path); +int cdev_connect(char *path); |