Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753232AbaFWKPq (ORCPT ); Mon, 23 Jun 2014 06:15:46 -0400 Received: from cn.fujitsu.com ([59.151.112.132]:13870 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752900AbaFWKPo (ORCPT ); Mon, 23 Jun 2014 06:15:44 -0400 X-IronPort-AV: E=Sophos;i="5.00,760,1396972800"; d="scan'208";a="32282776" From: "chenhanxiao@cn.fujitsu.com" To: Richard Weinberger , "containers@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , Pavel Emelyanov CC: "Eric W. Biederman" , Serge Hallyn , "Daniel P. Berrange" , "Oleg Nesterov" , Al Viro , David Howells , Vasiliy Kulikov , "Gotou, Yasunori" , "linux-api@vger.kernel.org" Subject: RE: [PATCH v2] ns: introduce getnspid syscall Thread-Topic: [PATCH v2] ns: introduce getnspid syscall Thread-Index: AQHPjHcgU6WUVvoJG0i3h/UNsKvNGJt+dQSQ Date: Mon, 23 Jun 2014 10:15:37 +0000 Message-ID: <5871495633F38949900D2BF2DC04883E54ECC5@G08CNEXMBPEKD02.g08.fujitsu.local> References: <1403259512-10510-1-git-send-email-chenhanxiao@cn.fujitsu.com> <53A414B2.20108@nod.at> In-Reply-To: <53A414B2.20108@nod.at> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.167.226.240] Content-Type: text/plain; charset="gb2312" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id s5NAFtGW017604 Hi > -----Original Message----- > From: Richard Weinberger [mailto:richard@nod.at] > Sent: Friday, June 20, 2014 7:02 PM > To: Chen, Hanxiao/?? ????; containers@lists.linux-foundation.org; > linux-kernel@vger.kernel.org > Cc: Eric W. Biederman; Serge Hallyn; Daniel P. Berrange; Oleg Nesterov; Al Viro; > David Howells; Pavel Emelyanov; Vasiliy Kulikov; Gotou, Yasunori/???u ????; > linux-api@vger.kernel.org > Subject: Re: [PATCH v2] ns: introduce getnspid syscall > > Am 20.06.2014 12:18, schrieb Chen Hanxiao: > > We need a direct method of getting the pid inside containers. > > If some issues occurred inside container guest, host user > > could not know which process is in trouble just by guest pid: > > the users of container guest only knew the pid inside containers. > > This will bring obstacle for trouble shooting. > > > > int getnspid(pid_t pid, int fd1, int fd2); > > > > pid: the pid number need to be translated. > > > > fd: a file descriptor referring to one of > > the namespace entries in a /proc/[pid]/ns/pid. > > fd1 for destination ns(ns1), where the pid came from. > > fd2 for reference ns(ns2), while fd2 = -2 means for current ns. > > > > return value: > > >0 : translated pid in ns1(fd1) seen from ns2(fd2). > > <=0: on failure. > > > > I don't think that adding a new system call for this is a good solution. > We need a more generic way. I bet people are interested in more than just PID > numbers. Could you please give some hints on how to expand this interface? > > I agree with Eric that a procfs solution is more appropriate. > Procfs is a good solution, but syscall is not bad though. Procfs works for me, but that seems could not fit Pavel's requirement. His opinion is that a syscall is a more generic interface than proc files, and also very helpful. And syscall could tell whether a pid lives in a specific pid namespace, much convenient than procfs. Thanks, - Chen ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?