Skip to content

Commit 9af5c90

Browse files
author
Riku Voipio
committed
linux-user: add setns and unshare
Add support for the setns and unshare syscalls, trivially passed through to the host. Based on patches by Paul Burton, added configure check. Signed-off-by: Paul Burton <[email protected]> Signed-off-by: Riku Voipio <[email protected]>
1 parent ab31cda commit 9af5c90

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

configure

+20
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,23 @@ if compile_prog "" "" ; then
34703470
timerfd=yes
34713471
fi
34723472

3473+
# check for setns and unshare support
3474+
setns=no
3475+
cat > $TMPC << EOF
3476+
#include <sched.h>
3477+
3478+
int main(void)
3479+
{
3480+
int ret;
3481+
ret = setns(0, 0);
3482+
ret = unshare(0);
3483+
return ret;
3484+
}
3485+
EOF
3486+
if compile_prog "" "" ; then
3487+
setns=yes
3488+
fi
3489+
34733490
# Check if tools are available to build documentation.
34743491
if test "$docs" != "no" ; then
34753492
if has makeinfo && has pod2man; then
@@ -4541,6 +4558,9 @@ fi
45414558
if test "$timerfd" = "yes" ; then
45424559
echo "CONFIG_TIMERFD=y" >> $config_host_mak
45434560
fi
4561+
if test "$setns" = "yes" ; then
4562+
echo "CONFIG_SETNS=y" >> $config_host_mak
4563+
fi
45444564
if test "$inotify" = "yes" ; then
45454565
echo "CONFIG_INOTIFY=y" >> $config_host_mak
45464566
fi

linux-user/strace.list

+3
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,9 @@
11851185
#ifdef TARGET_NR_set_mempolicy
11861186
{ TARGET_NR_set_mempolicy, "set_mempolicy" , NULL, NULL, NULL },
11871187
#endif
1188+
#ifdef TARGET_NR_setns
1189+
{ TARGET_NR_setns, "setns" , NULL, NULL, NULL },
1190+
#endif
11881191
#ifdef TARGET_NR_setpgid
11891192
{ TARGET_NR_setpgid, "setpgid" , NULL, NULL, NULL },
11901193
#endif

linux-user/syscall.c

+11
Original file line numberDiff line numberDiff line change
@@ -9610,6 +9610,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
96109610
break;
96119611
#endif
96129612

9613+
#if defined(TARGET_NR_setns) && defined(CONFIG_SETNS)
9614+
case TARGET_NR_setns:
9615+
ret = get_errno(setns(arg1, arg2));
9616+
break;
9617+
#endif
9618+
#if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS)
9619+
case TARGET_NR_unshare:
9620+
ret = get_errno(unshare(arg1));
9621+
break;
9622+
#endif
9623+
96139624
default:
96149625
unimplemented:
96159626
gemu_log("qemu: Unsupported syscall: %d\n", num);

0 commit comments

Comments
 (0)