From: Chuck Zmudzinski <brchuckz@aol.com> To: anthony.perard@citrix.com Cc: xen-devel@lists.xenproject.org, Wei Liu <wl@xen.org>, Juergen Gross <jgross@suse.com>, qemu-devel@nongnu.org Subject: [XEN PATCH 3/3] libxl/dm: Assign slot 2 by default for Intel IGD passthrough Date: Mon, 9 Jan 2023 18:08:13 -0500 [thread overview] Message-ID: <27bb3979f234c8de6b51be7bb8195e3cacb5181c.1673300848.git.brchuckz@aol.com> (raw) In-Reply-To: <cover.1673300848.git.brchuckz@aol.com> It is possible for the administrator to manually specify the virtual slot addresses of passed through pci devices on the guest's pci bus using the @VSLOT parameter in xl.cfg. With this patch, libxl will by default assign the Intel IGD to slot 2 when gfx_passthru is configured for the Intel IGD so it will no longer be necessary to use the @VSLOT setting to configure the IGD correctly. Also, with this patch, libxl will not override explicit @VSLOT settings by the administrator so in that case the patch will have no effect on guest behavior. The default behavior of letting qemu manage the slot addresses of passed through pci devices when gfx_passthru is disabled and the administrator does not set @VSLOT for passed through pci devices is also preserved. Signed-off-by: Chuck Zmudzinski <brchuckz@aol.com> --- tools/libs/light/libxl_dm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index 2720b5d4d0..b51ebae643 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -1207,6 +1207,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, int rc; int next_slot; bool configure_pci_for_igd = false; + const int igd_slot = 2; /* * next_slot is only used when we need to configure the pci * slots for the Intel IGD. Slot 2 will be for the Intel IGD. @@ -2173,6 +2174,27 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, flexarray_append(dm_envs, NULL); if (envs) *envs = (char **) flexarray_contents(dm_envs); + if (configure_pci_for_igd) { + libxl_device_pci *pci = NULL; + for (i = 0; i < guest_config->num_pcidevs; i++) { + pci = &guest_config->pcidevs[i]; + if (!pci->vdevfn) { + /* + * Find the Intel IGD and configure it for slot 2. + * Configure any other devices for slot next_slot. + * Since the guest is configured for IGD passthrough, + * assume the device on the host at slot 2 is the IGD. + */ + if (pci->domain == 0 && pci->bus == 0 && + pci->dev == igd_slot && pci->func == 0) { + pci->vdevfn = PCI_DEVFN(igd_slot, 0); + } else { + pci->vdevfn = PCI_DEVFN(next_slot, 0); + next_slot++; + } + } + } + } return 0; } -- 2.39.0
WARNING: multiple messages have this Message-ID (diff)
From: Chuck Zmudzinski <brchuckz@aol.com> To: anthony.perard@citrix.com Cc: xen-devel@lists.xenproject.org, Wei Liu <wl@xen.org>, Juergen Gross <jgross@suse.com>, qemu-devel@nongnu.org Subject: [XEN PATCH v2 3/3] libxl/dm: Assign slot 2 by default for Intel IGD passthrough Date: Tue, 10 Jan 2023 02:32:04 -0500 [thread overview] Message-ID: <27bb3979f234c8de6b51be7bb8195e3cacb5181c.1673300848.git.brchuckz@aol.com> (raw) Message-ID: <20230110073204.36sUJ7alZn0D1V_dVzB7uhs27gZ8NCscTT7zmjx2dkM@z> (raw) In-Reply-To: <cover.1673300848.git.brchuckz@aol.com> It is possible for the administrator to manually specify the virtual slot addresses of passed through pci devices on the guest's pci bus using the @VSLOT parameter in xl.cfg. With this patch, libxl will by default assign the Intel IGD to slot 2 when gfx_passthru is configured for the Intel IGD so it will no longer be necessary to use the @VSLOT setting to configure the IGD correctly. Also, with this patch, libxl will not override explicit @VSLOT settings by the administrator so in that case the patch will have no effect on guest behavior. The default behavior of letting qemu manage the slot addresses of passed through pci devices when gfx_passthru is disabled and the administrator does not set @VSLOT for passed through pci devices is also preserved. Signed-off-by: Chuck Zmudzinski <brchuckz@aol.com> --- v2: No changes to this patch since v1 tools/libs/light/libxl_dm.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c index 2720b5d4d0..b51ebae643 100644 --- a/tools/libs/light/libxl_dm.c +++ b/tools/libs/light/libxl_dm.c @@ -1207,6 +1207,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, int rc; int next_slot; bool configure_pci_for_igd = false; + const int igd_slot = 2; /* * next_slot is only used when we need to configure the pci * slots for the Intel IGD. Slot 2 will be for the Intel IGD. @@ -2173,6 +2174,27 @@ static int libxl__build_device_model_args_new(libxl__gc *gc, flexarray_append(dm_envs, NULL); if (envs) *envs = (char **) flexarray_contents(dm_envs); + if (configure_pci_for_igd) { + libxl_device_pci *pci = NULL; + for (i = 0; i < guest_config->num_pcidevs; i++) { + pci = &guest_config->pcidevs[i]; + if (!pci->vdevfn) { + /* + * Find the Intel IGD and configure it for slot 2. + * Configure any other devices for slot next_slot. + * Since the guest is configured for IGD passthrough, + * assume the device on the host at slot 2 is the IGD. + */ + if (pci->domain == 0 && pci->bus == 0 && + pci->dev == igd_slot && pci->func == 0) { + pci->vdevfn = PCI_DEVFN(igd_slot, 0); + } else { + pci->vdevfn = PCI_DEVFN(next_slot, 0); + next_slot++; + } + } + } + } return 0; } -- 2.39.0
next prev parent reply other threads:[~2023-01-09 23:08 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <cover.1673300848.git.brchuckz.ref@aol.com> 2023-01-09 23:08 ` [XEN PATCH 0/3] Configure qemu upstream correctly by default for igd-passthru Chuck Zmudzinski 2023-01-09 23:08 ` [XEN PATCH 1/3] libxl/dm: Use "pc" machine type for Intel IGD passthrough Chuck Zmudzinski 2023-01-10 7:32 ` [XEN PATCH v2 " Chuck Zmudzinski 2023-01-09 23:08 ` [XEN PATCH 2/3] libxl/dm: Manage pci slot assignment " Chuck Zmudzinski 2023-01-10 7:32 ` [XEN PATCH v2 " Chuck Zmudzinski 2023-01-09 23:08 ` Chuck Zmudzinski [this message] 2023-01-10 7:32 ` [XEN PATCH v2 3/3] libxl/dm: Assign slot 2 by default " Chuck Zmudzinski 2023-01-10 7:32 ` [XEN PATCH v2 0/3] Configure qemu upstream correctly by default for igd-passthru Chuck Zmudzinski 2023-01-25 11:37 ` Anthony PERARD via 2023-01-25 20:20 ` Chuck Zmudzinski 2023-01-25 23:19 ` Chuck Zmudzinski 2023-01-30 0:38 ` Chuck Zmudzinski 2023-01-31 19:35 ` Chuck Zmudzinski
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=27bb3979f234c8de6b51be7bb8195e3cacb5181c.1673300848.git.brchuckz@aol.com \ --to=brchuckz@aol.com \ --cc=anthony.perard@citrix.com \ --cc=jgross@suse.com \ --cc=qemu-devel@nongnu.org \ --cc=wl@xen.org \ --cc=xen-devel@lists.xenproject.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).