aboutsummaryrefslogtreecommitdiff
path: root/qemu-char.c
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2009-07-22 09:11:38 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2009-07-29 11:47:09 -0500
commit58cc6b7a5a664b83022f234458b50a0f263a6e03 (patch)
tree566a897da4c7799def861eee8e3f7eddae7a241c /qemu-char.c
parent583b6d0c043b6f91c12a686c483a076cb0e12cb6 (diff)
Make tcp_chr_read() use recvmsg()
Split out tcp_chr_recv() out of tcp_chr_read() and implement it on non-win32 using recvmsg(). This is needed for a subsequent patch which implements SCM_RIGHTS support. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'qemu-char.c')
-rw-r--r--qemu-char.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/qemu-char.c b/qemu-char.c
index 287e0cd326..9886228151 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1907,6 +1907,29 @@ static void tcp_chr_process_IAC_bytes(CharDriverState *chr,
*size = j;
}
+#ifndef WIN32
+static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
+{
+ TCPCharDriver *s = chr->opaque;
+ struct msghdr msg = { 0, };
+ struct iovec iov[1];
+
+ iov[0].iov_base = buf;
+ iov[0].iov_len = len;
+
+ msg.msg_iov = iov;
+ msg.msg_iovlen = 1;
+
+ return recvmsg(s->fd, &msg, 0);
+}
+#else
+static ssize_t tcp_chr_recv(CharDriverState *chr, char *buf, size_t len)
+{
+ TCPCharDriver *s = chr->opaque;
+ return recv(s->fd, buf, len, 0);
+}
+#endif
+
static void tcp_chr_read(void *opaque)
{
CharDriverState *chr = opaque;
@@ -1919,7 +1942,7 @@ static void tcp_chr_read(void *opaque)
len = sizeof(buf);
if (len > s->max_size)
len = s->max_size;
- size = recv(s->fd, (void *)buf, len, 0);
+ size = tcp_chr_recv(chr, (void *)buf, len);
if (size == 0) {
/* connection closed */
s->connected = 0;