diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2013-06-14 09:29:25 +0200 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2013-06-14 09:29:25 +0200 |
commit | b5933da90c6c3b33486428e4a8c78a84d4350caf (patch) | |
tree | 4e85f79386f27a9f7a8e928ce5d4d83e84f77319 | |
parent | 4dd64902cc41ecf28cac0053063d8cbd4c83562d (diff) | |
download | vconsole-b5933da90c6c3b33486428e4a8c78a84d4350caf.tar.gz |
a bunch of tweaks for lxc
-rw-r--r-- | connect.c | 20 | ||||
-rw-r--r-- | domain.c | 13 | ||||
-rw-r--r-- | vconsole.c | 13 | ||||
-rw-r--r-- | vconsole.h | 4 |
4 files changed, 40 insertions, 10 deletions
@@ -119,7 +119,8 @@ struct vconsole_connect *connect_init(struct vconsole_window *win, { struct vconsole_connect *conn; GtkTreeIter iter; - char *name; + const char *type; + char *name, *key, *caps; conn = g_new0(struct vconsole_connect, 1); conn->ptr = virConnectOpen(uri); @@ -130,7 +131,10 @@ struct vconsole_connect *connect_init(struct vconsole_window *win, return NULL; } conn->win = win; + type = virConnectGetType(conn->ptr); name = virConnectGetHostname(conn->ptr); + caps = virConnectGetCapabilities(conn->ptr); + key = g_strdup_printf("%s:%s", type, name); virConnectDomainEventRegister(conn->ptr, connect_domain_event, conn, NULL); virConnSetErrorFunc(conn->ptr, conn, connect_error); @@ -143,6 +147,7 @@ struct vconsole_connect *connect_init(struct vconsole_window *win, gtk_tree_store_set(win->store, &iter, CPTR_COL, conn, NAME_COL, name, + TYPE_COL, type, URI_COL, uri, FOREGROUND_COL, "black", WEIGHT_COL, PANGO_WEIGHT_NORMAL, @@ -151,9 +156,22 @@ struct vconsole_connect *connect_init(struct vconsole_window *win, if (debug) fprintf(stderr, "%s: %s\n", __func__, uri); g_key_file_set_string(config, "hosts", name, uri); + g_key_file_set_string(config, "connections", key, uri); config_write(); connect_list(conn); + if (strstr(caps, "<migration_features>")) { + if (debug) + fprintf(stderr, "%s: migration supported\n", __func__); + conn->cap_migration = TRUE; + } + if (strcmp(type, "QEMU") == 0) { + conn->cap_start_paused = TRUE; + conn->cap_console_force = TRUE; + } + + free(key); + free(caps); free(name); return conn; @@ -249,6 +249,7 @@ static void domain_user_input(VteTerminal *vte, gchar *buf, guint len, static void domain_connect(struct vconsole_domain *dom, virDomainPtr d) { + int flags = 0; int rc; if (dom->stream) @@ -256,8 +257,9 @@ static void domain_connect(struct vconsole_domain *dom, virDomainPtr d) dom->stream = virStreamNew(dom->conn->ptr, VIR_STREAM_NONBLOCK); - rc = virDomainOpenConsole(d, NULL, dom->stream, - VIR_DOMAIN_CONSOLE_FORCE); + if (dom->conn->cap_console_force) + flags |= VIR_DOMAIN_CONSOLE_FORCE; + rc = virDomainOpenConsole(d, NULL, dom->stream, flags); if (rc < 0) { if (debug) fprintf(stderr, "%s: %s failed\n", __func__, dom->name); @@ -281,13 +283,14 @@ static int domain_update_info(struct vconsole_domain *dom, virDomainPtr d) struct timeval ts; const char *name; int id, rc; - gboolean saved; + gboolean saved = FALSE; virDomainInfo info; gettimeofday(&ts, NULL); name = virDomainGetName(d); id = virDomainGetID(d); - saved = virDomainHasManagedSaveImage(d, 0); + if (dom->conn->cap_migration) + saved = virDomainHasManagedSaveImage(d, 0); rc = virDomainGetInfo(d, &info); if (rc != 0) { return rc; @@ -360,7 +363,7 @@ void domain_start(struct vconsole_domain *dom) domain_update_info(dom, d); switch (dom->info.state) { case VIR_DOMAIN_SHUTOFF: - if (dom->vte) { + if (dom->vte && dom->conn->cap_start_paused) { flags |= VIR_DOMAIN_START_PAUSED; dom->unpause = TRUE; } @@ -167,7 +167,7 @@ static void menu_cb_connect_menu(GtkAction *action, gpointer userdata) return; if (debug) fprintf(stderr, "%s: %s\n", __func__, name); - uri = g_key_file_get_string(config, "hosts", name, &err); + uri = g_key_file_get_string(config, "connections", name, &err); if (uri) { connect_init(win, uri); g_free(uri); @@ -528,8 +528,7 @@ static const GtkActionEntry entries[] = { .callback = G_CALLBACK(menu_cb_vm_run), },{ .name = "GuestRunGfx", - .label = "Run with grapics", - .tooltip = "Run guest and show graphic console", + .label = "Run and show grapics console", .callback = G_CALLBACK(menu_cb_vm_run_gfx), },{ .name = "GuestPause", @@ -556,11 +555,13 @@ static const GtkActionEntry entries[] = { .callback = G_CALLBACK(menu_cb_vm_shutdown), },{ .name = "GuestReset", + .stock_id = GTK_STOCK_REFRESH, .label = "Reset", .tooltip = "Reset guest", .callback = G_CALLBACK(menu_cb_vm_reset), },{ .name = "GuestKill", + .stock_id = GTK_STOCK_MEDIA_STOP, .label = "Destroy", .tooltip = "Destriy guest", .callback = G_CALLBACK(menu_cb_vm_kill), @@ -642,6 +643,9 @@ static char ui_xml[] = " <toolitem action='GuestPause'/>\n" " <toolitem action='GuestSave'/>\n" " <separator/>\n" +" <toolitem action='GuestReset'/>\n" +" <toolitem action='GuestKill'/>\n" +" <separator/>\n" " <toolitem action='GuestRunGfx'/>\n" " </toolbar>\n" "</ui>\n"; @@ -709,7 +713,7 @@ static void vconsole_build_recent(struct vconsole_window *win) win->r_ag = gtk_action_group_new("RecentActions"); /* add entries */ - keys = g_key_file_get_keys(config, "hosts", &nkeys, &err); + keys = g_key_file_get_keys(config, "connections", &nkeys, &err); for (i = 0; i < nkeys; i++) { action = g_strdup_printf("ConnectMenu_%s", keys[i]); memset(&entry, 0, sizeof(entry)); @@ -884,6 +888,7 @@ static void vconsole_tab_list_create(struct vconsole_window *win) win->store = gtk_tree_store_new(N_COLUMNS, G_TYPE_STRING, // NAME_COL G_TYPE_POINTER, // CPTR_COL + G_TYPE_STRING, // TYPE_COL G_TYPE_STRING, // URI_COL G_TYPE_POINTER, // DPTR_COL G_TYPE_INT, // ID_COL @@ -25,6 +25,7 @@ enum vconsole_cols { /* hosts only */ CPTR_COL, // vconsole_connect + TYPE_COL, URI_COL, /* guests only */ @@ -88,6 +89,9 @@ struct vconsole_connect { GtkWidget *warn; GtkWidget *err; GtkWidget *info; + gboolean cap_migration; + gboolean cap_start_paused; + gboolean cap_console_force; }; struct vconsole_connect *connect_init(struct vconsole_window *win, |