aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkraxel <kraxel>2008-11-04 14:22:31 +0000
committerkraxel <kraxel>2008-11-04 14:22:31 +0000
commit08b3fdf47379a3309daa8f33c501079f07de4571 (patch)
tree9ac7f659a123d0b8774664a754d6391835786982
parent5c906e533c9673d57b66f7c7ff4a40621fcaa9ab (diff)
downloadqemu-gtk-08b3fdf47379a3309daa8f33c501079f07de4571.tar.gz
- handle chardevs.
-rw-r--r--VERSION2
-rw-r--r--devices.c10
-rw-r--r--qemu-gtk.c4
-rw-r--r--tcp.c26
-rw-r--r--tcp.h1
5 files changed, 37 insertions, 6 deletions
diff --git a/VERSION b/VERSION
index 5a2a580..eb49d7c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.6
+0.7
diff --git a/devices.c b/devices.c
index d34468a..872afdd 100644
--- a/devices.c
+++ b/devices.c
@@ -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,
diff --git a/qemu-gtk.c b/qemu-gtk.c
index e4dab7c..4c456ea 100644
--- a/qemu-gtk.c
+++ b/qemu-gtk.c
@@ -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;
diff --git a/tcp.c b/tcp.c
index 454df75..50ae891 100644
--- a/tcp.c
+++ b/tcp.c
@@ -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;
diff --git a/tcp.h b/tcp.h
index 963ab83..c676d80 100644
--- a/tcp.h
+++ b/tcp.h
@@ -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);