From: Ian Campbell Subject: Re: [PATCH OSSTEST v2] PDU/xenuse: Support xenuse on machine not locked by current user Date: Mon, 21 Oct 2013 12:27:30 +0100 Message-ID: <1382354850.1657.14.camel@hastur.hellion.org.uk> References: <1382347749-32718-1-git-send-email-ian.campbell@citrix.com> <21092.63339.316030.742056@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21092.63339.316030.742056@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org On Mon, 2013-10-21 at 10:44 +0100, Ian Jackson wrote: > Ian Campbell writes ("[PATCH OSSTEST v2] PDU/xenuse: Support xenuse on machine not locked by current user"): > > xenuse checks that whoever is trying to reboot a machine "owns" that machine > > via a locking mechanism. This is usually fine doesn't work well when one wants > > to book a machine out of the osstest pool for adhoc testing. In this case > > machine ownership is maintained by osstest ahd the machine remains locked to > > osstest as far as xenuse is concerned. > ... > > + my $user= $c{XenUseUser} || undef; > > + $user= get_host_property($mo->{Host}, "XenUseUser", $user); > > I'm not sure what's wrong with: > > my $user= get_host_property($mo->{Host}, "XenUseUser", > $c{XenUseUser} || undef $user); > > ? I just don't think like a Perl programmer ;-) > > + local $ENV{USER} = $ENV{USER}; > > If USER isn't in the environment, this will set it to an empty value. Ah yes. I was trying to work around the fact that "local $ENV{USER}" by itself would clear any existing $USER but didn't think this through. > If you use the suffix if, you don't get a { } which limits the scope > of local: > > ( logm("XenUse overriding \$USER to $user"), > local $ENV{USER} = $user ) > if $user; > > perhaps. I was trying to avoid the double "if $user", this looks like it might work. I'll try it. Ian.