aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-09-06 14:17:34 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-09-06 14:17:34 +0200
commit0b005f4cff8ae28655243043529fa091a481c9fa (patch)
tree767d4f67afe4f17801965af8181c8ae37eb06617
parent8776506e3cabba93083438fef1587de915af8113 (diff)
downloadvconsole-0b005f4cff8ae28655243043529fa091a481c9fa.tar.gz
add menu item to save guest to disk
-rw-r--r--domain.c16
-rw-r--r--vconsole.c25
-rw-r--r--vconsole.h1
3 files changed, 37 insertions, 5 deletions
diff --git a/domain.c b/domain.c
index d0dc35c..ff768e0 100644
--- a/domain.c
+++ b/domain.c
@@ -313,6 +313,22 @@ void domain_pause(struct vconsole_domain *dom)
}
}
+void domain_save(struct vconsole_domain *dom)
+{
+ virDomainPtr d = virDomainLookupByUUIDString(dom->conn->ptr, dom->uuid);
+
+ virDomainGetInfo(d, &dom->info);
+ switch (dom->info.state) {
+ case VIR_DOMAIN_RUNNING:
+ case VIR_DOMAIN_PAUSED:
+ virDomainManagedSave(d, 0);
+ 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);
diff --git a/vconsole.c b/vconsole.c
index a4f6cad..2c23572 100644
--- a/vconsole.c
+++ b/vconsole.c
@@ -271,6 +271,15 @@ static void menu_cb_vm_pause(GtkAction *action, void *data)
domain_pause(dom);
}
+static void menu_cb_vm_save(GtkAction *action, void *data)
+{
+ struct vconsole_window *win = data;
+ struct vconsole_domain *dom = find_guest(win);
+
+ if (dom)
+ domain_save(dom);
+}
+
static void menu_cb_vm_reboot(GtkAction *action, void *data)
{
struct vconsole_window *win = data;
@@ -415,28 +424,33 @@ static const GtkActionEntry entries[] = {
.name = "GuestRun",
.stock_id = GTK_STOCK_MEDIA_PLAY,
.label = "Run",
- .tooltip = "Run Guest",
+ .tooltip = "Run guest",
.callback = G_CALLBACK(menu_cb_vm_run),
},{
.name = "GuestPause",
.stock_id = GTK_STOCK_MEDIA_PAUSE,
.label = "Pause",
- .tooltip = "Pause Guest",
+ .tooltip = "Pause guest",
.callback = G_CALLBACK(menu_cb_vm_pause),
},{
+ .name = "GuestSave",
+ .label = "Save to disk",
+ .tooltip = "Save guest to disk",
+ .callback = G_CALLBACK(menu_cb_vm_save),
+ },{
.name = "GuestReboot",
.label = "Reboot",
- .tooltip = "Reboot Guest",
+ .tooltip = "Reboot guest",
.callback = G_CALLBACK(menu_cb_vm_reboot),
},{
.name = "GuestShutdown",
.label = "Shutdown",
- .tooltip = "Shutdown Guest",
+ .tooltip = "Shutdown guest",
.callback = G_CALLBACK(menu_cb_vm_shutdown),
},{
.name = "GuestKill",
.label = "Destroy",
- .tooltip = "Destroy Guest",
+ .tooltip = "Destroy guest",
.callback = G_CALLBACK(menu_cb_vm_kill),
},{
@@ -496,6 +510,7 @@ static char ui_xml[] =
" <separator/>\n"
" <menuitem action='GuestRun'/>\n"
" <menuitem action='GuestPause'/>\n"
+" <menuitem action='GuestSave'/>\n"
" <menuitem action='GuestReboot'/>\n"
" <menuitem action='GuestShutdown'/>\n"
" <separator/>\n"
diff --git a/vconsole.h b/vconsole.h
index 0e132c0..e39b97d 100644
--- a/vconsole.h
+++ b/vconsole.h
@@ -83,6 +83,7 @@ struct vconsole_domain {
void domain_start(struct vconsole_domain *dom);
void domain_pause(struct vconsole_domain *dom);
+void domain_save(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);