[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH OSSTEST v3 02/19] TestSupport: Add helper to wait for a guest to shutdown



Refactor the guts of guest_await_reboot into a helper and use for both
shutdown and reboot handling.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
v3: Refactor common code with guest_await_reboot.
---
 Osstest/TestSupport.pm | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 477ad18..c0325c4 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -93,7 +93,8 @@ BEGIN {
                       guest_umount_lv guest_await guest_await_dhcp_tcp
                       guest_checkrunning guest_check_ip guest_find_ether
                       guest_find_domid guest_check_up guest_check_up_quick
-                      guest_get_state guest_await_reboot guest_destroy
+                      guest_get_state guest_await_reboot
+                      guest_await_shutdown guest_destroy
                       guest_vncsnapshot_begin guest_vncsnapshot_stash
                      guest_check_remus_ok guest_editconfig
                       host_involves_pcipassthrough host_get_pcipassthrough_devs
@@ -1278,17 +1279,28 @@ sub report_once ($$$) {
     $ho->{$k}= $msg;
 }
 
-sub guest_await_reboot ($$$) {
-    my ($ho,$gho, $timeout) = @_;
-    poll_loop($timeout, 30, "await reboot request from $gho->{Guest}", sub {
+sub guest_await_state ($$$$$) {
+    my ($ho,$gho, $what,$wait_st,$timeout) = @_;
+
+    poll_loop($timeout, 30, "await $what request from $gho->{Guest}", sub {
         my $st= guest_get_state($ho,$gho);
-        return undef if $st eq 'sr';
+        return undef if $st eq $wait_st;
         fail("guest unexpectedly shutdown; state is '$st'")
             if $st =~ m/^s/ || $st eq '';
-        return "guest state is $st";
+        return "guest state is \"$st\"";
     });
 }
 
+sub guest_await_reboot ($$$) {
+    my ($ho,$gho, $timeout) = @_;
+    return guest_await_state($ho,$gho, "reboot", "sr", $timeout);
+}
+
+sub guest_await_shutdown ($$$) {
+    my ($ho,$gho, $timeout) = @_;
+    return guest_await_state($ho,$gho, "shutdown", "s", $timeout);
+}
+
 sub guest_destroy ($$) {
     my ($ho,$gho) = @_;
     target_cmd_root($ho, toolstack()->{Command}." destroy $gho->{Name}", 40);
-- 
2.1.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.