|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH 6/6] flight preservation: Provide a way to allocate flights
Teach mg-allocate to create and delete resources table entries for
flights, as necessary. And, provide a conveniance alias F/<flight>.
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
README.planner | 10 ++++++++--
mg-allocate | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/README.planner b/README.planner
index 9d35b40..f3cab53 100644
--- a/README.planner
+++ b/README.planner
@@ -206,9 +206,15 @@ Flight logs and build artefacts are normally expired based
on their
start time, or the start time of the most recent flight which refers
to them.
-Flights can be protected (preserved) by allocating them somehow:
+Flights can be protected (preserved) by allocating them with
+./mg-allocate F/<flight>.
+
Flights are represented by restype='share-flight' entries in the
-resources table.
+resources table. Conventionally, the shareix is the owning taskid.
+This allows multiple tasks to lock a single flight. There is no
+corresponding entry with restype='flight', nor a resource_sharing
+entry. mg-allocate will create and clean up share-flight entries as
+needed.
DETAILED PROTOCOL NOTES
diff --git a/mg-allocate b/mg-allocate
index 0317229..ef57bb8 100755
--- a/mg-allocate
+++ b/mg-allocate
@@ -6,6 +6,7 @@
# <resource-spec> syntax:
# [!][<type>/]<name>[/<share>] type defaults to 'host'
# type=='S' means 'shared-host'
+# type=='F' means 'shared-flight'
# share defaults to *
# "!" prefix means deallocate
# name=option|option|... means
@@ -112,6 +113,17 @@ sub parse_1res ($) {
$restype= 'share-host' if $restype eq 'S';
my $resname= $3;
my $shareix= $4;
+
+ if ($restype eq 'F') {
+ die unless $resname =~ m/^\d+$/;
+ die unless $resname eq $resname+0;
+ die if defined $shareix;
+ die if $donate_spec;
+ die if @steal_specs;
+ $restype = 'share-flight';
+ $shareix = $tid;
+ }
+
$shareix= defined($shareix) ? $shareix+0 : '*';
my $shareixcond = $shareix eq '*' ? '' : "AND shareix = $shareix";
@@ -147,6 +159,23 @@ sub alloc_1rescand ($$) {
my ($res, $rescand) = @_;
my ($allocate, $restype, $resname, $shareix, $shareixcond) = @$rescand;
+ if ($allocate && $restype eq 'share-flight' && $shareix == $tid) {
+ $dbh_tests->do(<<END,{},
+ INSERT INTO resources
+ (SELECT ? AS restype,
+ ? AS resname,
+ ? AS shareix,
+ ? AS owntaskid
+ WHERE NOT EXISTS
+ (SELECT 1 FROM resources
+ WHERE restype=?
+ AND resname=?
+ AND shareix=?))
+END
+ $restype,$resname,$shareix, $magictask{idle},
+ $restype,$resname,$shareix);
+ }
+
my $resq= $dbh_tests->prepare(<<END);
SELECT * FROM resources r
JOIN tasks t
@@ -257,6 +286,16 @@ END
logm("$desc: freeing");
}
$setres->($donate_taskid // $magictask{idle});
+ if ($restype eq 'share-flight' && $shareix == $tid) {
+ $dbh_tests->do(<<END,{},
+ DELETE FROM resources
+ WHERE restype = ?
+ AND resname = ?
+ AND shareix = ?
+ AND owntaskid = ?
+END
+ $restype,$resname,$shareix, $magictask{idle});
+ }
}
if ($isshared) {
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |