Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
d26e6d94
Commit
d26e6d94
authored
Jul 15, 2016
by
Francesc Guasch
Browse files
fixed shutdown request takes forever
parent
54c1c93e
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/Ravada.pm
View file @
d26e6d94
...
...
@@ -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
(
$@
);
...
...
lib/Ravada/Request.pm
View file @
d26e6d94
...
...
@@ -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
...
...
t/35_request_start.t
View file @
d26e6d94
...
...
@@ -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
();
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment