From nobody@FreeBSD.org  Fri Mar  9 18:23:39 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 4FD731065670
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Mar 2012 18:23:39 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 219D88FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  9 Mar 2012 18:23:39 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q29INcPo007467
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 9 Mar 2012 18:23:38 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q29INclh007461;
	Fri, 9 Mar 2012 18:23:38 GMT
	(envelope-from nobody)
Message-Id: <201203091823.q29INclh007461@red.freebsd.org>
Date: Fri, 9 Mar 2012 18:23:38 GMT
From: Thomas Steen Rasmussen <thomas@gibfest.dk>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Using jail name in rctl(8) doesn't work - jail id works
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         165886
>Category:       bin
>Synopsis:       Using jail name in rctl(8) doesn't work - jail id works
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    trasz
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 09 18:30:11 UTC 2012
>Closed-Date:    Sun Mar 11 20:46:27 UTC 2012
>Last-Modified:  Sun Mar 11 20:46:27 UTC 2012
>Originator:     Thomas Steen Rasmussen
>Release:        FreeBSD 9.0-RELEASE amd64
>Organization:
>Environment:
FreeBSD osd-asrock 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Thu Mar  8 13:24:23 UTC 2012     root@osd-asrock:/usr/obj/usr/src/sys/RCTL  amd64

>Description:
Using jail name in rctl(8) doesn't work - jail id works. Observe:

[root@osd-asrock ~]# jls
   JID  IP Address      Hostname                      Path
     1  10.20.13.1      memtest1                      /usr/jails/memtest1
     2  10.20.13.2      disktest1                     /usr/jails/disktest1
[root@osd-asrock ~]# rctl -hu jail:memtest1
cputime=0
datasize=0
stacksize=0
coredumpsize=0
memoryuse=0
memorylocked=0
maxproc=0
openfiles=0
vmemoryuse=0
pseudoterminals=0
swapuse=0
nthr=0
msgqqueued=0
msgqsize=0
nmsgq=0
nsem=0
nsemop=0
nshm=0
shmsize=0
wallclock=0
[root@osd-asrock ~]# rctl -hu jail:1
cputime=3
datasize=6788k
stacksize=0
coredumpsize=0
memoryuse=8292k
memorylocked=0
maxproc=4
openfiles=0
vmemoryuse=71M
pseudoterminals=0
swapuse=0
nthr=4
msgqqueued=0
msgqsize=0
nmsgq=0
nsem=0
nsemop=0
nshm=0
shmsize=0
wallclock=1348

The problem also happens when setting the limits - if I set the limit using the jail name, the actions are not applied.

>How-To-Repeat:
Try using jail name in a rctl command, like this one from the rctl(8)  manpage:

           rctl -hu jail:www

     Display resource usage information for jail named "www".

Observe that all zeroes are returned instead of the expected values.
>Fix:
From the source I am guessing the function resolve_ids() should have contained code to resolve the jail name to the jail id - but it doesn't. Adding code to resolve the jail name to id using jail_getid() in the same way jexec(8) didn't help. 

In fact, testing revealed that jexec(8) is also unable to resolve the jail name:

# jls
   JID  IP Address      Hostname                      Path
     1  10.20.13.1      memtest1                      /usr/jails/memtest1
     2  10.20.13.2      disktest1                     /usr/jails/disktest1
# jexec memtest1 sh
jexec: jail "memtest1" not found
#

So I guess this is the basic problem.

These jails are installed with ezjail, if that matters.
Further info and testing available on request :)

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-jail 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Mar 10 06:06:49 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165886 
Responsible-Changed-From-To: freebsd-jail->trasz 
Responsible-Changed-By: trasz 
Responsible-Changed-When: Sat Mar 10 07:44:24 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165886 

From: Edward Napierala <trasz@FreeBSD.org>
To: bug-followup@FreeBSD.org, thomas@gibfest.dk
Cc:  
Subject: Re: bin/165886: Using jail name in rctl(8) doesn&#39;t work - jail id works
Date: Sat, 10 Mar 2012 08:46:40 +0100

 Reason for this is that both rctl(8) and jexec(8) use jail names, not
 jail hostnames, and jls(8) called without arguments displays jail
 hostname, not jail name.
State-Changed-From-To: open->closed 
State-Changed-By: trasz 
State-Changed-When: Sun Mar 11 20:46:25 UTC 2012 
State-Changed-Why:  
User error - jail name is not the jail hostname. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165886 
>Unformatted:
