From patchwork Tue Jun 17 15:26:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 32063 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C965A206A0 for ; Tue, 17 Jun 2014 15:27:49 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id y20sf42667245ier.9 for ; Tue, 17 Jun 2014 08:27:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=eRxjg2iLX2LlnW4Fy7LUsrbDFuXg0KICVOcag+TF0Yw=; b=Y9ufyNNDz4qjFvm3ii//687Mq5tE8UYlAZgbEimZcWIom/BT5qWQUxbPmO2iSYopWU taoJ8CVp9t0h8CpgK02qEPhLbvKkiP97aXjUZYRLOgW9FqaZYwL21bcmnp+v1YTnhWFI jxDUy+XUKhUbLuxpogeg2RFEe5drSlbEq2r0hWSIphyCOxdbt0mDKA959uEQY6dD2EVd WoyphVvz8fLRbY8qyCBH2LCwPSHA1nshp8oHdh3gMwRTZcBBrqK6uYQ00Vl2I8s52LC9 +Tov6F3ljF7v739/5/DOHLlRqFsVLcA2Fob8szuY8AaC7XI8bapVeyXhth1OPVZBFNdN zsFQ== X-Gm-Message-State: ALoCoQmLNQSnZdLwGBBybRPLsXr8cyc1cux4l+Kxj7HkjCzIrEVGcINj0YgRxkj8YYsuPiwHB9Zk X-Received: by 10.42.229.194 with SMTP id jj2mr1029366icb.18.1403018869186; Tue, 17 Jun 2014 08:27:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.229 with SMTP id j92ls4715335qgf.14.gmail; Tue, 17 Jun 2014 08:27:49 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr9199563vcb.28.1403018869045; Tue, 17 Jun 2014 08:27:49 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id qk6si5593387vdb.68.2014.06.17.08.27.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Jun 2014 08:27:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id il7so6606398vcb.13 for ; Tue, 17 Jun 2014 08:27:49 -0700 (PDT) X-Received: by 10.52.93.201 with SMTP id cw9mr793280vdb.80.1403018868962; Tue, 17 Jun 2014 08:27:48 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp217964vcb; Tue, 17 Jun 2014 08:27:48 -0700 (PDT) X-Received: by 10.53.2.129 with SMTP id bo1mr796545vdd.77.1403018868634; Tue, 17 Jun 2014 08:27:48 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id u4si5607290vcs.52.2014.06.17.08.27.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 17 Jun 2014 08:27:48 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwvHN-0005rV-Nc; Tue, 17 Jun 2014 15:26:33 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WwvHL-0005qM-Rx for xen-devel@lists.xen.org; Tue, 17 Jun 2014 15:26:32 +0000 Received: from [193.109.254.147:8694] by server-3.bemta-14.messagelabs.com id CD/49-22179-72E50A35; Tue, 17 Jun 2014 15:26:31 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1403018788!11897229!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19781 invoked from network); 17 Jun 2014 15:26:30 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-12.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 17 Jun 2014 15:26:30 -0000 X-IronPort-AV: E=Sophos;i="5.01,494,1400025600"; d="scan'208";a="144521693" Received: from accessns.citrite.net (HELO FTLPEX01CL02.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 17 Jun 2014 15:26:29 +0000 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.79) with Microsoft SMTP Server id 14.3.181.6; Tue, 17 Jun 2014 11:26:28 -0400 Received: from kazak.uk.xensource.com ([10.80.2.80] helo=kazak.uk.xensource.com.) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1WwvHH-00010a-MH; Tue, 17 Jun 2014 16:26:27 +0100 From: Ian Campbell To: Date: Tue, 17 Jun 2014 16:26:24 +0100 Message-ID: <1403018787-25442-6-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1403018758.25074.5.camel@kazak.uk.xensource.com>#> References: <1403018758.25074.5.camel@kazak.uk.xensource.com>#> MIME-Version: 1.0 X-DLP: MIA2 Cc: Ian Campbell , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH RFC OSSTEST 6/9] Toolstack: Refactor guest lifecycle. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: 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. Signed-off-by: Ian Campbell --- Osstest/TestSupport.pm | 5 ++--- Osstest/Toolstack/libvirt.pm | 19 +++++++++++++++++++ Osstest/Toolstack/xend.pm | 4 ++++ Osstest/Toolstack/xl.pm | 10 ++++++++++ ts-guest-saverestore | 2 +- ts-guest-start | 4 +--- ts-windows-install | 7 +------ 7 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index 1444629..e93687b 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -1274,13 +1274,12 @@ sub guest_await_reboot ($$$) { sub guest_destroy ($$) { my ($ho,$gho) = @_; - target_cmd_root($ho, toolstack($ho)->{Command}." destroy $gho->{Name}", 40); + toolstack($ho)->destroy($gho->{Name}); } 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..c1d2b09 100644 --- a/Osstest/Toolstack/libvirt.pm +++ b/Osstest/Toolstack/libvirt.pm @@ -20,15 +20,34 @@ 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,$gn) = @_; + 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..4f093bc 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,7 @@ sub new { }, $class; } +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..ca46094 100644 --- a/Osstest/Toolstack/xl.pm +++ b/Osstest/Toolstack/xl.pm @@ -32,4 +32,14 @@ sub new { }, $class; } +sub destroy ($$) { + my ($self,$gn) = @_; + 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);