From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEZ81-0003QD-Vo for qemu-devel@nongnu.org; Mon, 13 Jul 2015 04:30:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEZ7z-0007QW-1F for qemu-devel@nongnu.org; Mon, 13 Jul 2015 04:30:21 -0400 Message-ID: <55A37715.5030504@redhat.com> Date: Mon, 13 Jul 2015 16:30:13 +0800 From: Jason Wang MIME-Version: 1.0 References: <1436766411-29144-1-git-send-email-jasowang@redhat.com> <1436766411-29144-5-git-send-email-jasowang@redhat.com> <55A35FA7.2030901@redhat.com> In-Reply-To: <55A35FA7.2030901@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/5] virtio-net: unbreak any layout List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org, mst@redhat.com Cc: clg@fr.ibm.com, qemu-stable@nongnu.org On 07/13/2015 02:50 PM, Paolo Bonzini wrote: > > On 13/07/2015 07:46, Jason Wang wrote: >> - if (out_sg[0].iov_len < n->guest_hdr_len) { >> + s = iov_to_buf(out_sg, out_num, 0, &hdr, sizeof(hdr)); >> + if (s != sizeof(hdr)) { >> error_report("virtio-net header incorrect"); >> exit(1); >> } >> - virtio_net_hdr_swap(vdev, (void *) out_sg[0].iov_base); >> + virtio_net_hdr_swap(vdev, (void *) &hdr); >> + s = iov_from_buf(out_sg, out_num, 0, &hdr, sizeof(hdr)); >> + assert(s == sizeof(hdr)); >> } > Are the copies necessary in the common case of no swap? In that case > you can just use iov_size. > > Paolo > Not necessary, will fix this in V2. Thanks