]> xenbits.xensource.com Git - osstest.git/commitdiff
host allocation: *_shared_mark_ready: Allow other states
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 27 Oct 2017 14:41:31 +0000 (15:41 +0100)
committerIan Jackson <iwj@xenproject.org>
Fri, 2 Oct 2020 15:49:13 +0000 (16:49 +0100)
Generalise these functions so they can set the state to something
other than `ready', and so that they can expect a state other than
`prep'.

No functional change with existing callers.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Osstest/Executive.pm
Osstest/JobDB/Executive.pm
Osstest/TestSupport.pm

index 703f3d850cf1673151660c8b5db2258cf5816e10..f0038f6b059ecabf1c9b4c6a40b4e292f854758a 100644 (file)
@@ -1050,11 +1050,14 @@ END
     return $shared;
 }
 
-sub executive_resource_shared_mark_ready ($$$) {
-    my ($restype, $resname, $sharetype) = @_;
+sub executive_resource_shared_mark_ready ($$$;$$) {
+    my ($restype, $resname, $sharetype, $oldstate, $newstate) = @_;
     # must run outside transaction
 
     my $oldshr;
+    $oldstate //= 'prep';
+    $newstate //= 'ready';
+
     my $what= "resource $restype $resname";
     $sharetype .= ' '.get_harness_rev();
 
@@ -1063,11 +1066,11 @@ sub executive_resource_shared_mark_ready ($$$) {
         if (defined $oldshr) {
             die "$what shared $oldshr->{Type} not $sharetype"
                 unless $oldshr->{Type} eq $sharetype;
-            die "$what shared state $oldshr->{State} not prep"
-                unless $oldshr->{State} eq 'prep';
-            my $nrows= $dbh_tests->do(<<END,{}, $restype,$resname,$sharetype);
+            die "$what shared state $oldshr->{State} not $oldstate"
+                unless $oldshr->{State} eq $oldstate;
+            my $nrows= $dbh_tests->do(<<END,{}, $newstate, $restype,$resname,$sharetype);
                 UPDATE resource_sharing
-                   SET state='ready'
+                   SET state=?
                  WHERE restype=? AND resname=? AND sharetype=?
 END
             die "unexpected not updated state $what $sharetype $nrows"
@@ -1092,9 +1095,9 @@ END
        logm("post-mark-ready queue daemon prod failed: $@");
     }
     if ($oldshr) {
-       logm("$restype $resname shared $sharetype marked ready");
+       logm("$restype $resname shared $sharetype marked $newstate");
     } else {
-       logm("$restype $resname (not shared, $sharetype) is ready");
+       logm("$restype $resname (not shared, $sharetype) is $newstate");
     }
 }
 
index 39deb8a2b1d13b3fa8099e4321e53f766b219a79..3062957241dc684435d1cce6964922866e874247 100644 (file)
@@ -352,8 +352,9 @@ sub gen_ether_offset ($$) { #method
 }
 
 sub jobdb_resource_shared_mark_ready { #method
-    my ($mo, $restype, $resname, $sharetype) = @_;
-    executive_resource_shared_mark_ready($restype, $resname, $sharetype);
+    my ($mo, $restype, $resname, $sharetype, $oldstate, $newstate) = @_;
+    executive_resource_shared_mark_ready
+       ($restype, $resname, $sharetype, $oldstate,$newstate);
 }
 
 sub jobdb_check_other_job { #method
index 99c7654dc4170a369c8ee2074511b64db86bd790..7292a329e76abe3872dddc217d614d90d8523f1d 100644 (file)
@@ -3106,11 +3106,11 @@ sub sha256file ($;$) {
     return $truncate ? substr($digest, 0, $truncate) : $digest;
 }
 
-sub host_shared_mark_ready($$) {
-    my ($ho,$sharetype) = @_;
+sub host_shared_mark_ready($$;$$) {
+    my ($ho,$sharetype, $oldstate, $newstate) = @_;
 
     $mjobdb->jobdb_resource_shared_mark_ready('host', $ho->{Name},
-                                              $sharetype);
+        $sharetype, $oldstate, $newstate);
 }
 
 sub gitcache_setup ($) {