From patchwork Fri Aug 22 13:24:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35800 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f69.google.com (mail-qg0-f69.google.com [209.85.192.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8562720540 for ; Fri, 22 Aug 2014 13:28:18 +0000 (UTC) Received: by mail-qg0-f69.google.com with SMTP id a108sf31291539qge.0 for ; Fri, 22 Aug 2014 06:28:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=/h5GNTFrlkLtHxiduhmONK1vuXzRAXEEK6d9YbyQCfE=; b=GiIT9OCYvkXZlIxiDVr/SfOwY2KzKkX4qPwNVxYFFmHCJFfIPj+6gciZvNYdet39zM QhhAGBFnJGlBKpvw5mHXCO1VbWm/2oLCpQwSz1s9eQNwfP8HR1q7Pc/T0K7bwFvshydL Vuq2TYmA/gYi3vor75sYa0VZrB8oY9N2+I0a+VsrY6nwemKPO6g6U/RLgahLAi61LAhG LqrwFa+sRKYCPnAnlaUj8jHRfdHmXgRELc1MD4qR6AXO5TtwuTA5cYAzvjZgDnE2/koP O6fdliWBifqh56ps10D6AINZxL7C0Se2vxMzYLLBvph6DSzQACEl27S7FU2EgAdFHs+N sOdg== X-Gm-Message-State: ALoCoQnoUQXeAhmnG0s+9jkdce1xc7RqZQWZzCYMHMH8+aMrb+iLMe00SOcqibybv+XAZHb1V0Qj X-Received: by 10.236.23.230 with SMTP id v66mr8555072yhv.53.1408714098161; Fri, 22 Aug 2014 06:28:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.102.202 with SMTP id w68ls1099299qge.4.gmail; Fri, 22 Aug 2014 06:28:18 -0700 (PDT) X-Received: by 10.220.182.73 with SMTP id cb9mr4057115vcb.9.1408714098091; Fri, 22 Aug 2014 06:28:18 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id li13si13551325vdb.94.2014.08.22.06.28.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:28:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id le20so12535246vcb.0 for ; Fri, 22 Aug 2014 06:28:18 -0700 (PDT) X-Received: by 10.221.68.66 with SMTP id xx2mr4041145vcb.1.1408714098010; Fri, 22 Aug 2014 06:28:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp16868vcb; Fri, 22 Aug 2014 06:28:17 -0700 (PDT) X-Received: by 10.140.95.101 with SMTP id h92mr7419274qge.35.1408714097268; Fri, 22 Aug 2014 06:28:17 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n20si42225949qay.90.2014.08.22.06.28.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:37084 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKot6-0007XN-RA for patch@linaro.org; Fri, 22 Aug 2014 09:28:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopn-0006VF-0W for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKopg-0002Bh-IN for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:50 -0400 Received: from afflict.kos.to ([92.243.29.197]:39323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopg-0002BC-45 for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:44 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id B9BBC26546; Fri, 22 Aug 2014 15:24:42 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 22 Aug 2014 16:24:26 +0300 Message-Id: <9af5c906d189d8f4aae902d75567639d2a8f4e22.1408712881.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Riku Voipio Subject: [Qemu-devel] [PULL v3 08/22] linux-user: add setns and unshare X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Riku Voipio 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 Signed-off-by: Riku Voipio --- configure | 20 ++++++++++++++++++++ linux-user/strace.list | 3 +++ linux-user/syscall.c | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/configure b/configure index 3d0ab1b..c4e47e1 100755 --- a/configure +++ b/configure @@ -3470,6 +3470,23 @@ if compile_prog "" "" ; then timerfd=yes fi +# check for setns and unshare support +setns=no +cat > $TMPC << EOF +#include + +int main(void) +{ + int ret; + ret = setns(0, 0); + ret = unshare(0); + return ret; +} +EOF +if compile_prog "" "" ; then + setns=yes +fi + # Check if tools are available to build documentation. if test "$docs" != "no" ; then if has makeinfo && has pod2man; then @@ -4541,6 +4558,9 @@ fi if test "$timerfd" = "yes" ; then echo "CONFIG_TIMERFD=y" >> $config_host_mak fi +if test "$setns" = "yes" ; then + echo "CONFIG_SETNS=y" >> $config_host_mak +fi if test "$inotify" = "yes" ; then echo "CONFIG_INOTIFY=y" >> $config_host_mak fi diff --git a/linux-user/strace.list b/linux-user/strace.list index 8de972a..aa0cd73 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1185,6 +1185,9 @@ #ifdef TARGET_NR_set_mempolicy { TARGET_NR_set_mempolicy, "set_mempolicy" , NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_setns +{ TARGET_NR_setns, "setns" , NULL, NULL, NULL }, +#endif #ifdef TARGET_NR_setpgid { TARGET_NR_setpgid, "setpgid" , NULL, NULL, NULL }, #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f1c182b..dae10af 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9610,6 +9610,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #endif +#if defined(TARGET_NR_setns) && defined(CONFIG_SETNS) + case TARGET_NR_setns: + ret = get_errno(setns(arg1, arg2)); + break; +#endif +#if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS) + case TARGET_NR_unshare: + ret = get_errno(unshare(arg1)); + break; +#endif + default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num);