All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: ian.jackson@eu.citrix.com
Cc: Jim Fehlig <jfehlig@suse.com>,
	Ian Campbell <ian.campbell@citrix.com>,
	xen-devel@lists.xen.org
Subject: [PATCH OSSTEST v2 08/18] Toolstack: Refactor guest lifecycle.
Date: Tue, 2 Dec 2014 16:04:49 +0000	[thread overview]
Message-ID: <1417536299-1810-8-git-send-email-ian.campbell@citrix.com> (raw)
In-Reply-To: <1417536141.29004.6.camel@citrix.com>

Implement destory/create as per toolstack methods, including implementing the
libvirt version which previously didn't work. To do this we use the virsh
capability to convert an xl/xm style config file into the correct XML.

xend basically calls into the xl helper since they are compatible.

xl/x, uses ->{Command} which will eventually become private.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
---
 Osstest/TestSupport.pm       |  5 ++---
 Osstest/Toolstack/libvirt.pm | 20 ++++++++++++++++++++
 Osstest/Toolstack/xend.pm    |  5 +++++
 Osstest/Toolstack/xl.pm      | 13 +++++++++++++
 ts-guest-saverestore         |  2 +-
 ts-guest-start               |  4 +---
 ts-windows-install           |  7 +------
 7 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 616f7ed..16ab4c6 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -1326,13 +1326,12 @@ sub guest_await_shutdown ($$$) {
 
 sub guest_destroy ($$) {
     my ($ho,$gho) = @_;
-    target_cmd_root($ho, toolstack($ho)->{Command}." destroy $gho->{Name}", 40);
+    toolstack($ho)->destroy($gho);
 }
 
 sub guest_create ($$) {
     my ($ho,$gho) = @_;
-    my $ts= toolstack($ho);
-    target_cmd_root($ho, $ts->{Command}." create $gho->{CfgPath}", 100);
+    toolstack($ho)->create($gho->{CfgPath});
 }
 
 
diff --git a/Osstest/Toolstack/libvirt.pm b/Osstest/Toolstack/libvirt.pm
index 90fe434..ea83995 100644
--- a/Osstest/Toolstack/libvirt.pm
+++ b/Osstest/Toolstack/libvirt.pm
@@ -20,15 +20,35 @@ package Osstest::Toolstack::libvirt;
 use strict;
 use warnings;
 
+use Osstest::TestSupport;
+
 sub new {
     my ($class, $ho, $methname,$asset) = @_;
     return bless { Name => "libvirt",
 		   Host => $ho,
 		   NewDaemons => [qw(libvirtd)],
 		   Dom0MemFixed => 1,
+		   CfgPathVar => 'cfgpath',
 		   Command => 'virsh',
 		   ExtraPackages => [qw(libnl1 libavahi-client3)],
     }, $class;
 }
 
+sub destroy ($$) {
+    my ($self,$gho) = @_;
+    my $gn = $gho->{Name};
+    target_cmd_root($self->{Host}, "virsh destroy $gn", 40);
+}
+
+sub create ($$) {
+    my ($self,$cfg) = @_;
+    my $ho = $self->{Host};
+    my $lcfg = $cfg;
+    $lcfg =~ s,/,-,g;
+    $lcfg = "$ho->{Name}--$lcfg";
+    target_cmd_root($ho, "virsh domxml-from-native xen-xm $cfg > $cfg.xml", 30);
+    target_getfile_root($ho,60,"$cfg.xml", "$stash/$lcfg");
+    target_cmd_root($ho, "virsh create --file $cfg.xml", 100);
+}
+
 1;
diff --git a/Osstest/Toolstack/xend.pm b/Osstest/Toolstack/xend.pm
index 881417d..c921c20 100644
--- a/Osstest/Toolstack/xend.pm
+++ b/Osstest/Toolstack/xend.pm
@@ -19,6 +19,7 @@ package Osstest::Toolstack::xend;
 
 use strict;
 use warnings;
+use Osstest::Toolstack::xl;
 
 sub new {
     my ($class, $ho, $methname,$asset) = @_;
@@ -32,4 +33,8 @@ sub new {
     }, $class;
 }
 
+# Defer to xl driver for most things
+sub destroy { return &Osstest::Toolstack::xl::destroy; }
+sub create { return &Osstest::Toolstack::xl::create; }
+
 1;
diff --git a/Osstest/Toolstack/xl.pm b/Osstest/Toolstack/xl.pm
index 0b66201..12417ca 100644
--- a/Osstest/Toolstack/xl.pm
+++ b/Osstest/Toolstack/xl.pm
@@ -20,6 +20,8 @@ package Osstest::Toolstack::xl;
 use strict;
 use warnings;
 
+use Osstest::TestSupport;
+
 sub new {
     my ($class, $ho, $methname,$asset) = @_;
     return bless { Name => "xl",
@@ -32,4 +34,15 @@ sub new {
     }, $class;
 }
 
+sub destroy ($$) {
+    my ($self,$gho) = @_;
+    my $gn = $gho->{Name};
+    target_cmd_root($self->{Host}, $self->{Command}." destroy $gn", 40);
+}
+
+sub create ($$) {
+    my ($self,$cfg) = @_;
+    target_cmd_root($self->{Host}, $self->{Command}." create $cfg", 100);
+}
+
 1;
diff --git a/ts-guest-saverestore b/ts-guest-saverestore
index 9e04ae9..8911aed 100755
--- a/ts-guest-saverestore
+++ b/ts-guest-saverestore
@@ -38,7 +38,7 @@ sub restore () {
 		    toolstack($ho)->{Command}
 		    ." restore "
 		    .(toolstack($ho)->{RestoreNeedsConfig} ?
-		      $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} } : '')
+		      $gho->{CfgPath} : '')
 		    ." image", 200);
     target_ping_check_up($gho);
 }
diff --git a/ts-guest-start b/ts-guest-start
index bfbb734..fb6a174 100755
--- a/ts-guest-start
+++ b/ts-guest-start
@@ -26,9 +26,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV);
 
 sub start () {
     guest_umount_lv($ho, $gho);
-    my $cmd= toolstack($ho)->{Command}." create ".
-        $r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} };
-    target_cmd_root($ho, $cmd, 30);
+    toolstack($ho)->create($r{ $gho->{Guest}.'_'. toolstack($ho)->{CfgPathVar} });
 }
 
 sub checkstart () {
diff --git a/ts-windows-install b/ts-windows-install
index 4b06310..f12a4f4 100755
--- a/ts-windows-install
+++ b/ts-windows-install
@@ -49,13 +49,8 @@ END
     store_runvar("$gho->{Guest}_pingbroken", 1);
 }
 
-sub start () {
-    target_cmd_root($ho, toolstack($ho)->{Command}.
-                    " create $gho->{CfgPath}", 100);
-}
-
 prep();
-start();
+guest_create($ho,$gho);
 
 guest_await_dhcp_tcp($gho,7000);
 guest_check_up($gho);
-- 
2.1.1

  parent reply	other threads:[~2014-12-02 16:04 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-02 16:02 [PATCH v2 OSSTEST 0/18] Implement for driving libvirt via virsh Ian Campbell
2014-12-02 16:04 ` [PATCH OSSTEST v2 01/18] apt: lock osstest's usages of apt-get against each other Ian Campbell
2015-01-20 18:19   ` Ian Jackson
2015-01-21 11:29     ` Ian Campbell
2015-01-21 12:13       ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 02/18] ts-logs-capture: Collect some libvirt logs and capabilities Ian Campbell
2015-01-20 18:20   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 03/18] Pass host to toolstack() Ian Campbell
2015-01-20 18:21   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 04/18] ts-rumpuserxen-demo-xenstorels: Use standard functions for things Ian Campbell
2015-01-20 18:22   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 05/18] Toolstack: use get_host_method_object() to manage toolstack selection Ian Campbell
2015-01-20 18:23   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 06/18] TestSupport: always use xl for generic operations Ian Campbell
2015-01-20 18:26   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 07/18] TestSupport: guest_create takes a $ho Ian Campbell
2015-01-20 18:27   ` Ian Jackson
2014-12-02 16:04 ` Ian Campbell [this message]
2015-01-13 16:16   ` [PATCH OSSTEST v2 08/18] Toolstack: Refactor guest lifecycle Ian Campbell
2015-01-14 17:01     ` Ian Jackson
2015-01-20 18:32   ` Ian Jackson
2015-01-21 15:59     ` Ian Campbell
2015-01-21 16:28       ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 09/18] Toolstack: Refactor consolecmd handling Ian Campbell
2015-01-20 18:34   ` Ian Jackson
2015-01-22 11:24     ` Ian Campbell
2015-01-22 11:26       ` Ian Campbell
2015-01-22 14:35         ` Ian Campbell
2015-01-22 14:41           ` Ian Jackson
2015-01-22 14:42             ` Ian Campbell
2015-01-22 15:15               ` Ian Jackson
2015-01-22 15:17                 ` Ian Campbell
2014-12-02 16:04 ` [PATCH OSSTEST v2 10/18] Toolstack: Refactor shutdown support Ian Campbell
2015-01-20 18:35   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 11/18] Toolstack: Refactor migration support check Ian Campbell
2015-01-20 18:45   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 12/18] Toolstack: Refactor migration support Ian Campbell
2015-01-20 18:38   ` Ian Jackson
2015-01-22 15:06     ` Ian Campbell
2015-01-22 15:17       ` Ian Jackson
2015-01-22 15:19         ` Ian Campbell
2015-01-22 15:38           ` Ian Jackson
2015-01-22 16:11           ` Ian Campbell
2014-12-02 16:04 ` [PATCH OSSTEST v2 13/18] Toolstack: Refactor save/restore support Ian Campbell
2015-01-20 18:41   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 14/18] libvirt: Implement initscript restart which has some hope of working Ian Campbell
2015-01-20 18:37   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 15/18] libvirt: Implement shutdown_wait Ian Campbell
2015-01-20 18:44   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 16/18] Toolstack: Remove Command field for all toolstacks Ian Campbell
2015-01-20 18:39   ` Ian Jackson
2015-01-21 11:49     ` Ian Campbell
2015-01-21 12:14       ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 17/18] ts-guest-start: Use guest_create Ian Campbell
2015-01-20 18:46   ` Ian Jackson
2014-12-02 16:04 ` [PATCH OSSTEST v2 18/18] WIP: libvirt: migration + save/restore support Ian Campbell
2014-12-13 16:06   ` Wei Liu
2015-01-20 18:49   ` Ian Jackson
2015-01-21  5:42     ` Jim Fehlig
2015-01-21  9:48       ` Ian Campbell
2015-01-21 11:36         ` [PATCH OSSTEST v2 18/18] WIP: libvirt: migration + save/restore support. [and 1 more messages] Ian Jackson
2015-01-21 15:05           ` Jim Fehlig

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=1417536299-1810-8-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jfehlig@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.