From nobody Fri May 3 13:49:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1591490445; cv=none; d=zohomail.com; s=zohoarc; b=lyJfR4s10XoQkmUPzkriTwcIJBryHG1rWiifL2VAxbIkwMpM9mNptlU83VI+GJpAAsBXqcAaw91CGPQup0RxdYliC1TnlGVtWkRdY+55ax3FCdJMx7j/d7kgp0oLsP9wDXH1+6451On76L336dG4CbZjYVI9WjjTRHC8YJxtmpU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591490445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=eqSD4obu7qKvtP6n/EZrCfXrPcI0RDHd2BksWe5YKYg=; b=lYFao4MsIdacbVcJNXwACC/GiGdgPaCKBTyLzADU1Qf063+xc5411WqaGcUcF95U1j6sgMq5piND0OKtsTet4BMVP/xpy0URDaYc051QkQ9E+vTnYgGzhXK83lMhoGhFx30t6dyeGi4nMyuvzBRXMGIYeqdMNdGmErK2y6CYRnU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1591490445407634.3935422721214; Sat, 6 Jun 2020 17:40:45 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jhjMI-0003us-0N; Sun, 07 Jun 2020 00:40:18 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1jhjMH-0003un-70 for xen-devel@lists.xenproject.org; Sun, 07 Jun 2020 00:40:17 +0000 Received: from wout5-smtp.messagingengine.com (unknown [64.147.123.21]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 72a9aa16-a857-11ea-b15b-12813bfff9fa; Sun, 07 Jun 2020 00:40:13 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id D621977B; Sat, 6 Jun 2020 20:40:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sat, 06 Jun 2020 20:40:12 -0400 Received: from localhost.localdomain (ip5b412221.dynamic.kabel-deutschland.de [91.65.34.33]) by mail.messagingengine.com (Postfix) with ESMTPA id 84BA0328005A; Sat, 6 Jun 2020 20:40:10 -0400 (EDT) X-Inumbo-ID: 72a9aa16-a857-11ea-b15b-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=eqSD4o bu7qKvtP6n/EZrCfXrPcI0RDHd2BksWe5YKYg=; b=XDZzzjBXCmMJ04c9d3yiVc KOGdyxQ4rCDnMT1QdyD0XiqEOouOcE3TaNZw+XyfcN/foixooUOYKulnPI+Xk3V+ +AhvqShuBztH64UzEZBFzLRnvOpXOpxtqU5cLJOJIACUkV3PN98NYu1YxUPcDq+W 5HWZd2+qmM2J+sfm1rS4N7MkVJTvlfsVDL60k3OKkF6W+70waNOyozRmpvklhvFX QhSkb0TDQTOXuwputzFLREevcZJVqTcWHDDLBLOUlYxXyf7NWhhxQgwlOPfhw0v9 MvkLjaQeAi7IN4br/Rtz73kqKoQfeE4uCMyI1B4hlFgToeCCyOSR/Vo5m+WKbL8A == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudegjedgtdekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffogggtohfgsehtkeertdertdejnecuhfhrohhmpeforghrvghk ucforghrtgiihihkohifshhkihdqifpkrhgvtghkihcuoehmrghrmhgrrhgvkhesihhnvh hishhisghlvghthhhinhhgshhlrggsrdgtohhmqeenucggtffrrghtthgvrhhnpeeltdef fedtvefhtdetgeetteeuudefjeeijeetkeeiiedvudelueekieelfeehgfenucffohhmrg hinhepphhougdrihhnnecukfhppeeluddrieehrdefgedrfeefnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrrhhmrghrvghksehinhhvih hsihgslhgvthhhihhnghhslhgrsgdrtghomh X-ME-Proxy: From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= To: xen-devel@lists.xenproject.org Subject: [PATCH] libxl: automatically enable gfx_passthru if IGD is assigned Date: Sun, 7 Jun 2020 02:39:57 +0200 Message-Id: <20200607003957.443603-1-marmarek@invisiblethingslab.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Organization: Invisible Things Lab Content-Transfer-Encoding: quoted-printable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , Ian Jackson , =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The gfx_passthru option needs to be enabled whenever IGD is assigned, otherwise qemu refuses to start. Similarly, if gfx_passthru is enabled, IGD needs to be assigned, otherwise libxl refuses to start the guest. This means the gfx_passthru is fully redundant to assigning IGD (besides enabling various non-bootable configurations). Change the default value to follow IGD assignment state. For that, use existing libxl__detect_gfx_passthru_kind (move from libxl_dm.c to libxl_create.c). While the option is designed with various GFX in mind, only IGD ever got a special treatment. PCI passthrough of other GFX devices (some AMD and Nvidia at least) works just fine without setting gfx_passthru at all. This change simplifies configuration, but also fixes IGD passthrough when using libvirt (which doesn't expose gfx_passthru option). Signed-off-by: Marek Marczykowski-G=C3=B3recki --- docs/man/xl.cfg.5.pod.in | 3 +++ tools/libxl/libxl_create.c | 27 ++++++++++++++++++++++++++- tools/libxl/libxl_dm.c | 20 +------------------- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 0532739c1f..32228c1361 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1250,6 +1250,9 @@ Intel Graphics Device. =20 =3Dback =20 +By default, this option is enabled if Intel Graphics Device is assigned to= the +VM. + Note that some graphics cards (AMD/ATI cards, for example) do not necessarily require the B option, so you can use the normal = Xen PCI passthrough to assign the graphics card as a secondary graphics diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c index 75862dc6ed..7aca51cb9c 100644 --- a/tools/libxl/libxl_create.c +++ b/tools/libxl/libxl_create.c @@ -72,6 +72,22 @@ void libxl__rdm_setdefault(libxl__gc *gc, libxl_domain_b= uild_info *b_info) LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT; } =20 +static enum libxl_gfx_passthru_kind +libxl__detect_gfx_passthru_kind(libxl__gc *gc, + const libxl_domain_config *guest_config) +{ + const libxl_domain_build_info *b_info =3D &guest_config->b_info; + + if (b_info->u.hvm.gfx_passthru_kind !=3D LIBXL_GFX_PASSTHRU_KIND_DEFAU= LT) + return b_info->u.hvm.gfx_passthru_kind; + + if (libxl__is_igd_vga_passthru(gc, guest_config)) { + return LIBXL_GFX_PASSTHRU_KIND_IGD; + } + + return LIBXL_GFX_PASSTHRU_KIND_DEFAULT; +} + int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info) { @@ -411,7 +427,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, =20 libxl_defbool_setdefault(&b_info->u.hvm.nographic, false); =20 - libxl_defbool_setdefault(&b_info->u.hvm.gfx_passthru, false); + libxl_defbool_setdefault(&b_info->u.hvm.gfx_passthru, + b_info->u.hvm.gfx_passthru_kind !=3D LIBXL_GFX_PASSTHRU_KI= ND_DEFAULT); =20 libxl__rdm_setdefault(gc, b_info); break; @@ -1177,6 +1194,14 @@ int libxl__domain_config_setdefault(libxl__gc *gc, ? libxl__get_required_iommu_memory(d_config->b_info.max_memkb) : 0; =20 + if (d_config->b_info.type =3D=3D LIBXL_DOMAIN_TYPE_HVM) { + if (d_config->b_info.u.hvm.gfx_passthru_kind =3D=3D LIBXL_GFX_PASS= THRU_KIND_DEFAULT) { + /* this may also keep LIBXL_GFX_PASSTHRU_KIND_DEFAULT */ + d_config->b_info.u.hvm.gfx_passthru_kind =3D + libxl__detect_gfx_passthru_kind(gc, d_config); + } + } + ret =3D libxl__domain_build_info_setdefault(gc, &d_config->b_info); if (ret) { LOGD(ERROR, domid, "Unable to set domain build info defaults"); diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index f2dc5696b9..381be5e6ed 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -981,22 +981,6 @@ static char *dm_spice_options(libxl__gc *gc, return opt; } =20 -static enum libxl_gfx_passthru_kind -libxl__detect_gfx_passthru_kind(libxl__gc *gc, - const libxl_domain_config *guest_config) -{ - const libxl_domain_build_info *b_info =3D &guest_config->b_info; - - if (b_info->u.hvm.gfx_passthru_kind !=3D LIBXL_GFX_PASSTHRU_KIND_DEFAU= LT) - return b_info->u.hvm.gfx_passthru_kind; - - if (libxl__is_igd_vga_passthru(gc, guest_config)) { - return LIBXL_GFX_PASSTHRU_KIND_IGD; - } - - return LIBXL_GFX_PASSTHRU_KIND_DEFAULT; -} - /* colo mode */ enum { LIBXL__COLO_NONE =3D 0, @@ -1798,9 +1782,7 @@ static int libxl__build_device_model_args_new(libxl__= gc *gc, } =20 if (libxl_defbool_val(b_info->u.hvm.gfx_passthru)) { - enum libxl_gfx_passthru_kind gfx_passthru_kind =3D - libxl__detect_gfx_passthru_kind(gc, guest_conf= ig); - switch (gfx_passthru_kind) { + switch (b_info->u.hvm.gfx_passthru_kind) { case LIBXL_GFX_PASSTHRU_KIND_IGD: machinearg =3D GCSPRINTF("%s,igd-passthru=3Don", machinear= g); break; --=20 2.25.4