aboutsummaryrefslogtreecommitdiffstats
path: root/vconsole.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2013-05-14 09:43:42 +0200
committerGerd Hoffmann <kraxel@redhat.com>2013-05-14 09:43:42 +0200
commit4dd64902cc41ecf28cac0053063d8cbd4c83562d (patch)
tree39b116f37c2724b2a96fc804605ca9bc71d340a3 /vconsole.c
parent84c14fd2ab1fcc94ae2fccbf0deadb2c2e4f2711 (diff)
downloadvconsole-4dd64902cc41ecf28cac0053063d8cbd4c83562d.tar.gz
add run-and-show-virt-viewer button
Diffstat (limited to 'vconsole.c')
-rw-r--r--vconsole.c55
1 files changed, 46 insertions, 9 deletions
diff --git a/vconsole.c b/vconsole.c
index c9293f4..e758e45 100644
--- a/vconsole.c
+++ b/vconsole.c
@@ -291,30 +291,49 @@ static struct vconsole_domain *find_guest(struct vconsole_window *win)
return dom;
}
-static void menu_cb_vm_gfx(GtkAction *action, void *data)
+static void run_virt_viewer(struct vconsole_domain *dom,
+ bool direct,
+ bool reconnect)
{
- struct vconsole_window *win = data;
- struct vconsole_domain *dom = find_guest(win);
+ char *argv[32];
+ int argc = 0;
char *uri;
- if (!dom)
- return;
uri = virConnectGetURI(dom->conn->ptr);
+ argv[argc++] = "virt-viewer";
+ argv[argc++] = "--wait";
+ if (direct)
+ argv[argc++] = "--direct";
+ if (reconnect)
+ argv[argc++] = "--reconnect";
+ argv[argc++] = "-c";
+ argv[argc++] = uri;
+ argv[argc++] = dom->uuid;
+ argv[argc++] = NULL;
+ assert(argc < sizeof(argv)/sizeof(argv[0]));
+
if (fork() <= 0) {
/* parent */
free(uri);
return;
} else {
/* child */
- execlp("virt-viewer", "virt-viewer",
- "--direct", /* tunneling doesn't work well */
- "-w", "-c", uri, dom->uuid, NULL);
- perror("execlp");
+ execvp("virt-viewer", argv);
+ perror("execvp");
exit(1);
}
}
+static void menu_cb_vm_gfx(GtkAction *action, void *data)
+{
+ struct vconsole_window *win = data;
+ struct vconsole_domain *dom = find_guest(win);
+
+ if (dom)
+ run_virt_viewer(dom, true, true);
+}
+
static void menu_cb_vm_run(GtkAction *action, void *data)
{
struct vconsole_window *win = data;
@@ -324,6 +343,17 @@ static void menu_cb_vm_run(GtkAction *action, void *data)
domain_start(dom);
}
+static void menu_cb_vm_run_gfx(GtkAction *action, void *data)
+{
+ struct vconsole_window *win = data;
+ struct vconsole_domain *dom = find_guest(win);
+
+ if (dom) {
+ run_virt_viewer(dom, true, false);
+ domain_start(dom);
+ }
+}
+
static void menu_cb_vm_pause(GtkAction *action, void *data)
{
struct vconsole_window *win = data;
@@ -497,6 +527,11 @@ static const GtkActionEntry entries[] = {
.tooltip = "Run guest",
.callback = G_CALLBACK(menu_cb_vm_run),
},{
+ .name = "GuestRunGfx",
+ .label = "Run with grapics",
+ .tooltip = "Run guest and show graphic console",
+ .callback = G_CALLBACK(menu_cb_vm_run_gfx),
+ },{
.name = "GuestPause",
.stock_id = GTK_STOCK_MEDIA_PAUSE,
.label = "Pause",
@@ -606,6 +641,8 @@ static char ui_xml[] =
" <toolitem action='GuestRun'/>\n"
" <toolitem action='GuestPause'/>\n"
" <toolitem action='GuestSave'/>\n"
+" <separator/>\n"
+" <toolitem action='GuestRunGfx'/>\n"
" </toolbar>\n"
"</ui>\n";