public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH pve-qemu-server-rs v3 1/9] add pve-qemu-server-pci crate for guest PCI address generation
Date: Wed, 11 Nov 2026 10:19:23 +0100	[thread overview]
Message-ID: <b07d1d19-bfb7-4119-ab9a-e754fc8ace33@proxmox.com> (raw)
In-Reply-To: <eb4be018-ef64-405c-a7a5-01784f1610b3@proxmox.com>

Am 11.11.26 um 10:10 AM schrieb Dominik Csapak:
> On 11/10/26 5:03 PM, Fiona Ebner wrote:
>> Am 06.11.26 um 2:28 PM schrieb Dominik Csapak:
>>> +    /// The recorded required `+pveX` version
>>> +    pub required_pve_version: Arc<AtomicU16>,
>>> +}
>>> +
>>> +impl HardwareConfig {
>>> +    /// Builds a [`HardwareConfig`] from the raw configuration values.
>>> +    ///
>>> +    /// Unparsable `arch`, `scsihw` and `ostype` values are not an
>>> error here:
>>> +    /// `arch` falls back to x86_64 and the other two to `None`,
>>> which is the
>>> +    /// same defaulting the Perl implementation does.
>>
>> Arch falls back to the host architecture, not x86_64.
> 
> true.
> 
> Would it be better if we expect explicit values here and not fall
> back to anything (so let perl handle the defaults for now)
> and raise an error otherwise?

Sounds like a plan :)

>>> +    pub fn new(params: HardwareConfigParams) -> Self {
>>> +        let arch = params
>>> +            .arch
>>> +            .parse()
>>> +            .unwrap_or(ClusterResourceHostArch::X8664)
>>> +            .into();
>>> +        let scsihw = params.scsihw.and_then(|hw| hw.parse().ok());
>>> +        let ostype = params.ostype.and_then(|ostype|
>>> ostype.parse().ok());
>>> +
>>> +        let mainboard = match arch {
>>> +            Arch::Aarch64 => Mainboard::Virt,
>>> +            Arch::X8664 if params.machine_type.contains("q35") =>
>>> Mainboard::Q35,
>>> +            Arch::X8664 => Mainboard::I440fx,
>>
>> You must not rely on the default for the arch here, since we don't
>> enforce that a machine type matches the arch currently:
>>
>> [I] root@pve9a1 ~# qm create 100 --machine virt --arch x86_64
>> [I] root@pve9a1 ~# cat /etc/pve/qemu-server/100.conf
>> arch: x86_64
>> boot:
>> machine: virt
>> meta: creation-qemu=11.1.3,ctime=1794318573
>> smbios1: uuid=e325ddd6-f74b-4a08-be42-b618f2924a9e
>> vmgenid: ff99f0bf-96ef-44fe-9861-481c506c65ff
> 
> also true, but this can't work anyway ? no virt on x86 and no q35/i440fx
> on aarch64, so this should really be enforced somewhere in our stack
> before trying to start qemu?

We could start enforcing it, but it's not currently, so such guest
configurations already might exist (by accident, i.e. changing one
property without adapting the other). Even if they can't be started, the
generated commandline should not be different from what the config
contains. Otherwise they suddenly might be able to start ;) (not with
your series alone here, but still). Even if we did enforce it, I still
think we should not assume stuff about another config property, but
rather actually look at its value.

>>> +        const PREFIXES: &[(&str, BusConstructor)] = &[
>>> +            ("pci.", Bus::Pci),
>>> +            ("pcie.", Bus::Pcie),
>>> +            #[expect(deprecated)]
>>> +            ("ich9-pcie-port-", Bus::LegacyRootPort),
>>> +        ];
>>> +
>>> +        if s == "pcidmi" {
>>> +            return Ok(Bus::Pcidmi);
>>> +        }
>>> +
>>> +        for (prefix, c) in PREFIXES {
>>> +            if let Some(rest) = s.strip_prefix(prefix) {
>>> +                let index: u8 = rest.parse().map_err(|_|
>>> LayoutError::InvalidConfigId)?;
>>> +                return Ok(c(index));
>>> +            }
>>> +        }
>>> +
>>> +        Err(LayoutError::InvalidConfigId)
>>> +    }
>>> +}
>>
>> ---snip 8<---
>>
>>> +/// The address a layout assigns to a device.
>>> +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
>>> +pub struct AddressAssignment {
>>> +    pub addr: PciAddress,
>>> +    pub device: Device,
>>> +    /// Whether QEMU has to be told that other functions of this
>>> slot are in
>>> +    /// use. Only ever set on function 0.
>>
>> Should there be a check for this with a new() function? Or would that
>> complicate things too much?
> 
> mhmm i'll see. I tried to have most of the code free of Result's
> and do most of it statically, but can still make sense

It's just an idea, so maybe it isn't worth the overhead.




  reply	other threads:[~2026-11-11  9:19 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 [this message]
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
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=b07d1d19-bfb7-4119-ab9a-e754fc8ace33@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=d.csapak@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal