[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH OSSTEST v2 01/13] toolstack: save / restore check



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 <wei.liu2@xxxxxxxxxx>
> Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
> ---
> 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};



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.