aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-08-16 09:58:07 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-08-16 09:58:07 +0200
commitfe94f363725052b4157cf595a12e75f64e1289df (patch)
tree31734a9408f5955c021df867f9599aeef40b73dc
parente2add4678330ac78666ab572f6cf21705aec9300 (diff)
downloadvconsole-fe94f363725052b4157cf595a12e75f64e1289df.tar.gz
more guest actions
-rw-r--r--domain.c51
-rw-r--r--vconsole.c50
-rw-r--r--vconsole.h3
3 files changed, 102 insertions, 2 deletions
diff --git a/domain.c b/domain.c
index b1ce595..0ff2c26 100644
--- a/domain.c
+++ b/domain.c
@@ -186,6 +186,9 @@ void domain_start(struct vconsole_domain *dom)
case VIR_DOMAIN_PAUSED:
virDomainResume(d);
break;
+ default:
+ fprintf(stderr, "%s: invalid guest state: %s\n",
+ __func__, domain_state_name(dom));
}
}
@@ -198,6 +201,54 @@ void domain_pause(struct vconsole_domain *dom)
case VIR_DOMAIN_RUNNING:
virDomainSuspend(d);
break;
+ default:
+ fprintf(stderr, "%s: invalid guest state: %s\n",
+ __func__, domain_state_name(dom));
+ }
+}
+
+void domain_reboot(struct vconsole_domain *dom)
+{
+ virDomainPtr d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid);
+
+ virDomainGetInfo(d, &dom->info);
+ switch (dom->info.state) {
+ case VIR_DOMAIN_RUNNING:
+ virDomainReboot(d, 0);
+ break;
+ default:
+ fprintf(stderr, "%s: invalid guest state: %s\n",
+ __func__, domain_state_name(dom));
+ }
+}
+
+void domain_shutdown(struct vconsole_domain *dom)
+{
+ virDomainPtr d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid);
+
+ virDomainGetInfo(d, &dom->info);
+ switch (dom->info.state) {
+ case VIR_DOMAIN_RUNNING:
+ virDomainShutdown(d);
+ break;
+ default:
+ fprintf(stderr, "%s: invalid guest state: %s\n",
+ __func__, domain_state_name(dom));
+ }
+}
+
+void domain_kill(struct vconsole_domain *dom)
+{
+ virDomainPtr d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid);
+
+ virDomainGetInfo(d, &dom->info);
+ switch (dom->info.state) {
+ case VIR_DOMAIN_RUNNING:
+ virDomainDestroy(d);
+ break;
+ default:
+ fprintf(stderr, "%s: invalid guest state: %s\n",
+ __func__, domain_state_name(dom));
}
}
diff --git a/vconsole.c b/vconsole.c
index 6a93ff7..4451a21 100644
--- a/vconsole.c
+++ b/vconsole.c
@@ -247,6 +247,33 @@ static void menu_cb_vm_pause(GtkAction *action, void *data)
domain_pause(dom);
}
+static void menu_cb_vm_reboot(GtkAction *action, void *data)
+{
+ struct vconsole_window *win = data;
+ struct vconsole_domain *dom = find_guest(win);
+
+ if (dom)
+ domain_reboot(dom);
+}
+
+static void menu_cb_vm_shutdown(GtkAction *action, void *data)
+{
+ struct vconsole_window *win = data;
+ struct vconsole_domain *dom = find_guest(win);
+
+ if (dom)
+ domain_shutdown(dom);
+}
+
+static void menu_cb_vm_kill(GtkAction *action, void *data)
+{
+ struct vconsole_window *win = data;
+ struct vconsole_domain *dom = find_guest(win);
+
+ if (dom)
+ domain_kill(dom);
+}
+
static void menu_cb_about(GtkAction *action, gpointer userdata)
{
static char *comments = "virtual machine console";
@@ -336,8 +363,8 @@ static const GtkActionEntry entries[] = {
/* --- guest menu --- */
.name = "GuestRun",
.stock_id = GTK_STOCK_MEDIA_PLAY,
- .label = "Start",
- .tooltip = "Start Guest",
+ .label = "Run",
+ .tooltip = "Run Guest",
.callback = G_CALLBACK(menu_cb_vm_run),
},{
.name = "GuestPause",
@@ -345,6 +372,21 @@ static const GtkActionEntry entries[] = {
.label = "Pause",
.tooltip = "Pause Guest",
.callback = G_CALLBACK(menu_cb_vm_pause),
+ },{
+ .name = "GuestReboot",
+ .label = "Reboot",
+ .tooltip = "Reboot Guest",
+ .callback = G_CALLBACK(menu_cb_vm_reboot),
+ },{
+ .name = "GuestShutdown",
+ .label = "Shutdown",
+ .tooltip = "Shutdown Guest",
+ .callback = G_CALLBACK(menu_cb_vm_shutdown),
+ },{
+ .name = "GuestKill",
+ .label = "Destroy",
+ .tooltip = "Destroy Guest",
+ .callback = G_CALLBACK(menu_cb_vm_kill),
},{
/* --- help menu --- */
@@ -391,6 +433,10 @@ static char ui_xml[] =
" <menu action='GuestMenu'>\n"
" <menuitem action='GuestRun'/>\n"
" <menuitem action='GuestPause'/>\n"
+" <menuitem action='GuestReboot'/>\n"
+" <menuitem action='GuestShutdown'/>\n"
+" <separator/>\n"
+" <menuitem action='GuestKill'/>\n"
" </menu>\n"
" <menu action='HelpMenu'>\n"
" <menuitem action='About'/>\n"
diff --git a/vconsole.h b/vconsole.h
index be460dc..cfa19bd 100644
--- a/vconsole.h
+++ b/vconsole.h
@@ -77,6 +77,9 @@ struct vconsole_domain {
void domain_start(struct vconsole_domain *dom);
void domain_pause(struct vconsole_domain *dom);
+void domain_reboot(struct vconsole_domain *dom);
+void domain_shutdown(struct vconsole_domain *dom);
+void domain_kill(struct vconsole_domain *dom);
void domain_update(struct vconsole_connect *conn,
virDomainPtr d, virDomainEventType event);