Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>

Index: new/src/virt-viewer-session-spice.c
===================================================================
--- new.orig/src/virt-viewer-session-spice.c	2013-07-31 13:57:28.000000000 +0200
+++ new/src/virt-viewer-session-spice.c	2013-10-23 12:10:56.000000000 +0200
@@ -342,6 +342,11 @@
         g_object_set(G_OBJECT(session), "password", val, NULL);
         g_free(val);
     }
+    if (virt_viewer_file_is_set(file, "username")) {
+        gchar *val = virt_viewer_file_get_username(file);
+        g_object_set(G_OBJECT(session), "username", val, NULL);
+        g_free(val);
+    }
 
     if (virt_viewer_file_is_set(file, "tls-ciphers")) {
         gchar *val = virt_viewer_file_get_tls_ciphers(file);
@@ -468,6 +473,7 @@
 {
     VirtViewerSessionSpice *self = VIRT_VIEWER_SESSION_SPICE(session);
     gchar *password = NULL;
+    gchar *username = NULL;
 
     g_return_if_fail(self != NULL);
 
@@ -491,12 +497,13 @@
         int ret = virt_viewer_auth_collect_credentials(self->priv->main_window,
                                                        "SPICE",
                                                        NULL,
-                                                       NULL, &password);
+                                                       &username, &password);
         if (ret < 0) {
             g_signal_emit_by_name(session, "session-cancelled");
         } else {
             gboolean openfd;
 
+            g_object_set(self->priv->session, "username", username, NULL);
             g_object_set(self->priv->session, "password", password, NULL);
             g_object_get(self->priv->session, "client-sockets", &openfd, NULL);
 
@@ -520,6 +527,7 @@
         break;
     }
 
+    g_free(username);
     g_free(password);
 }
 

