From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH OSSTEST v2 01/13] toolstack: save / restore check Date: Mon, 13 Jul 2015 12:09:23 +0100 Message-ID: <1436785763.7019.97.camel@citrix.com> References: <1436718036-7985-1-git-send-email-wei.liu2@citrix.com> <1436718036-7985-2-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 1ZEbcB-0002VP-Rn for xen-devel@lists.xenproject.org; Mon, 13 Jul 2015 11:09:39 +0000 In-Reply-To: <1436718036-7985-2-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: Wei Liu Cc: Xen-devel , ian.jackson@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Sun, 2015-07-12 at 17:20 +0100, Wei Liu wrote: > Introduce _$TOOLSTACK_check_for_command function and use it to check > save / restore functionality. The _$TOOLSTACK_ prefix is not necessary IMHO, this is already within a Perl module named $TOOLSTACK.pm (which you can think of as a class in the OOP sense). (It seems like a Python-ism to me). IOW I think just check_for_command would be fine. I don't think it needs to be made private either, which would involve a bit more infrastructure than is worthwhile IMHO. > > 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};