All of lore.kernel.org
 help / color / mirror / Atom feed
* migration, PCIE ports, and parent_obj.parent_obj.parent_obj
@ 2026-10-26 16:11 Peter Maydell
  2026-10-26 16:19 ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2026-10-26 16:11 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Peter Xu, Fabiano Rosas, Michael S. Tsirkin

In reviewing a new pcie host bridge, I noticed (because this new device
copied existing code) that the vmstate structs for pcie root ports do
this in their vmstate structs:

    .fields = (const VMStateField[]) {
        VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
        VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
                       PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
        VMSTATE_MSIX(parent_obj.parent_obj.parent_obj.parent_obj,
                     GenPCIERootPort),
        VMSTATE_END_OF_LIST()
    }

(this specific example is hw/pci-bridge/gen_pcie_root_port.c).

Devices shouldn't have to have ugly long chains of "parent_obj"
like this and shouldn't have to care what in their parents needs
migration; compare e.g. SCSI devices, which start with a
"VMSTATE_SCSI_DEVICE" that captures all the parent class's needs,
followed by only the state that the child added.

How can we get to something more like that for PCIE port classes?

thanks
-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: migration, PCIE ports, and parent_obj.parent_obj.parent_obj
  2026-10-26 16:11 migration, PCIE ports, and parent_obj.parent_obj.parent_obj Peter Maydell
@ 2026-10-26 16:19 ` Michael S. Tsirkin
  2026-10-26 17:38   ` Peter Xu
  0 siblings, 1 reply; 5+ messages in thread
From: Michael S. Tsirkin @ 2026-10-26 16:19 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Peter Xu, Fabiano Rosas

On Mon, Oct 26, 2026 at 04:11:57PM +0000, Peter Maydell wrote:
> In reviewing a new pcie host bridge, I noticed (because this new device
> copied existing code) that the vmstate structs for pcie root ports do
> this in their vmstate structs:
> 
>     .fields = (const VMStateField[]) {
>         VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
>         VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
>                        PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
>         VMSTATE_MSIX(parent_obj.parent_obj.parent_obj.parent_obj,
>                      GenPCIERootPort),
>         VMSTATE_END_OF_LIST()
>     }
> 
> (this specific example is hw/pci-bridge/gen_pcie_root_port.c).
> 
> Devices shouldn't have to have ugly long chains of "parent_obj"
> like this and shouldn't have to care what in their parents needs
> migration; compare e.g. SCSI devices, which start with a
> "VMSTATE_SCSI_DEVICE" that captures all the parent class's needs,
> followed by only the state that the child added.
> 
> How can we get to something more like that for PCIE port classes?
> 
> thanks
> -- PMM

Yea makes total sense. Anyone has the bandwidth to take a stab?
I'm buried under a pile of ai generated security reports.

-- 
MST



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: migration, PCIE ports, and parent_obj.parent_obj.parent_obj
  2026-10-26 16:19 ` Michael S. Tsirkin
@ 2026-10-26 17:38   ` Peter Xu
  2026-10-26 19:10     ` Peter Maydell
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Xu @ 2026-10-26 17:38 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Peter Maydell, QEMU Developers, Fabiano Rosas

On Mon, Oct 26, 2026 at 12:19:07PM -0400, Michael S. Tsirkin wrote:
> On Mon, Oct 26, 2026 at 04:11:57PM +0000, Peter Maydell wrote:
> > In reviewing a new pcie host bridge, I noticed (because this new device
> > copied existing code) that the vmstate structs for pcie root ports do
> > this in their vmstate structs:
> > 
> >     .fields = (const VMStateField[]) {
> >         VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
> >         VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
> >                        PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
> >         VMSTATE_MSIX(parent_obj.parent_obj.parent_obj.parent_obj,
> >                      GenPCIERootPort),
> >         VMSTATE_END_OF_LIST()
> >     }
> > 
> > (this specific example is hw/pci-bridge/gen_pcie_root_port.c).
> > 
> > Devices shouldn't have to have ugly long chains of "parent_obj"
> > like this and shouldn't have to care what in their parents needs
> > migration; compare e.g. SCSI devices, which start with a
> > "VMSTATE_SCSI_DEVICE" that captures all the parent class's needs,
> > followed by only the state that the child added.
> > 
> > How can we get to something more like that for PCIE port classes?
> > 
> > thanks
> > -- PMM
> 
> Yea makes total sense. Anyone has the bandwidth to take a stab?
> I'm buried under a pile of ai generated security reports.

/me buried too on other things downstream.  I'm prepared to not be able to
work much upstream until after forum..

A quick look is this is not too bad yet:

$ git grep parent_obj.parent_obj | wc -l
20
$ git grep parent_obj.parent_obj.parent_obj | wc -l
11
(and, some of above lines are part of vm static checker script)

Looks not too bad yet? Still, I'll add a todo at least to myself (the other
place is https://wiki.qemu.org/ToDo/LiveMigration, feel free to update if
one sees it fit).

Thanks,

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: migration, PCIE ports, and parent_obj.parent_obj.parent_obj
  2026-10-26 17:38   ` Peter Xu
@ 2026-10-26 19:10     ` Peter Maydell
  2026-10-26 20:00       ` Peter Xu
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Maydell @ 2026-10-26 19:10 UTC (permalink / raw)
  To: Peter Xu; +Cc: Michael S. Tsirkin, QEMU Developers, Fabiano Rosas

On Mon, 26 Oct 2026 at 17:39, Peter Xu <peterx@redhat.com> wrote:
>
> On Mon, Oct 26, 2026 at 12:19:07PM -0400, Michael S. Tsirkin wrote:
> > On Mon, Oct 26, 2026 at 04:11:57PM +0000, Peter Maydell wrote:
> > > In reviewing a new pcie host bridge, I noticed (because this new device
> > > copied existing code) that the vmstate structs for pcie root ports do
> > > this in their vmstate structs:
> > >
> > >     .fields = (const VMStateField[]) {
> > >         VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
> > >         VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
> > >                        PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
> > >         VMSTATE_MSIX(parent_obj.parent_obj.parent_obj.parent_obj,
> > >                      GenPCIERootPort),
> > >         VMSTATE_END_OF_LIST()
> > >     }
> > >
> > > (this specific example is hw/pci-bridge/gen_pcie_root_port.c).
> > >
> > > Devices shouldn't have to have ugly long chains of "parent_obj"
> > > like this and shouldn't have to care what in their parents needs
> > > migration; compare e.g. SCSI devices, which start with a
> > > "VMSTATE_SCSI_DEVICE" that captures all the parent class's needs,
> > > followed by only the state that the child added.
> > >
> > > How can we get to something more like that for PCIE port classes?
> > >
> > > thanks
> > > -- PMM
> >
> > Yea makes total sense. Anyone has the bandwidth to take a stab?
> > I'm buried under a pile of ai generated security reports.
>
> /me buried too on other things downstream.  I'm prepared to not be able to
> work much upstream until after forum..
>
> A quick look is this is not too bad yet:
>
> $ git grep parent_obj.parent_obj | wc -l
> 20
> $ git grep parent_obj.parent_obj.parent_obj | wc -l
> 11
> (and, some of above lines are part of vm static checker script)
>
> Looks not too bad yet?

Depends on your definition of "bad" :-)  This is basically
the only vmstate that's doing this thing, and it would be
nice to correct it before we add more devices that end up
following the same pattern.

I agree it's not super urgent; I posted mostly because I have
no idea what the right fix is (especially given we want to
retain migration compat here).

thanks
-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: migration, PCIE ports, and parent_obj.parent_obj.parent_obj
  2026-10-26 19:10     ` Peter Maydell
@ 2026-10-26 20:00       ` Peter Xu
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Xu @ 2026-10-26 20:00 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Michael S. Tsirkin, QEMU Developers, Fabiano Rosas

On Mon, Oct 26, 2026 at 07:10:21PM +0000, Peter Maydell wrote:
> On Mon, 26 Oct 2026 at 17:39, Peter Xu <peterx@redhat.com> wrote:
> >
> > On Mon, Oct 26, 2026 at 12:19:07PM -0400, Michael S. Tsirkin wrote:
> > > On Mon, Oct 26, 2026 at 04:11:57PM +0000, Peter Maydell wrote:
> > > > In reviewing a new pcie host bridge, I noticed (because this new device
> > > > copied existing code) that the vmstate structs for pcie root ports do
> > > > this in their vmstate structs:
> > > >
> > > >     .fields = (const VMStateField[]) {
> > > >         VMSTATE_PCI_DEVICE(parent_obj.parent_obj.parent_obj, PCIESlot),
> > > >         VMSTATE_STRUCT(parent_obj.parent_obj.parent_obj.exp.aer_log,
> > > >                        PCIESlot, 0, vmstate_pcie_aer_log, PCIEAERLog),
> > > >         VMSTATE_MSIX(parent_obj.parent_obj.parent_obj.parent_obj,
> > > >                      GenPCIERootPort),
> > > >         VMSTATE_END_OF_LIST()
> > > >     }
> > > >
> > > > (this specific example is hw/pci-bridge/gen_pcie_root_port.c).
> > > >
> > > > Devices shouldn't have to have ugly long chains of "parent_obj"
> > > > like this and shouldn't have to care what in their parents needs
> > > > migration; compare e.g. SCSI devices, which start with a
> > > > "VMSTATE_SCSI_DEVICE" that captures all the parent class's needs,
> > > > followed by only the state that the child added.
> > > >
> > > > How can we get to something more like that for PCIE port classes?
> > > >
> > > > thanks
> > > > -- PMM
> > >
> > > Yea makes total sense. Anyone has the bandwidth to take a stab?
> > > I'm buried under a pile of ai generated security reports.
> >
> > /me buried too on other things downstream.  I'm prepared to not be able to
> > work much upstream until after forum..
> >
> > A quick look is this is not too bad yet:
> >
> > $ git grep parent_obj.parent_obj | wc -l
> > 20
> > $ git grep parent_obj.parent_obj.parent_obj | wc -l
> > 11
> > (and, some of above lines are part of vm static checker script)
> >
> > Looks not too bad yet?
> 
> Depends on your definition of "bad" :-)  This is basically
> the only vmstate that's doing this thing, and it would be
> nice to correct it before we add more devices that end up
> following the same pattern.

I agree.

> 
> I agree it's not super urgent; I posted mostly because I have
> no idea what the right fix is (especially given we want to
> retain migration compat here).

I confess I didn't even try to think further than counting lines. :(
I'll try some day.

Thanks,

-- 
Peter Xu



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-26 20:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-26 16:11 migration, PCIE ports, and parent_obj.parent_obj.parent_obj Peter Maydell
2026-10-26 16:19 ` Michael S. Tsirkin
2026-10-26 17:38   ` Peter Xu
2026-10-26 19:10     ` Peter Maydell
2026-10-26 20:00       ` Peter Xu

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.