From nobody Sun Feb 8 03:26:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1726596058348682.176349268839; Tue, 17 Sep 2024 11:00:58 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3B2D2178E; Tue, 17 Sep 2024 14:00:57 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3B6841AFC; Tue, 17 Sep 2024 13:59:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9EE9614B2; Tue, 17 Sep 2024 13:59:40 -0400 (EDT) Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id EE2F0152B for ; Tue, 17 Sep 2024 13:59:39 -0400 (EDT) Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5c24c92f699so6342411a12.2 for ; Tue, 17 Sep 2024 10:59:39 -0700 (PDT) Received: from localhost.localdomain ([37.186.51.20]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5c42bb89d44sm3968522a12.70.2024.09.17.10.59.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 10:59:37 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726595978; x=1727200778; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=n/+4D/S1aFkXG42J4Q9FmPuNkWJJERB5vU9r236Tgl0=; b=d18HY+gNfozKb5iaYd8phjf+cRzylCN5ZY7g6B6UscR2LHGx+loVs+6X576SwL99HG YfHf8pGO7zRn69QR3drwcMYmWhTiEf/fXDrOfLVab7YewseWlYy+yefOC7r7kgz/lOPD qO7M7uEPhoHZkGSXPBlPIqOFF6Ucj3bBmHYNy+Dh9FQZYPYCTKXgYRcTN6vhmOZLR4ID 3aZcmVUwtKVG1ywsqZvOsM9zDsFS2x4xC571wBPw5eVQBE18hJRbK0ptM/9aUPrLTyeA O/b7BKhHscNBLyF7Jcano8W+rCZ5TuGKsldg5HaPiPmQ+X2tI3zg1VH99GZ7ayADb8oP 1XCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726595978; x=1727200778; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n/+4D/S1aFkXG42J4Q9FmPuNkWJJERB5vU9r236Tgl0=; b=BTIpqVMIdHQN2Z7A0hSpei0VGMYuaM48eKqZ3UbAoXJcpZK2F4nOiFsWpZYJ1ql8AF xap2E1/ZNunXLssMvw1D/ANeJQNP4PMk53/wkEYHZe+GRPQgm7VV5hKJwQ6h2LqG1dxF BtbLPH8ceFun3+a5B111wK0kCG0smc5oGmGcYJiY0bAdXHg2eK4satIicogC3eieMd13 uYyEu0iPKsQq0JVSM9gA8ewmY08ie0MqmsGi5grSrmZ6HjIzgs8q4LznfLtO09Rk9EEy mhljvWWJc7uKoqqLL89qbpZHdnlR+o5jA0wEFrLwHY668R0XiharJgL/5AK32hfrW/6h i3Pg== X-Gm-Message-State: AOJu0YwtK0to+h6g25ltByZ4Zn938hDsn3QKGWG8SRiO9WKHiq/SvkIo wcGXyX2ZWskwOb+5MvaFSt1pNxnOL9dVbJ4FNj5nKC2kBFRYPTILnMA8Z6qR X-Google-Smtp-Source: AGHT+IEIGVT9A5EecBMufCpMbGHqn925S9B6KbAxWLNkzB8p8lD5SkMghOBcQatH55w987otEDGxvQ== X-Received: by 2002:aa7:d5c4:0:b0:5c2:6918:71cb with SMTP id 4fb4d7f45d1cf-5c413e4faf7mr15518764a12.23.1726595978431; Tue, 17 Sep 2024 10:59:38 -0700 (PDT) From: Rayhan Faizel To: devel@lists.libvirt.org Subject: [PATCH 2/2] libxl_conf: Add check for unsupported graphics type Date: Tue, 17 Sep 2024 23:28:46 +0530 Message-Id: <20240917175846.1351068-3-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240917175846.1351068-1-rayhan.faizel@gmail.com> References: <20240917175846.1351068-1-rayhan.faizel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: PYEIWXYWUFRHDBAGON4ZK4NQWWYF46W2 X-Message-ID-Hash: PYEIWXYWUFRHDBAGON4ZK4NQWWYF46W2 X-MailFrom: rayhan.faizel@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Rayhan Faizel X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726596059631116600 Content-Type: text/plain; charset="utf-8" libxlMakeVfb always succeeds regardless of if the graphics type is actually supported or not. libxl_defbool_val is called in libxlMakeBuildInfoVfb which besides returning the boolean value of the defbool also has an assertion that the defbool val= ue is not set to default. It is possible to fail this assertion if an unsupported graphics type is used. In libxlMakeVfb, the VNC and SDL enable defbools are still left in their default state if the graphics type falls outside the two, which leads to this issue. This patch adds a check to reject graphics types outside of SDL, VNC, and S= PICE very early on in libxlMakeVfb. As a safeguard, we also initialize both vnc enable and sdl enable defbools as false early. Signed-off-by: Rayhan Faizel --- src/libxl/libxl_conf.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 8c91489ffd..c404226e43 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1506,18 +1506,18 @@ libxlMakeVfb(virPortAllocatorRange *graphicsports, virDomainGraphicsListenDef *glisten =3D NULL; =20 libxl_device_vfb_init(x_vfb); + libxl_defbool_set(&x_vfb->sdl.enable, 0); + libxl_defbool_set(&x_vfb->vnc.enable, 0); =20 switch (l_vfb->type) { case VIR_DOMAIN_GRAPHICS_TYPE_SDL: libxl_defbool_set(&x_vfb->sdl.enable, 1); - libxl_defbool_set(&x_vfb->vnc.enable, 0); libxl_defbool_set(&x_vfb->sdl.opengl, 0); x_vfb->sdl.display =3D g_strdup(l_vfb->data.sdl.display); x_vfb->sdl.xauthority =3D g_strdup(l_vfb->data.sdl.xauth); break; case VIR_DOMAIN_GRAPHICS_TYPE_VNC: libxl_defbool_set(&x_vfb->vnc.enable, 1); - libxl_defbool_set(&x_vfb->sdl.enable, 0); /* driver handles selection of free port */ libxl_defbool_set(&x_vfb->vnc.findunused, 0); if (l_vfb->data.vnc.autoport) { @@ -1542,13 +1542,18 @@ libxlMakeVfb(virPortAllocatorRange *graphicsports, x_vfb->keymap =3D g_strdup(l_vfb->data.vnc.keymap); break; =20 + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + break; + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: - case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: case VIR_DOMAIN_GRAPHICS_TYPE_EGL_HEADLESS: case VIR_DOMAIN_GRAPHICS_TYPE_DBUS: case VIR_DOMAIN_GRAPHICS_TYPE_LAST: - break; + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported graphics type %1$s"), + virDomainGraphicsTypeToString(l_vfb->type)); + return -1; } =20 return 0; --=20 2.34.1