Skip to content

Commit

Permalink
[#493] Ping the VM and reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Nov 28, 2017
1 parent 0c17e3f commit 11cd08f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/Ravada/Front.pm
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,13 @@ sub open_vm {
my $type = shift or confess "I need vm type";
my $class = "Ravada::VM::$type";

if ($VM{$type}) {
return $VM{$type}
if (my $vm = $VM{$type}) {
if (!$vm->ping) {
$vm->disconnect();
$vm->connect();
} else {
return $vm;
}
}

my $proto = {};
Expand Down
1 change: 1 addition & 0 deletions lib/Ravada/VM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ requires 'connect';
requires 'disconnect';
requires 'import_domain';

requires 'ping';
############################################################

has 'host' => (
Expand Down
7 changes: 7 additions & 0 deletions lib/Ravada/VM/KVM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1793,4 +1793,11 @@ sub import_domain {
return $domain;
}
sub ping($self) {
return 0 if !$self->vm;
eval { $self->vm->list_defined_networks };
return 1 if !$@;
return 0;
}
1;
4 changes: 4 additions & 0 deletions lib/Ravada/VM/Void.pm
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ sub import_domain {
confess "Not implemented";
}

sub refresh_storage {}

sub ping { return 1 }

#########################################################################3

1;

0 comments on commit 11cd08f

Please sign in to comment.