From nobody Sun Apr 12 22:39:15 2026 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; dkim=pass header.i=thierry.escande@vates.tech; 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; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1775669046; cv=none; d=zohomail.com; s=zohoarc; b=MDQH5RPPyAzpfCOsMMwWl3+oSM9vKE6VXiJ1glo8HXOjVYOQSASeqOMHD4SPnix9X6zLEOSLC3Ho29xyGxcag/My+tYfcMi1ZL4hLBNuiABNX9a5Odq7dTg5dyFRPz3WmOZqqm3tPsXqubTZr/DvFdFDlG3lOtoHbNPfa1KhpPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775669046; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bL/Y0h09vhas0clUhCqZuQCPZsSmUUKUpgqhUdmmhks=; b=W2FuphwppZqyEhw4UU4ELiEDhpTjkjfDzUFoYCDQihjyuQJz82YFCp0gqJ/ii+fMEPEEHeP6orHdDpJFJmOnpK0fjz4/dzozMsUHQhvHIOJGOUw5fo//FkJZTfeSFSzqTw9/HiqfV3ANjPE3PwyJ+Mk9XwJMwi12tl5QNk6BRZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=thierry.escande@vates.tech; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775669046607689.753811406311; Wed, 8 Apr 2026 10:24:06 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1276424.1561895 (Exim 4.92) (envelope-from ) id 1wAWd4-0005QW-6H; Wed, 08 Apr 2026 17:23:50 +0000 Received: by outflank-mailman (output) from mailman id 1276424.1561895; Wed, 08 Apr 2026 17:23:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAWd4-0005QN-3f; Wed, 08 Apr 2026 17:23:50 +0000 Received: by outflank-mailman (input) for mailman id 1276424; Wed, 08 Apr 2026 17:23:49 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAWd3-0005Q7-3O for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 17:23:49 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wAWd2-005z4v-Fd for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 19:23:48 +0200 Received: from [10.42.69.9] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d68f00-e002-0a2a0a5209dd-0a2a4509a776-34 for ; Wed, 08 Apr 2026 19:23:48 +0200 Received: from [198.2.180.46] (helo=mail180-46.suw31.mandrillapp.com) by tlsNG-bad1c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d68f22-bf79-0a2a45090019-c602b42e53ca-3 for ; Wed, 08 Apr 2026 19:23:48 +0200 Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail180-46.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4frVKF48ZWz8XVRgS for ; Wed, 8 Apr 2026 17:23:45 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id a9ac9385157d4fe2811a2f8d5aeda822; Wed, 08 Apr 2026 17:23:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="thierry.escande@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1775669025; x=1775939025; bh=bL/Y0h09vhas0clUhCqZuQCPZsSmUUKUpgqhUdmmhks=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=AkuGAWul21I7hqPr7vG5L4oaDg6JuP/l8JnQqIRW+1hRaONFUZYgaUiXOqD1FHOmb IcNy4U/BqDnZBrwgUOCBBn5mLtX/o8nvvI+mhIExq/RiFkWfDik8LnDYCo2loIYYEp O9loGTWF3FLrC1oquRTlW5UZdYFhNoJV6ztyNt9BXvxri6A0awKvK1icNQUdTd2Z+E S1sLVF0pqP7CDGdXQSl8J+Vzi85Mc3QKuOOodt8Mlj2cS/AbUz4qlyrpBxE1P1Xsmv 5v046kdgKnjF70Xbvoz3qqOADi9sJDGxE99ifZCxZHs/qpP+HSywSGNRHwNhr+Tiu9 gn+6Tlz8RoQSA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1775669025; x=1775929525; i=thierry.escande@vates.tech; bh=bL/Y0h09vhas0clUhCqZuQCPZsSmUUKUpgqhUdmmhks=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=a2BE5wjKAyRaDbTphxwyPGO/DgF0jM9cK+4dPpThdNIDVOsQt45QMBSjDxTOV6Lvc abdDRqsCDYx53WSGv7a3G03uAB4rZWYqqbfyR9hrc+8t6OlmGEiV0vtKYdh3BM5aa8 HTNg43kZT8tKMbgb0nEJIEZbM1PvRV4S7V4mO2VuQg+T7RbTTSD/htyzg8R10eo/g3 rh1dY17f8P29zcAYNv+scOh5yW++S/swbpxaXaXBO4lrbDV8PS4zxKa3LpyzTUJrFm yoPtGBC4s1FRdFAUMAfKoF/puW7MxvCqVmcfXcMWbyMzzqQ+npwtrhXY3YmCI39ITD C3uCg8i8FMBaw== From: "Thierry Escande" Subject: =?utf-8?Q?[RFC=20PATCH=201/3]=20xl:=20Add=20pci=20device=20hotplug=20option?= X-Mailer: git-send-email 2.53.0 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1775669024628 To: xen-devel@lists.xenproject.org Cc: "Thierry Escande" , "Anthony PERARD" , "Juergen Gross" , "=?utf-8?Q?Daniel=20P=20.=20Berrang=C3=A9?=" , "=?utf-8?Q?Marek=20Marczykowski-G=C3=B3recki?=" Message-Id: <20260408172320.539750-2-thierry.escande@vates.tech> In-Reply-To: <20260408172320.539750-1-thierry.escande@vates.tech> References: <20260408172320.539750-1-thierry.escande@vates.tech> X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.a9ac9385157d4fe2811a2f8d5aeda822?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260408:md Date: Wed, 08 Apr 2026 17:23:45 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-bad1c0/1775669028-2E74A152-EAE45717/0/0 X-purgate-type: clean X-purgate-size: 2895 X-ZohoMail-DKIM: pass (identity thierry.escande@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1775669048956154100 Content-Type: text/plain; charset="utf-8" This option is used to passthrough PCI devices using the Qemu command line (-device driver,...) instead of the QMP hot-plug mechanism. This is needed for Q35 support since its PCI root bus doesn't support hotplugging. If not specified, the default behavior is to use hotplug via QMP. Signed-off-by: Thierry Escande --- tools/libs/light/libxl_types.idl | 1 + tools/libs/util/libxlu_pci.c | 2 ++ tools/xl/xl_parse.c | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_type= s.idl index a7893460f0..aca0e93793 100644 --- a/tools/libs/light/libxl_types.idl +++ b/tools/libs/light/libxl_types.idl @@ -922,6 +922,7 @@ libxl_device_pci =3D Struct("device_pci", [ ("seize", bool), ("rdm_policy", libxl_rdm_reserve_policy), ("name", string), + ("hotplug", bool), ]) =20 libxl_device_rdm =3D Struct("device_rdm", [ diff --git a/tools/libs/util/libxlu_pci.c b/tools/libs/util/libxlu_pci.c index 294482c6d7..f6440c878b 100644 --- a/tools/libs/util/libxlu_pci.c +++ b/tools/libs/util/libxlu_pci.c @@ -192,6 +192,8 @@ int xlu_pci_parse_spec_string(XLU_Config *cfg, libxl_de= vice_pci *pci, name_present =3D true; pci->name =3D strdup(val); if (!pci->name) ret =3D ERROR_NOMEM; + } else if (!strcmp(key, "hotplug")) { + pci->hotplug =3D atoi(val); } else { XLU__PCI_ERR(cfg, "Unknown PCI_SPEC_STRING option: %s", key); ret =3D ERROR_INVAL; diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c index 48c72dce9c..7ea2a76662 100644 --- a/tools/xl/xl_parse.c +++ b/tools/xl/xl_parse.c @@ -1361,6 +1361,7 @@ void parse_config_data(const char *config_source, int pci_msitranslate =3D 0; int pci_permissive =3D 0; int pci_seize =3D 0; + int pci_hotplug =3D 1; int i, e; int num_llc_colors; int num_xs_quota; @@ -1699,6 +1700,9 @@ void parse_config_data(const char *config_source, if (!xlu_cfg_get_long (config, "pci_seize", &l, 0)) pci_seize =3D l; =20 + if (!xlu_cfg_get_long (config, "pci_hotplug", &l, 0)) + pci_hotplug =3D l; + if (!xlu_cfg_get_string(config, "rdm", &buf, 0)) { libxl_rdm_reserve rdm; if (!xlu_rdm_parse(config, &rdm, buf)) { @@ -1720,6 +1724,7 @@ void parse_config_data(const char *config_source, pci->power_mgmt =3D pci_power_mgmt; pci->permissive =3D pci_permissive; pci->seize =3D pci_seize; + pci->hotplug =3D pci_hotplug; /* * Like other pci option, the per-device policy always follows * the global policy by default. --=20 2.53.0 -- Thierry Escande | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Sun Apr 12 22:39:15 2026 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; dkim=pass header.i=thierry.escande@vates.tech; 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; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1775669053; cv=none; d=zohomail.com; s=zohoarc; b=Mjf7biwqXaotuOC2LOrOITk13yhVaP6bRj/r1HlKuXUD5SkMnL3eAHE/vJF4pmeKROOkfi9Ka1nfiNaCPkKZ3ip2qrknLI42i32YGMN9QXNyr9VDR+jdljk8mSlbiMdnHVj8VYpTtEfGL11jy0r/Xfkyn6xZ7SzuAtCb3wgwaEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775669053; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7/8Qd+P7SPVDgY0eBLO5nKimQuCthoxn0Jd92VJL7wU=; b=I306rKPsh6vKpOpcjkhPJhuodzzAS0Sguc2H/635QJAhZfVyGSnAcZaMirRkssK1J8ldVk8xmnvtJADvrCzuGOcT7xEK0NgQYpLkyjPu+1tuSTRcA16ittTbDsel/WQ2A2O3Lz+2i5wTLqT/0JfuC9mvV/j1tPGzwrMJgvYhygQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=thierry.escande@vates.tech; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 177566905308892.26067994913728; Wed, 8 Apr 2026 10:24:13 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1276425.1561905 (Exim 4.92) (envelope-from ) id 1wAWdA-0005hj-DW; Wed, 08 Apr 2026 17:23:56 +0000 Received: by outflank-mailman (output) from mailman id 1276425.1561905; Wed, 08 Apr 2026 17:23:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAWdA-0005hc-9j; Wed, 08 Apr 2026 17:23:56 +0000 Received: by outflank-mailman (input) for mailman id 1276425; Wed, 08 Apr 2026 17:23:54 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAWd8-0005gI-Mc for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 17:23:54 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wAWd8-005z9Y-1O for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 19:23:54 +0200 Received: from [10.42.69.7] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d68f15-e002-0a2a0a5209dd-0a2a4507ddfe-26 for ; Wed, 08 Apr 2026 19:23:54 +0200 Received: from [198.2.178.25] (helo=mail178-25.suw51.mandrillapp.com) by tlsNG-ef75cf.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d68f28-ba2d-0a2a45070019-c602b219cc9a-3 for ; Wed, 08 Apr 2026 19:23:53 +0200 Received: from pmta13.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail178-25.suw51.mandrillapp.com (Mailchimp) with ESMTP id 4frVKN4P3rz4f3wgP for ; Wed, 8 Apr 2026 17:23:52 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id c0022b9fc07d4103bf9af3bb4037bf57; Wed, 08 Apr 2026 17:23:52 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="thierry.escande@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1775669032; x=1775939032; bh=7/8Qd+P7SPVDgY0eBLO5nKimQuCthoxn0Jd92VJL7wU=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=jZazIJ0jtqK0cqYE93+/V8XeLf8Yjrc5neEFcG92fAIu8nH8ixZBnxhOpquNEYBx4 TQuEwPv9OIRSe2KRYM1bshjh9bkhVymd9MimGM2Nb8CgzHKCy0Q30hJ9TwP0qAqPPS 5tmEvbcIGjYzB5nOrss/SBrI/m9MY1Hhi092Tdl+Xrx0SpnkuylvvwdBK8aYCG/UHb BZYdrwXLHhBd3nozJ+kKVV4oZse2vIovxbdlhbFaE4Bayk8rLmO/1ufffG+qt9qFQb qZo+1/KGWp3124sgN76Ja+aftxu5hJIc045swJs/c/4otr5aOMjNk0pQanLhOMPV+w qP3JlWNKH0Awg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1775669032; x=1775929532; i=thierry.escande@vates.tech; bh=7/8Qd+P7SPVDgY0eBLO5nKimQuCthoxn0Jd92VJL7wU=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=E3itFUbe/nZOklJZtVcEesSu0M7DPkwzIAzJmgtTf2Nd3p9lMXWJSGOtPLZ9sWAqk b4ZUumkX/jypTAv1JETOqF6U7q3o6ZAqLxBQkItJfmjbaG0WbMLZ/9fukQm85voWGW ub6r6dAstkniBpjxcstjr1kezyCwBhilaBf55RsjFF9N11EVHsDf0DN/wk9zwc5WNr /P6lW0N2SsAo6tnkaKkXYUy3EkLKVEXEq3YG3rD6YulGlB7gaE4N53PpzEhv9F1Wbt uH/7CyuMVWoMpL2yj1uIk0PdsZoRJF5XOed7+MkwdAMu+vqS76MAYGXrTWTnlniTB+ pacSjYaac9v3w== From: "Thierry Escande" Subject: =?utf-8?Q?[RFC=20PATCH=202/3]=20libxl:=20Allow=20PCI=20device=20passthrough=20using=20-device=20Qemu=20command=20line?= X-Mailer: git-send-email 2.53.0 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1775669030410 To: xen-devel@lists.xenproject.org Cc: "Thierry Escande" , "Anthony PERARD" , "Juergen Gross" , "=?utf-8?Q?Daniel=20P=20.=20Berrang=C3=A9?=" , "=?utf-8?Q?Marek=20Marczykowski-G=C3=B3recki?=" Message-Id: <20260408172320.539750-3-thierry.escande@vates.tech> In-Reply-To: <20260408172320.539750-1-thierry.escande@vates.tech> References: <20260408172320.539750-1-thierry.escande@vates.tech> X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.c0022b9fc07d4103bf9af3bb4037bf57?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260408:md Date: Wed, 08 Apr 2026 17:23:52 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-ef75cf/1775669034-83D4741E-F54737BC/0/0 X-purgate-type: clean X-purgate-size: 7318 X-ZohoMail-DKIM: pass (identity thierry.escande@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1775669054772154100 Content-Type: text/plain; charset="utf-8" This change makes use of the new option 'hotplug' for host PCI devices passthrough'd to the guest. If hotplug=3D0 is used in the pci device configuration table, the device will be attached to the guest using the Qemu command line as '-device xen-pci-passthrough,hostaddr=3D...' The host device configuration is passed to the -device option as a json array, just like it's done for hotplug using QMP. The json array is created by a new internal function libxl__device_pci_get_qmp_json() that is also used by pci_add_qmp_device_add(). Then, instead of sending the 'device_add' command, the device_add callback is called to perform the 'query-pci' check to make sure the passthrough'd device is present. In the same way at shutdown, the device is not removed using QMP and only the pci_remove_done() function is called. As with QMP, the use of the 'hotplug=3D0' option honors the 'seize' option by adding the PCI device to the assignable list if needed. Example use: pci =3D [ "00:03.0,seize=3D1,hotplug=3D0" ] Signed-off-by: Thierry Escande --- tools/include/libxl.h | 1 + tools/libs/light/libxl_dm.c | 31 +++++++++++++++++++++++ tools/libs/light/libxl_internal.h | 2 ++ tools/libs/light/libxl_pci.c | 41 +++++++++++++++++++++++-------- 4 files changed, 65 insertions(+), 10 deletions(-) diff --git a/tools/include/libxl.h b/tools/include/libxl.h index 7c098edab6..66fb07ad67 100644 --- a/tools/include/libxl.h +++ b/tools/include/libxl.h @@ -2666,6 +2666,7 @@ int libxl_device_pci_assignable_add(libxl_ctx *ctx, l= ibxl_device_pci *pci, int r int libxl_device_pci_assignable_remove(libxl_ctx *ctx, libxl_device_pci *p= ci, int rebind); libxl_device_pci *libxl_device_pci_assignable_list(libxl_ctx *ctx, int *nu= m); void libxl_device_pci_assignable_list_free(libxl_device_pci *list, int num= ); +bool libxl_pci_assignable(libxl_ctx *ctx, libxl_device_pci *pci); =20 /* CPUID handling */ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* s= tr); diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index 511ec76a65..96bb620f87 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -1169,6 +1169,37 @@ static int libxl__build_device_model_args_new(libxl_= _gc *gc, } } } + + if (guest_config->num_pcidevs) { + libxl_device_pci *pci; + libxl__json_object *qmp_json; + const char *json_str; +#ifndef HAVE_LIBJSONC +# error Missing JSON library +#endif + json_object *jso =3D NULL; + + for (i =3D 0; i < guest_config->num_pcidevs; i++) { + libxl_ctx *ctx =3D libxl__gc_owner(gc); + pci =3D &guest_config->pcidevs[i]; + + if (pci->hotplug) + continue; + + if (!libxl_pci_assignable(ctx, pci) && pci->seize) { + rc =3D libxl_device_pci_assignable_add(ctx, pci, 1= ); + if (rc) + return rc; + } + qmp_json =3D libxl__device_pci_get_qmp_json(gc, pci); + rc =3D libxl__json_object_to_json_object(gc, &jso, qmp= _json); + if (rc) + return rc; + json_str =3D json_object_to_json_string_ext(jso, + JSON_C_TO_ST= RING_PLAIN); + flexarray_vappend(dm_args, "-device", json_str, NULL); + } + } } =20 if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) { diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_int= ernal.h index b65e0064b9..06b5a14409 100644 --- a/tools/libs/light/libxl_internal.h +++ b/tools/libs/light/libxl_internal.h @@ -1729,6 +1729,8 @@ _hidden int libxl__device_pci_setdefault(libxl__gc *g= c, uint32_t domid, libxl_device_pci *pci, bool hotpl= ug); _hidden bool libxl__is_igd_vga_passthru(libxl__gc *gc, const libxl_domain_config *d_confi= g); +_hidden libxl__json_object *libxl__device_pci_get_qmp_json(libxl__gc *gc, + libxl_device_pci = *pci); =20 /* from libxl_dtdev */ =20 diff --git a/tools/libs/light/libxl_pci.c b/tools/libs/light/libxl_pci.c index 49d272d0de..3ef2c43412 100644 --- a/tools/libs/light/libxl_pci.c +++ b/tools/libs/light/libxl_pci.c @@ -1098,16 +1098,10 @@ out: pci_add_dm_done(egc, pas, rc); /* must be last */ } =20 -static void pci_add_qmp_device_add(libxl__egc *egc, pci_add_state *pas) +libxl__json_object *libxl__device_pci_get_qmp_json(libxl__gc *gc, + libxl_device_pci *pci) { - STATE_AO_GC(pas->aodev->ao); libxl__json_object *args =3D NULL; - int rc; - - /* Convenience aliases */ - libxl_domid domid =3D pas->domid; - libxl_device_pci *pci =3D &pas->pci; - libxl__ev_qmp *const qmp =3D &pas->qmp; =20 libxl__qmp_param_add_string(gc, &args, "driver", "xen-pci-passthrough"); @@ -1134,11 +1128,30 @@ static void pci_add_qmp_device_add(libxl__egc *egc,= pci_add_state *pas) if (pci->permissive) libxl__qmp_param_add_bool(gc, &args, "permissive", true); =20 + return args; +} + +static void pci_add_qmp_device_add(libxl__egc *egc, pci_add_state *pas) +{ + STATE_AO_GC(pas->aodev->ao); + libxl__json_object *args =3D NULL; + int rc =3D 0; + + /* Convenience aliases */ + libxl_domid domid =3D pas->domid; + libxl_device_pci *pci =3D &pas->pci; + libxl__ev_qmp *const qmp =3D &pas->qmp; + + args =3D libxl__device_pci_get_qmp_json(gc, pci); + qmp->ao =3D pas->aodev->ao; qmp->domid =3D domid; qmp->payload_fd =3D -1; qmp->callback =3D pci_add_qmp_device_add_cb; - rc =3D libxl__ev_qmp_send(egc, qmp, "device_add", args); + if (pci->hotplug) + rc =3D libxl__ev_qmp_send(egc, qmp, "device_add", args); + else + pci_add_qmp_device_add_cb(egc, qmp, NULL, 0); if (rc) goto out; return; =20 @@ -1509,7 +1522,7 @@ int libxl_device_pci_add(libxl_ctx *ctx, uint32_t dom= id, return AO_INPROGRESS; } =20 -static bool libxl_pci_assignable(libxl_ctx *ctx, libxl_device_pci *pci) +bool libxl_pci_assignable(libxl_ctx *ctx, libxl_device_pci *pci) { libxl_device_pci *pcis; int num; @@ -1820,6 +1833,14 @@ static void do_pci_remove(libxl__egc *egc, pci_remov= e_state *prs) libxl_domain_type type =3D libxl__domain_type(gc, domid); libxl_device_pci *pci =3D &prs->pci; int rc, num; + + /* Passthrough'd device has been passed to Qemu command line so there = is + * no need to remove it via QMP */ + if (!pci->hotplug) { + pci_remove_done(egc, prs, 0); + return; + } + pcis =3D libxl_device_pci_list(ctx, domid, &num); if (!pcis) { rc =3D ERROR_FAIL; --=20 2.53.0 -- Thierry Escande | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Sun Apr 12 22:39:15 2026 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; dkim=pass header.i=thierry.escande@vates.tech; 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; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1775669051; cv=none; d=zohomail.com; s=zohoarc; b=Diu1KFA7xeoXuF7iq7AUD0gZuhYY9TCC3cxeUhlivQWHm/wi4/nEyQyovWpHUDCCghymtTUn4/2tEmITF66DxNCWHkoY2JS1PiUyGHpHlO4+bBzRKSLqwHLfBWhCRDYmKNfDDaLscTUoHlzSyk/hj8xe1lBjKDh3D9thkhQP1HQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775669051; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dBdXC8CLXllaOOaQAKE2xMRBGZ2MJ8SlC6WJCLiAOQE=; b=gqmLvH6Gsk1dNeGzn3A+QUin6usbkqRQ6YqsfCdvsKrpaSDyCLtp+lvZuJRLqf++6WQOBpclsP4H1jieS6TAToLyvkHbbohU5+Q5KLohkTs99xCrppkKctxD10k/kwHU+X4bEBT4IXcb5cftS/OkbIwZnU8XinWonzHJ9hz4sAI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=thierry.escande@vates.tech; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1775669051686593.9882084625461; Wed, 8 Apr 2026 10:24:11 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1276428.1561913 (Exim 4.92) (envelope-from ) id 1wAWdE-00060c-NW; Wed, 08 Apr 2026 17:24:00 +0000 Received: by outflank-mailman (output) from mailman id 1276428.1561913; Wed, 08 Apr 2026 17:24:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAWdE-00060V-Ka; Wed, 08 Apr 2026 17:24:00 +0000 Received: by outflank-mailman (input) for mailman id 1276428; Wed, 08 Apr 2026 17:23:58 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAWdC-0005x3-MH for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 17:23:58 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wAWdC-006jn2-2J for xen-devel@lists.xenproject.org; Wed, 08 Apr 2026 19:23:58 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d68ef4-bab6-0a2a0a5309dd-0a2a450295d8-36 for ; Wed, 08 Apr 2026 19:23:58 +0200 Received: from [198.2.180.46] (helo=mail180-46.suw31.mandrillapp.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d68f2c-42fa-0a2a45020019-c602b42e8a13-3 for ; Wed, 08 Apr 2026 19:23:57 +0200 Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail180-46.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4frVKS4FH1z8XVRg6 for ; Wed, 8 Apr 2026 17:23:56 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 44c5db41318c4e0bbf8ffde4898d605a; Wed, 08 Apr 2026 17:23:56 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="thierry.escande@vates.tech" header.h="From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1775669036; x=1775939036; bh=dBdXC8CLXllaOOaQAKE2xMRBGZ2MJ8SlC6WJCLiAOQE=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=XZE8gBvZWloVMYtiIeoTj1MB1z6InRyjNsL2DMJxfQRMPuuCpyqz143vvpTWY91Bi xAtAmo4X/sHLd1s7AlbC9Ql2fi953LVhxYBMml7mX+6r2fxmaefOBHhePvqxOVu4T5 sLXYq4DrG/nILAIIbYJktfJ54KrpZqfrfyVFUhUt2aO84WeXM9aUftNjUDBn2F/2Qn R1z6XY5M2yqWY3vSlT2DLT3JOdH4WN4E+Zt6QTCbbkSsz5yPynpMXnksq+Ol73g6eo RzMy1CE4FTfjp2hKndFY0susW3UA6BkhuBKzh2dPmOOZHguRdKJmLRDkoOkzVGQYHx PriXoRjz3xZYA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1775669036; x=1775929536; i=thierry.escande@vates.tech; bh=dBdXC8CLXllaOOaQAKE2xMRBGZ2MJ8SlC6WJCLiAOQE=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=DmDbwGmEh+MUtKjHP/VlSdzvF3WAEBEt5upyEfz+cf6/WHGl1NssmE0vipkbKPRa8 dV/aEB5yxOUCKsALo2XV9oVv7EudzTlLXupraI4y1PGenEAgKAKMSx7ayEvi7v5g9q pg/L3HRoaR6t5S7xJJiZaI5qALgRiLhydi7Yt2D8kqVDrR6iICUaY60RyrfJO/6AaI x94LoA4fwXRGNVFarWNgvGgQPe1pBvl1LKJzdQJNw45bKEUFi2TcMT1s3qpBHAJRlz QIrSxwYh7IAsL3bZSHWbYtgMvwjwm/c1HizkJov1j2dQlMWy/vY3qnpnD/Y8yqykYn 0GxFEwSZ0ewxg== From: "Thierry Escande" Subject: =?utf-8?Q?[RFC=20PATCH=203/3]=20docs:=20provide=20description=20for=20pci=20hotplug=20option?= X-Mailer: git-send-email 2.53.0 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1775669035607 To: xen-devel@lists.xenproject.org Cc: "Thierry Escande" , "Anthony PERARD" , "Juergen Gross" , "=?utf-8?Q?Daniel=20P=20.=20Berrang=C3=A9?=" , "=?utf-8?Q?Marek=20Marczykowski-G=C3=B3recki?=" Message-Id: <20260408172320.539750-4-thierry.escande@vates.tech> In-Reply-To: <20260408172320.539750-1-thierry.escande@vates.tech> References: <20260408172320.539750-1-thierry.escande@vates.tech> X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.44c5db41318c4e0bbf8ffde4898d605a?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260408:md Date: Wed, 08 Apr 2026 17:23:56 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1775669037-AF122CD1-A241C7AF/0/0 X-purgate-type: clean X-purgate-size: 1877 X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity thierry.escande@vates.tech) X-ZM-MESSAGEID: 1775669053961158500 Content-Type: text/plain; charset="utf-8" This patch adds description for the 'hotplug' PCI option, allowing devices to be attached to the guest using the legacy QMP hotplug mechanism or by passing them to the Qemu command line using '-device'. Signed-off-by: Thierry Escande --- docs/man/xl-pci-configuration.5.pod | 17 +++++++++++++++++ docs/man/xl.cfg.5.pod.in | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/docs/man/xl-pci-configuration.5.pod b/docs/man/xl-pci-configur= ation.5.pod index 0691f06ad3..8b664173cb 100644 --- a/docs/man/xl-pci-configuration.5.pod +++ b/docs/man/xl-pci-configuration.5.pod @@ -166,6 +166,23 @@ dom0 without confirmation. Please use with care. =20 =3Dback =20 +=3Ditem B=3DI + +=3Dover 4 + +=3Ditem Description + +Tells L to use QMP hotplug mechanism to attach assignable device to +the guest, or to pass it via Qemu command line using +'B<-device xen-pci-passthrough,...>'. The default is to use the legacy QMP +mechanism. + +=3Ditem Default Value + +1 + +=3Dback + =3Ditem B=3DI =20 =3Dover 4 diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in index 3aac0bc4fb..181aaffa0f 100644 --- a/docs/man/xl.cfg.5.pod.in +++ b/docs/man/xl.cfg.5.pod.in @@ -1230,6 +1230,12 @@ B<(HVM only)> Changes the default value of B for all PCI devices passed through to this VM. See B above. =20 +=3Ditem B + +B<(HVM only)> Changes the default value of B for all PCI +devices passed through to this VM. See L for +more details. + =3Ditem B =20 Enable graphics device PCI passthrough. This option makes an assigned --=20 2.53.0 -- Thierry Escande | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech