Executive: Break out task_spec_desc (no functional change)
PATCH 1/2 Executive: Break out task_spec_desc (no functional change)
Signed-off-by Ian Jackson <[email protected]>
--- Osstest/Executive.pm | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
Osstest/Executive.pm +17 -8
@@ -45,7 +45,7 @@ BEGIN { $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = qw(grabrepolock_reexec - findtask findtask_spec @all_lock_tables + task_spec_desc findtask findtask_spec @all_lock_tables restrictflight_arg restrictflight_cond report_run_getinfo report_altcolour report_altchangecolour
@@ -524,6 +524,20 @@ END our $taskid; +sub task_spec_desc ($) { + my ($row) = @_; # NB row maybe modifed, to fill in username and comment + # => ($newspec, $desc); + + foreach my $k (qw(username comment)) { + next if defined $row->{$k}; + $row->{$k}= "[no $k]"; + } + + my $newspec = "$row->{taskid} $row->{type} $row->{refkey}"; + my $desc = "$row->{username} $row->{comment}"; + return ($newspec,$desc); +} + sub findtask_spec ($$) { my ($spec, $why) = @_;
@@ -556,13 +570,8 @@ END die "task $what dead" unless $row->{live}; $q->finish(); - foreach my $k (qw(username comment)) { - next if defined $row->{$k}; - $row->{$k}= "[no $k]"; - } - - my $newspec= "$row->{taskid} $row->{type} $row->{refkey}"; - logm("${why}task $newspec: $row->{username} $row->{comment}"); + my ($newspec, $desc) = task_spec_desc($row); + logm("${why}task $newspec: $desc"); $taskid= $row->{taskid};
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 2/2 mg-allocate: Provide command line way to list allocated resources
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 <[email protected]>
--- mg-allocate | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+)
mg-allocate +92 -0
@@ -2,6 +2,7 @@ # # usage: # ./mg-allocate [<options>] <resource-spec>... +# ./mg-allocate [-l] [-l] [-l] # # <resource-spec> syntax: # [!][<type>/]<name>[/<share>] 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. +# # <task-spec> 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 = <<END; + ( CASE WHEN restype LIKE 'share-%' + THEN SUBSTRING(restype FROM 7) + ELSE restype + END ) AS resbasetype +END + my $orderqtxt = "restype, resname, shareix"; + my $tid; + my $lq; + if ($list_only==1) { + $tid = findtask(); + $lq = $dbh_tests->prepare(<<END); + SELECT *, +$resbasetypeqtxt + FROM resources + WHERE owntaskid=? + ORDER BY resbasetype, $orderqtxt +END + $lq->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(<<END); + SELECT *, +$resbasetypeqtxt + FROM resources + JOIN tasks + ON owntaskid=taskid + WHERE tasks.live + AND NOT (tasks.type='magic' AND $hiderefkey) + ORDER BY resbasetype, + tasks.type, tasks.refkey, + $orderqtxt +END + $lq->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;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel