aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--GNUmakefile8
-rw-r--r--xd_view.c151
2 files changed, 121 insertions, 38 deletions
diff --git a/GNUmakefile b/GNUmakefile
index 3ed3abe..ae9b3b6 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -31,12 +31,12 @@ ifeq ($(HAVE_GTK),yes)
endif
# xenstore
-ifeq ($(XENSRC),)
- LDLIBS += -lxenstore
-else
+ifneq ($(XENSRC),)
CFLAGS += -I $(XENSRC)/dist/install/usr/include
- LDLIBS += -I $(XENSRC)/dist/install/usr/$(LIB) -lxenstore
+ LDLIBS += -I $(XENSRC)/dist/install/usr/$(LIB)
endif
+xenlog : LDLIBS += -lxenstore
+xenwatch : LDLIBS += -lxenstore -lxc
########################################################################
diff --git a/xd_view.c b/xd_view.c
index 77bab72..6544a69 100644
--- a/xd_view.c
+++ b/xd_view.c
@@ -9,6 +9,7 @@
#include <gtk/gtk.h>
#include <xs.h>
+#include <xenctrl.h>
#include "xd_store.h"
#include "xenviews.h"
@@ -66,6 +67,30 @@ gtk_message(GtkMessageType type, char *fmt, ...)
return rc;
}
+static gboolean get_domain(gint *id, char **name, char **tty, char **os)
+{
+ GtkTreeSelection *sel;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ if (!gtk_tree_selection_get_selected(sel, &model, &iter)) {
+ gtk_message(GTK_MESSAGE_ERROR, "No domain selected\n");
+ return false;
+ }
+ 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,
+ -1);
+ if (0 == *id) {
+ gtk_message(GTK_MESSAGE_ERROR, "You can't do that for Domain-0\n");
+ return false;
+ }
+ return true;
+}
+
/* ------------------------------------------------------------------ */
static gboolean have_binary(char *name)
@@ -180,6 +205,7 @@ static int attach_to_screen(gint id, char *name, char *tty)
gtk_message(GTK_MESSAGE_ERROR, "creating screen session failed\n");
return -1;
}
+ sleep(1); /* workaround for the race we have here ... */
/* ... configure ... */
rc = run_application(1, "screen", "screen",
@@ -285,6 +311,29 @@ static void detect_apps(void)
/* ------------------------------------------------------------------ */
+static int xc_action(int (*func)(int xc_handle, uint32_t domid))
+{
+ char *name, *tty, *ostype;
+ gint id = -1;
+ int xc_handle;
+ int rc;
+
+ if (!get_domain(&id, &name, &tty, &ostype))
+ return -1;
+ xc_handle = xc_interface_open();
+ if (-1 == xc_handle) {
+ gtk_message(GTK_MESSAGE_ERROR, "can't open control interface\n");
+ return -1;
+ }
+ rc = func(xc_handle, id);
+ xc_interface_close(xc_handle);
+ if (-1 == rc)
+ gtk_message(GTK_MESSAGE_ERROR, "xc action failed\n");
+ return rc;
+}
+
+/* ------------------------------------------------------------------ */
+
static void menu_cb_quit(void)
{
gtk_widget_destroy(xd_toplevel);
@@ -297,30 +346,6 @@ static void menu_cb_xenstore(void)
gtk_widget_show_all(xs_toplevel);
}
-static gboolean get_domain(gint *id, char **name, char **tty, char **os)
-{
- GtkTreeSelection *sel;
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- if (!gtk_tree_selection_get_selected(sel, &model, &iter)) {
- gtk_message(GTK_MESSAGE_ERROR, "No domain selected\n");
- return false;
- }
- 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,
- -1);
- if (0 == *id) {
- gtk_message(GTK_MESSAGE_ERROR, "You can't do that for Domain-0\n");
- return false;
- }
- return true;
-}
-
static void menu_cb_open_vnc(void)
{
char *name, *tty, *ostype;
@@ -362,6 +387,26 @@ static void menu_cb_display_screen(void)
display_screen_xterm();
}
+static void menu_cb_domain_pause(void)
+{
+ xc_action(xc_domain_pause);
+}
+
+static void menu_cb_domain_unpause(void)
+{
+ xc_action(xc_domain_unpause);
+}
+
+static void menu_cb_domain_shutdown(void)
+{
+ gtk_message(GTK_MESSAGE_INFO, "shutdown is not implemented yet\n");
+}
+
+static void menu_cb_domain_destroy(void)
+{
+ xc_action(xc_domain_destroy);
+}
+
static void menu_cb_about(void)
{
static char *comments = "xen domain monitor";
@@ -396,8 +441,8 @@ static const GtkActionEntry entries[] = {
.name = "ViewMenu",
.label = "_View",
},{
- .name = "ActionMenu",
- .label = "_Action",
+ .name = "DomainMenu",
+ .label = "_Domain",
},{
.name = "HelpMenu",
.label = "_Help",
@@ -411,33 +456,56 @@ static const GtkActionEntry entries[] = {
.tooltip = "Quit the job",
.callback = menu_cb_quit,
},{
+ .name = "About",
+ .stock_id = GTK_STOCK_ABOUT,
+ .label = "_About ...",
+ .callback = menu_cb_about,
+ },{
+
.name = "Xenstore",
.label = "_Xenstore browser",
.accelerator = "<control>X",
.callback = menu_cb_xenstore,
},{
+
.name = "OpenVNC",
- .label = "Open _VNC",
+ .label = "_VNC",
.accelerator = "<control>V",
.callback = menu_cb_open_vnc,
},{
.name = "OpenConsole",
- .label = "Open _Console",
+ .label = "_Console",
.accelerator = "<control>C",
.callback = menu_cb_open_console,
},{
.name = "AttachScreen",
- .label = "Attach to _screen",
+ .label = "_Screen",
.accelerator = "<control>S",
.callback = menu_cb_attach_screen,
},{
.name = "DisplayScreen",
- .label = "_Display screen",
+ .label = "Show screen _xterm",
.callback = menu_cb_display_screen,
+
},{
- .name = "About",
- .label = "_About ...",
- .callback = menu_cb_about,
+ .name = "DomainPause",
+ .stock_id = GTK_STOCK_MEDIA_PAUSE,
+ .label = "Pause",
+ .callback = menu_cb_domain_pause,
+ },{
+ .name = "DomainUnpause",
+ .stock_id = GTK_STOCK_MEDIA_PLAY,
+ .label = "Unpause",
+ .callback = menu_cb_domain_unpause,
+ },{
+ .name = "DomainShutdown",
+ .stock_id = GTK_STOCK_MEDIA_STOP,
+ .label = "Shutdown",
+ .callback = menu_cb_domain_shutdown,
+ },{
+ .name = "DomainDestroy",
+ .label = "Destroy",
+ .callback = menu_cb_domain_destroy,
},
};
@@ -450,11 +518,16 @@ static char ui_xml[] =
" <menu action='ViewMenu'>"
" <menuitem action='Xenstore'/>"
" </menu>"
-" <menu action='ActionMenu'>"
+" <menu action='DomainMenu'>"
" <menuitem action='OpenVNC'/>"
" <menuitem action='OpenConsole'/>"
" <menuitem action='AttachScreen'/>"
" <menuitem action='DisplayScreen'/>"
+" <separator/>"
+" <menuitem action='DomainPause'/>"
+" <menuitem action='DomainUnpause'/>"
+" <menuitem action='DomainShutdown'/>"
+" <menuitem action='DomainDestroy'/>"
" </menu>"
" <menu action='HelpMenu'>"
" <menuitem action='About'/>"
@@ -462,6 +535,16 @@ static char ui_xml[] =
" </menubar>"
" <toolbar action='ToolBar'>"
" <toolitem action='Quit'/>"
+" <separator/>"
+#if 0
+" <toolitem action='OpenVNC'/>"
+" <toolitem action='OpenConsole'/>"
+" <toolitem action='AttachScreen'/>"
+" <separator/>"
+#endif
+" <toolitem action='DomainPause'/>"
+" <toolitem action='DomainUnpause'/>"
+" <toolitem action='DomainShutdown'/>"
" </toolbar>"
"</ui>";