From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZEXZL-0003ox-1i for qemu-devel@nongnu.org; Mon, 13 Jul 2015 02:50:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZEXZJ-0003uV-QO for qemu-devel@nongnu.org; Mon, 13 Jul 2015 02:50:27 -0400 Sender: Paolo Bonzini References: <1436766411-29144-1-git-send-email-jasowang@redhat.com> <1436766411-29144-5-git-send-email-jasowang@redhat.com> From: Paolo Bonzini Message-ID: <55A35FA7.2030901@redhat.com> Date: Mon, 13 Jul 2015 08:50:15 +0200 MIME-Version: 1.0 In-Reply-To: <1436766411-29144-5-git-send-email-jasowang@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: Jason Wang , qemu-devel@nongnu.org, mst@redhat.com Cc: clg@fr.ibm.com, qemu-stable@nongnu.org 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