From nobody Fri May 17 07:47:31 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1696240516; cv=none; d=zohomail.com; s=zohoarc; b=iqN6OJmg+253FPKEOvFCoqjDU9YFS2y02jQhTsaKqJqNTiX6+LvIPLSM/B4A6LMET9tch2jNec9Hu+Qmi1nmdeFP3WM6LrUIcUqw+MY4AXmcYzO3/VNjkzN5hPpbppi97RQMph28XtJOzf77WSvckeRARxz0mJ4u9Dp25/FAdNs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1696240516; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=FJDLRUVJaBhfpCQ8P7M/Fh+0LBnQJh6KJ8GiG+zb1QU=; b=dCiLf1CIHcUVzcbhJWcNLz9tDggVFQUkA8WK6/RCEWzA//vIpbgoaGmxEn/quaU9n14sY+4lsmz7Ce1PGG5RvG+g9fNIyjUpKR2mB8UwzBo+TovR+LvHhj9o2NYiaj5FhjtgwPEh/r9UzUs5xmz4kA83gJCpFk0krJVcIKuMl+U= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1696240516026852.6434128777961; Mon, 2 Oct 2023 02:55:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qnFdf-0007CG-NZ; Mon, 02 Oct 2023 05:54:55 -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 1qnFdd-00076a-HH for qemu-devel@nongnu.org; Mon, 02 Oct 2023 05:54:53 -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 1qnFda-0004lW-Uo for qemu-devel@nongnu.org; Mon, 02 Oct 2023 05:54:53 -0400 Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-449-LmtoSbQaOU6iSmjQGhRpTQ-1; Mon, 02 Oct 2023 05:54:48 -0400 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9a9f282713fso1359940666b.3 for ; Mon, 02 Oct 2023 02:54:48 -0700 (PDT) Received: from [192.168.10.117] ([2001:b07:6468:f312:48f9:bea:a04c:3dfe]) by smtp.gmail.com with ESMTPSA id bu24-20020a170906a15800b0098669cc16b2sm16580411ejb.83.2023.10.02.02.54.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 02:54:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696240489; h=from:from: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; bh=FJDLRUVJaBhfpCQ8P7M/Fh+0LBnQJh6KJ8GiG+zb1QU=; b=HqTiT7kZLu7Eg0jR6+fbaN9J7L3bQln8JYSFtFfM6ncfXUvCayjsb76Ip32HeuwL9mjhuI tEpFZJUuQ6/VjpzP/0Q5dRE1M2iD7Cc3uhECmgNFPWZNoETugiNYmVW1YbRusZzoVwRIn1 eX1tsksVTU17b7aq7am9KlY5QXS6jTg= X-MC-Unique: LmtoSbQaOU6iSmjQGhRpTQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696240487; x=1696845287; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FJDLRUVJaBhfpCQ8P7M/Fh+0LBnQJh6KJ8GiG+zb1QU=; b=mwU80yt8+TcFulJyd3rI8fWh7g26GpPdmUk0Wa0reQbuNmpy6aXwdApFMXfKKDWDZn CrHoAxcAvzHZvmMnyzX7KMMXTMXh5HVE6Wz/a8qckXriG82SmGvoqGuqrxGz4wnUWyq8 EOboBSsEyGXBnqvsXoDW15mg0vcoo15hSeNciPdfiwybOE/RKwgvfqqsW88XOUOJIID5 p8UixXOu7oUEK2SF6szhV90w7iHZyqxwlnhHMQZMkZieYElQ/kcjTxMMKpUKUrwB96fb DTdHONjjr3FY7R8eMSAzCEvNdl97D8DS1D9mrZ4eqXxQQcnN+XXHZyoGeni4ujKLoSNb 6VHQ== X-Gm-Message-State: AOJu0Yx0wurwtYmqUiyai/GY1ehloCNq8lfhsLE021tRe9HNaCMUa60r omhj3Wzjq5Mjy8ZJxSuyGqLbpypqNbRv4XDiWdd3BSRr+Q/xx7i4fTDEWtOjJOp/lBNHNn1C/9O 6pToytIX3M0mBSePWeIboWIb+bdfJ0f+Xj/++2wD0dralOzkKw5tB5ohGrYAGR0+NNUNt1q5XUx U= X-Received: by 2002:a17:907:7602:b0:9b2:b2ad:2a8f with SMTP id jx2-20020a170907760200b009b2b2ad2a8fmr8605215ejc.11.1696240486841; Mon, 02 Oct 2023 02:54:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVd/xlbc4oxWGFInTQP1FTJnARX9mkZpLktXkhqcy7ctL/jtPLI97BIKa6PnH/hSgBqfhmxw== X-Received: by 2002:a17:907:7602:b0:9b2:b2ad:2a8f with SMTP id jx2-20020a170907760200b009b2b2ad2a8fmr8605205ejc.11.1696240486432; Mon, 02 Oct 2023 02:54:46 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com Subject: [PATCH v2] ui: fix dpy_ui_info_supported(con) assertion Date: Mon, 2 Oct 2023 11:54:45 +0200 Message-ID: <20231002095445.65311-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, 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_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, 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: 1696240516646100003 Content-Type: text/plain; charset="utf-8" VGA does not support getting the physical video size or refresh rate. This is causing an assertion failure when the GTK+ user interface calls dpy_get_ui_info(). Return NULL from dpy_get_ui_info() if the information is not supported, and just ignore the request to set refresh rate or size in that case. While the assertion failure was introduced by commit a92e7bb4cad ("ui: add precondition for dpy_get_ui_info()", 2023-09-12), QEMU had been using con->ui_info incorrectly since before. Fixes: a92e7bb4cad ("ui: add precondition for dpy_get_ui_info()", 2023-09-1= 2) Fixes: aeffd071ed8 ("ui: Deliver refresh rate via QemuUIInfo", 2022-06-14) Signed-off-by: Paolo Bonzini Reviewed-by: Michael Tokarev --- ui/console.c | 4 +++- ui/gtk.c | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ui/console.c b/ui/console.c index 4a4f19ed33e..24438b187c8 100644 --- a/ui/console.c +++ b/ui/console.c @@ -815,7 +815,9 @@ bool dpy_ui_info_supported(const QemuConsole *con) =20 const QemuUIInfo *dpy_get_ui_info(const QemuConsole *con) { - assert(dpy_ui_info_supported(con)); + if (!dpy_ui_info_supported(con)) { + return NULL; + } =20 if (con =3D=3D NULL) { con =3D active_console; diff --git a/ui/gtk.c b/ui/gtk.c index e09f97a86b7..0b5e314cf0d 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -724,18 +724,32 @@ static gboolean gd_window_close(GtkWidget *widget, Gd= kEvent *event, =20 static void gd_set_ui_refresh_rate(VirtualConsole *vc, int refresh_rate) { + const QemuUIInfo *p_info; QemuUIInfo info; =20 - info =3D *dpy_get_ui_info(vc->gfx.dcl.con); + p_info =3D dpy_get_ui_info(vc->gfx.dcl.con); + if (!p_info) { + /* not supported by guest */ + return; + } + + info =3D *p_info; info.refresh_rate =3D refresh_rate; dpy_set_ui_info(vc->gfx.dcl.con, &info, true); } =20 static void gd_set_ui_size(VirtualConsole *vc, gint width, gint height) { + const QemuUIInfo *p_info; QemuUIInfo info; =20 - info =3D *dpy_get_ui_info(vc->gfx.dcl.con); + p_info =3D dpy_get_ui_info(vc->gfx.dcl.con); + if (!p_info) { + /* not supported by guest */ + return; + } + + info =3D *p_info; info.width =3D width; info.height =3D height; dpy_set_ui_info(vc->gfx.dcl.con, &info, true); --=20 2.41.0