Patchwork [1/3] linux-user: pass sockaddr from host to target

login
register
mail settings
Submitter Jing Huang
Date July 14, 2012, 5:11 p.m.
Message ID <CAK8mDgrzzJ4dDypGFavVE4puozmyPQ8jsG14Vgbf-+qK29jAgA@mail.gmail.com>
Download mbox | patch
Permalink /patch/171009/
State New
Headers show

Comments

Jing Huang - July 14, 2012, 5:11 p.m.
This patch pass sockaddr from host to target.

Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>
---
 linux-user/syscall.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

     unlock_iovec(vec, target_vec, count, !send);

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 539af3f..fa251df 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1873,8 +1873,17 @@  static abi_long do_sendrecvmsg(int fd,
abi_ulong target_msg,
         if (!is_error(ret)) {
             len = ret;
             ret = host_to_target_cmsg(msgp, &msg);
-            if (!is_error(ret))
+            if (!is_error(ret)) {
+                msgp->msg_namelen = msg.msg_namelen;
+                ret = host_to_target_sockaddr(tswapal(msgp->msg_name),
+                                    msg.msg_name, msg.msg_namelen);
+                if (ret) {
+                    qemu_log("Failed to pass sockaddr to target guest");
+                    return ret;
+                }
+
                 ret = len;
+            }
         }
     }