Commit d26e6d94 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

fixed shutdown request takes forever

parent 54c1c93e
......@@ -202,7 +202,7 @@ sub search_domain {
for my $vm (@{$self->vm}) {
my $domain = $vm->search_domain($name, $import);
next if !$domain;
warn "found domain $name";
next if !$domain->_select_domain_db && !$import;
my $id;
eval { $id = $domain->id };
# TODO import the domain in the database with an _insert_db or something
......@@ -565,12 +565,13 @@ sub _cmd_shutdown {
$request->status('working');
my $name = $request->args('name');
my $timeout = ($request->args('timeout') or 60);
my $domain;
eval {
my $domain = $self->search_domain($name);
$domain = $self->search_domain($name);
die "Unknown domain '$name'\n" if !$domain;
$domain->shutdown();
$domain->shutdown(timeout => $timeout);
};
sleep(60000);
$request->status('done');
$request->error($@);
......
......@@ -148,7 +148,8 @@ sub start_domain {
Requests to stop a domain
my $req = Ravada::Request->shutdown_domain( name => 'name' );
my $req = Ravada::Request->shutdown_domain( 'name' );
my $req = Ravada::Request->shutdown_domain( 'name' , $timeout );
=cut
......@@ -159,11 +160,13 @@ sub shutdown_domain {
my $name = shift;
$name = $name->name if ref($name) =~ /Domain/;
my %args = ( name => $name ) or confess "Missing domain name";
my $timeout = ( shift or 10 );
my %args = ( name => $name, timeout => $timeout ) or confess "Missing domain name";
my $self = {};
bless($self,$class);
return $self->_new_request(command => 'shutdown' , args => encode_json({ name => $name }));
return $self->_new_request(command => 'shutdown' , args => encode_json(\%args));
}
=head2 prepare_base
......
......@@ -112,6 +112,8 @@ sub test_start {
my $domain3 = $RAVADA->search_domain($name);
ok(!$domain3->is_active);
return $domain3;
}
sub remove_old_domains {
my ($name) = $0 =~ m{.*/(.*)\.t};
......@@ -159,7 +161,10 @@ SKIP: {
remove_old_domains();
remove_old_disks();
test_start();
my $domain = test_start();
$domain->shutdown_now();
$domain->remove();
};
done_testing();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment