From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: [PATCH OSSTEST v2 01/13] toolstack: save / restore check Date: Sun, 12 Jul 2015 17:20:24 +0100 Message-ID: <1436718036-7985-2-git-send-email-wei.liu2@citrix.com> References: <1436718036-7985-1-git-send-email-wei.liu2@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ZEJzg-0002W5-4n for xen-devel@lists.xenproject.org; Sun, 12 Jul 2015 16:20:44 +0000 In-Reply-To: <1436718036-7985-1-git-send-email-wei.liu2@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: ian.jackson@eu.citrix.com, Wei Liu , ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org Introduce _$TOOLSTACK_check_for_command function and use it to check save / restore functionality. Signed-off-by: Wei Liu Cc: Ian Campbell Cc: Ian Jackson --- v2: introduce $TOOLSTACK_check_for_command function. --- Osstest/Toolstack/libvirt.pm | 14 ++++++++++++++ Osstest/Toolstack/xend.pm | 3 +++ Osstest/Toolstack/xl.pm | 16 +++++++++++++--- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Osstest/Toolstack/libvirt.pm b/Osstest/Toolstack/libvirt.pm index 51a10de..592cfa2 100644 --- a/Osstest/Toolstack/libvirt.pm +++ b/Osstest/Toolstack/libvirt.pm @@ -77,6 +77,20 @@ sub migrate_check ($) { die "Migration check is not yet supported on libvirt."; } +sub _libvirt_check_for_command($$) { + my ($self,$cmd) = @_; + my $ho = $self->{Host}; + my $help = target_cmd_output_root($ho, "virsh help"); + my $rc = ($help =~ m/^\s*$cmd/m) ? 0 : 1; + logm("rc=$rc"); + return $rc; +} + +sub saverestore_check ($) { + my ($self) = @_; + return _libvirt_check_for_command($self, "save"); +} + sub migrate ($) { my ($self,$gho,$dst,$timeout) = @_; die "Migration is not yet supported on libvirt."; diff --git a/Osstest/Toolstack/xend.pm b/Osstest/Toolstack/xend.pm index 972b3b1..fd54ae1 100644 --- a/Osstest/Toolstack/xend.pm +++ b/Osstest/Toolstack/xend.pm @@ -38,4 +38,7 @@ sub new { # xend always supported migration sub migrate_check ($) { return 0; } +# xend always supported save / restore +sub saverestore_check ($) { return 0; } + 1; diff --git a/Osstest/Toolstack/xl.pm b/Osstest/Toolstack/xl.pm index 3c3d348..440d9d0 100644 --- a/Osstest/Toolstack/xl.pm +++ b/Osstest/Toolstack/xl.pm @@ -61,15 +61,25 @@ sub shutdown_wait ($$$) { target_cmd_root($ho,"$self->{_Command} shutdown -w${acpi_fallback} $gn", $timeout); } -sub migrate_check ($) { - my ($self) = @_; +sub _xl_check_for_command($$) { + my ($self,$cmd) = @_; my $ho = $self->{Host}; my $help = target_cmd_output_root($ho, $self->{_Command}." help"); - my $rc = ($help =~ m/^\s*migrate/m) ? 0 : 1; + my $rc = ($help =~ m/^\s*$cmd/m) ? 0 : 1; logm("rc=$rc"); return $rc; } +sub migrate_check ($) { + my ($self) = @_; + return _xl_check_for_command($self, "migrate"); +} + +sub saverestore_check ($) { + my ($self) = @_; + return _xl_check_for_command($self, "save"); +} + sub migrate ($$$$) { my ($self,$gho,$dho,$timeout) = @_; my $sho = $self->{Host}; -- 1.9.1