From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: qemu-devel@nongnu.org, Anthony Liguori <anthony@codemonkey.ws>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH qom-next for-next v2 2/6] pci: Simplify VMSTATE_PCIE_DEVICE() macro
Date: Mon, 2 Sep 2013 14:45:19 +0300 [thread overview]
Message-ID: <20130902114519.GE20911@redhat.com> (raw)
In-Reply-To: <522478B1.4030407@suse.de>
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
next prev parent reply other threads:[~2013-09-02 11:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130902114519.GE20911@redhat.com \
--to=mst@redhat.com \
--cc=afaerber@suse.de \
--cc=anthony@codemonkey.ws \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).