From: Dominik Csapak <d.csapak@proxmox.com>
To: Fiona Ebner <f.ebner@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH pve-qemu-server-rs v3 4/9] pci: layout: add grouped PCI and PCIe layouts
Date: Wed, 11 Nov 2026 10:58:22 +0100 [thread overview]
Message-ID: <a940debb-3861-452c-85e7-b4eca1b5018c@proxmox.com> (raw)
In-Reply-To: <3e0667f1-b7c2-4988-8ce8-3c6a462c206d@proxmox.com>
On 11/10/26 6:08 PM, Fiona Ebner wrote:
> Note that I didn't go in-depth here yet when reviewing, just some things
> I noted:
>
> Am 06.11.26 um 2:27 PM schrieb Dominik Csapak:
>> The legacy layout grew over many releases and it shows: devices of one
>> kind are spread over several buses, the bus a device lands on depends on
>> how many devices of other kinds exist, and the remaining free slots are
>> scattered. That makes it hard to raise any of the per-kind limits
>> without further scattering the types over the available addresses.
>>
>> Add a second set of layouts that gives every device kind its own set of
>> bridges instead. A device's address then only depends on its own index,
>> so raising a limit adds bridges at the end rather than shifting anything
>> that exists, and the built-in devices move to a bridge of their own to
>> keep the root bus free.
>
> There currently are 9 (or 13 for pcie, or 9 for the standalone devices)
> slots in the new layout's root port assigned already. So we can add at
> most 23 (or 19 for pcie, or 23 for the standalone devices) more kinds of
> devices, or? Which might seem a lot at first glance, but in the long run
> might be a bit restrictive? Although I suppose some of them will be
> standalone and if we really reach that point we can add a switch for new
> layout again. Still, might be worth a bit of consideration if we can
> increase those limits a bit without too much trouble? If it's not easy
> to do so, don't mind me :)
actually we could add up to 8 devices per slot, the only requirement is
that slot 0 is there. In the worst case we can expand by adding bridges
though i won't guess there won't be many slots necessary for upcoming
device types, more like single devices and these can be put behind
new bridges too if we want/need.
>
>>
>> The new `layout` field of `HardwareConfig` selects which set is used,
>> so `pci_bridge_for_device` now takes the config too. Since the layout
>> is part of the guest ABI, the grouped one is only intended for new
>> guests.
>>
>> `pci_bus_devices` returns its bridges and the hostpcie root ports,
>> with the same function 0 handling as for the legacy layout.
>>
>
> ---snip 8<---
>
>> diff --git a/pve-qemu-server-pci/src/layout/grouped.rs b/pve-qemu-server-pci/src/layout/grouped.rs
>> new file mode 100644
>> index 0000000..7ee1458
>> --- /dev/null
>> +++ b/pve-qemu-server-pci/src/layout/grouped.rs
>> @@ -0,0 +1,467 @@
>> +use crate::constants::{
>> + MAX_HOSTPCI_DEVICES, MAX_NET_DEVICES, MAX_SCSI_DEVICES, MAX_VIRTIO_BLK_DEVICES,
>> + MAX_VIRTIOFS_DEVICES, SLOTS_PER_BUS,
>> +};
>> +use crate::layout::bridge_slots;
>> +use crate::{
>> + Bus, Device, Function, HardwareConfig, Layout, LayoutError, PciAddress, PveBridge, Slot,
>> +};
>> +
>> +/// The guest's built-in devices, which all live on a bridge of their own so
>> +/// that the root bus stays free for the per-kind bridges.
>> +///
>> +/// NOTE: only append here, don't reorder. The order implies the address, which
>> +/// has to stay stable.
>> +const BUILTIN_DEVICES: [Slot; SLOTS_PER_BUS] = bridge_slots(&[
>> + single_device!(Ahci),
>> + single_device!(Balloon),
>> + single_device!(XhciController),
>> + single_device!(GuestAgent),
>> + single_device!(SpiceSerial),
>> + single_device!(Rng),
>> + single_device!(Audio),
>> + single_device!(Watchdog),
>> + single_device!(Ivshmem),
>
> Are we sure we never want to have multiple instances for any of these?
> Maybe for rng or audio at some point? At least their config keys are
> named rng0 and audio0 in qemu-server ;)
i thought about that shortly, but honestly most of them don't make sense
to have multiple of or the use case is very niche in the first place
(ivshmem for example).
for usb controllers we can solve it for a long time with usb hubs
instead (up to i think ~200 devices) so that should not be a problem
If anybody has a very niche use case for multiple of those one
can always use 'args' as an escape hatch.
>
> ---snip 8<---
>
>> diff --git a/pve-qemu-server-pci/src/types/layout.rs b/pve-qemu-server-pci/src/types/layout.rs
>> index 00a5a01..c08eacf 100644
>> --- a/pve-qemu-server-pci/src/types/layout.rs
>> +++ b/pve-qemu-server-pci/src/types/layout.rs
>> @@ -1,7 +1,7 @@
>> use std::collections::{HashSet, VecDeque};
>>
>> -use crate::constants::{FUNCTIONS_PER_DEVICE, SLOTS_PER_BUS};
>
> Only noticing it now, but maybe MAX_FUNCTIONS_PER_DEVICE?
>
> And the type Device is used for one function, so clashes a bit with the
> naming,so MAX_FUNCTIONS_PER_DEVICE_SLOT or similar? Not sure.
yeah makes sense
next prev parent reply other threads:[~2026-11-11 9:58 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 13:25 [RFC proxmox-perl-rs/qemu-server/qemu-server-rs v3 0/9] pci-handling rewrite (part 1/2/3) Dominik Csapak
2026-11-06 13:25 ` [PATCH pve-qemu-server-rs v3 1/9] add pve-qemu-server-pci crate for guest PCI address generation Dominik Csapak
2026-11-10 16:03 ` Fiona Ebner
2026-11-10 16:32 ` Fiona Ebner
2026-11-11 9:10 ` Dominik Csapak
2026-11-11 9:19 ` Fiona Ebner
2026-11-06 13:25 ` [PATCH pve-qemu-server-rs v3 2/9] pci: legacy: generate pci bridges Dominik Csapak
2026-11-10 16:23 ` Fiona Ebner
2026-11-06 13:25 ` [PATCH pve-qemu-server-rs v3 3/9] pci: legacy: generate q35 chipset devices and hostpcie root ports Dominik Csapak
2026-11-06 13:25 ` [PATCH pve-qemu-server-rs v3 4/9] pci: layout: add grouped PCI and PCIe layouts Dominik Csapak
2026-11-10 17:08 ` Fiona Ebner
2026-11-11 9:58 ` Dominik Csapak [this message]
2026-11-06 13:25 ` [PATCH proxmox-perl-rs v3 5/9] pve: add bindings for `pve-qemu-server-pci` crate Dominik Csapak
2026-11-06 13:25 ` [PATCH qemu-server v3 6/9] pci: use PVE::RS::PCI bindings for addresses and bus devices Dominik Csapak
2026-11-06 13:25 ` [PATCH qemu-server v3 7/9] tree-wide: use HardwareConfig for the machine version checks Dominik Csapak
2026-11-06 13:25 ` [PATCH qemu-server v3 8/9] cfg2cmd: q35: generate chipset devices with machine version 11.1+pve1 Dominik Csapak
2026-11-06 13:25 ` [PATCH qemu-server v3 9/9] machine: add 'pci-layout' option Dominik Csapak
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=a940debb-3861-452c-85e7-b4eca1b5018c@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.