All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups
@ 2013-07-29  0:26 Andreas Färber
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro Andreas Färber
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Andreas Färber @ 2013-07-29  0:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Stefan Hajnoczi, Juan Quintela, Gerd Hoffmann,
	Andreas Färber, Michael S. Tsirkin

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.

Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Stefan Hajnoczi <stefanha@gmail.com>
Cc: Juan Quintela <quintela@redhat.com>

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(-)

-- 
1.8.1.4

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

* [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro
  2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
@ 2013-07-29  0:26 ` Andreas Färber
  2013-09-02 11:38   ` Michael S. Tsirkin
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro Andreas Färber
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Andreas Färber @ 2013-07-29  0:26 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, open list:PReP, Michael S. Tsirkin,
	Andreas Färber, Vassili Karpov (malc),
	Gerd Hoffmann, Paolo Bonzini, Andreas Färber, Paul Brook

Drop the arguments to avoid QOM refactorings causing more churn.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index c885690..c95d0b4 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -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),
diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
index 365b2f1..d23882b 100644
--- a/hw/audio/ac97.c
+++ b/hw/audio/ac97.c
@@ -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),
diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
index f2c40da..d681a44 100644
--- a/hw/audio/es1370.c
+++ b/hw/audio/es1370.c
@@ -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),
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 58984dc..fb7f8ef 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -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),
diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
index a17c702..f6a21af 100644
--- a/hw/char/serial-pci.c
+++ b/hw/char/serial-pci.c
@@ -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),
diff --git a/hw/char/tpci200.c b/hw/char/tpci200.c
index a199e57..2ba5ad2 100644
--- a/hw/char/tpci200.c
+++ b/hw/char/tpci200.c
@@ -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),
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index a440575..c116bc4 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -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()
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index ddefa06..813c31a 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -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),
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index 3e150ab..ce76e9c 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -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()
     }
diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
index 3536cde..97c7ba1 100644
--- a/hw/display/vmware_vga.c
+++ b/hw/display/vmware_vga.c
@@ -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()
diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
index ca22978..c2ac696 100644
--- a/hw/i2c/smbus_ich9.c
+++ b/hw/i2c/smbus_ich9.c
@@ -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()
     }
 };
diff --git a/hw/ide/ich.c b/hw/ide/ich.c
index 4eb5488..bf16847 100644
--- a/hw/ide/ich.c
+++ b/hw/ide/ich.c
@@ -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()
     },
diff --git a/hw/ide/pci.c b/hw/ide/pci.c
index 91151fc..a3ede4f 100644
--- a/hw/ide/pci.c
+++ b/hw/ide/pci.c
@@ -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),
diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
index b25ed04..b147b82 100644
--- a/hw/isa/i82378.c
+++ b/hw/isa/i82378.c
@@ -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()
     },
 };
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index d1921aa..5a9fd03 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -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),
diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
index 1a1d451..fe13429 100644
--- a/hw/isa/piix4.c
+++ b/hw/isa/piix4.c
@@ -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()
     }
 };
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 2174eaa..72e2dfd 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -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()
     }
 };
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index b952d8d..a2f3c70 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -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),
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index e0befb2..f3def09 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -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),
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index 8d43fd9..d7ca182 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -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()
     }
diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
index 6ef28f7..cb9f361 100644
--- a/hw/net/pcnet-pci.c
+++ b/hw/net/pcnet-pci.c
@@ -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()
     }
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 6552034..283d02d 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -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),
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index b39ff08..3bad83c 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -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),
diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
index cf3c53c..a909dbf 100644
--- a/hw/pci-bridge/pci_bridge_dev.c
+++ b/hw/pci-bridge/pci_bridge_dev.c
@@ -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()
     }
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 5086d42..1b82df4 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -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()
     }
 };
diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
index 3908860..982f29c 100644
--- a/hw/pci-host/piix.c
+++ b/hw/pci-host/piix.c
@@ -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()
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index b41d564..f6582ea 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -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()
     },
 };
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 6b1b3b7..1f0b5db 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -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()
     }
diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
index 2ac21d4..76b8cfa 100644
--- a/hw/scsi/esp-pci.c
+++ b/hw/scsi/esp-pci.c
@@ -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()
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 776e31a..f723f26 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -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),
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index eb52164..8cb6714 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -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),
diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
index e1074e1..7e9ea39 100644
--- a/hw/scsi/vmw_pvscsi.c
+++ b/hw/scsi/vmw_pvscsi.c
@@ -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),
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 5d229bc..385745e 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -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()
     }
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
index 066072e..d9170f7 100644
--- a/hw/usb/hcd-uhci.c
+++ b/hw/usb/hcd-uhci.c
@@ -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),
diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
index 85aebc2..bfe19dd 100644
--- a/hw/watchdog/wdt_i6300esb.c
+++ b/hw/watchdog/wdt_i6300esb.c
@@ -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),
diff --git a/hw/xen/xen_platform.c b/hw/xen/xen_platform.c
index 6a8ba7e..5f2d2b6 100644
--- a/hw/xen/xen_platform.c
+++ b/hw/xen/xen_platform.c
@@ -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()
     }
diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
index ccec2ba..5997d91 100644
--- a/include/hw/pci/pci.h
+++ b/include/hw/pci/pci.h
@@ -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) {                 \
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
  2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro Andreas Färber
@ 2013-07-29  0:26 ` Andreas Färber
  2013-09-02 11:36   ` Michael S. Tsirkin
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 3/6] vmstate: Introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST() Andreas Färber
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Andreas Färber @ 2013-07-29  0:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Andreas Färber, Michael S. Tsirkin

Drop the arguments to avoid QOM refactorings causing more churn.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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(-)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index e07c7e8..0657354 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -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()
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
index 2c84b1a..9022949 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -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()
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index 82add15..046b790 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -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()
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 9ba3e3e..a22861f 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -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,
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index c010007..fc4ebd3 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -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 */
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH qom-next for-next v2 3/6] vmstate: Introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST()
  2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro Andreas Färber
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro Andreas Färber
@ 2013-07-29  0:26 ` Andreas Färber
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 4/6] pci: Unify vmstate_{pci, pcie}_device Andreas Färber
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Andreas Färber @ 2013-07-29  0:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Andreas Färber, Michael S. Tsirkin

To be used by PCIDevice.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 include/migration/vmstate.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h
index 1c31b5d..3590e1f 100644
--- a/include/migration/vmstate.h
+++ b/include/migration/vmstate.h
@@ -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)
 
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH qom-next for-next v2 4/6] pci: Unify vmstate_{pci, pcie}_device
  2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
                   ` (2 preceding siblings ...)
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 3/6] vmstate: Introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST() Andreas Färber
@ 2013-07-29  0:26 ` Andreas Färber
  2013-07-29  0:27 ` [Qemu-devel] [PATCH qom-next for-next v2 5/6] pci: Move vmstate_pcie_aer_log into vmstate_pci_device Andreas Färber
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Andreas Färber @ 2013-07-29  0:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Andreas Färber, Michael S. Tsirkin

The 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.

Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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(-)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index 0657354..680a13d 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -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()
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
index 9022949..3fa4ec2 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -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()
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index 046b790..0edacc3 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -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()
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 4c004f5..6461c9d 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -460,6 +460,20 @@ static VMStateInfo vmstate_info_pci_irq_state = {
     .put  = put_pci_irq_state,
 };
 
+static bool pci_device_express_needed(void *opaque, int version_id)
+{
+    PCIDevice *s = opaque;
+
+    return pci_is_express(s);
+}
+
+static bool pci_device_non_express_needed(void *opaque, int version_id)
+{
+    PCIDevice *s = opaque;
+
+    return !pci_is_express(s);
+}
+
 const VMStateDescription vmstate_pci_device = {
     .name = "PCIDevice",
     .version_id = 2,
@@ -467,38 +481,21 @@ const VMStateDescription vmstate_pci_device = {
     .minimum_version_id_old = 1,
     .fields      = (VMStateField []) {
         VMSTATE_INT32_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
-                                   vmstate_info_pci_config,
-                                   PCI_CONFIG_SPACE_SIZE),
-        VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
-				   vmstate_info_pci_irq_state,
-				   PCI_NUM_PINS * sizeof(int32_t)),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
-const VMStateDescription vmstate_pcie_device = {
-    .name = "PCIEDevice",
-    .version_id = 2,
-    .minimum_version_id = 1,
-    .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
-        VMSTATE_INT32_LE(version_id, PCIDevice),
-        VMSTATE_BUFFER_UNSAFE_INFO(config, PCIDevice, 0,
-                                   vmstate_info_pci_config,
-                                   PCIE_CONFIG_SPACE_SIZE),
+        VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, 0,
+                                        pci_device_non_express_needed,
+                                        vmstate_info_pci_config,
+                                        PCI_CONFIG_SPACE_SIZE),
+        VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, 0,
+                                        pci_device_express_needed,
+                                        vmstate_info_pci_config,
+                                        PCIE_CONFIG_SPACE_SIZE),
         VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2,
-				   vmstate_info_pci_irq_state,
-				   PCI_NUM_PINS * sizeof(int32_t)),
+                                   vmstate_info_pci_irq_state,
+                                   PCI_NUM_PINS * sizeof(int32_t)),
         VMSTATE_END_OF_LIST()
     }
 };
 
-static inline const VMStateDescription *pci_get_vmstate(PCIDevice *s)
-{
-    return pci_is_express(s) ? &vmstate_pcie_device : &vmstate_pci_device;
-}
-
 void pci_device_save(PCIDevice *s, QEMUFile *f)
 {
     /* Clear interrupt status bit: it is implicit
@@ -506,7 +503,7 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)
      * This makes us compatible with old devices
      * which never set or clear this bit. */
     s->config[PCI_STATUS] &= ~PCI_STATUS_INTERRUPT;
-    vmstate_save_state(f, pci_get_vmstate(s), s);
+    vmstate_save_state(f, &vmstate_pci_device, s);
     /* Restore the interrupt status bit. */
     pci_update_irq_status(s);
 }
@@ -514,7 +511,8 @@ void pci_device_save(PCIDevice *s, QEMUFile *f)
 int pci_device_load(PCIDevice *s, QEMUFile *f)
 {
     int ret;
-    ret = vmstate_load_state(f, pci_get_vmstate(s), s, s->version_id);
+
+    ret = vmstate_load_state(f, &vmstate_pci_device, s, s->version_id);
     /* Restore the interrupt status bit. */
     pci_update_irq_status(s);
     return ret;
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index a22861f..167b58d 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -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,
diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
index fc4ebd3..41e2f8c 100644
--- a/include/hw/pci/pcie.h
+++ b/include/hw/pci/pcie.h
@@ -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 */
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH qom-next for-next v2 5/6] pci: Move vmstate_pcie_aer_log into vmstate_pci_device
  2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
                   ` (3 preceding siblings ...)
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 4/6] pci: Unify vmstate_{pci, pcie}_device Andreas Färber
@ 2013-07-29  0:27 ` Andreas Färber
  2013-07-29  0:27 ` [Qemu-devel] [PATCH RFC qom-next for-next v2 6/6] pci: Move VMSTATE_MSIX() " Andreas Färber
  2013-09-02 11:25 ` [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
  6 siblings, 0 replies; 13+ messages in thread
From: Andreas Färber @ 2013-07-29  0:27 UTC (permalink / raw)
  To: qemu-devel; +Cc: Gerd Hoffmann, Andreas Färber, Michael S. Tsirkin

Make it conditional on PCIe and allocation of the AER log.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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(-)

diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
index 680a13d..bf92884 100644
--- a/hw/pci-bridge/ioh3420.c
+++ b/hw/pci-bridge/ioh3420.c
@@ -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()
     }
 };
diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
index 3fa4ec2..bf7099d 100644
--- a/hw/pci-bridge/xio3130_downstream.c
+++ b/hw/pci-bridge/xio3130_downstream.c
@@ -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()
     }
 };
diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
index 0edacc3..b564c7f 100644
--- a/hw/pci-bridge/xio3130_upstream.c
+++ b/hw/pci-bridge/xio3130_upstream.c
@@ -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()
     }
 };
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 6461c9d..b790d98 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -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()
     }
 };
diff --git a/hw/pci/pcie_aer.c b/hw/pci/pcie_aer.c
index ca762ab..2767ebc 100644
--- a/hw/pci/pcie_aer.c
+++ b/hw/pci/pcie_aer.c
@@ -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)
-- 
1.8.1.4

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

* [Qemu-devel] [PATCH RFC qom-next for-next v2 6/6] pci: Move VMSTATE_MSIX() into vmstate_pci_device
  2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
                   ` (4 preceding siblings ...)
  2013-07-29  0:27 ` [Qemu-devel] [PATCH qom-next for-next v2 5/6] pci: Move vmstate_pcie_aer_log into vmstate_pci_device Andreas Färber
@ 2013-07-29  0:27 ` Andreas Färber
  2013-09-02 11:31   ` Michael S. Tsirkin
  2013-09-02 11:25 ` [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
  6 siblings, 1 reply; 13+ messages in thread
From: Andreas Färber @ 2013-07-29  0:27 UTC (permalink / raw)
  To: qemu-devel
  Cc: Anthony Liguori, Gerd Hoffmann, Andreas Färber, Michael S. Tsirkin

Use 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.

Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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(-)

diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 4a74856..de997cd 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -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);
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index 3bad83c..471ca24 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -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[]) {
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index b790d98..bd6078b 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -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()
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index 167b58d..ca7b3cd 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -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),
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index c38cfd1..8e2789d 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -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;
 }
diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
index 954d82b..b1b8874 100644
--- a/include/hw/pci/msix.h
+++ b/include/hw/pci/msix.h
@@ -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
-- 
1.8.1.4

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

* Re: [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups
  2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
                   ` (5 preceding siblings ...)
  2013-07-29  0:27 ` [Qemu-devel] [PATCH RFC qom-next for-next v2 6/6] pci: Move VMSTATE_MSIX() " Andreas Färber
@ 2013-09-02 11:25 ` Andreas Färber
  6 siblings, 0 replies; 13+ messages in thread
From: Andreas Färber @ 2013-09-02 11:25 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: Stefan Hajnoczi, Gerd Hoffmann, qemu-devel, Juan Quintela

Am 29.07.2013 02:26, schrieb Andreas Färber:
> 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.

Ping! Stefan requested researching a solution that doesn't break vmxnet3
migration compatibility, but previous patches are waiting for review.

Andreas

> 
> 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.
> 
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Gerd Hoffmann <kraxel@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@gmail.com>
> Cc: Juan Quintela <quintela@redhat.com>
> 
> 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(-)
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH RFC qom-next for-next v2 6/6] pci: Move VMSTATE_MSIX() into vmstate_pci_device
  2013-07-29  0:27 ` [Qemu-devel] [PATCH RFC qom-next for-next v2 6/6] pci: Move VMSTATE_MSIX() " Andreas Färber
@ 2013-09-02 11:31   ` Michael S. Tsirkin
  0 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2013-09-02 11:31 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Anthony Liguori, qemu-devel, Gerd Hoffmann

On Mon, Jul 29, 2013 at 02:27:01AM +0200, Andreas Färber wrote:
> Use 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.

No, that's a bug. msix_unuse_all_vectors clears pending state
if any, it will lose state if called before load.

> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
>  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(-)
> 
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index 4a74856..de997cd 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -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);
> diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
> index 3bad83c..471ca24 100644
> --- a/hw/net/vmxnet3.c
> +++ b/hw/net/vmxnet3.c
> @@ -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[]) {
> diff --git a/hw/pci/pci.c b/hw/pci/pci.c
> index b790d98..bd6078b 100644
> --- a/hw/pci/pci.c
> +++ b/hw/pci/pci.c
> @@ -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()
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index 167b58d..ca7b3cd 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -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),
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index c38cfd1..8e2789d 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -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;
>  }
> diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h
> index 954d82b..b1b8874 100644
> --- a/include/hw/pci/msix.h
> +++ b/include/hw/pci/msix.h
> @@ -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
> -- 
> 1.8.1.4

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

* Re: [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro Andreas Färber
@ 2013-09-02 11:36   ` Michael S. Tsirkin
  2013-09-02 11:38     ` Andreas Färber
  0 siblings, 1 reply; 13+ messages in thread
From: Michael S. Tsirkin @ 2013-09-02 11:36 UTC (permalink / raw)
  To: Andreas Färber; +Cc: qemu-devel, Gerd Hoffmann

On Mon, Jul 29, 2013 at 02:26:57AM +0200, Andreas Färber wrote:
> Drop the arguments to avoid QOM refactorings causing more churn.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

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".


> ---
>  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(-)
> 
> diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
> index e07c7e8..0657354 100644
> --- a/hw/pci-bridge/ioh3420.c
> +++ b/hw/pci-bridge/ioh3420.c
> @@ -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()
> diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
> index 2c84b1a..9022949 100644
> --- a/hw/pci-bridge/xio3130_downstream.c
> +++ b/hw/pci-bridge/xio3130_downstream.c
> @@ -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()
> diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
> index 82add15..046b790 100644
> --- a/hw/pci-bridge/xio3130_upstream.c
> +++ b/hw/pci-bridge/xio3130_upstream.c
> @@ -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()
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index 9ba3e3e..a22861f 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -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,
> diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
> index c010007..fc4ebd3 100644
> --- a/include/hw/pci/pcie.h
> +++ b/include/hw/pci/pcie.h
> @@ -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 */
> -- 
> 1.8.1.4

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

* Re: [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro
  2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro Andreas Färber
@ 2013-09-02 11:38   ` Michael S. Tsirkin
  0 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2013-09-02 11:38 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Kevin Wolf, open list:PReP, qemu-devel, Andreas Färber,
	Vassili Karpov (malc),
	Gerd Hoffmann, Paolo Bonzini, Paul Brook

On Mon, Jul 29, 2013 at 02:26:56AM +0200, Andreas Färber wrote:
> Drop the arguments to avoid QOM refactorings causing more churn.
> 
> Signed-off-by: Andreas Färber <afaerber@suse.de>

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.


> ---
>  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(-)
> 
> diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
> index c885690..c95d0b4 100644
> --- a/hw/acpi/piix4.c
> +++ b/hw/acpi/piix4.c
> @@ -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),
> diff --git a/hw/audio/ac97.c b/hw/audio/ac97.c
> index 365b2f1..d23882b 100644
> --- a/hw/audio/ac97.c
> +++ b/hw/audio/ac97.c
> @@ -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),
> diff --git a/hw/audio/es1370.c b/hw/audio/es1370.c
> index f2c40da..d681a44 100644
> --- a/hw/audio/es1370.c
> +++ b/hw/audio/es1370.c
> @@ -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),
> diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
> index 58984dc..fb7f8ef 100644
> --- a/hw/audio/intel-hda.c
> +++ b/hw/audio/intel-hda.c
> @@ -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),
> diff --git a/hw/char/serial-pci.c b/hw/char/serial-pci.c
> index a17c702..f6a21af 100644
> --- a/hw/char/serial-pci.c
> +++ b/hw/char/serial-pci.c
> @@ -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),
> diff --git a/hw/char/tpci200.c b/hw/char/tpci200.c
> index a199e57..2ba5ad2 100644
> --- a/hw/char/tpci200.c
> +++ b/hw/char/tpci200.c
> @@ -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),
> diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
> index a440575..c116bc4 100644
> --- a/hw/display/cirrus_vga.c
> +++ b/hw/display/cirrus_vga.c
> @@ -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()
> diff --git a/hw/display/qxl.c b/hw/display/qxl.c
> index ddefa06..813c31a 100644
> --- a/hw/display/qxl.c
> +++ b/hw/display/qxl.c
> @@ -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),
> diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
> index 3e150ab..ce76e9c 100644
> --- a/hw/display/vga-pci.c
> +++ b/hw/display/vga-pci.c
> @@ -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()
>      }
> diff --git a/hw/display/vmware_vga.c b/hw/display/vmware_vga.c
> index 3536cde..97c7ba1 100644
> --- a/hw/display/vmware_vga.c
> +++ b/hw/display/vmware_vga.c
> @@ -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()
> diff --git a/hw/i2c/smbus_ich9.c b/hw/i2c/smbus_ich9.c
> index ca22978..c2ac696 100644
> --- a/hw/i2c/smbus_ich9.c
> +++ b/hw/i2c/smbus_ich9.c
> @@ -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()
>      }
>  };
> diff --git a/hw/ide/ich.c b/hw/ide/ich.c
> index 4eb5488..bf16847 100644
> --- a/hw/ide/ich.c
> +++ b/hw/ide/ich.c
> @@ -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()
>      },
> diff --git a/hw/ide/pci.c b/hw/ide/pci.c
> index 91151fc..a3ede4f 100644
> --- a/hw/ide/pci.c
> +++ b/hw/ide/pci.c
> @@ -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),
> diff --git a/hw/isa/i82378.c b/hw/isa/i82378.c
> index b25ed04..b147b82 100644
> --- a/hw/isa/i82378.c
> +++ b/hw/isa/i82378.c
> @@ -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()
>      },
>  };
> diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
> index d1921aa..5a9fd03 100644
> --- a/hw/isa/lpc_ich9.c
> +++ b/hw/isa/lpc_ich9.c
> @@ -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),
> diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c
> index 1a1d451..fe13429 100644
> --- a/hw/isa/piix4.c
> +++ b/hw/isa/piix4.c
> @@ -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()
>      }
>  };
> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
> index 2174eaa..72e2dfd 100644
> --- a/hw/isa/vt82c686.c
> +++ b/hw/isa/vt82c686.c
> @@ -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()
>      }
>  };
> diff --git a/hw/net/e1000.c b/hw/net/e1000.c
> index b952d8d..a2f3c70 100644
> --- a/hw/net/e1000.c
> +++ b/hw/net/e1000.c
> @@ -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),
> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> index e0befb2..f3def09 100644
> --- a/hw/net/eepro100.c
> +++ b/hw/net/eepro100.c
> @@ -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),
> diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
> index 8d43fd9..d7ca182 100644
> --- a/hw/net/ne2000.c
> +++ b/hw/net/ne2000.c
> @@ -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()
>      }
> diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c
> index 6ef28f7..cb9f361 100644
> --- a/hw/net/pcnet-pci.c
> +++ b/hw/net/pcnet-pci.c
> @@ -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()
>      }
> diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
> index 6552034..283d02d 100644
> --- a/hw/net/rtl8139.c
> +++ b/hw/net/rtl8139.c
> @@ -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),
> diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
> index b39ff08..3bad83c 100644
> --- a/hw/net/vmxnet3.c
> +++ b/hw/net/vmxnet3.c
> @@ -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),
> diff --git a/hw/pci-bridge/pci_bridge_dev.c b/hw/pci-bridge/pci_bridge_dev.c
> index cf3c53c..a909dbf 100644
> --- a/hw/pci-bridge/pci_bridge_dev.c
> +++ b/hw/pci-bridge/pci_bridge_dev.c
> @@ -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()
>      }
> diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
> index 5086d42..1b82df4 100644
> --- a/hw/pci-host/bonito.c
> +++ b/hw/pci-host/bonito.c
> @@ -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()
>      }
>  };
> diff --git a/hw/pci-host/piix.c b/hw/pci-host/piix.c
> index 3908860..982f29c 100644
> --- a/hw/pci-host/piix.c
> +++ b/hw/pci-host/piix.c
> @@ -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()
> diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
> index b41d564..f6582ea 100644
> --- a/hw/pci-host/prep.c
> +++ b/hw/pci-host/prep.c
> @@ -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()
>      },
>  };
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index 6b1b3b7..1f0b5db 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -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()
>      }
> diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c
> index 2ac21d4..76b8cfa 100644
> --- a/hw/scsi/esp-pci.c
> +++ b/hw/scsi/esp-pci.c
> @@ -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()
> diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
> index 776e31a..f723f26 100644
> --- a/hw/scsi/lsi53c895a.c
> +++ b/hw/scsi/lsi53c895a.c
> @@ -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),
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index eb52164..8cb6714 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -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),
> diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c
> index e1074e1..7e9ea39 100644
> --- a/hw/scsi/vmw_pvscsi.c
> +++ b/hw/scsi/vmw_pvscsi.c
> @@ -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),
> diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
> index 5d229bc..385745e 100644
> --- a/hw/usb/hcd-ehci-pci.c
> +++ b/hw/usb/hcd-ehci-pci.c
> @@ -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()
>      }
> diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
> index 066072e..d9170f7 100644
> --- a/hw/usb/hcd-uhci.c
> +++ b/hw/usb/hcd-uhci.c
> @@ -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),
> diff --git a/hw/watchdog/wdt_i6300esb.c b/hw/watchdog/wdt_i6300esb.c
> index 85aebc2..bfe19dd 100644
> --- a/hw/watchdog/wdt_i6300esb.c
> +++ b/hw/watchdog/wdt_i6300esb.c
> @@ -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),
> diff --git a/hw/xen/xen_platform.c b/hw/xen/xen_platform.c
> index 6a8ba7e..5f2d2b6 100644
> --- a/hw/xen/xen_platform.c
> +++ b/hw/xen/xen_platform.c
> @@ -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()
>      }
> diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h
> index ccec2ba..5997d91 100644
> --- a/include/hw/pci/pci.h
> +++ b/include/hw/pci/pci.h
> @@ -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) {                 \
> -- 
> 1.8.1.4

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

* Re: [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
  2013-09-02 11:36   ` Michael S. Tsirkin
@ 2013-09-02 11:38     ` Andreas Färber
  2013-09-02 11:45       ` Michael S. Tsirkin
  0 siblings, 1 reply; 13+ messages in thread
From: Andreas Färber @ 2013-09-02 11:38 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel, Anthony Liguori, Gerd Hoffmann

Am 02.09.2013 13:36, schrieb Michael S. Tsirkin:
> On Mon, Jul 29, 2013 at 02:26:57AM +0200, Andreas Färber wrote:
>> Drop the arguments to avoid QOM refactorings causing more churn.
>>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
> 
> We discussed and discarded something very similar.

Anthony requested that I don't mix different types for the offsets in
VMSTATE_*() macros.

> 
> 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.

> 
> 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

> Or go back to give fields sane names instead
> of "parent_obj".
> 
> 
>> ---
>>  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(-)
>>
>> diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
>> index e07c7e8..0657354 100644
>> --- a/hw/pci-bridge/ioh3420.c
>> +++ b/hw/pci-bridge/ioh3420.c
>> @@ -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()
>> diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
>> index 2c84b1a..9022949 100644
>> --- a/hw/pci-bridge/xio3130_downstream.c
>> +++ b/hw/pci-bridge/xio3130_downstream.c
>> @@ -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()
>> diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
>> index 82add15..046b790 100644
>> --- a/hw/pci-bridge/xio3130_upstream.c
>> +++ b/hw/pci-bridge/xio3130_upstream.c
>> @@ -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()
>> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
>> index 9ba3e3e..a22861f 100644
>> --- a/hw/usb/hcd-xhci.c
>> +++ b/hw/usb/hcd-xhci.c
>> @@ -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,
>> diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
>> index c010007..fc4ebd3 100644
>> --- a/include/hw/pci/pcie.h
>> +++ b/include/hw/pci/pcie.h
>> @@ -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 */
>> -- 
>> 1.8.1.4


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
  2013-09-02 11:38     ` Andreas Färber
@ 2013-09-02 11:45       ` Michael S. Tsirkin
  0 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2013-09-02 11:45 UTC (permalink / raw)
  To: Andreas Färber; +Cc: qemu-devel, Anthony Liguori, Gerd Hoffmann

On Mon, Sep 02, 2013 at 01:38:25PM +0200, Andreas Färber wrote:
> Am 02.09.2013 13:36, schrieb Michael S. Tsirkin:
> > On Mon, Jul 29, 2013 at 02:26:57AM +0200, Andreas Färber wrote:
> >> Drop the arguments to avoid QOM refactorings causing more churn.
> >>
> >> Signed-off-by: Andreas Färber <afaerber@suse.de>
> > 
> > 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.

> > 
> > 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.

> > 
> > 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.

> > Or go back to give fields sane names instead
> > of "parent_obj".
> > 
> > 
> >> ---
> >>  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(-)
> >>
> >> diff --git a/hw/pci-bridge/ioh3420.c b/hw/pci-bridge/ioh3420.c
> >> index e07c7e8..0657354 100644
> >> --- a/hw/pci-bridge/ioh3420.c
> >> +++ b/hw/pci-bridge/ioh3420.c
> >> @@ -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()
> >> diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_downstream.c
> >> index 2c84b1a..9022949 100644
> >> --- a/hw/pci-bridge/xio3130_downstream.c
> >> +++ b/hw/pci-bridge/xio3130_downstream.c
> >> @@ -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()
> >> diff --git a/hw/pci-bridge/xio3130_upstream.c b/hw/pci-bridge/xio3130_upstream.c
> >> index 82add15..046b790 100644
> >> --- a/hw/pci-bridge/xio3130_upstream.c
> >> +++ b/hw/pci-bridge/xio3130_upstream.c
> >> @@ -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()
> >> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> >> index 9ba3e3e..a22861f 100644
> >> --- a/hw/usb/hcd-xhci.c
> >> +++ b/hw/usb/hcd-xhci.c
> >> @@ -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,
> >> diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h
> >> index c010007..fc4ebd3 100644
> >> --- a/include/hw/pci/pcie.h
> >> +++ b/include/hw/pci/pcie.h
> >> @@ -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 */
> >> -- 
> >> 1.8.1.4
> 
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

end of thread, other threads:[~2013-09-02 11:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-29  0:26 [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber
2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 1/6] pci: Simplify VMSTATE_PCI_DEVICE() macro Andreas Färber
2013-09-02 11:38   ` Michael S. Tsirkin
2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro Andreas Färber
2013-09-02 11:36   ` Michael S. Tsirkin
2013-09-02 11:38     ` Andreas Färber
2013-09-02 11:45       ` Michael S. Tsirkin
2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 3/6] vmstate: Introduce VMSTATE_BUFFER_UNSAFE_INFO_TEST() Andreas Färber
2013-07-29  0:26 ` [Qemu-devel] [PATCH qom-next for-next v2 4/6] pci: Unify vmstate_{pci, pcie}_device Andreas Färber
2013-07-29  0:27 ` [Qemu-devel] [PATCH qom-next for-next v2 5/6] pci: Move vmstate_pcie_aer_log into vmstate_pci_device Andreas Färber
2013-07-29  0:27 ` [Qemu-devel] [PATCH RFC qom-next for-next v2 6/6] pci: Move VMSTATE_MSIX() " Andreas Färber
2013-09-02 11:31   ` Michael S. Tsirkin
2013-09-02 11:25 ` [Qemu-devel] [PATCH qom-next for-next v2 0/6] PCI VMState cleanups Andreas Färber

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.