From patchwork Tue Aug 12 13:42:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35263 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D168F20540 for ; Tue, 12 Aug 2014 13:48:29 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id lf10sf71179106pab.1 for ; Tue, 12 Aug 2014 06:48:29 -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=LhkfufPouBcUhi3+IGJbXSbtMZiSCDRrzoJ4VSul6GKZA937dWu5TyYl2kGT1ZnIYB Rv+IN8SN9FIUKjUfWPdj4drOAWBP6ZayrBDKf8swp3BOU/OYFgzxHa/VEfShBfLWInan 5t9izoXfoZ7EF+PPFODMfb1lpOPYaWTRL9F5BWNmEIyTnTZUVm49d5HAgJpsdoXI9w2N cKFsN9uGCsRk7BJoVr3XYr7tUZ7SUZaA1NqIXIxwi+Usc4GMFoc2LpSL44mQkr2p0Azs MBHt4ouV1v+fvBlny3NfrNdAoW8N+2kdxUTN1o6dFdPI4RDnmcGFexf99JAhoNBX6Yzj fncg== X-Gm-Message-State: ALoCoQmwZiOdbFGbekNWGngXZlY1trujaEudbcTvrSXxFP1A4/FuJxaGqYv22YXkkBVdacmbPZZW X-Received: by 10.68.222.194 with SMTP id qo2mr2392478pbc.6.1407851309140; Tue, 12 Aug 2014 06:48:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.41.11 with SMTP id y11ls147093qgy.23.gmail; Tue, 12 Aug 2014 06:48:28 -0700 (PDT) X-Received: by 10.53.3.169 with SMTP id bx9mr577338vdd.80.1407851308947; Tue, 12 Aug 2014 06:48:28 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id h13si8232741vdj.81.2014.08.12.06.48.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:48:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so13430727vcb.13 for ; Tue, 12 Aug 2014 06:48:28 -0700 (PDT) X-Received: by 10.221.47.9 with SMTP id uq9mr1034707vcb.48.1407851308864; Tue, 12 Aug 2014 06:48:28 -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 tc5csp250344vcb; Tue, 12 Aug 2014 06:48:28 -0700 (PDT) X-Received: by 10.224.86.5 with SMTP id q5mr6991650qal.36.1407851308291; Tue, 12 Aug 2014 06:48:28 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 66si3161371qgg.107.2014.08.12.06.48.28 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:48:28 -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]:42142 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCR9-0008RK-TP for patch@linaro.org; Tue, 12 Aug 2014 09:48:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCLN-0007S2-9n for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHCLH-00019L-Gz for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:29 -0400 Received: from afflict.kos.to ([92.243.29.197]:55504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCLH-00018q-AA for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:23 -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 C8FCA26595; Tue, 12 Aug 2014 15:42:21 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 12 Aug 2014 16:42:20 +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: Riku Voipio Subject: [Qemu-devel] [PATCH 10/10] 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.182 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);