From patchwork Thu Oct 6 16:35:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Jackson X-Patchwork-Id: 9365143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A23F3607D3 for ; Thu, 6 Oct 2016 16:38:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 935D7291AB for ; Thu, 6 Oct 2016 16:38:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 881AA291AD; Thu, 6 Oct 2016 16:38:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 145C9291AB for ; Thu, 6 Oct 2016 16:38:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bsBeQ-0003JR-5r; Thu, 06 Oct 2016 16:36:06 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bsBeO-0003JE-JB for xen-devel@lists.xenproject.org; Thu, 06 Oct 2016 16:36:04 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 46/5F-28813-37D76F75; Thu, 06 Oct 2016 16:36:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuphkeJIrShJLcpLzFFi42JxWrohUreo9lu 4wdlWTYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNeNL/222guVKFZPnX2FqYFwr0cXIySEh4C9x 9uIhFhCbTUBXomnLX7YuRg4OEQEVidt7DUBMZoFQiR0vLEEqhAXiJFp+T2EDsVmAKmYcmcUKY vMKeErs/PyXEWKinMT54z+ZQWxOAS+JTa/3gdUIAdU8nnGQBWSkkICaxNz18RCtghInZz4BO4 BZQELi4IsXzCAlEgLcEn+77Scw8s1CUjULSdUCRqZVjOrFqUVlqUW6hnpJRZnpGSW5iZk5uoY Gxnq5qcXFiempOYlJxXrJ+bmbGIGhxAAEOxiXf3Q6xCjJwaQkynur/Fu4EF9SfkplRmJxRnxR aU5q8SFGGQ4OJQnelhqgnGBRanpqRVpmDjCoYdISHDxKIrxWIGne4oLE3OLMdIjUKUZFKXHea pCEAEgiozQPrg0WSZcYZaWEeRmBDhHiKUgtys0sQZV/xSjOwagkzOsLMoUnM68EbvoroMVMQI vzl34BWVySiJCSamBc9uqz09vvzXlCX76pdicEHdAt/XJU1EDiUIn0xzbVW3XuK1dZ7zmhU37 9fWMyb2lov2z3k2q5L8uC/5xcJmVwhGeV8IwpUQ8jp1Vz5ZfIevW9v30+LuMF3+9Vpok7fjJe UT8r9iZLrLzZcmZAXVJdDku79dfj75oXHhPc+bKXNSvp/jMx8aVKLMUZiYZazEXFiQC0uKpqn wIAAA== X-Env-Sender: prvs=0807beae1=Ian.Jackson@citrix.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1475771760!64159023!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50303 invoked from network); 6 Oct 2016 16:36:02 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-10.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 6 Oct 2016 16:36:02 -0000 X-IronPort-AV: E=Sophos;i="5.31,454,1473120000"; d="scan'208";a="382816720" From: Ian Jackson To: Date: Thu, 6 Oct 2016 17:35:50 +0100 Message-ID: <1475771750-12776-2-git-send-email-ian.jackson@eu.citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1475771750-12776-1-git-send-email-ian.jackson@eu.citrix.com> References: <1475771750-12776-1-git-send-email-ian.jackson@eu.citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Ian Jackson Subject: [Xen-devel] [OSSTEST PATCH 2/2] mg-allocate: Provide command line way to list allocated resources X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Freely shareable resources don't appear in the plan, and the plan is not always immediately updated, and is generally not always a convenient interface. Provide a command line way to list allocated resources. Signed-off-by: Ian Jackson --- mg-allocate | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/mg-allocate b/mg-allocate index ef57bb8..3b3fa72 100755 --- a/mg-allocate +++ b/mg-allocate @@ -2,6 +2,7 @@ # # usage: # ./mg-allocate [] ... +# ./mg-allocate [-l] [-l] [-l] # # syntax: # [!][/][/] type defaults to 'host' @@ -45,6 +46,15 @@ # as if they were free. This allows us to steal # resources from other tasks. May be repeated. # +# -l | --list Instead of allocating (or deallocating), simply list +# allocated resources. +# +# -l: resources owned by this task (this user). +# -ll: resources owned by all tasks +# -lll: include "administrative" resources +# +# Not compatible with other options. +# # must exist (and be in a format valid for OSSTEST_TASK). # This is part of "osstest", an automated testing framework for Xen. @@ -77,6 +87,7 @@ $|=1; our $tid; our %magictask; +our $list_only; our $donate_spec; our $donate_taskid; our @steal_specs; @@ -491,6 +502,9 @@ while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) { 1); } elsif (s/^\-U/-/) { $ENV{OSSTEST_RESOURCE_PRIORITY} //= -1000000; + } elsif (s/^\-l/-/ || s/^--list$/--/) { + $list_only++; + die "-l may be repeated only thrice\n" if $list_only > 3; } elsif (s/^--as$/-/) { die "--as needs task\n" unless @ARGV; $ENV{OSSTEST_TASK} = shift @ARGV; @@ -506,6 +520,84 @@ while (@ARGV && $ARGV[0] =~ m/^[-0-9]/) { } } +$list_only = 1 if !@ARGV; + +if ($list_only) { + die "-l (--list) specified (or implied) with other options or arguments\n" + if $donate_spec || @steal_specs || @ARGV || $duration; + + db_retry($dbh_tests, [], sub { + my $resbasetypeqtxt = <prepare(<execute($tid); + } else { + $tid = ''; + my @hidemagic = qw(allocatable); + if ($list_only<3) { + push @hidemagic, qw(preparing shared); + } + my $hiderefkey = join ' OR ', + map { "tasks.refkey='$_'" } + @hidemagic; + $lq = $dbh_tests->prepare(<execute(); + } + my $resbasetype = ''; + while (my $c = $lq->fetchrow_hashref()) { + if ($c->{resbasetype} ne $resbasetype) { + printf "===== %s =====\n", $c->{resbasetype}; + $resbasetype = $c->{resbasetype}; + } + if ($c->{owntaskid} ne $tid) { + my ($spec,$desc) = task_spec_desc($c); + printf "------ %s -- %s ------\n", $spec, $desc; + $tid = $c->{owntaskid}; + } + printf " %-40s ", (join "/", map { $c->{$_} } + qw(restype resname shareix)); + my $restype = $c->{restype}; + my $resname = $c->{resname}; + if ($restype eq 'share-host') { + print "S/$resname"; + } elsif ($restype eq 'host') { + print "$resname"; + } elsif ($restype eq 'share-flight') { + print "F/$resname"; + } + print "\n"; + } + db_retry_abort(); + }); + exit 0; +} + if (defined $donate_spec) { die "--donate specified with deallocations, too confusing\n" if grep { m/^!/ } @ARGV;