Received: from eggs.gnu.org ([2001:4830:134:3::10]:45977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c4LDY-0000bM-I6 for qemu-devel@nongnu.org; Wed, 09 Nov 2016 00:14:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c4LDU-0006wU-Bx for qemu-devel@nongnu.org; Wed, 09 Nov 2016 00:14:36 -0500 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:36498) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1c4LDU-0006w1-2f for qemu-devel@nongnu.org; Wed, 09 Nov 2016 00:14:32 -0500 Received: by mail-pf0-x241.google.com with SMTP id n85so22139118pfi.3 for ; Tue, 08 Nov 2016 21:14:31 -0800 (PST) References: <1478663122-29357-1-git-send-email-david@gibson.dropbear.id.au> From: Alexey Kardashevskiy Message-ID: <8711c844-ccae-a4ef-3c42-eeda73cee5e2@ozlabs.ru> Date: Wed, 9 Nov 2016 16:14:25 +1100 MIME-Version: 1.0 In-Reply-To: <1478663122-29357-1-git-send-email-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] spapr: Fix migration of PCI host bridges from qemu-2.7 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Gibson , mdroth@linux.vnet.ibm.com Cc: agraf@suse.de, thuth@redhat.com, lvivier@redhat.com, qemu-ppc@nongnu.org, qemu-devel@nongnu.org On 09/11/16 14:45, David Gibson wrote: > daa2369 "spapr_pci: Add a 64-bit MMIO window" subtly broke migration from > qemu-2.7 to the current version. It split the device's MMIO window into > two pieces for 32-bit and 64-bit MMIO. > > The patch included backwards compatibility code to convert the old property > into the new format. However, the property value was also transferred in > the migration stream and compared with a (probably unwise) VMSTATE_EQUAL. > So, the "raw" value from 2.7 is compared to the new style converted value > from (pre-)2.8 giving a mismatch and migration failure. > > Although it would be technically possible to fix this in a way allowing > backwards migration, that would leave an ugly legacy around indefinitely. > This patch takes the simpler approach of bumping the migration version, > dropping the unwise VMSTATE_EQUAL (and some equally unwise ones around it) > and ignoring them on an incoming migration. > > Signed-off-by: David Gibson > --- > hw/ppc/spapr_pci.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c > index 7cde30e..7f1cc29 100644 > --- a/hw/ppc/spapr_pci.c > +++ b/hw/ppc/spapr_pci.c > @@ -1658,19 +1658,24 @@ static int spapr_pci_post_load(void *opaque, int version_id) > return 0; > } > > +static bool version_before_3(void *opaque, int version_id) > +{ > + return version_id < 3; > +} > + > static const VMStateDescription vmstate_spapr_pci = { > .name = "spapr_pci", > - .version_id = 2, > + .version_id = 3, > .minimum_version_id = 2, > .pre_save = spapr_pci_pre_save, > .post_load = spapr_pci_post_load, > .fields = (VMStateField[]) { > VMSTATE_UINT64_EQUAL(buid, sPAPRPHBState), You could probably go one step further and get rid of @buid as well. Nevertheless, this works, Reviewed-by: Alexey Kardashevskiy > - VMSTATE_UINT32_EQUAL(dma_liobn[0], sPAPRPHBState), > - VMSTATE_UINT64_EQUAL(mem_win_addr, sPAPRPHBState), > - VMSTATE_UINT64_EQUAL(mem_win_size, sPAPRPHBState), > - VMSTATE_UINT64_EQUAL(io_win_addr, sPAPRPHBState), > - VMSTATE_UINT64_EQUAL(io_win_size, sPAPRPHBState), > + VMSTATE_UNUSED_TEST(version_before_3, sizeof(uint32_t) /* dma_liobn[0] */ > + + sizeof(uint64_t) /* mem_win_addr */ > + + sizeof(uint64_t) /* mem_win_size */ > + + sizeof(uint64_t) /* io_win_addr */ > + + sizeof(uint64_t) /* io_win_size */), > VMSTATE_STRUCT_ARRAY(lsi_table, sPAPRPHBState, PCI_NUM_PINS, 0, > vmstate_spapr_pci_lsi, struct spapr_pci_lsi), > VMSTATE_INT32(msi_devs_num, sPAPRPHBState), > -- Alexey