From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57771) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3FzC-0003y3-D7 for qemu-devel@nongnu.org; Sat, 27 Jul 2013 21:41:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V3Fz4-0003Fs-TE for qemu-devel@nongnu.org; Sat, 27 Jul 2013 21:41:26 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49441 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V3Fz4-0003FX-Kv for qemu-devel@nongnu.org; Sat, 27 Jul 2013 21:41:18 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 28 Jul 2013 03:41:10 +0200 Message-Id: <1374975670-8820-4-git-send-email-afaerber@suse.de> In-Reply-To: <1374975670-8820-1-git-send-email-afaerber@suse.de> References: <1374975670-8820-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH RFC for-1.6 qom-next 3/3] pci: Move AER log into VMStateSubsection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Gerd Hoffmann , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Juan Quintela XHCI does not call pcie_aer_init(), so use allocation of the AER log as indicator for whether vmstate_pcie_aer_log is needed. Go safe and zero the log pointer to support unrealizing and re-realizing a PCIDevice without AER. Signed-off-by: Andreas F=C3=A4rber --- hw/pci/pci.c | 24 ++++++++++++++++++++++-- hw/pci/pcie_aer.c | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index b69421a..4f373f9 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -477,6 +477,25 @@ const VMStateDescription vmstate_pci_device =3D { } }; =20 +static bool pcie_aer_log_needed(void *opaque) +{ + PCIDevice *s =3D opaque; + + return s->exp.aer_log.log !=3D NULL; +} + +static const VMStateDescription vmstate_pcie_device_aer_log =3D { + .name =3D "PCIEDevice/AER_Log", + .version_id =3D 1, + .minimum_version_id =3D 1, + .minimum_version_id_old =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_STRUCT(exp.aer_log, PCIDevice, 0, + vmstate_pcie_aer_log, PCIEAERLog), + VMSTATE_END_OF_LIST() + } +}; + static bool pcie_msix_needed(void *opaque) { PCIDevice *s =3D opaque; @@ -497,12 +516,13 @@ const VMStateDescription vmstate_pcie_device =3D { VMSTATE_BUFFER_UNSAFE_INFO(irq_state, PCIDevice, 2, vmstate_info_pci_irq_state, PCI_NUM_PINS * sizeof(int32_t)), - VMSTATE_STRUCT(exp.aer_log, PCIDevice, 0, - vmstate_pcie_aer_log, PCIEAERLog), VMSTATE_END_OF_LIST() }, .subsections =3D (VMStateSubsection[]) { { + .vmsd =3D &vmstate_pcie_device_aer_log, + .needed =3D pcie_aer_log_needed, + }, { .vmsd =3D &vmstate_msix, .needed =3D pcie_msix_needed, }, { 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 =3D NULL; } =20 static void pcie_aer_update_uncor_status(PCIDevice *dev) --=20 1.8.1.4