From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmR1V-0001V0-SE for qemu-devel@nongnu.org; Mon, 19 May 2014 13:06:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmR1O-0005kD-Ak for qemu-devel@nongnu.org; Mon, 19 May 2014 13:06:49 -0400 Received: from cantor2.suse.de ([195.135.220.15]:48108 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmR1O-0005k9-4x for qemu-devel@nongnu.org; Mon, 19 May 2014 13:06:42 -0400 Message-ID: <537A3A1F.8010303@suse.de> Date: Mon, 19 May 2014 19:06:39 +0200 From: =?ISO-8859-1?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <20140519063132.22955.63563.stgit@bahia.local> <20140519083908.22955.12177.stgit@bahia.local> <20140519150633.4871817d@bahia.local> In-Reply-To: <20140519150633.4871817d@bahia.local> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: Greg Kurz Cc: Kevin Wolf , Fam Zheng , Anthony Liguori , "Michael S. Tsirkin" , Juan Quintela , Alexander Graf , qemu-devel@nongnu.org, Stefan Hajnoczi , Amit Shah , Paolo Bonzini 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 } >> }; >> 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? Regards, Andreas --=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