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

[Xen-devel] [OSSTEST PATCH [RFC] 3/3] ts-guest-start, -stop, -destroy: support multiple guests



so that now, for example, this is possible:

$ OSSTEST_JOB=test-amd64-amd64-xl
$ export OSSTEST_JOB
$ ./ts-debian-install host=tg03 debian1 debian2 debian3
$ ./ts-debian-fixup host=tg03 debian1 debian2 debian3

$ ./ts-guest-start host=tg03 debian1 debian2 debian3
$ ./ts-guest-stop host=tg03 debian1 debian2
$ ./ts-guest-destroy host=tg03 debian3

This again assumes that either the host is explicitly specified
via a 'host=somehost' first argument, or the arguments are all
guest names.

Signed-off-by: Dario Faggioli <dario.faggioli@xxxxxxxxxx>
---
 ts-guest-destroy |   28 +++++++++++++++++++++-------
 ts-guest-start   |   35 +++++++++++++++++++++++++----------
 ts-guest-stop    |   30 ++++++++++++++++++++++--------
 3 files changed, 68 insertions(+), 25 deletions(-)

diff --git a/ts-guest-destroy b/ts-guest-destroy
index 738650a..794f38d 100755
--- a/ts-guest-destroy
+++ b/ts-guest-destroy
@@ -22,13 +22,27 @@ use Osstest::TestSupport;
 
 tsreadconfig();
 
-our ($ho,$gho) = ts_get_host_guest(@ARGV);
+our $whhost = 'host';
+if (@ARGV && ($ARGV[0] =~ m/^host=.*$/ || $ARGV[0] eq 'host')) {
+    $whhost = $ARGV[0];
+    shift @ARGV;
+}
+our (@guests) = @ARGV;
+
+our ($ho,%gho);
 
-sub destroy () {
-    guest_destroy($ho, $gho);
-    guest_checkrunning($ho, $gho) and die $gho->{Name};
+sub destroy ($) {
+    my ($gn) = @_;
+    guest_destroy($ho, $gho{$gn});
+    guest_checkrunning($ho, $gho{$gn}) and die $gho{$gn}->{Name};
 }
 
-guest_await_dhcp_tcp($gho, 5);
-destroy();
-target_ping_check_down($gho);
+# Let's first destroy all domains and then check they're gone
+foreach my $g (@guests) {
+    ($ho,$gho{$g}) = ts_get_host_guest($whhost, $g);
+    guest_await_dhcp_tcp($gho{$g}, 5);
+    destroy($g);
+}
+foreach my $g (@guests) {
+    target_ping_check_down($gho{$g});
+}
diff --git a/ts-guest-start b/ts-guest-start
index 057afe6..410f5fd 100755
--- a/ts-guest-start
+++ b/ts-guest-start
@@ -22,20 +22,35 @@ use Osstest::TestSupport;
 
 tsreadconfig();
 
-our ($ho,$gho) = ts_get_host_guest(@ARGV);
+our $whhost = 'host';
+if (@ARGV && ($ARGV[0] =~ m/^host=.*$/ || $ARGV[0] eq 'host')) {
+    $whhost = $ARGV[0];
+    shift @ARGV;
+}
+our (@guests) = @ARGV;
+
+our ($ho,%gho);
 
-sub start () {
-    guest_umount_lv($ho, $gho);
+sub start ($) {
+    my ($gn) = @_;
+    guest_umount_lv($ho, $gho{$gn});
     my $cmd= toolstack()->{Command}." create ".
-        $r{ $gho->{Guest}.'_'. toolstack()->{CfgPathVar} };
+        $r{ $gho{$gn}->{Guest}.'_'. toolstack()->{CfgPathVar} };
     target_cmd_root($ho, $cmd, 30);
 }
 
-sub checkstart () {
-    guest_checkrunning($ho, $gho) or die "$gho->{Name} not running";
+sub checkstart ($) {
+    my ($gn) = @_;
+    guest_checkrunning($ho, $gho{$gn}) or die "$gho{$gn}->{Name} not running";
 }
 
-start();
-checkstart();
-guest_await($gho, target_var($gho,'boot_timeout'));
-guest_check_up($gho);
+# Let's first ask all domains to start and then check they're all actually up
+foreach my $g (@guests) {
+    ($ho,$gho{$g}) = ts_get_host_guest($whhost, $g);
+    start($g);
+    checkstart($g);
+}
+foreach my $g (@guests) {
+    guest_await($gho{$g}, target_var($gho{$g},'boot_timeout'));
+    guest_check_up($gho{$g});
+}
diff --git a/ts-guest-stop b/ts-guest-stop
index cc7db4c..a4fddf4 100755
--- a/ts-guest-stop
+++ b/ts-guest-stop
@@ -22,17 +22,31 @@ use Osstest::TestSupport;
 
 tsreadconfig();
 
-our ($ho,$gho) = ts_get_host_guest(@ARGV);
+our $whhost = 'host';
+if (@ARGV && ($ARGV[0] =~ m/^host=.*$/ || $ARGV[0] eq 'host')) {
+    $whhost = $ARGV[0];
+    shift @ARGV;
+}
+our (@guests) = @ARGV;
+
+our ($ho,%gho);
 
-sub stop () {
-    guest_checkrunning($ho, $gho) or die "$gho->{Name} not running";
+sub stop ($) {
+    my ($gn) = @_;
+    guest_checkrunning($ho, $gho{$gn}) or die "$gho{$gn}->{Name} not running";
     target_cmd_root($ho,
                    toolstack()->{Command}
                    ." shutdown -w "
-                   .$gho->{Name}, 200);
-    guest_checkrunning($ho, $gho) and die $gho->{Name};
+                   .$gho{$gn}->{Name}, 200);
+    guest_checkrunning($ho, $gho{$gn}) and die $gho{$gn}->{Name};
 }
 
-guest_await_dhcp_tcp($gho, 5);
-stop();
-target_ping_check_down($gho);
+# Let's first ask all domains to stop and then check they're down
+foreach my $g (@guests) {
+    ($ho,$gho{$g}) = ts_get_host_guest($whhost, $g);
+    guest_await_dhcp_tcp($gho{$g}, 5);
+    stop($g);
+}
+foreach my $g (@guests) {
+    target_ping_check_down($gho{$g});
+}


_______________________________________________
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®.