Skip to content

Commit 11cd08f

Browse files
committed
[#493] Ping the VM and reconnect
1 parent 0c17e3f commit 11cd08f

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

lib/Ravada/Front.pm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,13 @@ sub open_vm {
485485
my $type = shift or confess "I need vm type";
486486
my $class = "Ravada::VM::$type";
487487

488-
if ($VM{$type}) {
489-
return $VM{$type}
488+
if (my $vm = $VM{$type}) {
489+
if (!$vm->ping) {
490+
$vm->disconnect();
491+
$vm->connect();
492+
} else {
493+
return $vm;
494+
}
490495
}
491496

492497
my $proto = {};

lib/Ravada/VM.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ requires 'connect';
4444
requires 'disconnect';
4545
requires 'import_domain';
4646

47+
requires 'ping';
4748
############################################################
4849

4950
has 'host' => (

lib/Ravada/VM/KVM.pm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,4 +1793,11 @@ sub import_domain {
17931793
return $domain;
17941794
}
17951795
1796+
sub ping($self) {
1797+
return 0 if !$self->vm;
1798+
eval { $self->vm->list_defined_networks };
1799+
return 1 if !$@;
1800+
return 0;
1801+
}
1802+
17961803
1;

lib/Ravada/VM/Void.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ sub import_domain {
148148
confess "Not implemented";
149149
}
150150

151+
sub refresh_storage {}
152+
153+
sub ping { return 1 }
154+
151155
#########################################################################3
152156

153157
1;

0 commit comments

Comments
 (0)