xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dario.faggioli@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>
Subject: [OSSTEST PATCH [RFC] 3/3] ts-guest-start, -stop, -destroy: support multiple guests
Date: Thu, 5 Dec 2013 15:10:10 +0000	[thread overview]
Message-ID: <20131205151009.20194.9013.stgit@drall.uk.xensource.com> (raw)
In-Reply-To: <20131205150935.20194.10427.stgit@drall.uk.xensource.com>

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@citrix.com>
---
 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});
+}

  parent reply	other threads:[~2013-12-05 15:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-05 15:09 [OSSTEST PATCH [RFC] 0/3] Series short description Dario Faggioli
2013-12-05 15:09 ` [OSSTEST PATCH [RFC] 1/3] ts-debian-install: support for installing multiple guests Dario Faggioli
2013-12-05 15:10 ` [OSSTEST PATCH [RFC] 2/3] ts-debian-fixup: support " Dario Faggioli
2013-12-05 15:10 ` Dario Faggioli [this message]
2013-12-05 15:25 ` [OSSTEST PATCH [RFC] 0/3] Series short description Ian Jackson
2013-12-05 16:17   ` Dario Faggioli
2013-12-05 17:34     ` Ian Jackson
2013-12-06  9:23       ` Dario Faggioli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131205151009.20194.9013.stgit@drall.uk.xensource.com \
    --to=dario.faggioli@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).