From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57376) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv0pK-0002YR-OB for qemu-devel@nongnu.org; Thu, 12 Jun 2014 04:57:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wv0pD-0003xz-6H for qemu-devel@nongnu.org; Thu, 12 Jun 2014 04:57:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57465 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv0pC-0003xq-Tx for qemu-devel@nongnu.org; Thu, 12 Jun 2014 04:57:35 -0400 Message-ID: <53996B7C.2000707@suse.de> Date: Thu, 12 Jun 2014 10:57:32 +0200 From: Alexander Graf MIME-Version: 1.0 References: <20140514154130.10746.1412.stgit@bahia.local> <20140514154230.10746.56297.stgit@bahia.local> <5384A8D2.8050104@redhat.com> <20140529111253.4ff55199@bahia.local> <538708FA.4070309@redhat.com> <20140612094351.6295fd38@bahia.local> <53996B0E.4040808@redhat.com> In-Reply-To: <53996B0E.4040808@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: Paolo Bonzini , Greg Kurz Cc: Kevin Wolf , Fam Zheng , Anthony Liguori , Juan Quintela , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Stefan Hajnoczi , Amit Shah , =?ISO-8859-1?Q?Andreas_F=E4rber?= On 12.06.14 10:55, Paolo Bonzini wrote: > Il 12/06/2014 09:43, Greg Kurz ha scritto: >> Since we know that 0 < max_nr_ports < 32, is it acceptable to guess >> the correct endianness with a heuristic ? >> >> if (max_nr_ports > tswap32(s->config.max_nr_ports)) { >> max_nr_ports = bswap32(max_nr_ports); >> } >> >> if (max_nr_ports > tswap32(s->config.max_nr_ports)) { >> return -EINVAL; >> } > > Yes, I guess it is acceptable. So first you should fix the code to > always serialize fields as big-endian, and then apply this little hack > and virtio_tswap on top of the previous change. Why don't we just ignore those config fields? They won't change during the lifetime of the guest anyway - and configuration needs to be the same on source and dest to work. Alex