From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmRyx-00006A-8y for qemu-devel@nongnu.org; Mon, 19 May 2014 14:08:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmRyr-0002cu-Qo for qemu-devel@nongnu.org; Mon, 19 May 2014 14:08:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8367) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmRyr-0002cQ-Jo for qemu-devel@nongnu.org; Mon, 19 May 2014 14:08:09 -0400 Date: Mon, 19 May 2014 19:07:58 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20140519180758.GC2198@work-vm> References: <20140519063132.22955.63563.stgit@bahia.local> <20140519083908.22955.12177.stgit@bahia.local> <20140519150633.4871817d@bahia.local> <537A3A1F.8010303@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <537A3A1F.8010303@suse.de> Subject: Re: [Qemu-devel] [PATCH RFC 8/8] virtio: add endian-ambivalent support to VirtIODevice List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas F?rber Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , Juan Quintela , "Michael S. Tsirkin" , Alexander Graf , qemu-devel@nongnu.org, Anthony Liguori , Amit Shah , Paolo Bonzini , Greg Kurz * Andreas F?rber (afaerber@suse.de) wrote: > Am 19.05.2014 15:06, schrieb Greg Kurz: > > On Mon, 19 May 2014 10:39:09 +0200 > > Greg Kurz wrote: > >> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > >> index 7fbad29..6578854 100644 > >> --- a/hw/virtio/virtio.c > >> +++ b/hw/virtio/virtio.c > [...] > >> @@ -839,10 +849,39 @@ typedef struct VirtIOSubsection { > >> int version_id; > >> void (*save)(VirtIODevice *vdev, QEMUFile *f); > >> int (*load)(VirtIODevice *vdev, QEMUFile *f); > >> - int (*needed)(VirtIODevice *vdev); > >> + bool (*needed)(VirtIODevice *vdev); > >> } VirtIOSubsection; > >> > >> +static void virtio_save_device_endian(VirtIODevice *vdev, QEMUFile *f) > >> +{ > >> + qemu_put_byte(f, vdev->device_endian); > >> +} > >> + > >> +static int virtio_load_device_endian(VirtIODevice *vdev, QEMUFile *f) > >> +{ > >> + vdev->device_endian =3D qemu_get_byte(f); > >> + return 0; > >> +} > >> + > >> +static bool virtio_device_endian_needed(VirtIODevice *vdev) > >> +{ > >> + /* No migration is supposed to occur while we are loading state. > >> + */ > >> + assert(vdev->device_endian !=3D VIRTIO_DEVICE_ENDIAN_UNKNOWN); > >> + if (target_words_bigendian()) { > >> + return vdev->device_endian =3D=3D VIRTIO_DEVICE_ENDIAN_LITTLE; > >> + } else { > >> + return vdev->device_endian =3D=3D VIRTIO_DEVICE_ENDIAN_BIG; > >> + } > >> +} > >> + > >> static const VirtIOSubsection virtio_subsection[] =3D { > >> + { .name =3D "virtio/device_endian", > >=20 > > Can anyone comment the subsection name ? Is there a chance the > > VMState port would come up with the same ? > >=20 > >> + .version_id =3D 1, > >> + .save =3D virtio_save_device_endian, > >> + .load =3D virtio_load_device_endian, > >> + .needed =3D virtio_device_endian_needed, > >> + }, > >> { .name =3D NULL } > >> }; > >> >=20 > Different question: With converting VirtIO to VMState in mind, why are > you not using a regular VMStateSubsection and loading/saving that as > part of the old-style load/save functions? Is an API for that missing? There are a handful of places that call into vmstate from a non-vmstate routine but I don't think they're using plain subsections. hw/pci/pci.c: pci_device_save/load hw/scsi/spapr_vscsi.c: vscsi_save_request hw/acpi/piix4.c: acpi_load_old Dave >=20 > Regards, > Andreas >=20 > --=20 > SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany > GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg >=20 -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK