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

Reply via email to