qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/4] ui patch queue
@ 2016-01-18 15:53 Gerd Hoffmann
  2016-01-18 15:53 ` [Qemu-devel] [PULL 1/4] gtk: implement set_echo Gerd Hoffmann
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2016-01-18 15:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann

  Hi,

Flushing ui patch queue.  Just a few small fixes, no major changes.

please pull,
  Gerd

The following changes since commit 4aaddc2976bff1918edcd53900b647dde473dd4d:

  Merge remote-tracking branch 'remotes/mcayland/tags/qemu-sparc-signed' into staging (2016-01-18 09:33:36 +0000)

are available in the git repository at:


  git://git.kraxel.org/qemu tags/pull-ui-20160118-1

for you to fetch changes up to c62e90af8c2e8b1a89d973963db2bb817702bf42:

  vnc: fix tls-creds error message (2016-01-18 16:36:21 +0100)

----------------------------------------------------------------
ui: misc small gtk/spice/vnc patches.

----------------------------------------------------------------
Christophe Fergeau (1):
      Fix corner-case when using VNC+SASL+SPICE

Paolo Bonzini (1):
      gtk: implement set_echo

Wolfgang Bumiller (2):
      vnc: clear vs->tlscreds after unparenting it
      vnc: fix tls-creds error message

 include/ui/gtk.h |  1 +
 ui/gtk.c         | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 ui/spice-core.c  |  4 ++--
 ui/vnc.c         |  3 ++-
 4 files changed, 49 insertions(+), 4 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 1/4] gtk: implement set_echo
  2016-01-18 15:53 [Qemu-devel] [PULL 0/4] ui patch queue Gerd Hoffmann
@ 2016-01-18 15:53 ` Gerd Hoffmann
  2016-01-18 15:53 ` [Qemu-devel] [PULL 2/4] vnc: clear vs->tlscreds after unparenting it Gerd Hoffmann
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2016-01-18 15:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Gerd Hoffmann

From: Paolo Bonzini <pbonzini@redhat.com>

Even without line editing, this makes -qmp vc more pleasant with the
GTK+ backend.  The only issue is that set_echo is invoked very early,
long before a vc is actually associated with a VirtualConsole.  To work
around this, create a temporary VirtualConsole until then.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1450356422-31710-1-git-send-email-pbonzini@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 include/ui/gtk.h |  1 +
 ui/gtk.c         | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/include/ui/gtk.h b/include/ui/gtk.h
index bf289cf..2bf60f3 100644
--- a/include/ui/gtk.h
+++ b/include/ui/gtk.h
@@ -61,6 +61,7 @@ typedef struct VirtualVteConsole {
     GtkWidget *scrollbar;
     GtkWidget *terminal;
     CharDriverState *chr;
+    bool echo;
 } VirtualVteConsole;
 #endif
 
diff --git a/ui/gtk.c b/ui/gtk.c
index 40e78c5..ce7018e 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -1588,6 +1588,13 @@ static int gd_vc_chr_write(CharDriverState *chr, const uint8_t *buf, int len)
     return len;
 }
 
+static void gd_vc_chr_set_echo(CharDriverState *chr, bool echo)
+{
+    VirtualConsole *vc = chr->opaque;
+
+    vc->vte.echo = echo;
+}
+
 static int nb_vcs;
 static CharDriverState *vcs[MAX_VCS];
 
@@ -1597,6 +1604,11 @@ static CharDriverState *gd_vc_handler(ChardevVC *unused, Error **errp)
 
     chr = g_malloc0(sizeof(*chr));
     chr->chr_write = gd_vc_chr_write;
+    chr->chr_set_echo = gd_vc_chr_set_echo;
+
+    /* Temporary, until gd_vc_vte_init runs.  */
+    chr->opaque = g_new(VirtualConsole, 1);
+
     /* defer OPENED events until our vc is fully initialized */
     chr->explicit_be_open = true;
 
@@ -1610,6 +1622,24 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar *text, guint size,
 {
     VirtualConsole *vc = user_data;
 
+    if (vc->vte.echo) {
+        VteTerminal *term = VTE_TERMINAL(vc->vte.terminal);
+        int i;
+        for (i = 0; i < size; i++) {
+            uint8_t c = text[i];
+            if (c >= 128 || isprint(c)) {
+                /* 8-bit characters are considered printable.  */
+                vte_terminal_feed(term, &text[i], 1);
+            } else if (c == '\r' || c == '\n') {
+                vte_terminal_feed(term, "\r\n", 2);
+            } else {
+                char ctrl[2] = { '^', 0};
+                ctrl[1] = text[i] ^ 64;
+                vte_terminal_feed(term, ctrl, 2);
+            }
+        }
+    }
+
     qemu_chr_be_write(vc->vte.chr, (uint8_t  *)text, (unsigned int)size);
     return TRUE;
 }
@@ -1622,9 +1652,14 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
     GtkWidget *box;
     GtkWidget *scrollbar;
     GtkAdjustment *vadjustment;
+    VirtualConsole *tmp_vc = chr->opaque;
 
     vc->s = s;
+    vc->vte.echo = tmp_vc->vte.echo;
+
     vc->vte.chr = chr;
+    chr->opaque = vc;
+    g_free(tmp_vc);
 
     snprintf(buffer, sizeof(buffer), "vc%d", idx);
     vc->label = g_strdup_printf("%s", vc->vte.chr->label
@@ -1634,6 +1669,15 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
     vc->vte.terminal = vte_terminal_new();
     g_signal_connect(vc->vte.terminal, "commit", G_CALLBACK(gd_vc_in), vc);
 
+    /* The documentation says that the default is UTF-8, but actually it is
+     * 7-bit ASCII at least in VTE 0.38.
+     */
+#if VTE_CHECK_VERSION(0, 40, 0)
+    vte_terminal_set_encoding(VTE_TERMINAL(vc->vte.terminal), "UTF-8", NULL);
+#else
+    vte_terminal_set_encoding(VTE_TERMINAL(vc->vte.terminal), "UTF-8");
+#endif
+
     vte_terminal_set_scrollback_lines(VTE_TERMINAL(vc->vte.terminal), -1);
     vte_terminal_set_size(VTE_TERMINAL(vc->vte.terminal),
                           VC_TERM_X_MIN, VC_TERM_Y_MIN);
@@ -1656,7 +1700,6 @@ static GSList *gd_vc_vte_init(GtkDisplayState *s, VirtualConsole *vc,
     gtk_box_pack_start(GTK_BOX(box), vc->vte.terminal, TRUE, TRUE, 0);
     gtk_box_pack_start(GTK_BOX(box), scrollbar, FALSE, FALSE, 0);
 
-    vc->vte.chr->opaque = vc;
     vc->vte.box = box;
     vc->vte.scrollbar = scrollbar;
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 2/4] vnc: clear vs->tlscreds after unparenting it
  2016-01-18 15:53 [Qemu-devel] [PULL 0/4] ui patch queue Gerd Hoffmann
  2016-01-18 15:53 ` [Qemu-devel] [PULL 1/4] gtk: implement set_echo Gerd Hoffmann
@ 2016-01-18 15:53 ` Gerd Hoffmann
  2016-01-18 15:53 ` [Qemu-devel] [PULL 3/4] Fix corner-case when using VNC+SASL+SPICE Gerd Hoffmann
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2016-01-18 15:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wolfgang Bumiller, Gerd Hoffmann

From: Wolfgang Bumiller <w.bumiller@proxmox.com>

This pointer should be cleared in vnc_display_close()
otherwise a use-after-free can happen when when using the
old style 'x509' and 'tls' options rather than a persistent
tls-creds -object, by issuing monitor commands to change
the vnc server like so:

Start with: -vnc unix:test.socket,x509,tls
Then use the following monitor command:
  change vnc unix:test.socket

After this the pointer is still set but invalid and a crash
can be triggered for instance by issuing the same command a
second time which will try to object_unparent() the same
pointer again.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ui/vnc.c b/ui/vnc.c
index 54673eb..c2d3773 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3134,6 +3134,7 @@ static void vnc_display_close(VncDisplay *vs)
     vs->subauth = VNC_AUTH_INVALID;
     if (vs->tlscreds) {
         object_unparent(OBJECT(vs->tlscreds));
+        vs->tlscreds = NULL;
     }
     g_free(vs->tlsaclname);
     vs->tlsaclname = NULL;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 3/4] Fix corner-case when using VNC+SASL+SPICE
  2016-01-18 15:53 [Qemu-devel] [PULL 0/4] ui patch queue Gerd Hoffmann
  2016-01-18 15:53 ` [Qemu-devel] [PULL 1/4] gtk: implement set_echo Gerd Hoffmann
  2016-01-18 15:53 ` [Qemu-devel] [PULL 2/4] vnc: clear vs->tlscreds after unparenting it Gerd Hoffmann
@ 2016-01-18 15:53 ` Gerd Hoffmann
  2016-01-18 15:53 ` [Qemu-devel] [PULL 4/4] vnc: fix tls-creds error message Gerd Hoffmann
  2016-01-18 17:09 ` [Qemu-devel] [PULL 0/4] ui patch queue Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2016-01-18 15:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Christophe Fergeau

From: Christophe Fergeau <cfergeau@redhat.com>

Similarly to the commit 764eb39d1b6 fixing VNC+SASL+QXL, when starting
QEMU with SPICE but no SASL, and at the same time VNC with SASL, then
spice_server_init() will get called without a previous call to
spice_server_set_sasl_appname(), which will cause cyrus-sasl to
try to use /etc/sasl2/spice.conf (spice-server uses "spice" as its
default appname) rather than the expected /etc/sasl2/qemu.conf.

This commit unconditionally calls spice_server_set_sasl_appname()
before calling spice_server_init() in order to use the correct appname
even if SPICE without SASL was requested on qemu command line.

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Message-id: 1452607738-1521-1-git-send-email-cfergeau@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/spice-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 6a62d71..8f27768 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -727,8 +727,7 @@ void qemu_spice_init(void)
         qemu_spice_set_passwd(password, false, false);
     }
     if (qemu_opt_get_bool(opts, "sasl", 0)) {
-        if (spice_server_set_sasl_appname(spice_server, "qemu") == -1 ||
-            spice_server_set_sasl(spice_server, 1) == -1) {
+        if (spice_server_set_sasl(spice_server, 1) == -1) {
             error_report("spice: failed to enable sasl");
             exit(1);
         }
@@ -794,6 +793,7 @@ void qemu_spice_init(void)
 
     seamless_migration = qemu_opt_get_bool(opts, "seamless-migration", 0);
     spice_server_set_seamless_migration(spice_server, seamless_migration);
+    spice_server_set_sasl_appname(spice_server, "qemu");
     if (spice_server_init(spice_server, &core_interface) != 0) {
         error_report("failed to initialize spice server");
         exit(1);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PULL 4/4] vnc: fix tls-creds error message
  2016-01-18 15:53 [Qemu-devel] [PULL 0/4] ui patch queue Gerd Hoffmann
                   ` (2 preceding siblings ...)
  2016-01-18 15:53 ` [Qemu-devel] [PULL 3/4] Fix corner-case when using VNC+SASL+SPICE Gerd Hoffmann
@ 2016-01-18 15:53 ` Gerd Hoffmann
  2016-01-18 17:09 ` [Qemu-devel] [PULL 0/4] ui patch queue Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Gerd Hoffmann @ 2016-01-18 15:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wolfgang Bumiller, Gerd Hoffmann

From: Wolfgang Bumiller <w.bumiller@proxmox.com>

The parameter is called 'tls-creds', 'credid' is just the
variable name in the code.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
Message-id: 1452681360-29239-1-git-send-email-w.bumiller@proxmox.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/vnc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/vnc.c b/ui/vnc.c
index c2d3773..85e3462 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3606,7 +3606,7 @@ void vnc_display_open(const char *id, Error **errp)
             qemu_opt_get(opts, "x509") ||
             qemu_opt_get(opts, "x509verify")) {
             error_setg(errp,
-                       "'credid' parameter is mutually exclusive with "
+                       "'tls-creds' parameter is mutually exclusive with "
                        "'tls', 'x509' and 'x509verify' parameters");
             goto fail;
         }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PULL 0/4] ui patch queue
  2016-01-18 15:53 [Qemu-devel] [PULL 0/4] ui patch queue Gerd Hoffmann
                   ` (3 preceding siblings ...)
  2016-01-18 15:53 ` [Qemu-devel] [PULL 4/4] vnc: fix tls-creds error message Gerd Hoffmann
@ 2016-01-18 17:09 ` Peter Maydell
  4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2016-01-18 17:09 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: QEMU Developers

On 18 January 2016 at 15:53, Gerd Hoffmann <kraxel@redhat.com> wrote:
>   Hi,
>
> Flushing ui patch queue.  Just a few small fixes, no major changes.
>
> please pull,
>   Gerd
>
> The following changes since commit 4aaddc2976bff1918edcd53900b647dde473dd4d:
>
>   Merge remote-tracking branch 'remotes/mcayland/tags/qemu-sparc-signed' into staging (2016-01-18 09:33:36 +0000)
>
> are available in the git repository at:
>
>
>   git://git.kraxel.org/qemu tags/pull-ui-20160118-1
>
> for you to fetch changes up to c62e90af8c2e8b1a89d973963db2bb817702bf42:
>
>   vnc: fix tls-creds error message (2016-01-18 16:36:21 +0100)
>
> ----------------------------------------------------------------
> ui: misc small gtk/spice/vnc patches.

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-01-18 17:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-18 15:53 [Qemu-devel] [PULL 0/4] ui patch queue Gerd Hoffmann
2016-01-18 15:53 ` [Qemu-devel] [PULL 1/4] gtk: implement set_echo Gerd Hoffmann
2016-01-18 15:53 ` [Qemu-devel] [PULL 2/4] vnc: clear vs->tlscreds after unparenting it Gerd Hoffmann
2016-01-18 15:53 ` [Qemu-devel] [PULL 3/4] Fix corner-case when using VNC+SASL+SPICE Gerd Hoffmann
2016-01-18 15:53 ` [Qemu-devel] [PULL 4/4] vnc: fix tls-creds error message Gerd Hoffmann
2016-01-18 17:09 ` [Qemu-devel] [PULL 0/4] ui patch queue Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).