From patchwork Fri Aug 15 11:01:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35441 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 806F6203C5 for ; Fri, 15 Aug 2014 11:09:23 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf16165161pdb.5 for ; Fri, 15 Aug 2014 04:09:16 -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=Vzs69LsoXU3IGg0gELGZqT8uyqWHUZDdugngAye96wo=; b=A5Y4jEUMCb839hVB7bkO8YRPj4yt5OCzvXRY/0b3v+geF73A5Sta41U1LVjL0VrJpq GAsD6PzZVT91gXN0JMLHaPB+QLh7ahNxOqH3Rb+gQbePu2mdejgk1WPtfgEadLEShkhg LNH68ayUad+JHjj5nbxTj3wP5EVI7FYYeD6O0A5jy4LPfF/nsow+A7uO2J4bxNqtt1gE Mp2AkQ1MFl54AOSnUEc7aF6nmlyitK2eGtB/IUzisZl9bAVMrDy5P+LZzi84ZLJarzFO uWw4eYdVO9S/LD3BLoNHqYDqoYkM4lh9pPfu5huRT+5nGiDSNdwUW2nF67zmdjHfOjGD s6fA== X-Gm-Message-State: ALoCoQm8HKESD7Foty6o2vkgrooIrYZmWsrPA2wz5JnaQCSgEsjytvXSQ6ZA9tkLA+sv5jGW2bpf X-Received: by 10.66.66.3 with SMTP id b3mr8605928pat.6.1408100955467; Fri, 15 Aug 2014 04:09:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.17.47 with SMTP id 44ls977190qgc.11.gmail; Fri, 15 Aug 2014 04:09:15 -0700 (PDT) X-Received: by 10.224.64.201 with SMTP id f9mr27160308qai.64.1408100955314; Fri, 15 Aug 2014 04:09:15 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id x9si11334070qal.104.2014.08.15.04.09.15 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:09:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so2773017vcb.19 for ; Fri, 15 Aug 2014 04:09:15 -0700 (PDT) X-Received: by 10.52.165.129 with SMTP id yy1mr337232vdb.57.1408100955105; Fri, 15 Aug 2014 04:09:15 -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.37.5 with SMTP id tc5csp104398vcb; Fri, 15 Aug 2014 04:09:14 -0700 (PDT) X-Received: by 10.140.94.100 with SMTP id f91mr24915207qge.41.1408100954551; Fri, 15 Aug 2014 04:09:14 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x8si11343189qas.81.2014.08.15.04.09.14 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:09:14 -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]:58597 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFNi-0008PX-2r for patch@linaro.org; Fri, 15 Aug 2014 07:09:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGd-0004xE-CJ for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIFGU-000723-Lv for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:55 -0400 Received: from afflict.kos.to ([92.243.29.197]:57595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGU-00071U-Fq for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:46 -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 C73E1265A9; Fri, 15 Aug 2014 13:01:44 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 15 Aug 2014 14:01:28 +0300 Message-Id: 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: Peter Maydell , Riku Voipio Subject: [Qemu-devel] [PULL 10/24] 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.174 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 577e2b9..f6de265 100755 --- a/configure +++ b/configure @@ -3434,6 +3434,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 @@ -4503,6 +4520,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 147f579..d5b8033 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -1191,6 +1191,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 74c5d49..e5c3ebb 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9680,6 +9680,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);