From nobody Sun Apr 12 22:38:38 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=1775751693; cv=none; d=zohomail.com; s=zohoarc; b=ZYloLoBb6zm1QQUkULtTJjf7ta5xdHV33UhP9UvNW05n9FyXWCTv4iYQVaI2zcU9u6H+u8jrtNY88MsWuL4/fvQf33i/qXK9Afx9o2UZbJ82y0LoDHC/OvmfZgzkV9ibCyHZrpQ4ceXo6IYCuiC6harzvuR+ICQnfgoQShmCzDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775751693; 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=Nz9cFB5Mcx1tT5bpJb3P1KzNsuuko5bfszc5bYglBPc=; b=Bx8pNPHF5WssA/veukdKR8MsFwTvDf2IyjlSdMA9FxruwuKAQdDXyiFY6TIRWor2OZt4cQdVSE2/rnXHQ135CJi+lN9Rb7IT/Q3BGfcQZpMVex7wWLMaF5jMRWPd6NyTwmVkKxn+cWm/neTqCzxczWoloMR9wyk3WrBUQXVyYQQ= 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 1775751693349836.7955869213264; Thu, 9 Apr 2026 09:21:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1277969.1563027 (Exim 4.92) (envelope-from ) id 1wAs7v-0006Lp-87; Thu, 09 Apr 2026 16:21:07 +0000 Received: by outflank-mailman (output) from mailman id 1277969.1563027; Thu, 09 Apr 2026 16:21:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAs7v-0006Li-4H; Thu, 09 Apr 2026 16:21:07 +0000 Received: by outflank-mailman (input) for mailman id 1277969; Thu, 09 Apr 2026 16:21:06 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAs7t-0006LW-VW for xen-devel@lists.xenproject.org; Thu, 09 Apr 2026 16:21:05 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wAs7t-00AE9I-BP for xen-devel@lists.xenproject.org; Thu, 09 Apr 2026 18:21:05 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d7d1e5-5cb7-0a2a0a5109dd-0a2a450ae60c-16 for ; Thu, 09 Apr 2026 18:21:05 +0200 Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d7d1f0-ee98-0a2a450a0019-c602bb0ee608-3 for ; Thu, 09 Apr 2026 18:21:05 +0200 Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fs4tR3b3xz8XS2Rn for ; Thu, 9 Apr 2026 16:21:03 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 79112c74a4eb403bb19f7e2d994d5317; Thu, 09 Apr 2026 16:21:03 +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=1775751663; x=1776021663; bh=Nz9cFB5Mcx1tT5bpJb3P1KzNsuuko5bfszc5bYglBPc=; 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=LSkNrZLdzHFgCWHDR4OlVLnNFiaF4Kw5htG77yaS9aPysISMCILfP+HQpgYMuEvYA LXbrAMd9LzWzgU3LiRZxyS9uREgEvSjZcZhUrUEcvbr44nvVP44x8oLj8LJ0BgNSpH 4jUmRLObZfWGdmC/LnqP76PYgyvAgXGF6SXMueyJrjXQ1MOl5ir+k2ZpPhjCHIV+oX xjeC813O3PL/JmUlh4YO0Tw1xcpVWYb/gqniBaqDKEGZcZDNMI2EjJfbZeId6qVpO0 US7HpKFXirzpRT4rZKEtCGKNWZZnpUKIp+8WkK3BIqwT3gxpkNkBnJoh4HvR5GGu3O ByWfZv3vw8EAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1775751663; x=1776012163; i=thierry.escande@vates.tech; bh=Nz9cFB5Mcx1tT5bpJb3P1KzNsuuko5bfszc5bYglBPc=; 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=UhweX3OBt8mayspvrUrkiNjyHDQSwbhUVgmgFC7ItbpcV0Lmz000p0vSXDtH2J3+5 4JnKc0F91sND+7RALcebEHTaAuPn29IFxLu5NQDl2ZudvTnJhYSb01rtixKkjkXSWz rH8OCUXxl4MIOxEwPbjWfmE6qTe3TqANaMaSBX5wfFcUpA7fV8hqprgNB9Orgk/KFV 55BTsseTefHteKUpMVZWH4kcqXa28rzPnAustlvBFXbHLzUPTAzj2NInv4xDig12eD BXQpsRzf/KZNud/mBak3z0iM/3Kd25bvAxlfd/+T+8GI+A3WVotFbvfqAZbBiYHRWE tU+9e4jj7EhKg== From: "Thierry Escande" Subject: =?utf-8?Q?[RFC=20PATCH=20v2=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: 1775751662747 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: <20260409162000.1102680-2-thierry.escande@vates.tech> In-Reply-To: <20260409162000.1102680-1-thierry.escande@vates.tech> References: <20260409162000.1102680-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.79112c74a4eb403bb19f7e2d994d5317?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260409:md Date: Thu, 09 Apr 2026 16:21:03 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1775751665-C481C0B1-8F0CA5CE/0/0 X-purgate-type: clean X-purgate-size: 2915 X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity thierry.escande@vates.tech) X-ZM-MESSAGEID: 1775751695711158500 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 --- v2: no change --- 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:38:38 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=1775751693; cv=none; d=zohomail.com; s=zohoarc; b=Hlzmu8gkUNDZl01EHtElkfEbJdnuJuQIMW4daka5aB1INKGxrxUWNqU9aA5oF7btAx0YDFWuk/XOBrPV9b7lq4jB7o8FmQS+nU5vbED36eeviAn7ceETdY9F2T8kDPRfvOEiWRxjH5GRgJdpXTC/06gpMMQSrUXqwfYdB3R7Q4M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775751693; 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=0UnZsd6VMv3nhahDJTmKjpYZpYAGnJoqucRzautn7QA=; b=JoAH4+kM5Yd36jEKWthQT08Koj2r8qCyuwjyl+QxokGOMMo5Beod1ahze7GPyI/DXdf5efTsbZnvTuN7Vnn26pJY8ks+zitg7DEJDKWZDZ/681EAfnmy6YVXhHh/RsBXkRoSpx01dMcGNDlTjFNaINz9r/X2Wt/gYIP00aiZ7so= 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 1775751693349265.73837421373776; Thu, 9 Apr 2026 09:21:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1277970.1563035 (Exim 4.92) (envelope-from ) id 1wAs7y-0006an-Gj; Thu, 09 Apr 2026 16:21:10 +0000 Received: by outflank-mailman (output) from mailman id 1277970.1563035; Thu, 09 Apr 2026 16:21:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAs7y-0006ag-E3; Thu, 09 Apr 2026 16:21:10 +0000 Received: by outflank-mailman (input) for mailman id 1277970; Thu, 09 Apr 2026 16:21:09 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAs7x-0006Zr-6L for xen-devel@lists.xenproject.org; Thu, 09 Apr 2026 16:21:09 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wAs7w-002Kv1-IN for xen-devel@lists.xenproject.org; Thu, 09 Apr 2026 18:21:08 +0200 Received: from [10.42.69.2] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d7d1c8-2eae-0a2a0a5409dd-0a2a450295e2-42 for ; Thu, 09 Apr 2026 18:21:08 +0200 Received: from [198.2.187.14] (helo=mail187-14.suw11.mandrillapp.com) by tlsNG-720697.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d7d1f3-42fa-0a2a45020019-c602bb0e046b-3 for ; Thu, 09 Apr 2026 18:21:08 +0200 Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-14.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fs4tW0whgz8XWZyF for ; Thu, 9 Apr 2026 16:21:07 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 2d68c2e86b134086aff945f8d500e260; Thu, 09 Apr 2026 16:21:07 +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=1775751667; x=1776021667; bh=0UnZsd6VMv3nhahDJTmKjpYZpYAGnJoqucRzautn7QA=; 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=qbefgWiqvZErQ9/ybAH4YbWRSO4lAPnBrUa9n60XJtZ+FaQUBpuwIZGQtJ7wf6jAd 20TesU2SbQbkXhU62M5LdTgbHooW1tgnnR7gwxu26BfYWdhY6aMCADgQgzedyVCZ87 66eKLmn73R33tJZyoTsN0uZiJdZOjKJl+RUuKfNbWbn0H5io3aBCgN+YDWwWFKxQdU tfuefmUyuxSETWquPkU3CiwC2owPqjVYKu45uqaEYjJydRabwHdLB6ltPf3+tDr3Dj tW6PwzhDXhM+d8lIIDRo4y7Q1DYq+x06dbvwP3paBdQq68ySheMhO+KbuCW4/e0bRX x89LfC7f55tSQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1775751667; x=1776012167; i=thierry.escande@vates.tech; bh=0UnZsd6VMv3nhahDJTmKjpYZpYAGnJoqucRzautn7QA=; 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=UReoS+ahOd18SgPZmRFWbbfx0xIgFHLHhSfxKjnlXGUAz8e9dg+UGV6vPiv4EVfPC oucDswE963viLI8gwfSxOx70oy6L+EiNoIOxpwH8pGE+FWaSvLPOEK1bRfDVrfCWFQ cePt3vjSVZW1vUH7M+lW2EVq6+j/HyFFPCWZTnToXJ3+G7x8Bo+HbsnllxIcdhsVnZ JmwZJh5cQdd0yA3ROgHTrEW2fcsaxMtTUNMUPVJx+kroQtbbd83VLrzqGBUZyOIJzp nc4MyShmXadcHSABuafEuOlqgfQVF2Stk6VFKI3BgLM5Fdzo6WVP6gNoYqG6ovFcvG 7JinwSTsMZz8A== From: "Thierry Escande" Subject: =?utf-8?Q?[RFC=20PATCH=20v2=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: 1775751666400 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: <20260409162000.1102680-3-thierry.escande@vates.tech> In-Reply-To: <20260409162000.1102680-1-thierry.escande@vates.tech> References: <20260409162000.1102680-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.2d68c2e86b134086aff945f8d500e260?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260409:md Date: Thu, 09 Apr 2026 16:21:07 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-720697/1775751668-AE926CD1-767AF0B8/0/0 X-purgate-type: clean X-purgate-size: 8941 X-ZohoMail-DKIM: pass (identity thierry.escande@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1775751696346154100 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 --- v2: - Add support for YAJL json parser --- tools/include/libxl.h | 1 + tools/libs/light/libxl_dm.c | 80 +++++++++++++++++++++++++++++++ tools/libs/light/libxl_internal.h | 2 + tools/libs/light/libxl_pci.c | 41 ++++++++++++---- 4 files changed, 114 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..4f4781b36d 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -1169,6 +1169,86 @@ static int libxl__build_device_model_args_new(libxl_= _gc *gc, } } } + + if (guest_config->num_pcidevs) { + libxl_ctx *ctx =3D libxl__gc_owner(gc); + libxl_device_pci *pci; + libxl__json_object *qmp_json; + char *json_str; +#ifdef HAVE_LIBJSONC + json_object *jso; + const char *buf; +#elif defined(HAVE_LIBYAJL) + yajl_gen hand; + /* memory for 'buf' is owned by 'hand' */ + const unsigned char *buf; + libxl_yajl_length len; +#else +# error Missing JSON library +#endif + + for (i =3D 0; i < guest_config->num_pcidevs; i++) { + 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); + +#ifdef HAVE_LIBJSONC + rc =3D libxl__json_object_to_json_object(gc, &jso, qmp= _json); + if (rc) + return rc; + + buf =3D json_object_to_json_string_ext(jso, + JSON_C_TO_STRING_= PLAIN); + if (!buf) { + json_object_put(jso); + return ERROR_NOMEM; + } +#elif defined(HAVE_LIBYAJL) + hand =3D libxl_yajl_gen_alloc(NULL); + if (!hand) { + return ERROR_NOMEM; + } +#if HAVE_YAJL_V2 + /* Disable beautify for data sent to QEMU */ + yajl_gen_config(hand, yajl_gen_beautify, 0); +#endif + + rc =3D libxl__json_object_to_yajl_gen(gc, hand, qmp_js= on); + if (rc) { + yajl_gen_free(hand); + return rc; + } + + rc =3D yajl_gen_get_buf(hand, &buf, &len); + if (rc !=3D yajl_gen_status_ok) { + yajl_gen_free(hand); + return rc; + } +#endif + + json_str =3D libxl__strdup(gc, (const char *)buf); + if (json_str) + flexarray_vappend(dm_args, "-device", json_str, NU= LL); + +#ifdef HAVE_LIBJSONC + json_object_put(jso); +#elif defined(HAVE_LIBYAJL) + yajl_gen_free(hand); +#endif + + if (!json_str) + return ERROR_NOMEM; + } + } } =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:38:38 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=1775751695; cv=none; d=zohomail.com; s=zohoarc; b=nQIpFInflTSAUTLcO1dK05qrR4lcy5JpLkhC2YVg6GOAaFhJjk3LOC260OYw7zE3DnP02fuvs0eEkpgNRwSGuXmm+WZuhp7fszh7c55FjPTmaQCW/7JbWqYF8bdVNys2FCVUbLa8tCL87wBMHyrikornGYskx+9A9974MRgeQZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775751695; 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=aEGweMh3nn2we8a8H+DP/OH/jK1OTcDX5edzheCVTKg=; b=dDyI7hfULvkIhJJAQdFxTK5y64PQhZ2Q7A9UpwFgPJUcpeokLWJyF28G4zV4rfveeXsBhnZ+xn05d/kzxg9Hz5FesIIkCTQZdKI/qqFzuGrQzYTRew9wpPiPzf1wtN0HAqBUnGeFAtPFbTBC/9TOW3ETeSaJeGWpaMnXHwuxnsM= 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 1775751695483889.752801508543; Thu, 9 Apr 2026 09:21:35 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1277972.1563045 (Exim 4.92) (envelope-from ) id 1wAs82-0006s9-PL; Thu, 09 Apr 2026 16:21:14 +0000 Received: by outflank-mailman (output) from mailman id 1277972.1563045; Thu, 09 Apr 2026 16:21:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAs82-0006ry-L6; Thu, 09 Apr 2026 16:21:14 +0000 Received: by outflank-mailman (input) for mailman id 1277972; Thu, 09 Apr 2026 16:21:13 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wAs81-0006qc-PY for xen-devel@lists.xenproject.org; Thu, 09 Apr 2026 16:21:13 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wAs81-00AE9I-5G for xen-devel@lists.xenproject.org; Thu, 09 Apr 2026 18:21:13 +0200 Received: from [10.42.69.10] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 69d7d1e5-5cb7-0a2a0a5109dd-0a2a450ae60c-38 for ; Thu, 09 Apr 2026 18:21:13 +0200 Received: from [198.2.187.1] (helo=mail187-1.suw11.mandrillapp.com) by tlsNG-4011c0.mxtls.expurgate.net with ESMTPS (eXpurgate 4.56.0) (envelope-from ) id 69d7d1f7-ee98-0a2a450a0019-c602bb01ba26-3 for ; Thu, 09 Apr 2026 18:21:12 +0200 Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-1.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4fs4tb59lKzBsTvmW for ; Thu, 9 Apr 2026 16:21:11 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 739e440ecbe14cfe85700eac099145f7; Thu, 09 Apr 2026 16:21:11 +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=1775751671; x=1776021671; bh=aEGweMh3nn2we8a8H+DP/OH/jK1OTcDX5edzheCVTKg=; 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=uviAdraaIAKgWK8MUDWijOltDBdI1GTWJU2WJf2RYEcBk9sbLaJUki4KiXpLBTAy8 gii4EYYFY7lYGOQDkbb8QKel0ffAssf2VN/YBD5drts0cHD4UwsrUzwYeVe5J6e8en Yd//ppt5++PUn4M8R5zWqfxR8W0dvJ6NlzgljxNdEnn+oZo91sp4MjkbPpOgzlsWXq CnMV01CQpj3W2SCk2TzXf11kliUbfdr5FQBed7A6h6MGgacG0v8JJTM6aMSuGlz21S XvUT1sRuFgg+KxEQoksvFqUpRZRjm5yTo4kVFvXjdOlXSuqOR0/624Y50A1Jg4PJhs +CkGytnLNCPaw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1775751671; x=1776012171; i=thierry.escande@vates.tech; bh=aEGweMh3nn2we8a8H+DP/OH/jK1OTcDX5edzheCVTKg=; 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=Uj1FqENKAg7IoF81l92a47OI80P0/OeB7Yg+6CMgJEs4O+ZHR+j8wDXA3PD1AWiDU thRbtqACKW6mceDiXYfeP26QdQ13IMbGfyx5vIuNB+L7Donnookv4OBJb8oB+5zCUx 8E6vLX2xPfFoe/sxgldszo3bslDB4owDSGU7Z9HM1B9tEuE4gbuPZIHLMVi+c8wsdi 848XybE4XI9ilb8y3DGcCNFzYAzRn/pZgGmtS/72LONZZ1n6rPOcQDSIZpcdB1zlO9 86x/fss8OIjtxQrwdfvj9QO/pCofltGMPGZFtNnwqy4LDIav5tNxju3nz7mv+qklvF kF3z2YsJT1n7A== From: "Thierry Escande" Subject: =?utf-8?Q?[RFC=20PATCH=20v2=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: 1775751671088 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: <20260409162000.1102680-4-thierry.escande@vates.tech> In-Reply-To: <20260409162000.1102680-1-thierry.escande@vates.tech> References: <20260409162000.1102680-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.739e440ecbe14cfe85700eac099145f7?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20260409:md Date: Thu, 09 Apr 2026 16:21:11 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-purgate-ID: tlsNG-4011c0/1775751673-0DB550B1-350197DB/0/0 X-purgate-type: clean X-purgate-size: 1897 X-ZohoMail-DKIM: pass (identity thierry.escande@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1775751698000154100 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 --- v2: no change --- 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