aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-08-16 09:42:48 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-08-16 09:42:48 +0200
commite2add4678330ac78666ab572f6cf21705aec9300 (patch)
tree0ae7d4927b403229232cac3deafe7c9d01d7b361
parentbb27e16b7fe2eebb8ca2001152e82eb1fe00f2df (diff)
downloadvconsole-e2add4678330ac78666ab572f6cf21705aec9300.tar.gz
add pause/unpause
-rw-r--r--domain.c19
-rw-r--r--vconsole.c28
-rw-r--r--vconsole.h2
3 files changed, 45 insertions, 4 deletions
diff --git a/domain.c b/domain.c
index 80e7874..b1ce595 100644
--- a/domain.c
+++ b/domain.c
@@ -179,8 +179,25 @@ void domain_start(struct vconsole_domain *dom)
virDomainPtr d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid);
virDomainGetInfo(d, &dom->info);
- if (dom->info.state == VIR_DOMAIN_SHUTOFF) {
+ switch (dom->info.state) {
+ case VIR_DOMAIN_SHUTOFF:
virDomainCreate(d);
+ break;
+ case VIR_DOMAIN_PAUSED:
+ virDomainResume(d);
+ break;
+ }
+}
+
+void domain_pause(struct vconsole_domain *dom)
+{
+ virDomainPtr d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid);
+
+ virDomainGetInfo(d, &dom->info);
+ switch (dom->info.state) {
+ case VIR_DOMAIN_RUNNING:
+ virDomainSuspend(d);
+ break;
}
}
diff --git a/vconsole.c b/vconsole.c
index ba5a1e8..6a93ff7 100644
--- a/vconsole.c
+++ b/vconsole.c
@@ -213,11 +213,16 @@ static void menu_cb_fullscreen(GtkToggleAction *action, gpointer userdata)
static struct vconsole_domain *find_guest(struct vconsole_window *win)
{
- struct vconsole_domain *dom;
+ struct vconsole_domain *dom = NULL;
+ GtkTreeSelection *select;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
if (gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)) == 0) {
- fprintf(stderr, "%s: [ TODO ] figure list selected guest\n", __func__);
- dom = NULL;
+ select = gtk_tree_view_get_selection(GTK_TREE_VIEW(win->tree));
+ if (gtk_tree_selection_get_selected(select, &model, &iter)) {
+ gtk_tree_model_get(model, &iter, DPTR_COL, &dom, -1);
+ }
} else {
dom = domain_find_current_tab(win);
}
@@ -233,6 +238,15 @@ static void menu_cb_vm_run(GtkAction *action, void *data)
domain_start(dom);
}
+static void menu_cb_vm_pause(GtkAction *action, void *data)
+{
+ struct vconsole_window *win = data;
+ struct vconsole_domain *dom = find_guest(win);
+
+ if (dom)
+ domain_pause(dom);
+}
+
static void menu_cb_about(GtkAction *action, gpointer userdata)
{
static char *comments = "virtual machine console";
@@ -325,6 +339,12 @@ static const GtkActionEntry entries[] = {
.label = "Start",
.tooltip = "Start Guest",
.callback = G_CALLBACK(menu_cb_vm_run),
+ },{
+ .name = "GuestPause",
+ .stock_id = GTK_STOCK_MEDIA_PAUSE,
+ .label = "Pause",
+ .tooltip = "Pause Guest",
+ .callback = G_CALLBACK(menu_cb_vm_pause),
},{
/* --- help menu --- */
@@ -370,6 +390,7 @@ static char ui_xml[] =
" </menu>\n"
" <menu action='GuestMenu'>\n"
" <menuitem action='GuestRun'/>\n"
+" <menuitem action='GuestPause'/>\n"
" </menu>\n"
" <menu action='HelpMenu'>\n"
" <menuitem action='About'/>\n"
@@ -379,6 +400,7 @@ static char ui_xml[] =
" <toolitem action='CloseTab'/>\n"
" <separator/>\n"
" <toolitem action='GuestRun'/>\n"
+" <toolitem action='GuestPause'/>\n"
" </toolbar>\n"
"</ui>\n";
diff --git a/vconsole.h b/vconsole.h
index 0125dfc..be460dc 100644
--- a/vconsole.h
+++ b/vconsole.h
@@ -76,6 +76,8 @@ struct vconsole_domain {
};
void domain_start(struct vconsole_domain *dom);
+void domain_pause(struct vconsole_domain *dom);
+
void domain_update(struct vconsole_connect *conn,
virDomainPtr d, virDomainEventType event);
void domain_activate(struct vconsole_domain *dom);