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

Reply via email to