[libvirt] [PATCH] Make tcp_chr_read() use recvmsg()

Mark McLoughlin markmc at redhat.com
Tue Jul 21 16:47:11 UTC 2009


Signed-off-by: Mark McLoughlin <markmc at redhat.com>
---
 qemu-char.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/qemu-char.c b/qemu-char.c
index 287e0cd..e0d7220 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1911,15 +1911,25 @@ static void tcp_chr_read(void *opaque)
 {
     CharDriverState *chr = opaque;
     TCPCharDriver *s = chr->opaque;
+    struct msghdr msg = { 0, };
+    struct iovec iov[1];
     uint8_t buf[1024];
     int len, size;
 
     if (!s->connected || s->max_size <= 0)
         return;
+
     len = sizeof(buf);
     if (len > s->max_size)
         len = s->max_size;
-    size = recv(s->fd, (void *)buf, len, 0);
+
+    iov[0].iov_base = buf;
+    iov[0].iov_len = len;
+
+    msg.msg_iov = iov;
+    msg.msg_iovlen = 1;
+
+    size = recvmsg(s->fd, &msg, 0);
     if (size == 0) {
         /* connection closed */
         s->connected = 0;
-- 
1.6.2.5




More information about the libvir-list mailing list