From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43018) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmRQp-0004LG-Il for qemu-devel@nongnu.org; Mon, 19 May 2014 13:33:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WmRQh-0006xt-Jf for qemu-devel@nongnu.org; Mon, 19 May 2014 13:32:59 -0400 Received: from e06smtp17.uk.ibm.com ([195.75.94.113]:59314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WmRQh-0006xY-B8 for qemu-devel@nongnu.org; Mon, 19 May 2014 13:32:51 -0400 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 19 May 2014 18:32:48 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0EDAB2190041 for ; Mon, 19 May 2014 18:32:36 +0100 (BST) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s4JHWjSQ52363516 for ; Mon, 19 May 2014 17:32:45 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s4JIWjDi013755 for ; Mon, 19 May 2014 12:32:45 -0600 Date: Mon, 19 May 2014 19:32:40 +0200 From: Greg Kurz Message-ID: <20140519193240.4b860d40@bahia.local> In-Reply-To: <537A3A1F.8010303@suse.de> 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=UTF-8 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: Andreas =?UTF-8?B?RsOkcmJlcg==?= Cc: Kevin Wolf , Fam Zheng , Anthony Liguori , "Michael S. Tsirkin" , Juan Quintela , Alexander Graf , qemu-devel@nongnu.org, Stefan Hajnoczi , Amit Shah , Paolo Bonzini On Mon, 19 May 2014 19:06:39 +0200 Andreas F=C3=A4rber 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? >=20 I guess because I haven't tried yet. :) I'll have a closer look at this. > Regards, > Andreas >=20 Thanks. --=20 Gregory Kurz kurzgreg@fr.ibm.com gkurz@linux.vnet.ibm.com Software Engineer @ IBM/Meiosys http://www.ibm.com Tel +33 (0)562 165 496 "Anarchy is about taking complete responsibility for yourself." Alan Moore.