[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 54/65] qdev: adjust PciDevfn declared type
- To: Daniel P. Berrangé <berrange@xxxxxxxxxx>
- From: Markus Armbruster <armbru@xxxxxxxxxx>
- Date: Wed, 28 Oct 2026 08:13:44 +0100
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=mimecast20190719 header.d=redhat.com header.i="@redhat.com" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:In-Reply-To:References"
- Cc: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>, qemu-devel@xxxxxxxxxx, Michael Roth <michael.roth@xxxxxxx>, John Snow <jsnow@xxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>, Pierrick Bouvier <pierrick.bouvier@xxxxxxxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Kostiantyn Kostiuk <kkostiuk@xxxxxxxxxx>, Eric Blake <eblake@xxxxxxxxxx>, David Hildenbrand <david@xxxxxxxxxx>, Igor Mammedov <imammedo@xxxxxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Jason Wang <jasowangio@xxxxxxxxx>, Marcelo Tosatti <mtosatti@xxxxxxxxxx>, kvm@xxxxxxxxxxxxxxx, Alberto Garcia <berto@xxxxxxxxxx>, Kevin Wolf <kwolf@xxxxxxxxxx>, Hanna Reitz <hreitz@xxxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxxxxxxxx>, Zhao Liu <zhao1.liu@xxxxxxxxx>, Jonathan Cameron <jic23@xxxxxxxxxx>, Junjie Cao <junjie.cao@xxxxxxxxx>, Anisa Su <anisa.su@xxxxxxxxxxx>, Elena Ufimtseva <elena.ufimtseva@xxxxxxxxxx>, Jagannathan Raman <jag.raman@xxxxxxxxxx>, John Levon <john.levon@xxxxxxxxxxx>, Thanos Makatos <thanos.makatos@xxxxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxxxx>, Cornelia Huck <cohuck@xxxxxxxxxx>, Eric Farman <farman@xxxxxxxxxxxxx>, Matthew Rosato <mjrosato@xxxxxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Ilya Leoshkevich <iii@xxxxxxxxxxxxx>, qemu-block@xxxxxxxxxx, linux-cxl@xxxxxxxxxxxxxxx, qemu-s390x@xxxxxxxxxx, "Michael S. Tsirkin" <mst@xxxxxxxxxx>, Sergio Lopez <slp@xxxxxxxxxx>, qemu-arm@xxxxxxxxxx, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Weiwei Li <liwei1518@xxxxxxxxx>, Daniel Henrique Barboza <daniel.barboza@xxxxxxxxxxxxxxxx>, Liu Zhiwei <zhiwei_liu@xxxxxxxxxxxxxxxxx>, Chao Liu <chao.liu@xxxxxxxxxxxxxxxxxx>, qemu-riscv@xxxxxxxxxx, Song Gao <17746591750@xxxxxxx>, Bibo Mao <maobibo@xxxxxxxxxxx>, Xianglai Li <lixianglai@xxxxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, Pedro Barbuda <pbarbuda@xxxxxxxxxxxxx>, Mohamed Mediouni <mohamed@xxxxxxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Harsh Prateek Bora <harshpb@xxxxxxxxxxxxx>, Amit Machhiwal <amachhiw@xxxxxxxxxxxxx>, qemu-ppc@xxxxxxxxxx, Zhang Chen <zhangckid@xxxxxxxxx>, Li Zhijian <lizhijian@xxxxxxxxxxx>, Alistair Francis <alistair@xxxxxxxxxxxxx>, Alexander Graf <graf@xxxxxxxxxx>, "Gonglei (Arei)" <arei.gonglei@xxxxxxxxxx>, zhenwei pi <zhenwei.pi@xxxxxxxxx>, Ani Sinha <anisinha@xxxxxxxxxx>, Luc Michel <luc@xxxxxxxxxx>, Cédric Le Goater <clg@xxxxxxxx>, Jamin Lin <jamin_lin@xxxxxxxxxxxxxx>, Kane Chen <kane_chen@xxxxxxxxxxxxxx>, Samuel Tardieu <sam@xxxxxxxxxxx>, "Denis V. Lunev" <den@xxxxxxxxxx>, FangSheng Huang <FangSheng.Huang@xxxxxxx>, Tyrone Ting <kfting@xxxxxxxxxxx>, Hao Wu <wuhaotsh@xxxxxxxxxx>, Keith Busch <kbusch@xxxxxxxxxx>, Klaus Jensen <its@xxxxxxxxxxxxx>, Jesper Devantier <foss@xxxxxxxxxxx>, Aditya Gupta <adityag@xxxxxxxxxxxxx>, Glenn Miles <milesg@xxxxxxxxxxxxx>, Conor Dooley <conor@xxxxxxxxxx>, Sebastian Huber <sebastian.huber@xxxxxxxxxxxxxxxxxx>, Halil Pasic <pasic@xxxxxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxxxxx>, Jason Herne <jjherne@xxxxxxxxxxxxx>, Titus Rwantare <titusr@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, Peter Xu <peterx@xxxxxxxxxx>, Chinmay Rath <rathc@xxxxxxxxxxxxx>, Hendrik Brueckner <brueckner@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Roman Bolshakov <rbolshakov@xxxxxxx>, Phil Dennis-Jordan <phil@xxxxxxxxxxxxx>, Fam Zheng <fam@xxxxxxxxxx>, Farhan Ali <alifm@xxxxxxxxxxxxx>, Alex Williamson <alex@xxxxxxxxxxx>, Tao Tang <tangtao1634@xxxxxxxxxxxxxx>, Stefan Berger <stefanb@xxxxxxxxxxxxxxxxxx>, Fabiano Rosas <farosas@xxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, Yoshinori Sato <yoshinori.sato@xxxxxxxxx>, Jiri Pirko <jiri@xxxxxxxxxxx>, Eric Auger <eric.auger@xxxxxxxxxx>, Laurent Vivier <lvivier@xxxxxxxxxx>
- Delivery-date: Wed, 28 Oct 2026 07:32:52 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
Daniel P. Berrangé <berrange@xxxxxxxxxx> writes:
> On Tue, Oct 27, 2026 at 03:54:03PM +0100, Markus Armbruster wrote:
>> Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> writes:
>>
>> > Hi
>> >
>> > On Fri, Oct 23, 2026 at 2:04 PM Daniel P. Berrangé <berrange@xxxxxxxxxx>
>> > wrote:
>> >>
>> >> On Tue, Oct 20, 2026 at 02:46:11PM +0400, Marc-André Lureau wrote:
>> >> > PciDevfn is a bit special, since it accepts integer and string as
>> >> > setter, but only output integer as getter.
>
> snip
>
>> > But I agree we
>> > could do better.
>> >
>> > There are multiple options. We could keep declaring the property as
>> > str instead. In this case, the getter should probably return a string
>> > for consistency and correctness. This might surprise some existing
>> > users though.
>>
>> I.e. ditch numeric suppport for numeric addresses, right?
>>
>> Incompatible change. Do we care?
>>
>> If we don't, we should be honest about it and mark qom-get unstable.
>>
>> > We could introduce new properties like `devfn-str` and `devfn-int`
>> > that alias the same value.
>>
>> Compatibility break. If breaking compatibility is okay, I'd rather use
>> the opportunity to get rid of cleverness, and go with your first option.
>>
>> > We could also introduce a new structured QAPI type.
>>
>> What kind of type do you have in mind?
>
> IMHO the root cause design flaw here was to overload 'addr' as a
> way to set both the slot number and function number, as using
> one property for two pieces of data is a well known anti-pattern
> we caution against.
>
> IOW, we should have had 'slot' and 'function' as separate properties
> from the start.
Fair.
Our modeling of PCI is old and weird.
What we call "pci-device" isn't a device, it's a function, where
function 0 sort of stands in for the device.
Its "addr" isn't a PCI address, it's the address of the function on its
PCI bus, i.e. the tail of a PCI address.
> From a CLI POV, we could easily change 'addr' to mean only the slot
> number, since it is always parsed in string format without the
> magic (slot << 4) | function encoding. Then add a 'function' prop
In CLI, HMP and QMP string (not integer), value "5" is shorthand for
"5.0", and means device 5, function 0.
We could deprecate the .FN part in favor of a new property "function".
Once we drop support for .FN from "addr", its name becomes even more
misleading than it always was.
> The challenge is the impact on QMP with strict typing, as ideally
> int format would soley represent the slot number, but today the
> int format is encoded (slot << 4) | function. So anyone relying
> on int format in QMP would silently have a semantic change if we
> altered what 'addr' means.
That's a no-go.
> Deprecating 'addr' entirely and adding brand new 'slot' and
> 'function' properties would be a significant disruption to
> a syntax which has been documented for years (decades).
What about this:
* No change to PCIDevice member @devfn: encodes slot and function as an
integer.
* New "pci-device" properties "slot" and "function". "slot" sets just
the slot bits of @devfn, and "function" sets just the function bits.
Both default to zero, so specifying just "slot" gives you
PCI_DEVFN(slot, 0), which makes sense.
* Deprecate "pci-device" property "addr" for QMP. We can keep it around
for longer than the required grace period if that helps.
* Declare it legacy for CLI and HMP, with no intent to remove it.
|