From nobody Sat Nov 15 20:52:53 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747840646; cv=none; d=zohomail.com; s=zohoarc; b=CSMAbCOfhXCTXKgUwjsUNc1rA41XYTMAF3VeLAAg1ZWsk8MQxnU568t8q8pqc3oEigRW/oC2+i/zPF9NHBwpz5NC6HRkU15foSo3WAKBXJXVsjuHC5wZMBNPWRblAN3axuFXSGv9V1tNGez2ANnYHSI0EI+OZ5wOsqF6h5+zRbE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747840646; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Shz/tZqIt2lGAR4MMQw16a29wqa0BbKrakqQWjPt//U=; b=UOP4UAK9XCrnZgTvczz01z+5CqpwfhHQc3+g7phrFbsbdqjtImPUT6AJmuef8yK8UHPNxaZUWfg2HgPzwMWyNC2NHKvnzpcoKkPvJlMql9R4mYadkWxb/Q/E3QRMTKfhhfCEjjz8IG1YHfkYtWFhXxRJZUSBn/nKn4QTtc54sm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747840646576405.8805198915263; Wed, 21 May 2025 08:17:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHlBe-0006BE-5Z; Wed, 21 May 2025 11:16:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHlBc-0006Ai-2l for qemu-devel@nongnu.org; Wed, 21 May 2025 11:16:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHlBY-0002fL-O8 for qemu-devel@nongnu.org; Wed, 21 May 2025 11:16:51 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-325-oQRwa7jiMwyT0pGEA8RjLQ-1; Wed, 21 May 2025 11:16:44 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A10A619560BF for ; Wed, 21 May 2025 15:16:43 +0000 (UTC) Received: from fedora.brq.redhat.com (unknown [10.43.2.64]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A94C830001AB; Wed, 21 May 2025 15:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747840605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Shz/tZqIt2lGAR4MMQw16a29wqa0BbKrakqQWjPt//U=; b=KRw1owpP/V7670rS2E6op+xPNr/zWhPAqUrpd0Cgl3LGHuxspl/4vL+J09RQSaZhEbufy3 VK2Psmyl56XvDuwPxk3dvqmMCxunn5MRzoSoxkvXyHAPLSFdUWD9/0A7TfzzKAEU0Jp5hl ROeNay0SH6EvU+QzTX/InpykvR0Kl3M= X-MC-Unique: oQRwa7jiMwyT0pGEA8RjLQ-1 X-Mimecast-MFC-AGG-ID: oQRwa7jiMwyT0pGEA8RjLQ_1747840603 From: Juraj Marcin To: qemu-devel@nongnu.org Cc: Juraj Marcin , peterx@redhat.com, kraxel@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH] ui/vnc: Update display update interval when VM state changes to RUNNING Date: Wed, 21 May 2025 17:16:13 +0200 Message-ID: <20250521151616.3951178-1-jmarcin@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=jmarcin@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747840647625116600 Content-Type: text/plain; charset="utf-8" From: Juraj Marcin If a virtual machine is paused for an extended period time, for example, due to an incoming migration, there are also no changes on the screen. VNC in such case increases the display update interval by VNC_REFRESH_INTERVAL_INC (50 ms). The update interval can then grow up to VNC_REFRESH_INTERVAL_MAX (3000 ms). When the machine resumes, it can then take up to 3 seconds for the first display update. Furthermore, the update interval is then halved with each display update with changes on the screen. If there are moving elements on the screen, such as a video, this can be perceived as freezing and stuttering for few seconds before the movement is smooth again. This patch resolves this issue, by adding a listener to VM state changes and changing the update interval when the VM state changes to RUNNING. The update_displaychangelistener() function updates the internal timer, and the display is refreshed immediately if the timer is expired. Signed-off-by: Juraj Marcin Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Peter Xu --- ui/vnc.c | 12 ++++++++++++ ui/vnc.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/ui/vnc.c b/ui/vnc.c index 9e097dc4b4..32f8bfd1f9 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3384,6 +3384,16 @@ static const DisplayChangeListenerOps dcl_ops =3D { .dpy_cursor_define =3D vnc_dpy_cursor_define, }; =20 +static void vmstate_change_handler(void *opaque, bool running, RunState st= ate) +{ + VncDisplay *vd =3D opaque; + + if (state !=3D RUN_STATE_RUNNING) { + return; + } + update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); +} + void vnc_display_init(const char *id, Error **errp) { VncDisplay *vd; @@ -3420,6 +3430,8 @@ void vnc_display_init(const char *id, Error **errp) vd->dcl.ops =3D &dcl_ops; register_displaychangelistener(&vd->dcl); vd->kbd =3D qkbd_state_init(vd->dcl.con); + vd->vmstate_handler_entry =3D qemu_add_vm_change_state_handler( + &vmstate_change_handler, vd); } =20 =20 diff --git a/ui/vnc.h b/ui/vnc.h index acc53a2cc1..3bb23acd34 100644 --- a/ui/vnc.h +++ b/ui/vnc.h @@ -185,6 +185,8 @@ struct VncDisplay #endif =20 AudioState *audio_state; + + VMChangeStateEntry *vmstate_handler_entry; }; =20 typedef struct VncTight { --=20 2.49.0