From nobody Thu May 2 03:44:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506680639179206.39430503448148; Fri, 29 Sep 2017 03:23:59 -0700 (PDT) Received: from localhost ([::1]:34519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsSK-0007tL-BN for importer@patchew.org; Fri, 29 Sep 2017 06:23:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsQr-00073K-QG for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxsQo-0005gO-Ag for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43058) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxsQo-0005ff-24 for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:06 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB2452CB6; Fri, 29 Sep 2017 10:22:04 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id CC58317C5C; Fri, 29 Sep 2017 10:22:02 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 78ED71FCD7; Fri, 29 Sep 2017 12:22:01 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB2452CB6 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 29 Sep 2017 12:21:57 +0200 Message-Id: <20170929102201.15408-2-kraxel@redhat.com> In-Reply-To: <20170929102201.15408-1-kraxel@redhat.com> References: <20170929102201.15408-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 29 Sep 2017 10:22:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/5] console: purge curses bits from console.h X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Guan Xuetao , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Handle the translation from vga chars to curses chars in curses_update() instead of console_write_ch(). Purge any curses support bits from ui/console.h include file. Signed-off-by: Gerd Hoffmann Message-id: 20170927103811.19249-1-kraxel@redhat.com --- include/ui/console.h | 23 ++--------------------- target/unicore32/helper.c | 6 ++++++ ui/curses.c | 25 ++++++++++++++++++++----- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 8024878bae..6966e4bd9d 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -336,29 +336,10 @@ static inline pixman_format_code_t surface_format(Dis= playSurface *s) return s->format; } =20 -#ifdef CONFIG_CURSES -/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */ -#undef KEY_EVENT -#include -#undef KEY_EVENT -typedef chtype console_ch_t; -extern chtype vga_to_curses[]; -#else -typedef unsigned long console_ch_t; -#endif +typedef uint32_t console_ch_t; + static inline void console_write_ch(console_ch_t *dest, uint32_t ch) { - uint8_t c =3D ch; -#ifdef CONFIG_CURSES - if (vga_to_curses[c]) { - ch &=3D ~(console_ch_t)0xff; - ch |=3D vga_to_curses[c]; - } -#else - if (c =3D=3D '\0') { - ch |=3D ' '; - } -#endif *dest =3D ch; } =20 diff --git a/target/unicore32/helper.c b/target/unicore32/helper.c index 309dcd1ae1..3393d2c020 100644 --- a/target/unicore32/helper.c +++ b/target/unicore32/helper.c @@ -163,6 +163,12 @@ uint32_t helper_cp0_get(CPUUniCore32State *env, uint32= _t creg, uint32_t cop) } =20 #ifdef CONFIG_CURSES + +/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */ +#undef KEY_EVENT +#include +#undef KEY_EVENT + /* * FIXME: * 1. curses windows will be blank when switching back diff --git a/ui/curses.c b/ui/curses.c index 03cefdf470..85503876c0 100644 --- a/ui/curses.c +++ b/ui/curses.c @@ -33,6 +33,11 @@ #include "ui/input.h" #include "sysemu/sysemu.h" =20 +/* KEY_EVENT is defined in wincon.h and in curses.h. Avoid redefinition. */ +#undef KEY_EVENT +#include +#undef KEY_EVENT + #define FONT_HEIGHT 16 #define FONT_WIDTH 8 =20 @@ -42,16 +47,26 @@ static WINDOW *screenpad =3D NULL; static int width, height, gwidth, gheight, invalidate; static int px, py, sminx, sminy, smaxx, smaxy; =20 -chtype vga_to_curses[256]; +static chtype vga_to_curses[256]; =20 static void curses_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { - chtype *line; + console_ch_t *line; + chtype curses_line[width]; =20 - line =3D ((chtype *) screen) + y * width; - for (h +=3D y; y < h; y ++, line +=3D width) - mvwaddchnstr(screenpad, y, 0, line, width); + line =3D screen + y * width; + for (h +=3D y; y < h; y ++, line +=3D width) { + for (x =3D 0; x < width; x++) { + chtype ch =3D line[x] & 0xff; + chtype at =3D line[x] & ~0xff; + if (vga_to_curses[ch]) { + ch =3D vga_to_curses[ch]; + } + curses_line[x] =3D ch | at; + } + mvwaddchnstr(screenpad, y, 0, curses_line, width); + } =20 pnoutrefresh(screenpad, py, px, sminy, sminx, smaxy - 1, smaxx - 1); refresh(); --=20 2.9.3 From nobody Thu May 2 03:44:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506680633168617.7547905871071; Fri, 29 Sep 2017 03:23:53 -0700 (PDT) Received: from localhost ([::1]:34521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsSU-000800-8i for importer@patchew.org; Fri, 29 Sep 2017 06:23:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41414) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsQr-00073J-Pu for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxsQm-0005fI-Ui for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42924) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxsQm-0005eG-Mv for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:04 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 279D72CA4 for ; Fri, 29 Sep 2017 10:22:03 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48EF95C88B; Fri, 29 Sep 2017 10:22:02 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 84A9031EB7; Fri, 29 Sep 2017 12:22:01 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 279D72CA4 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 29 Sep 2017 12:21:58 +0200 Message-Id: <20170929102201.15408-3-kraxel@redhat.com> In-Reply-To: <20170929102201.15408-1-kraxel@redhat.com> References: <20170929102201.15408-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 29 Sep 2017 10:22:03 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/5] egl: misc framebuffer helper improvements. X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Rename the functions to to say "setup" instead of "create" because they support being called multiple times on the same egl framebuffer. Properly delete unused textures, update function interfaces to support this. Signed-off-by: Gerd Hoffmann Message-id: 20170927115031.12063-1-kraxel@redhat.com --- include/ui/egl-helpers.h | 5 +++-- ui/egl-headless.c | 6 +++--- ui/egl-helpers.c | 26 ++++++++++++++++++-------- ui/gtk-egl.c | 4 ++-- ui/gtk-gl-area.c | 4 ++-- ui/sdl2-gl.c | 4 ++-- 6 files changed, 30 insertions(+), 19 deletions(-) diff --git a/include/ui/egl-helpers.h b/include/ui/egl-helpers.h index be8908737c..81cb255de0 100644 --- a/include/ui/egl-helpers.h +++ b/include/ui/egl-helpers.h @@ -18,8 +18,9 @@ typedef struct egl_fb { =20 void egl_fb_destroy(egl_fb *fb); void egl_fb_setup_default(egl_fb *fb, int width, int height); -void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint textu= re); -void egl_fb_create_new_tex(egl_fb *fb, int width, int height); +void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, + GLuint texture, bool delete); +void egl_fb_setup_new_tex(egl_fb *fb, int width, int height); void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip); void egl_fb_read(void *dst, egl_fb *src); =20 diff --git a/ui/egl-headless.c b/ui/egl-headless.c index 809bfde99c..12ad64e995 100644 --- a/ui/egl-headless.c +++ b/ui/egl-headless.c @@ -54,14 +54,14 @@ static void egl_scanout_texture(DisplayChangeListener *= dcl, edpy->y_0_top =3D backing_y_0_top; =20 /* source framebuffer */ - egl_fb_create_for_tex(&edpy->guest_fb, - backing_width, backing_height, backing_id); + egl_fb_setup_for_tex(&edpy->guest_fb, + backing_width, backing_height, backing_id, false); =20 /* dest framebuffer */ if (edpy->blit_fb.width !=3D backing_width || edpy->blit_fb.height !=3D backing_height) { egl_fb_destroy(&edpy->blit_fb); - egl_fb_create_new_tex(&edpy->blit_fb, backing_width, backing_heigh= t); + egl_fb_setup_new_tex(&edpy->blit_fb, backing_width, backing_height= ); } } =20 diff --git a/ui/egl-helpers.c b/ui/egl-helpers.c index bb19a5eeca..cde9965dea 100644 --- a/ui/egl-helpers.c +++ b/ui/egl-helpers.c @@ -26,16 +26,23 @@ EGLConfig qemu_egl_config; =20 /* ------------------------------------------------------------------ */ =20 +static void egl_fb_delete_texture(egl_fb *fb) +{ + if (!fb->delete_texture) { + return; + } + + glDeleteTextures(1, &fb->texture); + fb->delete_texture =3D false; +} + void egl_fb_destroy(egl_fb *fb) { if (!fb->framebuffer) { return; } =20 - if (fb->delete_texture) { - glDeleteTextures(1, &fb->texture); - fb->delete_texture =3D false; - } + egl_fb_delete_texture(fb); glDeleteFramebuffers(1, &fb->framebuffer); =20 fb->width =3D 0; @@ -51,11 +58,15 @@ void egl_fb_setup_default(egl_fb *fb, int width, int he= ight) fb->framebuffer =3D 0; /* default framebuffer */ } =20 -void egl_fb_create_for_tex(egl_fb *fb, int width, int height, GLuint textu= re) +void egl_fb_setup_for_tex(egl_fb *fb, int width, int height, + GLuint texture, bool delete) { + egl_fb_delete_texture(fb); + fb->width =3D width; fb->height =3D height; fb->texture =3D texture; + fb->delete_texture =3D delete; if (!fb->framebuffer) { glGenFramebuffers(1, &fb->framebuffer); } @@ -65,7 +76,7 @@ void egl_fb_create_for_tex(egl_fb *fb, int width, int hei= ght, GLuint texture) GL_TEXTURE_2D, fb->texture, 0); } =20 -void egl_fb_create_new_tex(egl_fb *fb, int width, int height) +void egl_fb_setup_new_tex(egl_fb *fb, int width, int height) { GLuint texture; =20 @@ -74,8 +85,7 @@ void egl_fb_create_new_tex(egl_fb *fb, int width, int hei= ght) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, 0); =20 - egl_fb_create_for_tex(fb, width, height, texture); - fb->delete_texture =3D true; + egl_fb_setup_for_tex(fb, width, height, texture, true); } =20 void egl_fb_blit(egl_fb *dst, egl_fb *src, bool flip) diff --git a/ui/gtk-egl.c b/ui/gtk-egl.c index 0d5cab2bc8..0f0d35e041 100644 --- a/ui/gtk-egl.c +++ b/ui/gtk-egl.c @@ -190,8 +190,8 @@ void gd_egl_scanout_texture(DisplayChangeListener *dcl, vc->gfx.esurface, vc->gfx.ectx); =20 gtk_egl_set_scanout_mode(vc, true); - egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, - backing_id); + egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, + backing_id, false); } =20 void gd_egl_scanout_flush(DisplayChangeListener *dcl, diff --git a/ui/gtk-gl-area.c b/ui/gtk-gl-area.c index 18b298fc21..01ebf2c7de 100644 --- a/ui/gtk-gl-area.c +++ b/ui/gtk-gl-area.c @@ -185,8 +185,8 @@ void gd_gl_area_scanout_texture(DisplayChangeListener *= dcl, } =20 gtk_gl_area_set_scanout_mode(vc, true); - egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, - backing_id); + egl_fb_setup_for_tex(&vc->gfx.guest_fb, backing_width, backing_height, + backing_id, false); } =20 void gd_gl_area_scanout_flush(DisplayChangeListener *dcl, diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index dcad3d0d26..9110491ee5 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -207,8 +207,8 @@ void sdl2_gl_scanout_texture(DisplayChangeListener *dcl, SDL_GL_MakeCurrent(scon->real_window, scon->winctx); =20 sdl2_set_scanout_mode(scon, true); - egl_fb_create_for_tex(&scon->guest_fb, backing_width, backing_height, - backing_id); + egl_fb_setup_for_tex(&scon->guest_fb, backing_width, backing_height, + backing_id, false); } =20 void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, --=20 2.9.3 From nobody Thu May 2 03:44:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 150668074776615.148560073758631; Fri, 29 Sep 2017 03:25:47 -0700 (PDT) Received: from localhost ([::1]:34530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsUJ-000133-32 for importer@patchew.org; Fri, 29 Sep 2017 06:25:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsQw-00077w-8l for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxsQu-0005ke-VY for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37530) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxsQu-0005kE-MV for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C84B34DD7C for ; Fri, 29 Sep 2017 10:22:11 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 50F506060C; Fri, 29 Sep 2017 10:22:02 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 956B03F136; Fri, 29 Sep 2017 12:22:01 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C84B34DD7C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 29 Sep 2017 12:21:59 +0200 Message-Id: <20170929102201.15408-4-kraxel@redhat.com> In-Reply-To: <20170929102201.15408-1-kraxel@redhat.com> References: <20170929102201.15408-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 29 Sep 2017 10:22:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/5] virtio-input: send rel-wheel events for wheel buttons X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" qemu uses wheel-up/down button events for mouse wheel input, however linux applications typically want REL_WHEEL events. This fixes wheel with linux guests. Tested with X11/wayland, and windows virtio-input driver. Based on a patch from Marc. Added property to enable/disable wheel axis. Cc: Marc-Andr=C3=A9 Lureau Signed-off-by: Gerd Hoffmann Message-id: 20170926113243.26081-1-kraxel@redhat.com --- include/hw/compat.h | 10 +++- include/hw/virtio/virtio-input.h | 1 + hw/input/virtio-input-hid.c | 119 +++++++++++++++++++++++++++++++++++= ++-- 3 files changed, 124 insertions(+), 6 deletions(-) diff --git a/include/hw/compat.h b/include/hw/compat.h index 9cc14dd798..cf389b4e85 100644 --- a/include/hw/compat.h +++ b/include/hw/compat.h @@ -2,7 +2,15 @@ #define HW_COMPAT_H =20 #define HW_COMPAT_2_10 \ - /* empty */ + {\ + .driver =3D "virtio-mouse-device",\ + .property =3D "wheel-axis",\ + .value =3D "false",\ + },{\ + .driver =3D "virtio-tablet-device",\ + .property =3D "wheel-axis",\ + .value =3D "false",\ + }, =20 #define HW_COMPAT_2_9 \ {\ diff --git a/include/hw/virtio/virtio-input.h b/include/hw/virtio/virtio-in= put.h index 91df57eca4..054c38836f 100644 --- a/include/hw/virtio/virtio-input.h +++ b/include/hw/virtio/virtio-input.h @@ -89,6 +89,7 @@ struct VirtIOInputHID { QemuInputHandler *handler; QemuInputHandlerState *hs; int ledstate; + bool wheel_axis; }; =20 struct VirtIOInputHost { diff --git a/hw/input/virtio-input-hid.c b/hw/input/virtio-input-hid.c index 4d3afc1b14..e78faec0b1 100644 --- a/hw/input/virtio-input-hid.c +++ b/hw/input/virtio-input-hid.c @@ -190,6 +190,7 @@ static void virtio_input_key_config(VirtIOInput *vinput, static void virtio_input_handle_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { + VirtIOInputHID *vhid =3D VIRTIO_INPUT_HID(dev); VirtIOInput *vinput =3D VIRTIO_INPUT(dev); virtio_input_event event; int qcode; @@ -215,7 +216,14 @@ static void virtio_input_handle_event(DeviceState *dev= , QemuConsole *src, break; case INPUT_EVENT_KIND_BTN: btn =3D evt->u.btn.data; - if (keymap_button[btn->button]) { + if (vhid->wheel_axis && (btn->button =3D=3D INPUT_BUTTON_WHEEL_UP = || + btn->button =3D=3D INPUT_BUTTON_WHEEL_DOW= N)) { + event.type =3D cpu_to_le16(EV_REL); + event.code =3D cpu_to_le16(REL_WHEEL); + event.value =3D cpu_to_le32(btn->button =3D=3D INPUT_BUTTON_WH= EEL_UP + ? 1 : -1); + virtio_input_send(vinput, &event); + } else if (keymap_button[btn->button]) { event.type =3D cpu_to_le16(EV_KEY); event.code =3D cpu_to_le16(keymap_button[btn->button]); event.value =3D cpu_to_le32(btn->down ? 1 : 0); @@ -407,7 +415,7 @@ static QemuInputHandler virtio_mouse_handler =3D { .sync =3D virtio_input_handle_sync, }; =20 -static struct virtio_input_config virtio_mouse_config[] =3D { +static struct virtio_input_config virtio_mouse_config_v1[] =3D { { .select =3D VIRTIO_INPUT_CFG_ID_NAME, .size =3D sizeof(VIRTIO_ID_NAME_MOUSE), @@ -432,13 +440,53 @@ static struct virtio_input_config virtio_mouse_config= [] =3D { { /* end of list */ }, }; =20 +static struct virtio_input_config virtio_mouse_config_v2[] =3D { + { + .select =3D VIRTIO_INPUT_CFG_ID_NAME, + .size =3D sizeof(VIRTIO_ID_NAME_MOUSE), + .u.string =3D VIRTIO_ID_NAME_MOUSE, + },{ + .select =3D VIRTIO_INPUT_CFG_ID_DEVIDS, + .size =3D sizeof(struct virtio_input_devids), + .u.ids =3D { + .bustype =3D const_le16(BUS_VIRTUAL), + .vendor =3D const_le16(0x0627), /* same we use for usb hid de= vices */ + .product =3D const_le16(0x0002), + .version =3D const_le16(0x0002), + }, + },{ + .select =3D VIRTIO_INPUT_CFG_EV_BITS, + .subsel =3D EV_REL, + .size =3D 2, + .u.bitmap =3D { + (1 << REL_X) | (1 << REL_Y), + (1 << (REL_WHEEL - 8)) + }, + }, + { /* end of list */ }, +}; + +static Property virtio_mouse_properties[] =3D { + DEFINE_PROP_BOOL("wheel-axis", VirtIOInputHID, wheel_axis, true), + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_mouse_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->props =3D virtio_mouse_properties; +} + static void virtio_mouse_init(Object *obj) { VirtIOInputHID *vhid =3D VIRTIO_INPUT_HID(obj); VirtIOInput *vinput =3D VIRTIO_INPUT(obj); =20 vhid->handler =3D &virtio_mouse_handler; - virtio_input_init_config(vinput, virtio_mouse_config); + virtio_input_init_config(vinput, vhid->wheel_axis + ? virtio_mouse_config_v2 + : virtio_mouse_config_v1); virtio_input_key_config(vinput, keymap_button, ARRAY_SIZE(keymap_button)); } @@ -448,6 +496,7 @@ static const TypeInfo virtio_mouse_info =3D { .parent =3D TYPE_VIRTIO_INPUT_HID, .instance_size =3D sizeof(VirtIOInputHID), .instance_init =3D virtio_mouse_init, + .class_init =3D virtio_mouse_class_init, }; =20 /* ----------------------------------------------------------------- */ @@ -459,7 +508,7 @@ static QemuInputHandler virtio_tablet_handler =3D { .sync =3D virtio_input_handle_sync, }; =20 -static struct virtio_input_config virtio_tablet_config[] =3D { +static struct virtio_input_config virtio_tablet_config_v1[] =3D { { .select =3D VIRTIO_INPUT_CFG_ID_NAME, .size =3D sizeof(VIRTIO_ID_NAME_TABLET), @@ -496,13 +545,72 @@ static struct virtio_input_config virtio_tablet_confi= g[] =3D { { /* end of list */ }, }; =20 +static struct virtio_input_config virtio_tablet_config_v2[] =3D { + { + .select =3D VIRTIO_INPUT_CFG_ID_NAME, + .size =3D sizeof(VIRTIO_ID_NAME_TABLET), + .u.string =3D VIRTIO_ID_NAME_TABLET, + },{ + .select =3D VIRTIO_INPUT_CFG_ID_DEVIDS, + .size =3D sizeof(struct virtio_input_devids), + .u.ids =3D { + .bustype =3D const_le16(BUS_VIRTUAL), + .vendor =3D const_le16(0x0627), /* same we use for usb hid de= vices */ + .product =3D const_le16(0x0003), + .version =3D const_le16(0x0002), + }, + },{ + .select =3D VIRTIO_INPUT_CFG_EV_BITS, + .subsel =3D EV_ABS, + .size =3D 1, + .u.bitmap =3D { + (1 << ABS_X) | (1 << ABS_Y), + }, + },{ + .select =3D VIRTIO_INPUT_CFG_EV_BITS, + .subsel =3D EV_REL, + .size =3D 2, + .u.bitmap =3D { + 0, + (1 << (REL_WHEEL - 8)) + }, + },{ + .select =3D VIRTIO_INPUT_CFG_ABS_INFO, + .subsel =3D ABS_X, + .size =3D sizeof(virtio_input_absinfo), + .u.abs.min =3D const_le32(INPUT_EVENT_ABS_MIN), + .u.abs.max =3D const_le32(INPUT_EVENT_ABS_MAX), + },{ + .select =3D VIRTIO_INPUT_CFG_ABS_INFO, + .subsel =3D ABS_Y, + .size =3D sizeof(virtio_input_absinfo), + .u.abs.min =3D const_le32(INPUT_EVENT_ABS_MIN), + .u.abs.max =3D const_le32(INPUT_EVENT_ABS_MAX), + }, + { /* end of list */ }, +}; + +static Property virtio_tablet_properties[] =3D { + DEFINE_PROP_BOOL("wheel-axis", VirtIOInputHID, wheel_axis, true), + DEFINE_PROP_END_OF_LIST(), +}; + +static void virtio_tablet_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->props =3D virtio_tablet_properties; +} + static void virtio_tablet_init(Object *obj) { VirtIOInputHID *vhid =3D VIRTIO_INPUT_HID(obj); VirtIOInput *vinput =3D VIRTIO_INPUT(obj); =20 vhid->handler =3D &virtio_tablet_handler; - virtio_input_init_config(vinput, virtio_tablet_config); + virtio_input_init_config(vinput, vhid->wheel_axis + ? virtio_tablet_config_v2 + : virtio_tablet_config_v1); virtio_input_key_config(vinput, keymap_button, ARRAY_SIZE(keymap_button)); } @@ -512,6 +620,7 @@ static const TypeInfo virtio_tablet_info =3D { .parent =3D TYPE_VIRTIO_INPUT_HID, .instance_size =3D sizeof(VirtIOInputHID), .instance_init =3D virtio_tablet_init, + .class_init =3D virtio_tablet_class_init, }; =20 /* ----------------------------------------------------------------- */ --=20 2.9.3 From nobody Thu May 2 03:44:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506680631354849.4802438859566; Fri, 29 Sep 2017 03:23:51 -0700 (PDT) Received: from localhost ([::1]:34520 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsSP-0007vZ-HT for importer@patchew.org; Fri, 29 Sep 2017 06:23:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsQr-00073L-Qf for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxsQo-0005gF-8l for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxsQn-0005fb-Vs for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 178343680B for ; Fri, 29 Sep 2017 10:22:05 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D7E217C41; Fri, 29 Sep 2017 10:22:02 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9F44D3F137; Fri, 29 Sep 2017 12:22:01 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 178343680B Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 29 Sep 2017 12:22:00 +0200 Message-Id: <20170929102201.15408-5-kraxel@redhat.com> In-Reply-To: <20170929102201.15408-1-kraxel@redhat.com> References: <20170929102201.15408-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 29 Sep 2017 10:22:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/5] ui: add tracing of VNC operations related to QIOChannel X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Trace anything which opens/closes/wraps a QIOChannel in the VNC server. Signed-off-by: Daniel P. Berrange Message-id: 20170921121528.23935-2-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/vnc-auth-vencrypt.c | 2 ++ ui/vnc-ws.c | 6 +++--- ui/vnc.c | 11 ++++++++--- ui/trace-events | 6 ++++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c index ffaab57550..8ab00ef784 100644 --- a/ui/vnc-auth-vencrypt.c +++ b/ui/vnc-auth-vencrypt.c @@ -28,6 +28,7 @@ #include "vnc.h" #include "qapi/error.h" #include "qemu/main-loop.h" +#include "trace.h" =20 static void start_auth_vencrypt_subauth(VncState *vs) { @@ -121,6 +122,7 @@ static int protocol_client_vencrypt_auth(VncState *vs, = uint8_t *data, size_t len VNC_DEBUG("Start TLS VeNCrypt handshake process\n"); object_unref(OBJECT(vs->ioc)); vs->ioc =3D QIO_CHANNEL(tls); + trace_vnc_client_io_wrap(vs, vs->ioc, "tls"); vs->tls =3D qio_channel_tls_get_session(tls); =20 qio_channel_tls_handshake(tls, diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c index f530cd5474..aeaafe2c21 100644 --- a/ui/vnc-ws.c +++ b/ui/vnc-ws.c @@ -23,6 +23,7 @@ #include "vnc.h" #include "io/channel-websock.h" #include "qemu/bswap.h" +#include "trace.h" =20 static void vncws_tls_handshake_done(QIOTask *task, gpointer user_data) @@ -50,7 +51,6 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UN= USED, QIOChannelTLS *tls; Error *err =3D NULL; =20 - VNC_DEBUG("TLS Websocket connection required\n"); if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); vs->ioc_tag =3D 0; @@ -70,9 +70,9 @@ gboolean vncws_tls_handshake_io(QIOChannel *ioc G_GNUC_UN= USED, =20 qio_channel_set_name(QIO_CHANNEL(tls), "vnc-ws-server-tls"); =20 - VNC_DEBUG("Start TLS WS handshake process\n"); object_unref(OBJECT(vs->ioc)); vs->ioc =3D QIO_CHANNEL(tls); + trace_vnc_client_io_wrap(vs, vs->ioc, "tls"); vs->tls =3D qio_channel_tls_get_session(tls); =20 qio_channel_tls_handshake(tls, @@ -110,7 +110,6 @@ gboolean vncws_handshake_io(QIOChannel *ioc G_GNUC_UNUS= ED, VncState *vs =3D opaque; QIOChannelWebsock *wioc; =20 - VNC_DEBUG("Websocket negotiate starting\n"); if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); vs->ioc_tag =3D 0; @@ -121,6 +120,7 @@ gboolean vncws_handshake_io(QIOChannel *ioc G_GNUC_UNUS= ED, =20 object_unref(OBJECT(vs->ioc)); vs->ioc =3D QIO_CHANNEL(wioc); + trace_vnc_client_io_wrap(vs, vs->ioc, "websock"); =20 qio_channel_websock_handshake(wioc, vncws_handshake_done, diff --git a/ui/vnc.c b/ui/vnc.c index 0b5dbc62e4..ed6d659722 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -1118,6 +1118,7 @@ static void vnc_disconnect_start(VncState *vs) if (vs->disconnecting) { return; } + trace_vnc_client_disconnect_start(vs, vs->ioc); vnc_set_share_mode(vs, VNC_SHARE_MODE_DISCONNECTED); if (vs->ioc_tag) { g_source_remove(vs->ioc_tag); @@ -1130,6 +1131,8 @@ void vnc_disconnect_finish(VncState *vs) { int i; =20 + trace_vnc_client_disconnect_finish(vs, vs->ioc); + vnc_jobs_join(vs); /* Wait encoding jobs */ =20 vnc_lock_output(vs); @@ -1183,11 +1186,12 @@ ssize_t vnc_client_io_error(VncState *vs, ssize_t r= et, Error **errp) { if (ret <=3D 0) { if (ret =3D=3D 0) { - VNC_DEBUG("Closing down client sock: EOF\n"); + trace_vnc_client_eof(vs, vs->ioc); vnc_disconnect_start(vs); } else if (ret !=3D QIO_CHANNEL_ERR_BLOCK) { - VNC_DEBUG("Closing down client sock: ret %zd (%s)\n", - ret, errp ? error_get_pretty(*errp) : "Unknown"); + trace_vnc_client_io_error(vs, vs->ioc, + errp ? error_get_pretty(*errp) : + "Unknown"); vnc_disconnect_start(vs); } =20 @@ -2884,6 +2888,7 @@ static void vnc_connect(VncDisplay *vd, QIOChannelSoc= ket *sioc, bool first_client =3D QTAILQ_EMPTY(&vd->clients); int i; =20 + trace_vnc_client_connect(vs, sioc); vs->sioc =3D sioc; object_ref(OBJECT(vs->sioc)); vs->ioc =3D QIO_CHANNEL(sioc); diff --git a/ui/trace-events b/ui/trace-events index 34c2213700..e4c02e47f5 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -29,6 +29,12 @@ vnc_key_event_ext(bool down, int sym, int keycode, const= char *name) "down %d, s vnc_key_event_map(bool down, int sym, int keycode, const char *name) "down= %d, sym 0x%x -> keycode 0x%x [%s]" vnc_key_sync_numlock(bool on) "%d" vnc_key_sync_capslock(bool on) "%d" +vnc_client_eof(void *state, void *ioc) "VNC client EOF state=3D%p ioc=3D%p" +vnc_client_io_error(void *state, void *ioc, const char *msg) "VNC client I= /O error state=3D%p ioc=3D%p errmsg=3D%s" +vnc_client_connect(void *state, void *ioc) "VNC client connect state=3D%p = ioc=3D%p" +vnc_client_disconnect_start(void *state, void *ioc) "VNC client disconnect= start state=3D%p ioc=3D%p" +vnc_client_disconnect_finish(void *state, void *ioc) "VNC client disconnec= t finish state=3D%p ioc=3D%p" +vnc_client_io_wrap(void *state, void *ioc, const char *type) "VNC client I= /O wrap state=3D%p ioc=3D%p type=3D%s" =20 # ui/input.c input_event_key_number(int conidx, int number, const char *qcode, bool dow= n) "con %d, key number 0x%x [%s], down %d" --=20 2.9.3 From nobody Thu May 2 03:44:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@gnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@gnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1506680867434828.8629231609611; Fri, 29 Sep 2017 03:27:47 -0700 (PDT) Received: from localhost ([::1]:34541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsW6-0002GR-8j for importer@patchew.org; Fri, 29 Sep 2017 06:27:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxsQs-00073Z-So for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxsQp-0005hZ-VF for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39836) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxsQp-0005gq-I0 for qemu-devel@nongnu.org; Fri, 29 Sep 2017 06:22:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A488F267E0 for ; Fri, 29 Sep 2017 10:22:06 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-102.ams2.redhat.com [10.36.116.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id C41E160269; Fri, 29 Sep 2017 10:22:03 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A9A4E4F980; Fri, 29 Sep 2017 12:22:01 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A488F267E0 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=kraxel@redhat.com From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 29 Sep 2017 12:22:01 +0200 Message-Id: <20170929102201.15408-6-kraxel@redhat.com> In-Reply-To: <20170929102201.15408-1-kraxel@redhat.com> References: <20170929102201.15408-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 29 Sep 2017 10:22:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/5] ui: add tracing of VNC authentication process X-BeenThere: qemu-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@gnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Trace anything related to authentication in the VNC protocol handshake Signed-off-by: Daniel P. Berrange Message-id: 20170921121528.23935-3-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/vnc-auth-sasl.c | 113 ++++++++++++++++++++++-----------------------= ---- ui/vnc-auth-vencrypt.c | 21 ++++----- ui/vnc.c | 36 ++++++++-------- ui/trace-events | 15 +++++++ 4 files changed, 92 insertions(+), 93 deletions(-) diff --git a/ui/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c index 3ade4a4918..23f28280e7 100644 --- a/ui/vnc-auth-sasl.c +++ b/ui/vnc-auth-sasl.c @@ -25,6 +25,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "vnc.h" +#include "trace.h" =20 /* Max amount of data we send/recv for SASL steps to prevent DOS */ #define SASL_DATA_MAX_LEN (1024 * 1024) @@ -133,27 +134,26 @@ static int vnc_auth_sasl_check_access(VncState *vs) =20 err =3D sasl_getprop(vs->sasl.conn, SASL_USERNAME, &val); if (err !=3D SASL_OK) { - VNC_DEBUG("cannot query SASL username on connection %d (%s), denyi= ng access\n", - err, sasl_errstring(err, NULL, NULL)); + trace_vnc_auth_fail(vs, vs->auth, "Cannot fetch SASL username", + sasl_errstring(err, NULL, NULL)); return -1; } if (val =3D=3D NULL) { - VNC_DEBUG("no client username was found, denying access\n"); + trace_vnc_auth_fail(vs, vs->auth, "No SASL username set", ""); return -1; } - VNC_DEBUG("SASL client username %s\n", (const char *)val); =20 vs->sasl.username =3D g_strdup((const char*)val); + trace_vnc_auth_sasl_username(vs, vs->sasl.username); =20 if (vs->vd->sasl.acl =3D=3D NULL) { - VNC_DEBUG("no ACL activated, allowing access\n"); + trace_vnc_auth_sasl_acl(vs, 1); return 0; } =20 allow =3D qemu_acl_party_is_allowed(vs->vd->sasl.acl, vs->sasl.usernam= e); =20 - VNC_DEBUG("SASL client %s %s by ACL\n", vs->sasl.username, - allow ? "allowed" : "denied"); + trace_vnc_auth_sasl_acl(vs, allow); return allow ? 0 : -1; } =20 @@ -170,7 +170,9 @@ static int vnc_auth_sasl_check_ssf(VncState *vs) return 0; =20 ssf =3D *(const int *)val; - VNC_DEBUG("negotiated an SSF of %d\n", ssf); + + trace_vnc_auth_sasl_ssf(vs, ssf); + if (ssf < 56) return 0; /* 56 is good for Kerberos */ =20 @@ -218,33 +220,28 @@ static int protocol_client_auth_sasl_step(VncState *v= s, uint8_t *data, size_t le datalen--; /* Don't count NULL byte when passing to _start() */ } =20 - VNC_DEBUG("Step using SASL Data %p (%d bytes)\n", - clientdata, datalen); err =3D sasl_server_step(vs->sasl.conn, clientdata, datalen, &serverout, &serveroutlen); + trace_vnc_auth_sasl_step(vs, data, len, serverout, serveroutlen, err); if (err !=3D SASL_OK && err !=3D SASL_CONTINUE) { - VNC_DEBUG("sasl step failed %d (%s)\n", - err, sasl_errdetail(vs->sasl.conn)); + trace_vnc_auth_fail(vs, vs->auth, "Cannot step SASL auth", + sasl_errdetail(vs->sasl.conn)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; goto authabort; } =20 if (serveroutlen > SASL_DATA_MAX_LEN) { - VNC_DEBUG("sasl step reply data too long %d\n", - serveroutlen); + trace_vnc_auth_fail(vs, vs->auth, "SASL data too long", ""); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; goto authabort; } =20 - VNC_DEBUG("SASL return data %d bytes, nil; %d\n", - serveroutlen, serverout ? 0 : 1); - if (serveroutlen) { vnc_write_u32(vs, serveroutlen + 1); vnc_write(vs, serverout, serveroutlen + 1); @@ -256,22 +253,20 @@ static int protocol_client_auth_sasl_step(VncState *v= s, uint8_t *data, size_t le vnc_write_u8(vs, err =3D=3D SASL_CONTINUE ? 0 : 1); =20 if (err =3D=3D SASL_CONTINUE) { - VNC_DEBUG("%s", "Authentication must continue\n"); /* Wait for step length */ vnc_read_when(vs, protocol_client_auth_sasl_step_len, 4); } else { if (!vnc_auth_sasl_check_ssf(vs)) { - VNC_DEBUG("Authentication rejected for weak SSF %p\n", vs->ioc= ); + trace_vnc_auth_fail(vs, vs->auth, "SASL SSF too weak", ""); goto authreject; } =20 /* Check username whitelist ACL */ if (vnc_auth_sasl_check_access(vs) < 0) { - VNC_DEBUG("Authentication rejected for ACL %p\n", vs->ioc); goto authreject; } =20 - VNC_DEBUG("Authentication successful %p\n", vs->ioc); + trace_vnc_auth_pass(vs, vs->auth); vnc_write_u32(vs, 0); /* Accept auth */ /* * Delay writing in SSF encoded mode until pending output @@ -300,9 +295,9 @@ static int protocol_client_auth_sasl_step(VncState *vs,= uint8_t *data, size_t le static int protocol_client_auth_sasl_step_len(VncState *vs, uint8_t *data,= size_t len) { uint32_t steplen =3D read_u32(data, 0); - VNC_DEBUG("Got client step len %d\n", steplen); + if (steplen > SASL_DATA_MAX_LEN) { - VNC_DEBUG("Too much SASL data %d\n", steplen); + trace_vnc_auth_fail(vs, vs->auth, "SASL step len too large", ""); vnc_client_error(vs); return -1; } @@ -346,33 +341,28 @@ static int protocol_client_auth_sasl_start(VncState *= vs, uint8_t *data, size_t l datalen--; /* Don't count NULL byte when passing to _start() */ } =20 - VNC_DEBUG("Start SASL auth with mechanism %s. Data %p (%d bytes)\n", - vs->sasl.mechlist, clientdata, datalen); err =3D sasl_server_start(vs->sasl.conn, vs->sasl.mechlist, clientdata, datalen, &serverout, &serveroutlen); + trace_vnc_auth_sasl_start(vs, data, len, serverout, serveroutlen, err); if (err !=3D SASL_OK && err !=3D SASL_CONTINUE) { - VNC_DEBUG("sasl start failed %d (%s)\n", - err, sasl_errdetail(vs->sasl.conn)); + trace_vnc_auth_fail(vs, vs->auth, "Cannot start SASL auth", + sasl_errdetail(vs->sasl.conn)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; goto authabort; } if (serveroutlen > SASL_DATA_MAX_LEN) { - VNC_DEBUG("sasl start reply data too long %d\n", - serveroutlen); + trace_vnc_auth_fail(vs, vs->auth, "SASL data too long", ""); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; goto authabort; } =20 - VNC_DEBUG("SASL return data %d bytes, nil; %d\n", - serveroutlen, serverout ? 0 : 1); - if (serveroutlen) { vnc_write_u32(vs, serveroutlen + 1); vnc_write(vs, serverout, serveroutlen + 1); @@ -384,22 +374,20 @@ static int protocol_client_auth_sasl_start(VncState *= vs, uint8_t *data, size_t l vnc_write_u8(vs, err =3D=3D SASL_CONTINUE ? 0 : 1); =20 if (err =3D=3D SASL_CONTINUE) { - VNC_DEBUG("%s", "Authentication must continue\n"); /* Wait for step length */ vnc_read_when(vs, protocol_client_auth_sasl_step_len, 4); } else { if (!vnc_auth_sasl_check_ssf(vs)) { - VNC_DEBUG("Authentication rejected for weak SSF %p\n", vs->ioc= ); + trace_vnc_auth_fail(vs, vs->auth, "SASL SSF too weak", ""); goto authreject; } =20 /* Check username whitelist ACL */ if (vnc_auth_sasl_check_access(vs) < 0) { - VNC_DEBUG("Authentication rejected for ACL %p\n", vs->ioc); goto authreject; } =20 - VNC_DEBUG("Authentication successful %p\n", vs->ioc); + trace_vnc_auth_pass(vs, vs->auth); vnc_write_u32(vs, 0); /* Accept auth */ start_client_init(vs); } @@ -422,9 +410,9 @@ static int protocol_client_auth_sasl_start(VncState *vs= , uint8_t *data, size_t l static int protocol_client_auth_sasl_start_len(VncState *vs, uint8_t *data= , size_t len) { uint32_t startlen =3D read_u32(data, 0); - VNC_DEBUG("Got client start len %d\n", startlen); + if (startlen > SASL_DATA_MAX_LEN) { - VNC_DEBUG("Too much SASL data %d\n", startlen); + trace_vnc_auth_fail(vs, vs->auth, "SASL start len too large", ""); vnc_client_error(vs); return -1; } @@ -439,22 +427,18 @@ static int protocol_client_auth_sasl_start_len(VncSta= te *vs, uint8_t *data, size static int protocol_client_auth_sasl_mechname(VncState *vs, uint8_t *data,= size_t len) { char *mechname =3D g_strndup((const char *) data, len); - VNC_DEBUG("Got client mechname '%s' check against '%s'\n", - mechname, vs->sasl.mechlist); + trace_vnc_auth_sasl_mech_choose(vs, mechname); =20 if (strncmp(vs->sasl.mechlist, mechname, len) =3D=3D 0) { if (vs->sasl.mechlist[len] !=3D '\0' && vs->sasl.mechlist[len] !=3D ',') { - VNC_DEBUG("One %d", vs->sasl.mechlist[len]); goto fail; } } else { char *offset =3D strstr(vs->sasl.mechlist, mechname); - VNC_DEBUG("Two %p\n", offset); if (!offset) { goto fail; } - VNC_DEBUG("Two '%s'\n", offset); if (offset[-1] !=3D ',' || (offset[len] !=3D '\0'&& offset[len] !=3D ',')) { @@ -465,11 +449,11 @@ static int protocol_client_auth_sasl_mechname(VncStat= e *vs, uint8_t *data, size_ g_free(vs->sasl.mechlist); vs->sasl.mechlist =3D mechname; =20 - VNC_DEBUG("Validated mechname '%s'\n", mechname); vnc_read_when(vs, protocol_client_auth_sasl_start_len, 4); return 0; =20 fail: + trace_vnc_auth_fail(vs, vs->auth, "Unsupported mechname", mechname); vnc_client_error(vs); g_free(mechname); return -1; @@ -478,14 +462,14 @@ static int protocol_client_auth_sasl_mechname(VncStat= e *vs, uint8_t *data, size_ static int protocol_client_auth_sasl_mechname_len(VncState *vs, uint8_t *d= ata, size_t len) { uint32_t mechlen =3D read_u32(data, 0); - VNC_DEBUG("Got client mechname len %d\n", mechlen); + if (mechlen > 100) { - VNC_DEBUG("Too long SASL mechname data %d\n", mechlen); + trace_vnc_auth_fail(vs, vs->auth, "SASL mechname too long", ""); vnc_client_error(vs); return -1; } if (mechlen < 1) { - VNC_DEBUG("Too short SASL mechname %d\n", mechlen); + trace_vnc_auth_fail(vs, vs->auth, "SASL mechname too short", ""); vnc_client_error(vs); return -1; } @@ -524,19 +508,22 @@ void start_auth_sasl(VncState *vs) const char *mechlist =3D NULL; sasl_security_properties_t secprops; int err; + Error *local_err =3D NULL; char *localAddr, *remoteAddr; int mechlistlen; =20 - VNC_DEBUG("Initialize SASL auth %p\n", vs->ioc); - /* Get local & remote client addresses in form IPADDR;PORT */ - localAddr =3D vnc_socket_ip_addr_string(vs->sioc, true, NULL); + localAddr =3D vnc_socket_ip_addr_string(vs->sioc, true, &local_err); if (!localAddr) { + trace_vnc_auth_fail(vs, vs->auth, "Cannot format local IP", + error_get_pretty(local_err)); goto authabort; } =20 - remoteAddr =3D vnc_socket_ip_addr_string(vs->sioc, false, NULL); + remoteAddr =3D vnc_socket_ip_addr_string(vs->sioc, false, &local_err); if (!remoteAddr) { + trace_vnc_auth_fail(vs, vs->auth, "Cannot format remote IP", + error_get_pretty(local_err)); g_free(localAddr); goto authabort; } @@ -554,8 +541,8 @@ void start_auth_sasl(VncState *vs) localAddr =3D remoteAddr =3D NULL; =20 if (err !=3D SASL_OK) { - VNC_DEBUG("sasl context setup failed %d (%s)", - err, sasl_errstring(err, NULL, NULL)); + trace_vnc_auth_fail(vs, vs->auth, "SASL context setup failed", + sasl_errstring(err, NULL, NULL)); vs->sasl.conn =3D NULL; goto authabort; } @@ -570,8 +557,8 @@ void start_auth_sasl(VncState *vs) keysize =3D qcrypto_tls_session_get_key_size(vs->tls, &local_err); if (keysize < 0) { - VNC_DEBUG("cannot TLS get cipher size: %s\n", - error_get_pretty(local_err)); + trace_vnc_auth_fail(vs, vs->auth, "cannot TLS get cipher size", + error_get_pretty(local_err)); error_free(local_err); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; @@ -581,8 +568,8 @@ void start_auth_sasl(VncState *vs) =20 err =3D sasl_setprop(vs->sasl.conn, SASL_SSF_EXTERNAL, &ssf); if (err !=3D SASL_OK) { - VNC_DEBUG("cannot set SASL external SSF %d (%s)\n", - err, sasl_errstring(err, NULL, NULL)); + trace_vnc_auth_fail(vs, vs->auth, "cannot set SASL external SS= F", + sasl_errstring(err, NULL, NULL)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; goto authabort; @@ -617,8 +604,8 @@ void start_auth_sasl(VncState *vs) =20 err =3D sasl_setprop(vs->sasl.conn, SASL_SEC_PROPS, &secprops); if (err !=3D SASL_OK) { - VNC_DEBUG("cannot set SASL security props %d (%s)\n", - err, sasl_errstring(err, NULL, NULL)); + trace_vnc_auth_fail(vs, vs->auth, "cannot set SASL security props", + sasl_errstring(err, NULL, NULL)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; goto authabort; @@ -633,13 +620,13 @@ void start_auth_sasl(VncState *vs) NULL, NULL); if (err !=3D SASL_OK) { - VNC_DEBUG("cannot list SASL mechanisms %d (%s)\n", - err, sasl_errdetail(vs->sasl.conn)); + trace_vnc_auth_fail(vs, vs->auth, "cannot list SASL mechanisms", + sasl_errdetail(vs->sasl.conn)); sasl_dispose(&vs->sasl.conn); vs->sasl.conn =3D NULL; goto authabort; } - VNC_DEBUG("Available mechanisms for client: '%s'\n", mechlist); + trace_vnc_auth_sasl_mech_list(vs, mechlist); =20 vs->sasl.mechlist =3D g_strdup(mechlist); mechlistlen =3D strlen(mechlist); @@ -647,12 +634,12 @@ void start_auth_sasl(VncState *vs) vnc_write(vs, mechlist, mechlistlen); vnc_flush(vs); =20 - VNC_DEBUG("Wait for client mechname length\n"); vnc_read_when(vs, protocol_client_auth_sasl_mechname_len, 4); =20 return; =20 authabort: + error_free(local_err); vnc_client_error(vs); } =20 diff --git a/ui/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c index 8ab00ef784..f0bec204b3 100644 --- a/ui/vnc-auth-vencrypt.c +++ b/ui/vnc-auth-vencrypt.c @@ -35,27 +35,24 @@ static void start_auth_vencrypt_subauth(VncState *vs) switch (vs->subauth) { case VNC_AUTH_VENCRYPT_TLSNONE: case VNC_AUTH_VENCRYPT_X509NONE: - VNC_DEBUG("Accept TLS auth none\n"); vnc_write_u32(vs, 0); /* Accept auth completion */ start_client_init(vs); break; =20 case VNC_AUTH_VENCRYPT_TLSVNC: case VNC_AUTH_VENCRYPT_X509VNC: - VNC_DEBUG("Start TLS auth VNC\n"); start_auth_vnc(vs); break; =20 #ifdef CONFIG_VNC_SASL case VNC_AUTH_VENCRYPT_TLSSASL: case VNC_AUTH_VENCRYPT_X509SASL: - VNC_DEBUG("Start TLS auth SASL\n"); start_auth_sasl(vs); break; #endif /* CONFIG_VNC_SASL */ =20 default: /* Should not be possible, but just in case */ - VNC_DEBUG("Reject subauth %d server bug\n", vs->auth); + trace_vnc_auth_fail(vs, vs->auth, "Unhandled VeNCrypt subauth", ""); vnc_write_u8(vs, 1); if (vs->minor >=3D 8) { static const char err[] =3D "Unsupported authentication type"; @@ -73,8 +70,8 @@ static void vnc_tls_handshake_done(QIOTask *task, Error *err =3D NULL; =20 if (qio_task_propagate_error(task, &err)) { - VNC_DEBUG("Handshake failed %s\n", - error_get_pretty(err)); + trace_vnc_auth_fail(vs, vs->auth, "TLS handshake failed", + error_get_pretty(err)); vnc_client_error(vs); error_free(err); } else { @@ -89,15 +86,15 @@ static int protocol_client_vencrypt_auth(VncState *vs, = uint8_t *data, size_t len { int auth =3D read_u32(data, 0); =20 + trace_vnc_auth_vencrypt_subauth(vs, auth); if (auth !=3D vs->subauth) { - VNC_DEBUG("Rejecting auth %d\n", auth); + trace_vnc_auth_fail(vs, vs->auth, "Unsupported sub-auth version", = ""); vnc_write_u8(vs, 0); /* Reject auth */ vnc_flush(vs); vnc_client_error(vs); } else { Error *err =3D NULL; QIOChannelTLS *tls; - VNC_DEBUG("Accepting auth %d, setting up TLS for handshake\n", aut= h); vnc_write_u8(vs, 1); /* Accept auth */ vnc_flush(vs); =20 @@ -112,14 +109,14 @@ static int protocol_client_vencrypt_auth(VncState *vs= , uint8_t *data, size_t len vs->vd->tlsaclname, &err); if (!tls) { - VNC_DEBUG("Failed to setup TLS %s\n", error_get_pretty(err)); + trace_vnc_auth_fail(vs, vs->auth, "TLS setup failed", + error_get_pretty(err)); error_free(err); vnc_client_error(vs); return 0; } =20 qio_channel_set_name(QIO_CHANNEL(tls), "vnc-server-tls"); - VNC_DEBUG("Start TLS VeNCrypt handshake process\n"); object_unref(OBJECT(vs->ioc)); vs->ioc =3D QIO_CHANNEL(tls); trace_vnc_client_io_wrap(vs, vs->ioc, "tls"); @@ -135,14 +132,14 @@ static int protocol_client_vencrypt_auth(VncState *vs= , uint8_t *data, size_t len =20 static int protocol_client_vencrypt_init(VncState *vs, uint8_t *data, size= _t len) { + trace_vnc_auth_vencrypt_version(vs, (int)data[0], (int)data[1]); if (data[0] !=3D 0 || data[1] !=3D 2) { - VNC_DEBUG("Unsupported VeNCrypt protocol %d.%d\n", (int)data[0], (= int)data[1]); + trace_vnc_auth_fail(vs, vs->auth, "Unsupported version", ""); vnc_write_u8(vs, 1); /* Reject version */ vnc_flush(vs); vnc_client_error(vs); } else { - VNC_DEBUG("Sending allowed auth %d\n", vs->subauth); vnc_write_u8(vs, 0); /* Accept version */ vnc_write_u8(vs, 1); /* Number of sub-auths */ vnc_write_u32(vs, vs->subauth); /* The supported auth */ diff --git a/ui/vnc.c b/ui/vnc.c index ed6d659722..af810f0547 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -2406,11 +2406,11 @@ static int protocol_client_auth_vnc(VncState *vs, u= int8_t *data, size_t len) Error *err =3D NULL; =20 if (!vs->vd->password) { - VNC_DEBUG("No password configured on server"); + trace_vnc_auth_fail(vs, vs->auth, "password is not set", ""); goto reject; } if (vs->vd->expires < now) { - VNC_DEBUG("Password is expired"); + trace_vnc_auth_fail(vs, vs->auth, "password is expired", ""); goto reject; } =20 @@ -2427,8 +2427,8 @@ static int protocol_client_auth_vnc(VncState *vs, uin= t8_t *data, size_t len) key, G_N_ELEMENTS(key), &err); if (!cipher) { - VNC_DEBUG("Cannot initialize cipher %s", - error_get_pretty(err)); + trace_vnc_auth_fail(vs, vs->auth, "cannot create cipher", + error_get_pretty(err)); error_free(err); goto reject; } @@ -2438,18 +2438,18 @@ static int protocol_client_auth_vnc(VncState *vs, u= int8_t *data, size_t len) response, VNC_AUTH_CHALLENGE_SIZE, &err) < 0) { - VNC_DEBUG("Cannot encrypt challenge %s", - error_get_pretty(err)); + trace_vnc_auth_fail(vs, vs->auth, "cannot encrypt challenge respon= se", + error_get_pretty(err)); error_free(err); goto reject; } =20 /* Compare expected vs actual challenge response */ if (memcmp(response, data, VNC_AUTH_CHALLENGE_SIZE) !=3D 0) { - VNC_DEBUG("Client challenge response did not match\n"); + trace_vnc_auth_fail(vs, vs->auth, "mis-matched challenge response"= , ""); goto reject; } else { - VNC_DEBUG("Accepting VNC challenge response\n"); + trace_vnc_auth_pass(vs, vs->auth); vnc_write_u32(vs, 0); /* Accept auth */ vnc_flush(vs); =20 @@ -2488,7 +2488,7 @@ static int protocol_client_auth(VncState *vs, uint8_t= *data, size_t len) /* We only advertise 1 auth scheme at a time, so client * must pick the one we sent. Verify this */ if (data[0] !=3D vs->auth) { /* Reject auth */ - VNC_DEBUG("Reject auth %d because it didn't match advertized\n", (i= nt)data[0]); + trace_vnc_auth_reject(vs, vs->auth, (int)data[0]); vnc_write_u32(vs, 1); if (vs->minor >=3D 8) { static const char err[] =3D "Authentication failed"; @@ -2497,36 +2497,33 @@ static int protocol_client_auth(VncState *vs, uint8= _t *data, size_t len) } vnc_client_error(vs); } else { /* Accept requested auth */ - VNC_DEBUG("Client requested auth %d\n", (int)data[0]); + trace_vnc_auth_start(vs, vs->auth); switch (vs->auth) { case VNC_AUTH_NONE: - VNC_DEBUG("Accept auth none\n"); if (vs->minor >=3D 8) { vnc_write_u32(vs, 0); /* Accept auth completion */ vnc_flush(vs); } + trace_vnc_auth_pass(vs, vs->auth); start_client_init(vs); break; =20 case VNC_AUTH_VNC: - VNC_DEBUG("Start VNC auth\n"); start_auth_vnc(vs); break; =20 case VNC_AUTH_VENCRYPT: - VNC_DEBUG("Accept VeNCrypt auth\n"); start_auth_vencrypt(vs); break; =20 #ifdef CONFIG_VNC_SASL case VNC_AUTH_SASL: - VNC_DEBUG("Accept SASL auth\n"); start_auth_sasl(vs); break; #endif /* CONFIG_VNC_SASL */ =20 default: /* Should not be possible, but just in case */ - VNC_DEBUG("Reject auth %d server code bug\n", vs->auth); + trace_vnc_auth_fail(vs, vs->auth, "Unhandled auth method", ""); vnc_write_u8(vs, 1); if (vs->minor >=3D 8) { static const char err[] =3D "Authentication failed"; @@ -2571,10 +2568,11 @@ static int protocol_version(VncState *vs, uint8_t *= version, size_t len) vs->minor =3D 3; =20 if (vs->minor =3D=3D 3) { + trace_vnc_auth_start(vs, vs->auth); if (vs->auth =3D=3D VNC_AUTH_NONE) { - VNC_DEBUG("Tell client auth none\n"); vnc_write_u32(vs, vs->auth); vnc_flush(vs); + trace_vnc_auth_pass(vs, vs->auth); start_client_init(vs); } else if (vs->auth =3D=3D VNC_AUTH_VNC) { VNC_DEBUG("Tell client VNC auth\n"); @@ -2582,13 +2580,13 @@ static int protocol_version(VncState *vs, uint8_t *= version, size_t len) vnc_flush(vs); start_auth_vnc(vs); } else { - VNC_DEBUG("Unsupported auth %d for protocol 3.3\n", vs->auth); + trace_vnc_auth_fail(vs, vs->auth, + "Unsupported auth method for v3.3", ""); vnc_write_u32(vs, VNC_AUTH_INVALID); vnc_flush(vs); vnc_client_error(vs); } } else { - VNC_DEBUG("Telling client we support auth %d\n", vs->auth); vnc_write_u8(vs, 1); /* num auth */ vnc_write_u8(vs, vs->auth); vnc_read_when(vs, protocol_client_auth, 1); @@ -3942,12 +3940,14 @@ void vnc_display_open(const char *id, Error **errp) sasl, false, errp) < 0) { goto fail; } + trace_vnc_auth_init(vd, 0, vd->auth, vd->subauth); =20 if (vnc_display_setup_auth(&vd->ws_auth, &vd->ws_subauth, vd->tlscreds, password, sasl, true, errp) < 0) { goto fail; } + trace_vnc_auth_init(vd, 1, vd->ws_auth, vd->ws_subauth); =20 #ifdef CONFIG_VNC_SASL if ((saslErr =3D sasl_server_init(NULL, "qemu")) !=3D SASL_OK) { diff --git a/ui/trace-events b/ui/trace-events index e4c02e47f5..1a9f126330 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -35,6 +35,21 @@ vnc_client_connect(void *state, void *ioc) "VNC client c= onnect state=3D%p ioc=3D%p" vnc_client_disconnect_start(void *state, void *ioc) "VNC client disconnect= start state=3D%p ioc=3D%p" vnc_client_disconnect_finish(void *state, void *ioc) "VNC client disconnec= t finish state=3D%p ioc=3D%p" vnc_client_io_wrap(void *state, void *ioc, const char *type) "VNC client I= /O wrap state=3D%p ioc=3D%p type=3D%s" +vnc_auth_init(void *display, int websock, int auth, int subauth) "VNC auth= init state=3D%p websock=3D%d auth=3D%d subauth=3D%d" +vnc_auth_start(void *state, int method) "VNC client auth start state=3D%p = method=3D%d" +vnc_auth_pass(void *state, int method) "VNC client auth passed state=3D%p = method=3D%d" +vnc_auth_fail(void *state, int method, const char *message, const char *re= ason) "VNC client auth failed state=3D%p method=3D%d message=3D%s reason=3D= %s" +vnc_auth_reject(void *state, int expect, int got) "VNC client auth rejecte= d state=3D%p method expected=3D%d got=3D%d" +vnc_auth_vencrypt_version(void *state, int major, int minor) "VNC client a= uth vencrypt version state=3D%p major=3D%d minor=3D%d" +vnc_auth_vencrypt_subauth(void *state, int auth) "VNC client auth vencrypt= subauth state=3D%p auth=3D%d" +vnc_auth_sasl_mech_list(void *state, const char *mechs) "VNC client auth S= ASL state=3D%p mechlist=3D%s" +vnc_auth_sasl_mech_choose(void *state, const char *mech) "VNC client auth = SASL state=3D%p mech=3D%s" +vnc_auth_sasl_start(void *state, const void *clientdata, size_t clientlen,= const void *serverdata, size_t severlen, int ret) "VNC client auth SASL st= art state=3D%p clientdata=3D%p clientlen=3D%zu serverdata=3D%p serverlen=3D= %zu ret=3D%d" +vnc_auth_sasl_step(void *state, const void *clientdata, size_t clientlen, = const void *serverdata, size_t severlen, int ret) "VNC client auth SASL ste= p state=3D%p clientdata=3D%p clientlen=3D%zu serverdata=3D%p serverlen=3D%z= u ret=3D%d" +vnc_auth_sasl_ssf(void *state, int ssf) "VNC client auth SASL SSF state=3D= %p size=3D%d" +vnc_auth_sasl_username(void *state, const char *name) "VNC client auth SAS= L user state=3D%p name=3D%s" +vnc_auth_sasl_acl(void *state, int allow) "VNC client auth SASL ACL state= =3D%p allow=3D%d" + =20 # ui/input.c input_event_key_number(int conidx, int number, const char *qcode, bool dow= n) "con %d, key number 0x%x [%s], down %d" --=20 2.9.3