[Xen-devel] [OSSTEST PATCH 04/21] alloc_resources: Support special abandonment values

Ian Jackson posted 21 patches 6 years, 9 months ago
[Xen-devel] [OSSTEST PATCH 04/21] alloc_resources: Support special abandonment values
Posted by Ian Jackson 6 years, 9 months ago
This gives a way for the caller's $resourcecall to signal something
interesting, back to its main loop.  This is useful for calling
broken, for example: that can't be done within $resourcecall because
$resourcecall operates within the allocation db transaction (which
ought to be rolled back...)

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
 Osstest/Executive.pm | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/Osstest/Executive.pm b/Osstest/Executive.pm
index 0d8502b5..b27b8d25 100644
--- a/Osstest/Executive.pm
+++ b/Osstest/Executive.pm
@@ -737,7 +737,8 @@ sub alloc_resources {
     #
     #  values of $ok
     #            0  rollback, wait and try again
-    #            1  commit, completed ok
+    #            1  commit, completed ok } return the
+    #           >1  rollback and abandon }  value of $ok
     #  $bookinglist should be undef or a hash for making a booking
     #
     # $resourcecall should not look at tasks.live
@@ -859,10 +860,14 @@ sub alloc_resources {
 		    # $resourcecall itself failed: bomb out (don't retry)
 		    $ok=-1;
 		}
-		return db_retry_abort() unless $ok>0;
+		return db_retry_abort() unless $ok==1;
 	    }]);
 
-	    if ($bookinglist && $ok!=-1) {
+	    if ($ok<0 || $ok>1) {
+                return 1;
+	    }
+
+	    if ($bookinglist) {
 		my %prstart;
 		foreach my $book (@{ $bookinglist->{Bookings} }) {
 		    my $pr = $book->{Reso};
@@ -890,8 +895,6 @@ sub alloc_resources {
 
             if ($ok==1) {
                 print $qserv "thought-done\n" or die $!;
-            } elsif ($ok<0) {
-                return 1;
             } else { # 0
                 logm("resource allocation: deferring");
                 print $qserv "thought-wait\n" or die $!;
@@ -935,8 +938,12 @@ END
             $ok= 0;
         }
     }
-    die unless $ok==1;
-    logm("resource allocation: successful.");
+    if ($ok==1) {
+	logm("resource allocation: successful.");
+    } else {
+	logm("resource allocation: resourcecall returned ($ok,...)");
+    }
+    return $ok;
 }
 
 sub resource_check_allocated ($$) {
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel