diff options
author | kraxel <kraxel> | 2006-10-26 10:26:06 +0000 |
---|---|---|
committer | kraxel <kraxel> | 2006-10-26 10:26:06 +0000 |
commit | 631389c4dedf80e4d1f0abd3d4ac9db2496b2dcd (patch) | |
tree | 44dfa1f1c9a0763e3788d939843a84105fe843d5 /xd_view.c | |
parent | 07acecedbfa72393fd550115abca23ddb31e309d (diff) | |
download | xenwatch-631389c4dedf80e4d1f0abd3d4ac9db2496b2dcd.tar.gz |
xen 3.0.3 vnc support
Diffstat (limited to 'xd_view.c')
-rw-r--r-- | xd_view.c | 55 |
1 files changed, 34 insertions, 21 deletions
@@ -67,7 +67,7 @@ gtk_message(GtkMessageType type, char *fmt, ...) return rc; } -static gboolean get_domain(gint *id, char **name, char **tty, char **os) +static gboolean get_domain(gint *id, char **name, char **os, char **tty, gint *vncport) { GtkTreeSelection *sel; GtkTreeModel *model; @@ -81,8 +81,9 @@ static gboolean get_domain(gint *id, char **name, char **tty, char **os) gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, XEN_DOMS_COL_I_ID, id, XEN_DOMS_COL_S_NAME, name, - XEN_DOMS_COL_S_TERMINAL, tty, XEN_DOMS_COL_S_OSTYPE, os, + XEN_DOMS_COL_S_TERMINAL, tty, + XEN_DOMS_COL_I_VNCPORT, vncport, -1); if (0 == *id) { gtk_message(GTK_MESSAGE_ERROR, "You can't do that for Domain-0\n"); @@ -131,21 +132,16 @@ static void open_tty(gint id, char *name, char *tty) } } -static void open_vnc(gint id, char *name, char *ostype) +static void open_vnc(gint id, char *hostname, gint displayno) { - if (0 == strcmp(ostype, "hvm")) { - /* works for hvm ... */ #ifdef HAVE_VNCCLIENT - if (1) { - vnc_open("localhost", id, 0, 0); - return; - } -#endif - if (-1 == open_vnc_session("localhost", id)) - gtk_message(GTK_MESSAGE_ERROR, app_error); - } else { - gtk_message(GTK_MESSAGE_ERROR, "VNC works for hvm domains only.\n"); + if (1) { + vnc_open(hostname, displayno, 0, 0); + return; } +#endif + if (-1 == open_vnc_session(hostname, id)) + gtk_message(GTK_MESSAGE_ERROR, app_error); } /* ------------------------------------------------------------------ */ @@ -166,11 +162,11 @@ static int xmlrpc_request(char *method, ...) char reply[1024]; int sock,lhead, lbody, lreply, rc, eof; char *name, *tty, *ostype, *arg; - gint id = -1; + gint id = -1, vncport; struct timeval tv; fd_set rd; - if (!get_domain(&id, &name, &tty, &ostype)) + if (!get_domain(&id, &name, &ostype, &tty, &vncport)) return -1; /* try tcp first */ @@ -308,21 +304,33 @@ static void menu_cb_mdns(void) static void menu_cb_open_vnc(void) { char *name, *tty, *ostype; - gint id = -1; + gint id = -1, vncport, displayno = -1; - if (!get_domain(&id, &name, &tty, &ostype)) + if (!get_domain(&id, &name, &ostype, &tty, &vncport)) return; if (debug) fprintf(stderr, "%s: %d\n", __FUNCTION__, id); - open_vnc(id, name, ostype); + + if (vncport) + /* xen 3.0.3+ */ + displayno = vncport - 5900; + else if (0 == strcmp(ostype, "hvm")) { + /* xen 3.0.2 */ + displayno = id; + } + + if (-1 != displayno) + open_vnc(id, "localhost", displayno); + else + gtk_message(GTK_MESSAGE_ERROR, "Domain has no graphical display.\n"); } static void menu_cb_open_console(void) { char *name, *tty, *ostype; - gint id = -1; + gint id = -1, vncport; - if (!get_domain(&id, &name, &tty, &ostype)) + if (!get_domain(&id, &name, &ostype, &tty, &vncport)) return; if (debug) fprintf(stderr, "%s: %d\n", __FUNCTION__, id); @@ -596,6 +604,11 @@ static GtkWidget *xen_doms_create_view(XenDoms *store) "text", XEN_DOMS_COL_S_TERMINAL, NULL); + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_insert_column_with_attributes + (GTK_TREE_VIEW(view), -1, _("vnc"), renderer, + "text", XEN_DOMS_COL_I_VNCPORT, + NULL); /* fill remaining space */ renderer = gtk_cell_renderer_text_new(); |