Received: from eggs.gnu.org ([2001:4830:134:3::10]:59029) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv0xj-0006oz-HS for qemu-devel@nongnu.org; Thu, 12 Jun 2014 05:06:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wv0xW-0006ha-3Q for qemu-devel@nongnu.org; Thu, 12 Jun 2014 05:06:23 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:41502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv0xV-0006hP-Ip for qemu-devel@nongnu.org; Thu, 12 Jun 2014 05:06:10 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Jun 2014 10:06:08 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0D78F1B08061 for ; Thu, 12 Jun 2014 10:06:33 +0100 (BST) Received: from d06av11.portsmouth.uk.ibm.com (d06av11.portsmouth.uk.ibm.com [9.149.37.252]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s5C966ae21233740 for ; Thu, 12 Jun 2014 09:06:06 GMT Received: from d06av11.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av11.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s5C965jL004114 for ; Thu, 12 Jun 2014 03:06:06 -0600 Date: Thu, 12 Jun 2014 11:06:01 +0200 From: Greg Kurz Message-ID: <20140612110601.3fe5626e@bahia.local> In-Reply-To: <53996B0E.4040808@redhat.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , "Michael S. Tsirkin" , Juan Quintela , Alexander Graf , qemu-devel@nongnu.org, Anthony Liguori , Amit Shah , Andreas =?UTF-8?B?RsOkcmJlcg==?= On Thu, 12 Jun 2014 10:55:42 +0200 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. > > Paolo > BTW, can someone explain why we stream the device config ? -- 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.