PCI VMState cleanups
v2 cover PCI VMState cleanups
Hello Michael and Gerd,
As discussed, this series attempts to clean up PCIe devices fiddling with individual PCI VMStateFields. It is based on my qom-devices queue, containing changes to PCIe devices.
v2 has been changed to use VMStateField::field_exists instead of subsections and unifies PCI and PCIe. Making MSI-X such a conditional field affects PCI, too, now and therefore requires incompatible changes to VMXNET3 PCI NIC.
This has been successfully tested with a selection of PCI and PCIe devices on -machine pc (-machine q35 is unfortunately unmigratable due to ich9-ahci) and shows identically sized state files (for "exec:cat > pc-pci.state") and no immediate crashes. Not 1.6 material.
A QOM follow-up RFC will be sent out shortly.
Regards,
Andreas
v1 -> v2:
* Prepended patches to drop VMSTATE_{PCI,PCIE}_DEVICE() arguments.
* Added patch to introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST() macro.
* Unified PCI and PCIe VMStateDescriptions (mst).
* Instead of moving & turning into subsection, make AER log conditional field.
* Instead of subsection, make MSI-X a conditional field.
Andreas Färber (6):
pci: Simplify VMSTATE_PCI_DEVICE() macro
pci: Simplify VMSTATE_PCIE_DEVICE() macro
vmstate: Introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST()
pci: Unify vmstate_{pci,pcie}_device
pci: Move vmstate_pcie_aer_log into vmstate_pci_device
pci: Move VMSTATE_MSIX() into vmstate_pci_device
hw/acpi/piix4.c | 2 +- hw/audio/ac97.c | 2 +- hw/audio/es1370.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/char/serial-pci.c | 4 +-- hw/char/tpci200.c | 2 +- hw/display/cirrus_vga.c | 2 +- hw/display/qxl.c | 2 +- hw/display/vga-pci.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/i2c/smbus_ich9.c | 2 +- hw/ide/ich.c | 2 +- hw/ide/pci.c | 2 +- hw/isa/i82378.c | 2 +- hw/isa/lpc_ich9.c | 2 +- hw/isa/piix4.c | 2 +- hw/isa/vt82c686.c | 4 +-- hw/misc/ivshmem.c | 7 ++-- hw/net/e1000.c | 2 +- hw/net/eepro100.c | 2 +- hw/net/ne2000.c | 2 +- hw/net/pcnet-pci.c | 2 +- hw/net/rtl8139.c | 2 +- hw/net/vmxnet3.c | 29 +++------------ hw/pci-bridge/ioh3420.c | 4 +-- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 4 +-- hw/pci-bridge/xio3130_upstream.c | 4 +-- hw/pci-host/bonito.c | 2 +- hw/pci-host/piix.c | 4 +-- hw/pci-host/prep.c | 2 +- hw/pci-host/q35.c | 2 +- hw/pci/pci.c | 73 +++++++++++++++++++++++--------------- hw/pci/pcie_aer.c | 1 + hw/scsi/esp-pci.c | 2 +- hw/scsi/lsi53c895a.c | 2 +- hw/scsi/megasas.c | 2 +- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 3 +- hw/virtio/virtio-pci.c | 19 +++++----- hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 2 +- include/hw/pci/msix.h | 7 ++-- include/hw/pci/pci.h | 6 ++-- include/hw/pci/pcie.h | 10 ------ include/migration/vmstate.h | 6 +++- 48 files changed, 116 insertions(+), 133 deletions(-)
Signature · 1 line
1.8.1.4
PATCH v2 1/6 pci: Simplify VMSTATE_PCI_DEVICE() macro
Drop the arguments to avoid QOM refactorings causing more churn.
--- hw/acpi/piix4.c | 2 +- hw/audio/ac97.c | 2 +- hw/audio/es1370.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/char/serial-pci.c | 4 ++-- hw/char/tpci200.c | 2 +- hw/display/cirrus_vga.c | 2 +- hw/display/qxl.c | 2 +- hw/display/vga-pci.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/i2c/smbus_ich9.c | 2 +- hw/ide/ich.c | 2 +- hw/ide/pci.c | 2 +- hw/isa/i82378.c | 2 +- hw/isa/lpc_ich9.c | 2 +- hw/isa/piix4.c | 2 +- hw/isa/vt82c686.c | 4 ++-- hw/net/e1000.c | 2 +- hw/net/eepro100.c | 2 +- hw/net/ne2000.c | 2 +- hw/net/pcnet-pci.c | 2 +- hw/net/rtl8139.c | 2 +- hw/net/vmxnet3.c | 2 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-host/bonito.c | 2 +- hw/pci-host/piix.c | 4 ++-- hw/pci-host/prep.c | 2 +- hw/pci-host/q35.c | 2 +- hw/scsi/esp-pci.c | 2 +- hw/scsi/lsi53c895a.c | 2 +- hw/scsi/megasas.c | 2 +- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 2 +- include/hw/pci/pci.h | 6 +++--- 37 files changed, 42 insertions(+), 42 deletions(-)
hw/acpi/piix4.c +1 -1
@@ -294,7 +294,7 @@ static const VMStateDescription vmstate_acpi = { .load_state_old = acpi_load_old, .post_load = vmstate_acpi_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PIIX4PMState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT16 (ar.pm1.evt.sts, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.evt.en, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.cnt.cnt, PIIX4PMState),
hw/audio/ac97.c +1 -1
@@ -1214,7 +1214,7 @@ static const VMStateDescription vmstate_ac97 = { .minimum_version_id_old = 2, .post_load = ac97_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, AC97LinkState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT32 (glob_cnt, AC97LinkState),VMSTATE_UINT32 (glob_sta, AC97LinkState),VMSTATE_UINT32 (cas, AC97LinkState),
hw/audio/es1370.c +1 -1
@@ -1000,7 +1000,7 @@ static const VMStateDescription vmstate_es1370 = { .minimum_version_id_old = 2, .post_load = es1370_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, ES1370State), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT_ARRAY (chan, ES1370State,NB_CHANNELS ,2 , vmstate_es1370_channel, struct chan),VMSTATE_UINT32 (ctl, ES1370State),
hw/audio/intel-hda.c +1 -1
@@ -1191,7 +1191,7 @@ static const VMStateDescription vmstate_intel_hda = { .version_id = 1, .post_load = intel_hda_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci, IntelHDAState), +VMSTATE_PCI_DEVICE (),/* registers */ VMSTATE_UINT32 (g_ctl, IntelHDAState),
hw/char/serial-pci.c +2 -2
@@ -155,7 +155,7 @@ static const VMStateDescription vmstate_pci_serial = { .version_id = 1, .minimum_version_id =1 , .fields = (VMStateField[]) { -VMSTATE_PCI_DEVICE (dev, PCISerialState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (state, PCISerialState,0 , vmstate_serial, SerialState),VMSTATE_END_OF_LIST () }
@@ -166,7 +166,7 @@ static const VMStateDescription vmstate_pci_multi_serial = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIMultiSerialState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT_ARRAY (state, PCIMultiSerialState,PCI_SERIAL_MAX_PORTS ,0 , vmstate_serial, SerialState),VMSTATE_UINT32_ARRAY (level, PCIMultiSerialState,PCI_SERIAL_MAX_PORTS ),
hw/char/tpci200.c +1 -1
@@ -631,7 +631,7 @@ static const VMStateDescription vmstate_tpci200 = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, TPCI200State), +VMSTATE_PCI_DEVICE (),VMSTATE_BOOL_ARRAY (big_endian, TPCI200State,3 ),VMSTATE_UINT8_ARRAY (ctrl, TPCI200State,N_MODULES ),VMSTATE_UINT16 (status, TPCI200State),
hw/display/cirrus_vga.c +1 -1
@@ -2746,7 +2746,7 @@ static const VMStateDescription vmstate_pci_cirrus_vga = { .minimum_version_id = 2, .minimum_version_id_old = 2, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCICirrusVGAState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (cirrus_vga, PCICirrusVGAState,0 , vmstate_cirrus_vga, CirrusVGAState),VMSTATE_END_OF_LIST ()
hw/display/qxl.c +1 -1
@@ -2265,7 +2265,7 @@ static VMStateDescription qxl_vmstate = { .pre_load = qxl_pre_load, .post_load = qxl_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci, PCIQXLDevice), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (vga, PCIQXLDevice,0 , vmstate_vga_common, VGACommonState),VMSTATE_UINT32 (shadow_rom.mode, PCIQXLDevice),VMSTATE_UINT32 (num_free_res, PCIQXLDevice),
hw/display/vga-pci.c +1 -1
@@ -56,7 +56,7 @@ static const VMStateDescription vmstate_vga_pci = { .minimum_version_id = 2, .minimum_version_id_old =2 , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIVGAState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (vga, PCIVGAState,0 , vmstate_vga_common, VGACommonState),VMSTATE_END_OF_LIST () }
hw/display/vmware_vga.c +1 -1
@@ -1179,7 +1179,7 @@ static const VMStateDescription vmstate_vmware_vga = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { - VMSTATE_PCI_DEVICE(parent_obj, struct pci_vmsvga_state_s), +VMSTATE_PCI_DEVICE (), VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0, vmstate_vmware_vga_internal, struct vmsvga_state_s),VMSTATE_END_OF_LIST ()
hw/i2c/smbus_ich9.c +1 -1
@@ -50,7 +50,7 @@ static const VMStateDescription vmstate_ich9_smbus = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { - VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };
hw/ide/ich.c +1 -1
@@ -84,7 +84,7 @@ static const VMStateDescription vmstate_ich9_ahci = { .unmigratable = 1, /* Still buggy under I/O load */ .version_id = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, AHCIPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_AHCI (ahci, AHCIPCIState),VMSTATE_END_OF_LIST () },
hw/ide/pci.c +1 -1
@@ -482,7 +482,7 @@ const VMStateDescription vmstate_ide_pci = { .minimum_version_id_old = 0, .post_load = ide_pci_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIIDEState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT_ARRAY (bmdma, PCIIDEState,2 ,0 , vmstate_bmdma, BMDMAState),VMSTATE_IDE_BUS_ARRAY (bus, PCIIDEState,2 ),
hw/isa/i82378.c +1 -1
@@ -54,7 +54,7 @@ static const VMStateDescription vmstate_pci_i82378 = { .version_id = 0, .minimum_version_id = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci_dev, PCIi82378State), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () }, };
hw/isa/lpc_ich9.c +1 -1
@@ -579,7 +579,7 @@ static const VMStateDescription vmstate_ich9_lpc = { .minimum_version_id_old = 1, .post_load = ich9_lpc_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (d, ICH9LPCState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (apm, ICH9LPCState,0 , vmstate_apm, APMState),VMSTATE_STRUCT (pm, ICH9LPCState,0 , vmstate_ich9_pm, ICH9LPCPMRegs),VMSTATE_UINT8_ARRAY (chip_config, ICH9LPCState,ICH9_CC_SIZE ),
hw/isa/piix4.c +1 -1
@@ -78,7 +78,7 @@ static const VMStateDescription vmstate_piix4 = { .minimum_version_id = 2, .minimum_version_id_old = 2, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PIIX4State), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };
hw/isa/vt82c686.c +2 -2
@@ -233,7 +233,7 @@ static const VMStateDescription vmstate_acpi = { .minimum_version_id_old = 1, .post_load = vmstate_acpi_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, VT686PMState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT16 (ar.pm1.evt.sts, VT686PMState),VMSTATE_UINT16 (ar.pm1.evt.en, VT686PMState),VMSTATE_UINT16 (ar.pm1.cnt.cnt, VT686PMState),
@@ -417,7 +417,7 @@ static const VMStateDescription vmstate_via = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, VT82C686BState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };
hw/net/e1000.c +1 -1
@@ -1198,7 +1198,7 @@ static const VMStateDescription vmstate_e1000 = { .pre_save = e1000_pre_save, .post_load = e1000_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, E1000State), +VMSTATE_PCI_DEVICE (),VMSTATE_UNUSED_TEST (is_version_1,4 ),/* was instance id */ VMSTATE_UNUSED (4 ),/* Was mmio_base. */ VMSTATE_UINT32 (rxbuf_size, E1000State),
hw/net/eepro100.c +1 -1
@@ -1786,7 +1786,7 @@ static const VMStateDescription vmstate_eepro100 = { .minimum_version_id = 2, .minimum_version_id_old = 2, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, EEPRO100State), +VMSTATE_PCI_DEVICE (),VMSTATE_UNUSED (32 ),VMSTATE_BUFFER (mult, EEPRO100State),VMSTATE_BUFFER (mem, EEPRO100State),
hw/net/ne2000.c +1 -1
@@ -647,7 +647,7 @@ static const VMStateDescription vmstate_pci_ne2000 = { .minimum_version_id = 3, .minimum_version_id_old =3 , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCINE2000State), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (ne2000, PCINE2000State,0 , vmstate_ne2000, NE2000State),VMSTATE_END_OF_LIST () }
hw/net/pcnet-pci.c +1 -1
@@ -243,7 +243,7 @@ static const VMStateDescription vmstate_pci_pcnet = { .minimum_version_id = 2, .minimum_version_id_old =2 , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIPCNetState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (state, PCIPCNetState,0 , vmstate_pcnet, PCNetState),VMSTATE_END_OF_LIST () }
hw/net/rtl8139.c +1 -1
@@ -3292,7 +3292,7 @@ static const VMStateDescription vmstate_rtl8139 = { .post_load = rtl8139_post_load, .pre_save = rtl8139_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, RTL8139State), +VMSTATE_PCI_DEVICE (),VMSTATE_PARTIAL_BUFFER (phys, RTL8139State,6 ),VMSTATE_BUFFER (mult, RTL8139State),VMSTATE_UINT32_ARRAY (TxStatus, RTL8139State,4 ),
hw/net/vmxnet3.c +1 -1
@@ -2378,7 +2378,7 @@ static const VMStateDescription vmstate_vmxnet3 = { .pre_save = vmxnet3_pre_save, .post_load = vmxnet3_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, VMXNET3State), +VMSTATE_PCI_DEVICE (),VMSTATE_BOOL (rx_packets_compound, VMXNET3State),VMSTATE_BOOL (rx_vlan_stripping, VMXNET3State),VMSTATE_BOOL (lro_supported, VMXNET3State),
hw/pci-bridge/pci_bridge_dev.c +1 -1
@@ -126,7 +126,7 @@ static Property pci_bridge_dev_properties[] = {static const VMStateDescription pci_bridge_dev_vmstate = { .name ="pci_bridge" , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIBridge), +VMSTATE_PCI_DEVICE (),SHPC_VMSTATE (shpc, PCIDevice),VMSTATE_END_OF_LIST () }
hw/pci-host/bonito.c +1 -1
@@ -689,7 +689,7 @@ static const VMStateDescription vmstate_bonito = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIBonitoState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };
hw/pci-host/piix.c +2 -2
@@ -197,7 +197,7 @@ static const VMStateDescription vmstate_i440fx = { .load_state_old = i440fx_load_old, .post_load = i440fx_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCII440FXState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (smm_enabled, PCII440FXState),VMSTATE_END_OF_LIST () }
@@ -516,7 +516,7 @@ static const VMStateDescription vmstate_piix3 = { .post_load = piix3_post_load, .pre_save = piix3_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PIIX3State), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32_ARRAY_V (pci_irq_levels_vmstate, PIIX3State,PIIX_NUM_PIRQS ,3 ),VMSTATE_END_OF_LIST ()
hw/pci-host/prep.c +1 -1
@@ -179,7 +179,7 @@ static const VMStateDescription vmstate_raven = { .version_id = 0, .minimum_version_id = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, RavenPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () }, };
hw/pci-host/q35.c +1 -1
@@ -230,7 +230,7 @@ static const VMStateDescription vmstate_mch = { .minimum_version_id_old = 1, .post_load = mch_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, MCHPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (smm_enabled, MCHPCIState),VMSTATE_END_OF_LIST () }
hw/scsi/esp-pci.c +1 -1
@@ -312,7 +312,7 @@ static const VMStateDescription vmstate_esp_pci_scsi = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIESPState), +VMSTATE_PCI_DEVICE (),VMSTATE_BUFFER_UNSAFE (dma_regs, PCIESPState,0 ,8 *sizeof (uint32_t )),VMSTATE_STRUCT (esp, PCIESPState,0 , vmstate_esp, ESPState),VMSTATE_END_OF_LIST ()
hw/scsi/lsi53c895a.c +1 -1
@@ -1996,7 +1996,7 @@ static const VMStateDescription vmstate_lsi_scsi = { .minimum_version_id_old = 0, .pre_save = lsi_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, LSIState), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32 (carry, LSIState),VMSTATE_INT32 (status, LSIState),
hw/scsi/megasas.c +1 -1
@@ -2061,7 +2061,7 @@ static const VMStateDescription vmstate_megasas = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, MegasasState), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32 (fw_state, MegasasState),VMSTATE_INT32 (intr_mask, MegasasState),
hw/scsi/vmw_pvscsi.c +1 -1
@@ -1143,7 +1143,7 @@ static const VMStateDescription vmstate_pvscsi = { .pre_save = pvscsi_pre_save, .post_load = pvscsi_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PVSCSIState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (msi_used, PVSCSIState),VMSTATE_UINT32 (resetting, PVSCSIState),VMSTATE_UINT64 (reg_interrupt_status, PVSCSIState),
hw/usb/hcd-ehci-pci.c +1 -1
@@ -109,7 +109,7 @@ static const VMStateDescription vmstate_ehci_pci = { .version_id = 2, .minimum_version_id =1 , .fields = (VMStateField[]) { -VMSTATE_PCI_DEVICE (pcidev, EHCIPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (ehci, EHCIPCIState,2 , vmstate_ehci, EHCIState),VMSTATE_END_OF_LIST () }
hw/usb/hcd-uhci.c +1 -1
@@ -444,7 +444,7 @@ static const VMStateDescription vmstate_uhci = { .minimum_version_id_old = 1, .post_load = uhci_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, UHCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8_EQUAL (num_ports_vmstate, UHCIState),VMSTATE_STRUCT_ARRAY (ports, UHCIState,NB_PORTS ,1 , vmstate_uhci_port, UHCIPort),
hw/watchdog/wdt_i6300esb.c +1 -1
@@ -391,7 +391,7 @@ static const VMStateDescription vmstate_i6300esb = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, I6300State), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32 (reboot_enabled, I6300State),VMSTATE_INT32 (clock_scale, I6300State),VMSTATE_INT32 (int_type, I6300State),
hw/xen/xen_platform.c +1 -1
@@ -377,7 +377,7 @@ static const VMStateDescription vmstate_xen_platform = { .minimum_version_id_old = 4, .post_load = xen_platform_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIXenPlatformState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (flags, PCIXenPlatformState),VMSTATE_END_OF_LIST () }
include/hw/pci/pci.h +3 -3
@@ -710,12 +710,12 @@ static inline void pci_dma_sglist_init(QEMUSGList *qsg, PCIDevice *dev,extern const VMStateDescription vmstate_pci_device; -#define VMSTATE_PCI_DEVICE (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_PCI_DEVICE () { \ + .name = "parent_obj", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_pci_device, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ }#define VMSTATE_PCI_DEVICE_POINTER (_field, _state) { \
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro
Quoted 3 lines · Andreas Färber
Drop the arguments to avoid QOM refactorings causing more churn.
Signed-off-by Andreas Färber <[email protected]>
This discards compiler check that macro is used appropriately and does not add a runtime check.
We discussed and discarded this approach in the previous round of patches you sent.
Yes "parent_obj" in code is ugly, but this is not a good solution.
Quoted 557 lines
--- hw/acpi/piix4.c | 2 +- hw/audio/ac97.c | 2 +- hw/audio/es1370.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/char/serial-pci.c | 4 ++-- hw/char/tpci200.c | 2 +- hw/display/cirrus_vga.c | 2 +- hw/display/qxl.c | 2 +- hw/display/vga-pci.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/i2c/smbus_ich9.c | 2 +- hw/ide/ich.c | 2 +- hw/ide/pci.c | 2 +- hw/isa/i82378.c | 2 +- hw/isa/lpc_ich9.c | 2 +- hw/isa/piix4.c | 2 +- hw/isa/vt82c686.c | 4 ++-- hw/net/e1000.c | 2 +- hw/net/eepro100.c | 2 +- hw/net/ne2000.c | 2 +- hw/net/pcnet-pci.c | 2 +- hw/net/rtl8139.c | 2 +- hw/net/vmxnet3.c | 2 +- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-host/bonito.c | 2 +- hw/pci-host/piix.c | 4 ++-- hw/pci-host/prep.c | 2 +- hw/pci-host/q35.c | 2 +- hw/scsi/esp-pci.c | 2 +- hw/scsi/lsi53c895a.c | 2 +- hw/scsi/megasas.c | 2 +- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 2 +- include/hw/pci/pci.h | 6 +++--- 37 files changed, 42 insertions(+), 42 deletions(-)hw/acpi/piix4.c +1
-1@@ -294,7 +294,7 @@ static const VMStateDescription vmstate_acpi = { .load_state_old = acpi_load_old, .post_load = vmstate_acpi_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PIIX4PMState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT16 (ar.pm1.evt.sts, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.evt.en, PIIX4PMState),VMSTATE_UINT16 (ar.pm1.cnt.cnt, PIIX4PMState),hw/audio/ac97.c +1
-1@@ -1214,7 +1214,7 @@ static const VMStateDescription vmstate_ac97 = { .minimum_version_id_old = 2, .post_load = ac97_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, AC97LinkState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT32 (glob_cnt, AC97LinkState),VMSTATE_UINT32 (glob_sta, AC97LinkState),VMSTATE_UINT32 (cas, AC97LinkState),hw/audio/es1370.c +1
-1@@ -1000,7 +1000,7 @@ static const VMStateDescription vmstate_es1370 = { .minimum_version_id_old = 2, .post_load = es1370_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, ES1370State), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT_ARRAY (chan, ES1370State,NB_CHANNELS ,2 , vmstate_es1370_channel, struct chan),VMSTATE_UINT32 (ctl, ES1370State),hw/audio/intel-hda.c +1
-1@@ -1191,7 +1191,7 @@ static const VMStateDescription vmstate_intel_hda = { .version_id = 1, .post_load = intel_hda_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci, IntelHDAState), +VMSTATE_PCI_DEVICE (),/* registers */ VMSTATE_UINT32 (g_ctl, IntelHDAState),hw/char/serial-pci.c +2
-2@@ -155,7 +155,7 @@ static const VMStateDescription vmstate_pci_serial = { .version_id = 1, .minimum_version_id =1 , .fields = (VMStateField[]) { -VMSTATE_PCI_DEVICE (dev, PCISerialState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (state, PCISerialState,0 , vmstate_serial, SerialState),VMSTATE_END_OF_LIST () }@@ -166,7 +166,7 @@ static const VMStateDescription vmstate_pci_multi_serial = { .version_id = 1, .minimum_version_id = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIMultiSerialState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT_ARRAY (state, PCIMultiSerialState,PCI_SERIAL_MAX_PORTS ,0 , vmstate_serial, SerialState),VMSTATE_UINT32_ARRAY (level, PCIMultiSerialState,PCI_SERIAL_MAX_PORTS ),hw/char/tpci200.c +1
-1@@ -631,7 +631,7 @@ static const VMStateDescription vmstate_tpci200 = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, TPCI200State), +VMSTATE_PCI_DEVICE (),VMSTATE_BOOL_ARRAY (big_endian, TPCI200State,3 ),VMSTATE_UINT8_ARRAY (ctrl, TPCI200State,N_MODULES ),VMSTATE_UINT16 (status, TPCI200State),hw/display/cirrus_vga.c +1
-1@@ -2746,7 +2746,7 @@ static const VMStateDescription vmstate_pci_cirrus_vga = { .minimum_version_id = 2, .minimum_version_id_old = 2, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCICirrusVGAState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (cirrus_vga, PCICirrusVGAState,0 , vmstate_cirrus_vga, CirrusVGAState),VMSTATE_END_OF_LIST ()hw/display/qxl.c +1
-1@@ -2265,7 +2265,7 @@ static VMStateDescription qxl_vmstate = { .pre_load = qxl_pre_load, .post_load = qxl_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci, PCIQXLDevice), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (vga, PCIQXLDevice,0 , vmstate_vga_common, VGACommonState),VMSTATE_UINT32 (shadow_rom.mode, PCIQXLDevice),VMSTATE_UINT32 (num_free_res, PCIQXLDevice),hw/display/vga-pci.c +1
-1@@ -56,7 +56,7 @@ static const VMStateDescription vmstate_vga_pci = { .minimum_version_id = 2, .minimum_version_id_old =2 , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIVGAState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (vga, PCIVGAState,0 , vmstate_vga_common, VGACommonState),VMSTATE_END_OF_LIST () }hw/display/vmware_vga.c +1
-1@@ -1179,7 +1179,7 @@ static const VMStateDescription vmstate_vmware_vga = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { - VMSTATE_PCI_DEVICE(parent_obj, struct pci_vmsvga_state_s), +VMSTATE_PCI_DEVICE (), VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0, vmstate_vmware_vga_internal, struct vmsvga_state_s),VMSTATE_END_OF_LIST ()hw/i2c/smbus_ich9.c +1
-1@@ -50,7 +50,7 @@ static const VMStateDescription vmstate_ich9_smbus = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { - VMSTATE_PCI_DEVICE(dev, struct ICH9SMBState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };hw/ide/ich.c +1
-1@@ -84,7 +84,7 @@ static const VMStateDescription vmstate_ich9_ahci = { .unmigratable = 1, /* Still buggy under I/O load */ .version_id = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, AHCIPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_AHCI (ahci, AHCIPCIState),VMSTATE_END_OF_LIST () },hw/ide/pci.c +1
-1@@ -482,7 +482,7 @@ const VMStateDescription vmstate_ide_pci = { .minimum_version_id_old = 0, .post_load = ide_pci_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIIDEState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT_ARRAY (bmdma, PCIIDEState,2 ,0 , vmstate_bmdma, BMDMAState),VMSTATE_IDE_BUS_ARRAY (bus, PCIIDEState,2 ),hw/isa/i82378.c +1
-1@@ -54,7 +54,7 @@ static const VMStateDescription vmstate_pci_i82378 = { .version_id = 0, .minimum_version_id = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (pci_dev, PCIi82378State), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () }, };hw/isa/lpc_ich9.c +1
-1@@ -579,7 +579,7 @@ static const VMStateDescription vmstate_ich9_lpc = { .minimum_version_id_old = 1, .post_load = ich9_lpc_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (d, ICH9LPCState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (apm, ICH9LPCState,0 , vmstate_apm, APMState),VMSTATE_STRUCT (pm, ICH9LPCState,0 , vmstate_ich9_pm, ICH9LPCPMRegs),VMSTATE_UINT8_ARRAY (chip_config, ICH9LPCState,ICH9_CC_SIZE ),hw/isa/piix4.c +1
-1@@ -78,7 +78,7 @@ static const VMStateDescription vmstate_piix4 = { .minimum_version_id = 2, .minimum_version_id_old = 2, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PIIX4State), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };hw/isa/vt82c686.c +2
-2@@ -233,7 +233,7 @@ static const VMStateDescription vmstate_acpi = { .minimum_version_id_old = 1, .post_load = vmstate_acpi_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, VT686PMState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT16 (ar.pm1.evt.sts, VT686PMState),VMSTATE_UINT16 (ar.pm1.evt.en, VT686PMState),VMSTATE_UINT16 (ar.pm1.cnt.cnt, VT686PMState),@@ -417,7 +417,7 @@ static const VMStateDescription vmstate_via = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, VT82C686BState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };hw/net/e1000.c +1
-1@@ -1198,7 +1198,7 @@ static const VMStateDescription vmstate_e1000 = { .pre_save = e1000_pre_save, .post_load = e1000_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, E1000State), +VMSTATE_PCI_DEVICE (),VMSTATE_UNUSED_TEST (is_version_1,4 ),/* was instance id */ VMSTATE_UNUSED (4 ),/* Was mmio_base. */ VMSTATE_UINT32 (rxbuf_size, E1000State),hw/net/eepro100.c +1
-1@@ -1786,7 +1786,7 @@ static const VMStateDescription vmstate_eepro100 = { .minimum_version_id = 2, .minimum_version_id_old = 2, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, EEPRO100State), +VMSTATE_PCI_DEVICE (),VMSTATE_UNUSED (32 ),VMSTATE_BUFFER (mult, EEPRO100State),VMSTATE_BUFFER (mem, EEPRO100State),hw/net/ne2000.c +1
-1@@ -647,7 +647,7 @@ static const VMStateDescription vmstate_pci_ne2000 = { .minimum_version_id = 3, .minimum_version_id_old =3 , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCINE2000State), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (ne2000, PCINE2000State,0 , vmstate_ne2000, NE2000State),VMSTATE_END_OF_LIST () }hw/net/pcnet-pci.c +1
-1@@ -243,7 +243,7 @@ static const VMStateDescription vmstate_pci_pcnet = { .minimum_version_id = 2, .minimum_version_id_old =2 , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIPCNetState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (state, PCIPCNetState,0 , vmstate_pcnet, PCNetState),VMSTATE_END_OF_LIST () }hw/net/rtl8139.c +1
-1@@ -3292,7 +3292,7 @@ static const VMStateDescription vmstate_rtl8139 = { .post_load = rtl8139_post_load, .pre_save = rtl8139_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, RTL8139State), +VMSTATE_PCI_DEVICE (),VMSTATE_PARTIAL_BUFFER (phys, RTL8139State,6 ),VMSTATE_BUFFER (mult, RTL8139State),VMSTATE_UINT32_ARRAY (TxStatus, RTL8139State,4 ),hw/net/vmxnet3.c +1
-1@@ -2378,7 +2378,7 @@ static const VMStateDescription vmstate_vmxnet3 = { .pre_save = vmxnet3_pre_save, .post_load = vmxnet3_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, VMXNET3State), +VMSTATE_PCI_DEVICE (),VMSTATE_BOOL (rx_packets_compound, VMXNET3State),VMSTATE_BOOL (rx_vlan_stripping, VMXNET3State),VMSTATE_BOOL (lro_supported, VMXNET3State),hw/pci-bridge/pci_bridge_dev.c +1
-1@@ -126,7 +126,7 @@ static Property pci_bridge_dev_properties[] = {static const VMStateDescription pci_bridge_dev_vmstate = { .name ="pci_bridge" , .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIBridge), +VMSTATE_PCI_DEVICE (),SHPC_VMSTATE (shpc, PCIDevice),VMSTATE_END_OF_LIST () }hw/pci-host/bonito.c +1
-1@@ -689,7 +689,7 @@ static const VMStateDescription vmstate_bonito = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PCIBonitoState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () } };hw/pci-host/piix.c +2
-2@@ -197,7 +197,7 @@ static const VMStateDescription vmstate_i440fx = { .load_state_old = i440fx_load_old, .post_load = i440fx_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCII440FXState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (smm_enabled, PCII440FXState),VMSTATE_END_OF_LIST () }@@ -516,7 +516,7 @@ static const VMStateDescription vmstate_piix3 = { .post_load = piix3_post_load, .pre_save = piix3_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, PIIX3State), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32_ARRAY_V (pci_irq_levels_vmstate, PIIX3State,PIIX_NUM_PIRQS ,3 ),VMSTATE_END_OF_LIST ()hw/pci-host/prep.c +1
-1@@ -179,7 +179,7 @@ static const VMStateDescription vmstate_raven = { .version_id = 0, .minimum_version_id = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, RavenPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_END_OF_LIST () }, };hw/pci-host/q35.c +1
-1@@ -230,7 +230,7 @@ static const VMStateDescription vmstate_mch = { .minimum_version_id_old = 1, .post_load = mch_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, MCHPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (smm_enabled, MCHPCIState),VMSTATE_END_OF_LIST () }hw/scsi/esp-pci.c +1
-1@@ -312,7 +312,7 @@ static const VMStateDescription vmstate_esp_pci_scsi = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIESPState), +VMSTATE_PCI_DEVICE (),VMSTATE_BUFFER_UNSAFE (dma_regs, PCIESPState,0 ,8 *sizeof (uint32_t )),VMSTATE_STRUCT (esp, PCIESPState,0 , vmstate_esp, ESPState),VMSTATE_END_OF_LIST ()hw/scsi/lsi53c895a.c +1
-1@@ -1996,7 +1996,7 @@ static const VMStateDescription vmstate_lsi_scsi = { .minimum_version_id_old = 0, .pre_save = lsi_pre_save, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, LSIState), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32 (carry, LSIState),VMSTATE_INT32 (status, LSIState),hw/scsi/megasas.c +1
-1@@ -2061,7 +2061,7 @@ static const VMStateDescription vmstate_megasas = { .minimum_version_id = 0, .minimum_version_id_old = 0, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, MegasasState), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32 (fw_state, MegasasState),VMSTATE_INT32 (intr_mask, MegasasState),hw/scsi/vmw_pvscsi.c +1
-1@@ -1143,7 +1143,7 @@ static const VMStateDescription vmstate_pvscsi = { .pre_save = pvscsi_pre_save, .post_load = pvscsi_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PVSCSIState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (msi_used, PVSCSIState),VMSTATE_UINT32 (resetting, PVSCSIState),VMSTATE_UINT64 (reg_interrupt_status, PVSCSIState),hw/usb/hcd-ehci-pci.c +1
-1@@ -109,7 +109,7 @@ static const VMStateDescription vmstate_ehci_pci = { .version_id = 2, .minimum_version_id =1 , .fields = (VMStateField[]) { -VMSTATE_PCI_DEVICE (pcidev, EHCIPCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (ehci, EHCIPCIState,2 , vmstate_ehci, EHCIState),VMSTATE_END_OF_LIST () }hw/usb/hcd-uhci.c +1
-1@@ -444,7 +444,7 @@ static const VMStateDescription vmstate_uhci = { .minimum_version_id_old = 1, .post_load = uhci_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, UHCIState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8_EQUAL (num_ports_vmstate, UHCIState),VMSTATE_STRUCT_ARRAY (ports, UHCIState,NB_PORTS ,1 , vmstate_uhci_port, UHCIPort),hw/watchdog/wdt_i6300esb.c +1
-1@@ -391,7 +391,7 @@ static const VMStateDescription vmstate_i6300esb = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, I6300State), +VMSTATE_PCI_DEVICE (),VMSTATE_INT32 (reboot_enabled, I6300State),VMSTATE_INT32 (clock_scale, I6300State),VMSTATE_INT32 (int_type, I6300State),hw/xen/xen_platform.c +1
-1@@ -377,7 +377,7 @@ static const VMStateDescription vmstate_xen_platform = { .minimum_version_id_old = 4, .post_load = xen_platform_post_load, .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (parent_obj, PCIXenPlatformState), +VMSTATE_PCI_DEVICE (),VMSTATE_UINT8 (flags, PCIXenPlatformState),VMSTATE_END_OF_LIST () }include/hw/pci/pci.h +3
-3@@ -710,12 +710,12 @@ static inline void pci_dma_sglist_init(QEMUSGList *qsg, PCIDevice *dev,extern const VMStateDescription vmstate_pci_device; -#define VMSTATE_PCI_DEVICE (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_PCI_DEVICE () { \ + .name = "parent_obj", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_pci_device, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ }#define VMSTATE_PCI_DEVICE_POINTER (_field, _state) { \Signature · 1 line
1.8.1.4
PATCH v2 2/6 pci: Simplify VMSTATE_PCIE_DEVICE() macro
In reply to Andreas FärberDrop the arguments to avoid QOM refactorings causing more churn.
--- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/usb/hcd-xhci.c | 2 +- include/hw/pci/pcie.h | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-)
hw/pci-bridge/ioh3420.c +1 -1
@@ -187,7 +187,7 @@ static const VMStateDescription vmstate_ioh3420 = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()
hw/pci-bridge/xio3130_downstream.c +1 -1
@@ -154,7 +154,7 @@ static const VMStateDescription vmstate_xio3130_downstream = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()
hw/pci-bridge/xio3130_upstream.c +1 -1
@@ -133,7 +133,7 @@ static const VMStateDescription vmstate_xio3130_upstream = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj, PCIEPort), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.exp.aer_log, PCIEPort,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()
hw/usb/hcd-xhci.c +1 -1
@@ -3544,7 +3544,7 @@ static const VMStateDescription vmstate_xhci = { .version_id = 1, .post_load = usb_xhci_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj, XHCIState), +VMSTATE_PCIE_DEVICE (),VMSTATE_MSIX (parent_obj, XHCIState), VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1,
include/hw/pci/pcie.h +3 -3
@@ -132,12 +132,12 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);extern const VMStateDescription vmstate_pcie_device; -#define VMSTATE_PCIE_DEVICE (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_PCIE_DEVICE () { \ + .name = "parent_obj", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_pcie_device, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ }#endif /* QEMU_PCIE_H */
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
Quoted 3 lines · Andreas Färber
Drop the arguments to avoid QOM refactorings causing more churn.
Signed-off-by Andreas Färber <[email protected]>
We discussed and discarded something very similar.
This only works correctly if you put it in a struct which has the pci device at offset 0, and there's no either runtime or compile-time check to verify it's the correct type.
So please find some other way to do this.
Or go back to give fields sane names instead
of "parent_obj".
Quoted 82 lines
--- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/usb/hcd-xhci.c | 2 +- include/hw/pci/pcie.h | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-)hw/pci-bridge/ioh3420.c +1
-1@@ -187,7 +187,7 @@ static const VMStateDescription vmstate_ioh3420 = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/pci-bridge/xio3130_downstream.c +1
-1@@ -154,7 +154,7 @@ static const VMStateDescription vmstate_xio3130_downstream = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/pci-bridge/xio3130_upstream.c +1
-1@@ -133,7 +133,7 @@ static const VMStateDescription vmstate_xio3130_upstream = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj, PCIEPort), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.exp.aer_log, PCIEPort,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/usb/hcd-xhci.c +1
-1@@ -3544,7 +3544,7 @@ static const VMStateDescription vmstate_xhci = { .version_id = 1, .post_load = usb_xhci_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj, XHCIState), +VMSTATE_PCIE_DEVICE (),VMSTATE_MSIX (parent_obj, XHCIState), VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1,include/hw/pci/pcie.h +3
-3@@ -132,12 +132,12 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);extern const VMStateDescription vmstate_pcie_device; -#define VMSTATE_PCIE_DEVICE (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_PCIE_DEVICE () { \ + .name = "parent_obj", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_pcie_device, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ }#endif /* QEMU_PCIE_H */ Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
Am 02.09.2013 13:36, schrieb Michael S. Tsirkin:
Quoted 6 lines · Andreas Färber
Quoted 3 lines
Drop the arguments to avoid QOM refactorings causing more churn.
Signed-off-by Andreas Färber <[email protected]>We discussed and discarded something very similar.
Anthony requested that I don't mix different types for the offsets in VMSTATE_*() macros.
Quoted 4 lines
This only works correctly if you put it in a struct which has the pci device at offset 0, and there's no either runtime or compile-time check to verify it's the correct type.
As Anthony already said, QOM depends on the offset being 0, casts will fail otherwise. So there are runtime checks.
Quoted 2 lines
So please find some other way to do this.
I did post an RFC, but that is significantly more invasive, since it affects not only PCI and needs a lot of review before we can move forward with it.
Andreas
Quoted 86 lines
Or go back to give fields sane names instead
of "parent_obj".Quoted 82 lines
--- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/usb/hcd-xhci.c | 2 +- include/hw/pci/pcie.h | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-)hw/pci-bridge/ioh3420.c +1
-1@@ -187,7 +187,7 @@ static const VMStateDescription vmstate_ioh3420 = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/pci-bridge/xio3130_downstream.c +1
-1@@ -154,7 +154,7 @@ static const VMStateDescription vmstate_xio3130_downstream = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/pci-bridge/xio3130_upstream.c +1
-1@@ -133,7 +133,7 @@ static const VMStateDescription vmstate_xio3130_upstream = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj, PCIEPort), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.exp.aer_log, PCIEPort,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/usb/hcd-xhci.c +1
-1@@ -3544,7 +3544,7 @@ static const VMStateDescription vmstate_xhci = { .version_id = 1, .post_load = usb_xhci_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj, XHCIState), +VMSTATE_PCIE_DEVICE (),VMSTATE_MSIX (parent_obj, XHCIState), VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1,include/hw/pci/pcie.h +3
-3@@ -132,12 +132,12 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);extern const VMStateDescription vmstate_pcie_device; -#define VMSTATE_PCIE_DEVICE (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_PCIE_DEVICE () { \ + .name = "parent_obj", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_pcie_device, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ }#endif /* QEMU_PCIE_H */ Signature · 1 line
1.8.1.4
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
Quoted 10 lines · Andreas Färber
Am 02.09.2013 13:36, schrieb Michael S. Tsirkin:
Quoted 6 lines · Andreas Färber
Quoted 3 lines
Drop the arguments to avoid QOM refactorings causing more churn.
Signed-off-by Andreas Färber <[email protected]>We discussed and discarded something very similar.
Anthony requested that I don't mix different types for the offsets in VMSTATE_*() macros.
Exactly. The solution is *not* not to put any types there.
Quoted 7 lines
Quoted 4 lines
This only works correctly if you put it in a struct which has the pci device at offset 0, and there's no either runtime or compile-time check to verify it's the correct type.
As Anthony already said, QOM depends on the offset being 0, casts will fail otherwise. So there are runtime checks.
I don't see any runtime casts in vmstate. That's exactly the issue. This is a bad API.
vmstate isn't limited to QOM objects, if you make a macro without arguments it should either make sense in any vmstate, make compilation fail if misused, or at least quickly make migration fail if misused.
Not corrupt random memory.
Quoted 8 lines
Quoted 2 lines
So please find some other way to do this.
I did post an RFC, but that is significantly more invasive, since it affects not only PCI and needs a lot of review before we can move forward with it.
Andreas
That one looks ok.
Quoted 91 lines
Quoted 86 lines
Or go back to give fields sane names instead
of "parent_obj".Quoted 82 lines
--- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/usb/hcd-xhci.c | 2 +- include/hw/pci/pcie.h | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-)hw/pci-bridge/ioh3420.c +1
-1@@ -187,7 +187,7 @@ static const VMStateDescription vmstate_ioh3420 = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/pci-bridge/xio3130_downstream.c +1
-1@@ -154,7 +154,7 @@ static const VMStateDescription vmstate_xio3130_downstream = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj.parent_obj, PCIESlot), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/pci-bridge/xio3130_upstream.c +1
-1@@ -133,7 +133,7 @@ static const VMStateDescription vmstate_xio3130_upstream = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj.parent_obj, PCIEPort), +VMSTATE_PCIE_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.exp.aer_log, PCIEPort,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/usb/hcd-xhci.c +1
-1@@ -3544,7 +3544,7 @@ static const VMStateDescription vmstate_xhci = { .version_id = 1, .post_load = usb_xhci_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (parent_obj, XHCIState), +VMSTATE_PCIE_DEVICE (),VMSTATE_MSIX (parent_obj, XHCIState), VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1,include/hw/pci/pcie.h +3
-3@@ -132,12 +132,12 @@ void pcie_ari_init(PCIDevice *dev, uint16_t offset, uint16_t nextfn);extern const VMStateDescription vmstate_pcie_device; -#define VMSTATE_PCIE_DEVICE (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_PCIE_DEVICE () { \ + .name = "parent_obj", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_pcie_device, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ }#endif /* QEMU_PCIE_H */ Signature · 1 line
1.8.1.4Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
PATCH v2 3/6 vmstate: Introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST()
In reply to Andreas FärberTo be used by PCIDevice.
--- include/migration/vmstate.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/migration/vmstate.h +5 -1
@@ -444,9 +444,10 @@ extern const VMStateInfo vmstate_info_bitmap; .start = (_start), \ } -#define VMSTATE_BUFFER_UNSAFE_INFO (_field, _state, _version, _info, _size) { \ +#define VMSTATE_BUFFER_UNSAFE_INFO_TEST (_field, _state, _version, _test, _info, _size) { \ .name = (stringify(_field)), \ .version_id = (_version), \ + .field_exists = (_test), \ .size = (_size), \ .info = &(_info), \ .flags = VMS_BUFFER, \
@@ -696,6 +697,9 @@ extern const VMStateInfo vmstate_info_bitmap;#define VMSTATE_BUFFER_TEST (_f, _s, _test) \ VMSTATE_STATIC_BUFFER(_f, _s, 0, _test, 0, sizeof(typeof_field(_s, _f))) +#define VMSTATE_BUFFER_UNSAFE_INFO (_field, _state, _version, _info, _size) \ + VMSTATE_BUFFER_UNSAFE_INFO_TEST(_field, _state, _version, NULL, _info, _size) +#define VMSTATE_BUFFER_UNSAFE (_field, _state, _version, _size) \ VMSTATE_BUFFER_UNSAFE_INFO(_field, _state, _version, vmstate_info_buffer, _size)
Signature · 1 line
1.8.1.4
PATCH v2 4/6 pci: Unify vmstate_{pci, pcie}_device
In reply to Andreas FärberThe only difference so far is the size of the config space.
It is always used through either VMSTATE_{PCI,PCIE}_DEVICE() or pci_device_save(), so the name change for PCIe shouldn't matter.
--- hw/pci-bridge/ioh3420.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 2 +- hw/pci-bridge/xio3130_upstream.c | 2 +- hw/pci/pci.c | 56 ++++++++++++++++++-------------------- hw/usb/hcd-xhci.c | 2 +- include/hw/pci/pcie.h | 10 ------- 6 files changed, 31 insertions(+), 43 deletions(-)
hw/pci-bridge/ioh3420.c +1 -1
@@ -187,7 +187,7 @@ static const VMStateDescription vmstate_ioh3420 = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()
hw/pci-bridge/xio3130_downstream.c +1 -1
@@ -154,7 +154,7 @@ static const VMStateDescription vmstate_xio3130_downstream = { .minimum_version_id_old = 1, .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()
hw/pci-bridge/xio3130_upstream.c +1 -1
@@ -133,7 +133,7 @@ static const VMStateDescription vmstate_xio3130_upstream = { .minimum_version_id = 1, .minimum_version_id_old = 1, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (), +VMSTATE_PCI_DEVICE (),VMSTATE_STRUCT (parent_obj.parent_obj.exp.aer_log, PCIEPort,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()
hw/pci/pci.c +27 -29
85 lines not on this page · raw message
hw/usb/hcd-xhci.c +1 -1
@@ -3544,7 +3544,7 @@ static const VMStateDescription vmstate_xhci = { .version_id = 1, .post_load = usb_xhci_post_load, .fields = (VMStateField []) { -VMSTATE_PCIE_DEVICE (), +VMSTATE_PCI_DEVICE (),VMSTATE_MSIX (parent_obj, XHCIState), VMSTATE_STRUCT_VARRAY_UINT32(ports, XHCIState, numports, 1,
include/hw/pci/pcie.h +0 -10
@@ -130,14 +130,4 @@ void pcie_add_capability(PCIDevice *dev,void pcie_ari_init (PCIDevice *dev,uint16_t offset,uint16_t nextfn); -extern const VMStateDescription vmstate_pcie_device; - -#define VMSTATE_PCIE_DEVICE () { \ - .name = "parent_obj", \ - .size = sizeof(PCIDevice), \ - .vmsd = &vmstate_pcie_device, \ - .flags = VMS_STRUCT, \ - .offset = 0, \ -} -#endif /* QEMU_PCIE_H */
Signature · 1 line
1.8.1.4
PATCH v2 5/6 pci: Move vmstate_pcie_aer_log into vmstate_pci_device
In reply to Andreas FärberMake it conditional on PCIe and allocation of the AER log.
--- hw/pci-bridge/ioh3420.c | 2 -- hw/pci-bridge/xio3130_downstream.c | 2 -- hw/pci-bridge/xio3130_upstream.c | 2 -- hw/pci/pci.c | 9 +++++++++ hw/pci/pcie_aer.c | 1 + 5 files changed, 10 insertions(+), 6 deletions(-)
hw/pci-bridge/ioh3420.c +0 -2
@@ -188,8 +188,6 @@ static const VMStateDescription vmstate_ioh3420 = { .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (), -VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, - PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST () } };
hw/pci-bridge/xio3130_downstream.c +0 -2
@@ -155,8 +155,6 @@ static const VMStateDescription vmstate_xio3130_downstream = { .post_load = pcie_cap_slot_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (), -VMSTATE_STRUCT (parent_obj.parent_obj.parent_obj.exp.aer_log, - PCIESlot,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST () } };
hw/pci-bridge/xio3130_upstream.c +0 -2
@@ -134,8 +134,6 @@ static const VMStateDescription vmstate_xio3130_upstream = { .minimum_version_id_old = 1, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (), -VMSTATE_STRUCT (parent_obj.parent_obj.exp.aer_log, PCIEPort,0 , - vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST () } };
hw/pci/pci.c +9 -0
@@ -474,6 +474,13 @@ static bool pci_device_non_express_needed(void *opaque, int version_id)return !pci_is_express (s); } +static bool pci_device_aer_needed (void *opaque,int version_id) +{ +PCIDevice *s = opaque; + +return pci_is_express (s) && s->exp.aer_log.log !=NULL ; +} +const VMStateDescription vmstate_pci_device = { .name ="PCIDevice" , .version_id =2 ,
@@ -492,6 +499,8 @@ const VMStateDescription vmstate_pci_device = {VMSTATE_BUFFER_UNSAFE_INFO (irq_state, PCIDevice,2 , vmstate_info_pci_irq_state,PCI_NUM_PINS *sizeof (int32_t )), +VMSTATE_STRUCT_TEST (exp.aer_log, PCIDevice, pci_device_aer_needed,0 , + vmstate_pcie_aer_log, PCIEAERLog), VMSTATE_END_OF_LIST() } };
hw/pci/pcie_aer.c +1 -0
@@ -166,6 +166,7 @@ int pcie_aer_init(PCIDevice *dev, uint16_t offset)void pcie_aer_exit (PCIDevice *dev) {g_free (dev->exp.aer_log.log); + dev->exp.aer_log.log =NULL ; }static void pcie_aer_update_uncor_status (PCIDevice *dev)
Signature · 1 line
1.8.1.4
RFC PATCH v2 6/6 pci: Move VMSTATE_MSIX() into vmstate_pci_device
In reply to Andreas FärberUse it conditional on msix_present() and drop msix_{save,load}() calls following pci_device_{save,load}().
This reorders the msix_save() and msix_unuse_all_vectors() calls for virtio-pci, but they seem independent of each other.
--- hw/misc/ivshmem.c | 7 ++----- hw/net/vmxnet3.c | 27 +++------------------------ hw/pci/pci.c | 8 ++++++++ hw/usb/hcd-xhci.c | 1 - hw/virtio/virtio-pci.c | 19 +++++++++++-------- include/hw/pci/msix.h | 7 ++++--- 6 files changed, 28 insertions(+), 41 deletions(-)
hw/misc/ivshmem.c +2 -5
@@ -599,9 +599,7 @@ static void ivshmem_save(QEMUFile* f, void *opaque)IVSHMEM_DPRINTF ("ivshmem_save\n" );pci_device_save (pci_dev, f); -if (ivshmem_has_feature (proxy,IVSHMEM_MSI )) { -msix_save (pci_dev, f); - }else { +if (!ivshmem_has_feature (proxy,IVSHMEM_MSI )) {qemu_put_be32 (f, proxy->intrstatus);qemu_put_be32 (f, proxy->intrmask); }
@@ -631,8 +629,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) }if (ivshmem_has_feature (proxy,IVSHMEM_MSI )) { -msix_load (pci_dev, f); -ivshmem_use_msix (proxy); +ivshmem_use_msix (proxy); }else { proxy->intrstatus =qemu_get_be32 (f); proxy->intrmask =qemu_get_be32 (f);
hw/net/vmxnet3.c +3 -24
@@ -2031,21 +2031,6 @@ vmxnet3_cleanup_msi(VMXNET3State *s) } } -static void -vmxnet3_msix_save (QEMUFile *f,void *opaque) -{ -PCIDevice *d =PCI_DEVICE (opaque); -msix_save (d, f); -} - -static int -vmxnet3_msix_load (QEMUFile *f,void *opaque,int version_id) -{ -PCIDevice *d =PCI_DEVICE (opaque); -msix_load (d, f); -return 0 ; -} -static const MemoryRegionOps b0_ops = { .read = vmxnet3_io_bar0_read, .write = vmxnet3_io_bar0_write,
@@ -2103,9 +2088,6 @@ static int vmxnet3_pci_init(PCIDevice *pci_dev)vmxnet3_net_init (s); -register_savevm (dev,"vmxnet3-msix" ,-1 ,1 , - vmxnet3_msix_save, vmxnet3_msix_load, s); -add_boot_device_path (s->conf.bootindex, dev,"/ethernet-phy@0" );return 0 ;
@@ -2114,13 +2096,10 @@ static int vmxnet3_pci_init(PCIDevice *pci_dev)static void vmxnet3_pci_uninit (PCIDevice *pci_dev) { -DeviceState *dev =DEVICE (pci_dev);VMXNET3State *s =VMXNET3 (pci_dev);VMW_CBPRN ("Starting uninit..." ); -unregister_savevm (dev,"vmxnet3-msix" , s); -vmxnet3_net_uninit (s);vmxnet3_cleanup_msix (s);
@@ -2372,9 +2351,9 @@ const VMStateInfo int_state_info = {static const VMStateDescription vmstate_vmxnet3 = { .name ="vmxnet3" , - .version_id =1 , - .minimum_version_id =1 , - .minimum_version_id_old =1 , + .version_id =2 , + .minimum_version_id =2 , + .minimum_version_id_old =2 , .pre_save = vmxnet3_pre_save, .post_load = vmxnet3_post_load, .fields = (VMStateField []) {
hw/pci/pci.c +8 -0
@@ -481,6 +481,13 @@ static bool pci_device_aer_needed(void *opaque, int version_id)return pci_is_express (s) && s->exp.aer_log.log !=NULL ; } +static bool pci_device_msix_needed (void *opaque,int version_id) +{ +PCIDevice *s = opaque; + +return msix_present (s); +} +const VMStateDescription vmstate_pci_device = { .name ="PCIDevice" , .version_id =2 ,
@@ -499,6 +506,7 @@ const VMStateDescription vmstate_pci_device = {VMSTATE_BUFFER_UNSAFE_INFO (irq_state, PCIDevice,2 , vmstate_info_pci_irq_state,PCI_NUM_PINS *sizeof (int32_t )), +VMSTATE_MSIX_TEST (pci_device_msix_needed),VMSTATE_STRUCT_TEST (exp.aer_log, PCIDevice, pci_device_aer_needed,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()
hw/usb/hcd-xhci.c +0 -1
@@ -3545,7 +3545,6 @@ static const VMStateDescription vmstate_xhci = { .post_load = usb_xhci_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (), -VMSTATE_MSIX (parent_obj, XHCIState),VMSTATE_STRUCT_VARRAY_UINT32 (ports, XHCIState, numports,1 , vmstate_xhci_port, XHCIPort),
hw/virtio/virtio-pci.c +11 -8
@@ -121,10 +121,12 @@ static void virtio_pci_notify(DeviceState *d, uint16_t vector)static void virtio_pci_save_config (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); -pci_device_save (&proxy->pci_dev, f); -msix_save (&proxy->pci_dev, f); -if (msix_present (&proxy->pci_dev)) +PCIDevice *pci_dev =PCI_DEVICE (proxy); + +pci_device_save (pci_dev, f); +if (msix_present (pci_dev)) {qemu_put_be16 (f, proxy->vdev->config_vector); + } }static void virtio_pci_save_queue (DeviceState *d,int n,QEMUFile *f)
@@ -137,20 +139,21 @@ static void virtio_pci_save_queue(DeviceState *d, int n, QEMUFile *f)static int virtio_pci_load_config (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); +PCIDevice *pci_dev =PCI_DEVICE (proxy);int ret; - ret =pci_device_load (&proxy->pci_dev, f); + + ret =pci_device_load (pci_dev, f);if (ret) {return ret; } -msix_unuse_all_vectors (&proxy->pci_dev); -msix_load (&proxy->pci_dev, f); -if (msix_present (&proxy->pci_dev)) { +msix_unuse_all_vectors (pci_dev); +if (msix_present (pci_dev)) {qemu_get_be16s (f, &proxy->vdev->config_vector); }else { proxy->vdev->config_vector =VIRTIO_NO_VECTOR ; }if (proxy->vdev->config_vector !=VIRTIO_NO_VECTOR ) { -return msix_vector_use (&proxy->pci_dev, proxy->vdev->config_vector); +return msix_vector_use (pci_dev, proxy->vdev->config_vector); }return 0 ; }
include/hw/pci/msix.h +4 -3
@@ -46,12 +46,13 @@ void msix_unset_vector_notifiers(PCIDevice *dev);extern const VMStateDescription vmstate_msix; -#define VMSTATE_MSIX (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_MSIX_TEST (_test) { \ + .name = "MSI-X", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_msix, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ + .field_exists = (_test), \ }#endif
Signature · 1 line
1.8.1.4
Re: [Qemu-devel] [PATCH RFC qom-next for-next v2 6/6] pci: Move VMSTATE_MSIX() into vmstate_pci_device
Quoted 5 lines · Andreas Färber
Use it conditional on
msix_present()and drop msix_{save,load}() calls following pci_device_{save,load}().This reorders the
msix_save()andmsix_unuse_all_vectors()calls for virtio-pci, but they seem independent of each other.
No, that's a bug. msix_unuse_all_vectors clears pending state if any, it will lose state if called before load.
Quoted 207 lines
Signed-off-by Andreas Färber <[email protected]>--- hw/misc/ivshmem.c | 7 ++----- hw/net/vmxnet3.c | 27 +++------------------------ hw/pci/pci.c | 8 ++++++++ hw/usb/hcd-xhci.c | 1 - hw/virtio/virtio-pci.c | 19 +++++++++++-------- include/hw/pci/msix.h | 7 ++++--- 6 files changed, 28 insertions(+), 41 deletions(-)hw/misc/ivshmem.c +2
-5@@ -599,9 +599,7 @@ static void ivshmem_save(QEMUFile* f, void *opaque)IVSHMEM_DPRINTF ("ivshmem_save\n" );pci_device_save (pci_dev, f); -if (ivshmem_has_feature (proxy,IVSHMEM_MSI )) { -msix_save (pci_dev, f); - }else { +if (!ivshmem_has_feature (proxy,IVSHMEM_MSI )) {qemu_put_be32 (f, proxy->intrstatus);qemu_put_be32 (f, proxy->intrmask); }@@ -631,8 +629,7 @@ static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) }if (ivshmem_has_feature (proxy,IVSHMEM_MSI )) { -msix_load (pci_dev, f); -ivshmem_use_msix (proxy); +ivshmem_use_msix (proxy); }else { proxy->intrstatus =qemu_get_be32 (f); proxy->intrmask =qemu_get_be32 (f);hw/net/vmxnet3.c +3
-24@@ -2031,21 +2031,6 @@ vmxnet3_cleanup_msi(VMXNET3State *s) } } -static void -vmxnet3_msix_save (QEMUFile *f,void *opaque) -{ -PCIDevice *d =PCI_DEVICE (opaque); -msix_save (d, f); -} - -static int -vmxnet3_msix_load (QEMUFile *f,void *opaque,int version_id) -{ -PCIDevice *d =PCI_DEVICE (opaque); -msix_load (d, f); -return 0 ; -} -static const MemoryRegionOps b0_ops = { .read = vmxnet3_io_bar0_read, .write = vmxnet3_io_bar0_write,@@ -2103,9 +2088,6 @@ static int vmxnet3_pci_init(PCIDevice *pci_dev)vmxnet3_net_init (s); -register_savevm (dev,"vmxnet3-msix" ,-1 ,1 , - vmxnet3_msix_save, vmxnet3_msix_load, s); -add_boot_device_path (s->conf.bootindex, dev,"/ethernet-phy@0" );return 0 ;@@ -2114,13 +2096,10 @@ static int vmxnet3_pci_init(PCIDevice *pci_dev)static void vmxnet3_pci_uninit (PCIDevice *pci_dev) { -DeviceState *dev =DEVICE (pci_dev);VMXNET3State *s =VMXNET3 (pci_dev);VMW_CBPRN ("Starting uninit..." ); -unregister_savevm (dev,"vmxnet3-msix" , s); -vmxnet3_net_uninit (s);vmxnet3_cleanup_msix (s);@@ -2372,9 +2351,9 @@ const VMStateInfo int_state_info = {static const VMStateDescription vmstate_vmxnet3 = { .name ="vmxnet3" , - .version_id =1 , - .minimum_version_id =1 , - .minimum_version_id_old =1 , + .version_id =2 , + .minimum_version_id =2 , + .minimum_version_id_old =2 , .pre_save = vmxnet3_pre_save, .post_load = vmxnet3_post_load, .fields = (VMStateField []) {hw/pci/pci.c +8
-0@@ -481,6 +481,13 @@ static bool pci_device_aer_needed(void *opaque, int version_id)return pci_is_express (s) && s->exp.aer_log.log !=NULL ; } +static bool pci_device_msix_needed (void *opaque,int version_id) +{ +PCIDevice *s = opaque; + +return msix_present (s); +} +const VMStateDescription vmstate_pci_device = { .name ="PCIDevice" , .version_id =2 ,@@ -499,6 +506,7 @@ const VMStateDescription vmstate_pci_device = {VMSTATE_BUFFER_UNSAFE_INFO (irq_state, PCIDevice,2 , vmstate_info_pci_irq_state,PCI_NUM_PINS *sizeof (int32_t )), +VMSTATE_MSIX_TEST (pci_device_msix_needed),VMSTATE_STRUCT_TEST (exp.aer_log, PCIDevice, pci_device_aer_needed,0 , vmstate_pcie_aer_log, PCIEAERLog),VMSTATE_END_OF_LIST ()hw/usb/hcd-xhci.c +0
-1@@ -3545,7 +3545,6 @@ static const VMStateDescription vmstate_xhci = { .post_load = usb_xhci_post_load, .fields = (VMStateField []) {VMSTATE_PCI_DEVICE (), -VMSTATE_MSIX (parent_obj, XHCIState),VMSTATE_STRUCT_VARRAY_UINT32 (ports, XHCIState, numports,1 , vmstate_xhci_port, XHCIPort),hw/virtio/virtio-pci.c +11
-8@@ -121,10 +121,12 @@ static void virtio_pci_notify(DeviceState *d, uint16_t vector)static void virtio_pci_save_config (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); -pci_device_save (&proxy->pci_dev, f); -msix_save (&proxy->pci_dev, f); -if (msix_present (&proxy->pci_dev)) +PCIDevice *pci_dev =PCI_DEVICE (proxy); + +pci_device_save (pci_dev, f); +if (msix_present (pci_dev)) {qemu_put_be16 (f, proxy->vdev->config_vector); + } }static void virtio_pci_save_queue (DeviceState *d,int n,QEMUFile *f)@@ -137,20 +139,21 @@ static void virtio_pci_save_queue(DeviceState *d, int n, QEMUFile *f)static int virtio_pci_load_config (DeviceState *d,QEMUFile *f) {VirtIOPCIProxy *proxy =to_virtio_pci_proxy (d); +PCIDevice *pci_dev =PCI_DEVICE (proxy);int ret; - ret =pci_device_load (&proxy->pci_dev, f); + + ret =pci_device_load (pci_dev, f);if (ret) {return ret; } -msix_unuse_all_vectors (&proxy->pci_dev); -msix_load (&proxy->pci_dev, f); -if (msix_present (&proxy->pci_dev)) { +msix_unuse_all_vectors (pci_dev); +if (msix_present (pci_dev)) {qemu_get_be16s (f, &proxy->vdev->config_vector); }else { proxy->vdev->config_vector =VIRTIO_NO_VECTOR ; }if (proxy->vdev->config_vector !=VIRTIO_NO_VECTOR ) { -return msix_vector_use (&proxy->pci_dev, proxy->vdev->config_vector); +return msix_vector_use (pci_dev, proxy->vdev->config_vector); }return 0 ; }include/hw/pci/msix.h +4
-3@@ -46,12 +46,13 @@ void msix_unset_vector_notifiers(PCIDevice *dev);extern const VMStateDescription vmstate_msix; -#define VMSTATE_MSIX (_field, _state) { \ - .name = (stringify(_field)), \ +#define VMSTATE_MSIX_TEST (_test) { \ + .name = "MSI-X", \ .size = sizeof(PCIDevice), \ .vmsd = &vmstate_msix, \ .flags = VMS_STRUCT, \ - .offset = vmstate_offset_value(_state, _field, PCIDevice), \ + .offset = 0, \ + .field_exists = (_test), \ }#endif Signature · 1 line
1.8.1.4
Am 29.07.2013 02:26, schrieb Andreas Färber:
Quoted 6 lines
Hello Michael and Gerd,
As discussed, this series attempts to clean up PCIe devices fiddling with individual PCI VMStateFields. It is based on my qom-devices queue, containing changes to PCIe devices.
Quoted 8 lines
v2 has been changed to use
VMStateField::field_existsinstead of subsections and unifies PCI and PCIe. Making MSI-X such a conditional field affects PCI, too, now and therefore requires incompatible changes to VMXNET3 PCI NIC.This has been successfully tested with a selection of PCI and PCIe devices on -machine pc (-machine q35 is unfortunately unmigratable due to ich9-ahci) and shows identically sized state files (for "exec:cat > pc-pci.state") and no immediate crashes. Not 1.6 material.
Ping! Stefan requested researching a solution that doesn't break vmxnet3 migration compatibility, but previous patches are waiting for review.
Andreas
Quoted 76 lines
A QOM follow-up RFC will be sent out shortly.
Regards,
Andreasv1 -> v2:
* Prepended patches to drop VMSTATE_{PCI,PCIE}_DEVICE() arguments.
* Added patch to introduceVMSTATE_BUFFER_UNSAFE_INFO_TEST()macro.
* Unified PCI and PCIe VMStateDescriptions (mst).
* Instead of moving & turning into subsection, make AER log conditional field.
* Instead of subsection, make MSI-X a conditional field.Cc Michael S. Tsirkin <[email protected]>Cc Gerd Hoffmann <[email protected]>Cc Stefan Hajnoczi <[email protected]>Cc Juan Quintela <[email protected]>Andreas Färber (6):
pci: SimplifyVMSTATE_PCI_DEVICE()macro
pci: SimplifyVMSTATE_PCIE_DEVICE()macro
vmstate: IntroduceVMSTATE_BUFFER_UNSAFE_INFO_TEST()
pci: Unify vmstate_{pci,pcie}_device
pci: Movevmstate_pcie_aer_logintovmstate_pci_device
pci: MoveVMSTATE_MSIX()intovmstate_pci_devicehw/acpi/piix4.c | 2 +- hw/audio/ac97.c | 2 +- hw/audio/es1370.c | 2 +- hw/audio/intel-hda.c | 2 +- hw/char/serial-pci.c | 4 +-- hw/char/tpci200.c | 2 +- hw/display/cirrus_vga.c | 2 +- hw/display/qxl.c | 2 +- hw/display/vga-pci.c | 2 +- hw/display/vmware_vga.c | 2 +- hw/i2c/smbus_ich9.c | 2 +- hw/ide/ich.c | 2 +- hw/ide/pci.c | 2 +- hw/isa/i82378.c | 2 +- hw/isa/lpc_ich9.c | 2 +- hw/isa/piix4.c | 2 +- hw/isa/vt82c686.c | 4 +-- hw/misc/ivshmem.c | 7 ++-- hw/net/e1000.c | 2 +- hw/net/eepro100.c | 2 +- hw/net/ne2000.c | 2 +- hw/net/pcnet-pci.c | 2 +- hw/net/rtl8139.c | 2 +- hw/net/vmxnet3.c | 29 +++------------ hw/pci-bridge/ioh3420.c | 4 +-- hw/pci-bridge/pci_bridge_dev.c | 2 +- hw/pci-bridge/xio3130_downstream.c | 4 +-- hw/pci-bridge/xio3130_upstream.c | 4 +-- hw/pci-host/bonito.c | 2 +- hw/pci-host/piix.c | 4 +-- hw/pci-host/prep.c | 2 +- hw/pci-host/q35.c | 2 +- hw/pci/pci.c | 73 +++++++++++++++++++++++--------------- hw/pci/pcie_aer.c | 1 + hw/scsi/esp-pci.c | 2 +- hw/scsi/lsi53c895a.c | 2 +- hw/scsi/megasas.c | 2 +- hw/scsi/vmw_pvscsi.c | 2 +- hw/usb/hcd-ehci-pci.c | 2 +- hw/usb/hcd-uhci.c | 2 +- hw/usb/hcd-xhci.c | 3 +- hw/virtio/virtio-pci.c | 19 +++++----- hw/watchdog/wdt_i6300esb.c | 2 +- hw/xen/xen_platform.c | 2 +- include/hw/pci/msix.h | 7 ++-- include/hw/pci/pci.h | 6 ++-- include/hw/pci/pcie.h | 10 ------ include/migration/vmstate.h | 6 +++- 48 files changed, 116 insertions(+), 133 deletions(-)
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg