From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgv8h-0001PK-U6 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:40:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zgv8d-00025K-R9 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:40:15 -0400 Received: from mx6-phx2.redhat.com ([209.132.183.39]:54863) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zgv8d-00025E-Jm for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:40:11 -0400 Date: Tue, 29 Sep 2015 09:39:57 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <2105557509.19691388.1443533997719.JavaMail.zimbra@redhat.com> In-Reply-To: <560A91F8.1080209@huawei.com> References: <1443094669-4144-1-git-send-email-marcandre.lureau@redhat.com> <1443094669-4144-24-git-send-email-marcandre.lureau@redhat.com> <560A91F8.1080209@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 23/47] ivshmem: migrate with VMStateDescription List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Claudio Fontana Cc: drjones@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com, marcandre lureau , cam@cs.ualberta.ca ----- Original Message ----- > On 24.09.2015 13:37, marcandre.lureau@redhat.com wrote: > > From: Marc-Andr=C3=A9 Lureau > >=20 > > load_state_old() is used to keep compatibility with version 0. > >=20 > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > --- > > hw/misc/ivshmem.c | 141 > > ++++++++++++++++++++++++++++++++++-------------------- > > 1 file changed, 88 insertions(+), 53 deletions(-) > >=20 > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > > index 8207a98..54f7093 100644 > > --- a/hw/misc/ivshmem.c > > +++ b/hw/misc/ivshmem.c > > @@ -651,56 +651,6 @@ static int ivshmem_setup_msi(IVShmemState * s) > > return 0; > > } > > =20 > > -static void ivshmem_save(QEMUFile* f, void *opaque) > > -{ > > - IVShmemState *proxy =3D opaque; > > - PCIDevice *pci_dev =3D PCI_DEVICE(proxy); > > - > > - IVSHMEM_DPRINTF("ivshmem_save\n"); > > - pci_device_save(pci_dev, f); > > - > > - if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) { > > - msix_save(pci_dev, f); > > - } else { > > - qemu_put_be32(f, proxy->intrstatus); > > - qemu_put_be32(f, proxy->intrmask); > > - } > > - > > -} > > - > > -static int ivshmem_load(QEMUFile* f, void *opaque, int version_id) > > -{ > > - IVSHMEM_DPRINTF("ivshmem_load\n"); > > - > > - IVShmemState *proxy =3D opaque; > > - PCIDevice *pci_dev =3D PCI_DEVICE(proxy); > > - int ret; > > - > > - if (version_id > 0) { > > - return -EINVAL; > > - } > > - > > - if (proxy->role_val =3D=3D IVSHMEM_PEER) { > > - error_report("'peer' devices are not migratable"); > > - return -EINVAL; > > - } > > - > > - ret =3D pci_device_load(pci_dev, f); > > - if (ret) { > > - return ret; > > - } > > - > > - if (ivshmem_has_feature(proxy, IVSHMEM_MSI)) { > > - msix_load(pci_dev, f); > > -=09ivshmem_use_msix(proxy); > > - } else { > > - proxy->intrstatus =3D qemu_get_be32(f); > > - proxy->intrmask =3D qemu_get_be32(f); > > - } > > - > > - return 0; > > -} > > - > > static void ivshmem_write_config(PCIDevice *pci_dev, uint32_t address, > > uint32_t val, int len) > > { > > @@ -726,8 +676,7 @@ static void pci_ivshmem_realize(PCIDevice *dev, Err= or > > **errp) > > } > > =20 > > fifo8_create(&s->incoming_fifo, sizeof(long)); > > - register_savevm(DEVICE(dev), "ivshmem", 0, 0, ivshmem_save, > > ivshmem_load, > > - > > dev); > > + > > /* IRQFD requires MSI */ > > if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD) && > > !ivshmem_has_feature(s, IVSHMEM_MSI)) { > > @@ -853,10 +802,95 @@ static void pci_ivshmem_exit(PCIDevice *dev) > > =20 > > memory_region_del_subregion(&s->bar, &s->ivshmem); > > vmstate_unregister_ram(&s->ivshmem, DEVICE(dev)); > > - unregister_savevm(DEVICE(dev), "ivshmem", s); > > fifo8_destroy(&s->incoming_fifo); > > } > > =20 > > +static bool test_msix(void *opaque, int version_id) > > +{ > > + IVShmemState *s =3D opaque; > > + > > + return ivshmem_has_feature(s, IVSHMEM_MSI); > > +} > > + > > +static bool test_no_msix(void *opaque, int version_id) > > +{ > > + return !test_msix(opaque, version_id); > > +} > > + > > +static int ivshmem_pre_load(void *opaque) > > +{ > > + IVShmemState *s =3D opaque; > > + > > + if (s->role_val =3D=3D IVSHMEM_PEER) { > > + error_report("'peer' devices are not migratable"); > > + return -EINVAL; > > + } > > + > > + return 0; > > +} > > + > > +static int ivshmem_post_load(void *opaque, int version_id) > > +{ > > + IVShmemState *s =3D opaque; > > + > > + if (ivshmem_has_feature(s, IVSHMEM_MSI)) { > > + ivshmem_use_msix(s); > > + } > > + > > + return 0; > > +} > > + > > +static int ivshmem_load_old(QEMUFile *f, void *opaque, int version_id) > > +{ > > + IVShmemState *s =3D opaque; > > + PCIDevice *pdev =3D PCI_DEVICE(s); > > + int ret; > > + > > + IVSHMEM_DPRINTF("ivshmem_load_old\n"); > > + > > + if (version_id !=3D 0) { > > + return -EINVAL; > > + } > > + > > + if (s->role_val =3D=3D IVSHMEM_PEER) { > > + error_report("'peer' devices are not migratable"); > > + return -EINVAL; > > + } > > + > > + ret =3D pci_device_load(pdev, f); > > + if (ret) { > > + return ret; > > + } > > + > > + if (ivshmem_has_feature(s, IVSHMEM_MSI)) { > > + msix_load(pdev, f); > > + ivshmem_use_msix(s); > > + } else { > > + s->intrstatus =3D qemu_get_be32(f); > > + s->intrmask =3D qemu_get_be32(f); > > + } > > + > > + return 0; > > +} > > + > > +static const VMStateDescription ivshmem_vmsd =3D { > > + .name =3D "ivshmem", > > + .version_id =3D 1, > > + .minimum_version_id =3D 1, > > + .pre_load =3D ivshmem_pre_load, > > + .post_load =3D ivshmem_post_load, > > + .fields =3D (VMStateField[]) { > > + VMSTATE_PCI_DEVICE(parent_obj, IVShmemState), > > + > > + VMSTATE_MSIX_TEST(parent_obj, IVShmemState, test_msix), > > + VMSTATE_UINT32_TEST(intrstatus, IVShmemState, test_no_msix), > > + VMSTATE_UINT32_TEST(intrmask, IVShmemState, test_no_msix), > > + > > + VMSTATE_END_OF_LIST() > > + }, > > + .load_state_old =3D ivshmem_load_old >=20 > Should you not have a minimum_version_id_old if you want to support > load_state_old? > Granted, it should be =3D0, so it probably works anyway.. yes, I can make this more explicit though, agree. is the rest of the patch getting your reviewed-by? >=20 > > +}; > > + > > static Property ivshmem_properties[] =3D { > > DEFINE_PROP_CHR("chardev", IVShmemState, server_chr), > > DEFINE_PROP_STRING("size", IVShmemState, sizearg), > > @@ -882,6 +916,7 @@ static void ivshmem_class_init(ObjectClass *klass, = void > > *data) > > k->class_id =3D PCI_CLASS_MEMORY_RAM; > > dc->reset =3D ivshmem_reset; > > dc->props =3D ivshmem_properties; > > + dc->vmsd =3D &ivshmem_vmsd; > > set_bit(DEVICE_CATEGORY_MISC, dc->categories); > > } > > =20 > >=20 >=20 >=20 > -- > Claudio Fontana > Server Virtualization Architect > Huawei Technologies Duesseldorf GmbH > Riesstra=C3=9Fe 25 - 80992 M=C3=BCnchen >=20 >=20