From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv1Ay-0006Zr-It for qemu-devel@nongnu.org; Thu, 12 Jun 2014 05:20:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wv1As-000304-5u for qemu-devel@nongnu.org; Thu, 12 Jun 2014 05:20:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46584) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wv1Ar-0002zy-Rs for qemu-devel@nongnu.org; Thu, 12 Jun 2014 05:19:58 -0400 Message-ID: <539970B3.3040304@redhat.com> Date: Thu, 12 Jun 2014 11:19:47 +0200 From: Paolo Bonzini 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> <20140612110601.3fe5626e@bahia.local> In-Reply-To: <20140612110601.3fe5626e@bahia.local> 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: Greg Kurz Cc: Kevin Wolf , Fam Zheng , Stefan Hajnoczi , "Michael S. Tsirkin" , Juan Quintela , Alexander Graf , qemu-devel@nongnu.org, Anthony Liguori , Amit Shah , =?ISO-8859-1?Q?Andreas_F=E4rber?= Il 12/06/2014 11:06, Greg Kurz ha scritto: > 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. > > BTW, can someone explain why we stream the device config ? For max_nr_ports it is useless indeed. Let's keep storing it for backwards compatibility, but you can remove its load. The cols and rows values should be defined by the host and thus could even change on migration, there is no need to store them. As of now, however, they are unused in QEMU and should always be zero, because VIRTIO_CONSOLE_F_SIZE is not supported. Paolo