From nobody Mon Feb 9 14:34:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615873145; cv=none; d=zohomail.com; s=zohoarc; b=XkTUah/Df7Ehh76Iopv3gtO47Xo464qrXUP2is1/Rh/N9V8lTZDbgbJ069X7VKYS/OmoR0hkt+1GTDV0XK/cku3VWW4iG9vPFbM3A/ezoI8ToLp9xfpPmqo8/41S12pdI2Ge36PnPyCCIUVWQFMHODRWBgix1UXaC+JumKE8UhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615873145; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eT73Zv6nbeUUWWKYtRetEVwL1cjukwGLaIyWzLuBOoM=; b=SgNHGMdbidFQRHxblaNlPgIYuylUZCvwXDMEy//ZtYbrQWlTA0DaSxePXR/7zya6hU2+fF0M3AyQBGvRM7IFJGmZac3jjjhz/hvMCw9ikrWC/I64ELLe5RCMg+QL+ZQ9bekSL0hX+IfJUUvBQl0El1qfUhp8VbUoOQ1tJfe5EtY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1615873145915230.10301652560668; Mon, 15 Mar 2021 22:39:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-iDGjZ2jkNTqwNP6vAC_Rlg-1; Tue, 16 Mar 2021 01:39:01 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 48EDE184610E; Tue, 16 Mar 2021 05:38:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1984A100164C; Tue, 16 Mar 2021 05:38:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CBBE657DD0; Tue, 16 Mar 2021 05:38:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12G5cQx7017059 for ; Tue, 16 Mar 2021 01:38:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id A1FF646; Tue, 16 Mar 2021 05:38:26 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-141.ams2.redhat.com [10.36.112.141]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA2B91F04E; Tue, 16 Mar 2021 05:38:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 871891800841; Tue, 16 Mar 2021 06:38:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615873144; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eT73Zv6nbeUUWWKYtRetEVwL1cjukwGLaIyWzLuBOoM=; b=IK7H6VOabLER/UywtZUyE2mgQeTj0IVyGsVBvny9ebIqOIp1iaHvOjPi2HI8ulzt3Wc6EQ afgutFJf+ecMq4Hjnz5uqhXjjsVVBhdhrKg4kkU4H5MKn1Ed+ib7HAbAU1bP/qSiQtvrwg PS18h3nN8yZ+y/sCMaqeeDLAC/moTGA= X-MC-Unique: iDGjZ2jkNTqwNP6vAC_Rlg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 09/11] ui: honour the actual guest display dimensions without rounding Date: Tue, 16 Mar 2021 06:38:11 +0100 Message-Id: <20210316053813.1719442-10-kraxel@redhat.com> In-Reply-To: <20210316053813.1719442-1-kraxel@redhat.com> References: <20210316053813.1719442-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, Peter Maydell , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Daniel P. Berrang=C3=A9 A long time ago the VNC server code had some memory corruption fixes done in: commit bea60dd7679364493a0d7f5b54316c767cf894ef Author: Peter Lieven Date: Mon Jun 30 10:57:51 2014 +0200 ui/vnc: fix potential memory corruption issues One of the implications of the fix was that the VNC server would have a thin black bad down the right hand side if the guest desktop width was not a multiple of 16. In practice this was a non-issue since the VNC server was always honouring a guest specified resolution and guests essentially always pick from a small set of sane resolutions likely in real world hardware. We recently introduced support for the extended desktop resize extension and as a result the VNC client has ability to specify an arbitrary desktop size and the guest OS may well honour it exactly. As a result we no longer have any guarantee that the width will be a multiple of 16, and so when resizing the desktop we have a 93% chance of getting the black bar on the right hand size. The VNC server maintains three different desktop dimensions 1. The guest surface 2. The server surface 3. The client desktop The requirement for the width to be a multiple of 16 only applies to item 2, the server surface, for the purpose of doing dirty bitmap tracking. Normally we will set the client desktop size to always match the server surface size, but that's not a strict requirement. In order to cope with clients that don't support the desktop size encoding, we already allow for the client desktop to be a different size that the server surface. Thus we can trivially eliminate the black bar, but setting the client desktop size to be the un-rounded server surface size - the so called "true width". Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Message-Id: <20210311182957.486939-5-berrange@redhat.com> Signed-off-by: Gerd Hoffmann --- ui/vnc.h | 1 + ui/vnc.c | 23 +++++++++++++++++++---- ui/trace-events | 2 ++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ui/vnc.h b/ui/vnc.h index 116463d5f099..d4f3e1555809 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -164,6 +164,7 @@ struct VncDisplay =20 struct VncSurface guest; /* guest visible surface (aka ds->surface) = */ pixman_image_t *server; /* vnc server surface */ + int true_width; /* server surface width before rounding up */ =20 const char *id; QTAILQ_ENTRY(VncDisplay) next; diff --git a/ui/vnc.c b/ui/vnc.c index 8c9890b3cdc4..9c004a11f495 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -608,6 +608,11 @@ static int vnc_width(VncDisplay *vd) VNC_DIRTY_PIXELS_PER_BIT)); } =20 +static int vnc_true_width(VncDisplay *vd) +{ + return MIN(VNC_MAX_WIDTH, surface_width(vd->ds)); +} + static int vnc_height(VncDisplay *vd) { return MIN(VNC_MAX_HEIGHT, surface_height(vd->ds)); @@ -691,16 +696,16 @@ static void vnc_desktop_resize(VncState *vs) !vnc_has_feature(vs, VNC_FEATURE_RESIZE_EXT)))= { return; } - if (vs->client_width =3D=3D pixman_image_get_width(vs->vd->server) && + if (vs->client_width =3D=3D vs->vd->true_width && vs->client_height =3D=3D pixman_image_get_height(vs->vd->server)) { return; } =20 - assert(pixman_image_get_width(vs->vd->server) < 65536 && - pixman_image_get_width(vs->vd->server) >=3D 0); + assert(vs->vd->true_width < 65536 && + vs->vd->true_width >=3D 0); assert(pixman_image_get_height(vs->vd->server) < 65536 && pixman_image_get_height(vs->vd->server) >=3D 0); - vs->client_width =3D pixman_image_get_width(vs->vd->server); + vs->client_width =3D vs->vd->true_width; vs->client_height =3D pixman_image_get_height(vs->vd->server); =20 if (vnc_has_feature(vs, VNC_FEATURE_RESIZE_EXT)) { @@ -774,6 +779,7 @@ static void vnc_update_server_surface(VncDisplay *vd) =20 width =3D vnc_width(vd); height =3D vnc_height(vd); + vd->true_width =3D vnc_true_width(vd); vd->server =3D pixman_image_create_bits(VNC_SERVER_FB_FORMAT, width, height, NULL, 0); @@ -809,13 +815,22 @@ static void vnc_dpy_switch(DisplayChangeListener *dcl, vd->guest.fb =3D pixman_image_ref(surface->image); vd->guest.format =3D surface->format; =20 + if (pageflip) { + trace_vnc_server_dpy_pageflip(vd, + surface_width(surface), + surface_height(surface), + surface_format(surface)); vnc_set_area_dirty(vd->guest.dirty, vd, 0, 0, surface_width(surface), surface_height(surface)); return; } =20 + trace_vnc_server_dpy_recreate(vd, + surface_width(surface), + surface_height(surface), + surface_format(surface)); /* server surface */ vnc_update_server_surface(vd); =20 diff --git a/ui/trace-events b/ui/trace-events index 3838ae2d849a..5d1da6f23668 100644 --- a/ui/trace-events +++ b/ui/trace-events @@ -59,6 +59,8 @@ vnc_client_throttle_audio(void *state, void *ioc, size_t = offset) "VNC client thr vnc_client_unthrottle_forced(void *state, void *ioc) "VNC client unthrottl= e forced offset state=3D%p ioc=3D%p" vnc_client_unthrottle_incremental(void *state, void *ioc, size_t offset) "= VNC client unthrottle incremental state=3D%p ioc=3D%p offset=3D%zu" vnc_client_output_limit(void *state, void *ioc, size_t offset, size_t thre= shold) "VNC client output limit state=3D%p ioc=3D%p offset=3D%zu threshold= =3D%zu" +vnc_server_dpy_pageflip(void *dpy, int w, int h, int fmt) "VNC server dpy = pageflip dpy=3D%p size=3D%dx%d fmt=3D%d" +vnc_server_dpy_recreate(void *dpy, int w, int h, int fmt) "VNC server dpy = recreate dpy=3D%p size=3D%dx%d fmt=3D%d" vnc_job_add_rect(void *state, void *job, int x, int y, int w, int h) "VNC = add rect state=3D%p job=3D%p offset=3D%d,%d size=3D%dx%d" vnc_job_discard_rect(void *state, void *job, int x, int y, int w, int h) "= VNC job discard rect state=3D%p job=3D%p offset=3D%d,%d size=3D%dx%d" vnc_job_clamp_rect(void *state, void *job, int x, int y, int w, int h) "VN= C job clamp rect state=3D%p job=3D%p offset=3D%d,%d size=3D%dx%d" --=20 2.29.2