[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] net: Use iov helper functions
From: |
Aurelien Jarno |
Subject: |
Re: [Qemu-devel] [PATCH] net: Use iov helper functions |
Date: |
Sun, 6 Mar 2011 19:29:27 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Wed, Feb 23, 2011 at 07:57:21PM -0500, Benjamin Poirier wrote:
> Signed-off-by: Benjamin Poirier <address@hidden>
> ---
> net.c | 28 ++++++----------------------
> 1 files changed, 6 insertions(+), 22 deletions(-)
Thanks, applied.
> diff --git a/net.c b/net.c
> index ec4745d..15ed40b 100644
> --- a/net.c
> +++ b/net.c
> @@ -36,6 +36,7 @@
> #include "qemu-common.h"
> #include "qemu_socket.h"
> #include "hw/qdev.h"
> +#include "iov.h"
>
> static QTAILQ_HEAD(, VLANState) vlans;
> static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
> @@ -572,30 +573,13 @@ static ssize_t vc_sendv_compat(VLANClientState *vc,
> const struct iovec *iov,
> int iovcnt)
> {
> uint8_t buffer[4096];
> - size_t offset = 0;
> - int i;
> -
> - for (i = 0; i < iovcnt; i++) {
> - size_t len;
> + size_t offset;
>
> - len = MIN(sizeof(buffer) - offset, iov[i].iov_len);
> - memcpy(buffer + offset, iov[i].iov_base, len);
> - offset += len;
> - }
> + offset = iov_to_buf(iov, iovcnt, buffer, 0, sizeof(buffer));
>
> return vc->info->receive(vc, buffer, offset);
> }
>
> -static ssize_t calc_iov_length(const struct iovec *iov, int iovcnt)
> -{
> - size_t offset = 0;
> - int i;
> -
> - for (i = 0; i < iovcnt; i++)
> - offset += iov[i].iov_len;
> - return offset;
> -}
> -
> static ssize_t qemu_deliver_packet_iov(VLANClientState *sender,
> unsigned flags,
> const struct iovec *iov,
> @@ -605,7 +589,7 @@ static ssize_t qemu_deliver_packet_iov(VLANClientState
> *sender,
> VLANClientState *vc = opaque;
>
> if (vc->link_down) {
> - return calc_iov_length(iov, iovcnt);
> + return iov_size(iov, iovcnt);
> }
>
> if (vc->info->receive_iov) {
> @@ -633,7 +617,7 @@ static ssize_t
> qemu_vlan_deliver_packet_iov(VLANClientState *sender,
> }
>
> if (vc->link_down) {
> - ret = calc_iov_length(iov, iovcnt);
> + ret = iov_size(iov, iovcnt);
> continue;
> }
>
> @@ -658,7 +642,7 @@ ssize_t qemu_sendv_packet_async(VLANClientState *sender,
> NetQueue *queue;
>
> if (sender->link_down || (!sender->peer && !sender->vlan)) {
> - return calc_iov_length(iov, iovcnt);
> + return iov_size(iov, iovcnt);
> }
>
> if (sender->peer) {
> --
> 1.7.2.3
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
address@hidden http://www.aurel32.net
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Qemu-devel] [PATCH] net: Use iov helper functions,
Aurelien Jarno <=