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
4ff5fb5f
Commit
4ff5fb5f
authored
Mar 15, 2020
by
Francesc Guasch
Browse files
refactor(backend): fast search already started
issue #1265
parent
d3e5fed0
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/Ravada/Domain.pm
View file @
4ff5fb5f
...
...
@@ -316,7 +316,8 @@ sub _start_preconditions{
}
#_check_used_memory(@_);
return
if
$self
->
_search_already_started
();
return
if
$self
->
_search_already_started
('
fast
');
$self
->
status
('
starting
');
# if it is a clone ( it is not a base )
if
(
$self
->
id_base
)
{
# $self->_set_last_vm(1)
...
...
@@ -349,10 +350,10 @@ sub _start_preconditions{
#$self->_check_cpu_usage($request);
}
sub
_search_already_started
($self) {
my
$s
th
=
$$CONNECTOR
->
dbh
->
prepare
(
"
SELECT id FROM vms where vm_type=?
"
);
sub
_search_already_started
($self
, $fast = 0
) {
my
$s
ql
=
"
SELECT id FROM vms where vm_type=?
";
$sql
.=
"
AND is_active=1
"
if
$fast
;
my
$sth
=
$$CONNECTOR
->
dbh
->
prepare
(
$sql
);
$sth
->
execute
(
$self
->
_vm
->
type
);
my
%started
;
while
(
my
(
$id
)
=
$sth
->
fetchrow
)
{
...
...
@@ -876,7 +877,7 @@ sub _around_display_info($orig,$self,$user ) {
if
(
!
$self
->
readonly
)
{
$self
->
_set_display_ip
(
$display
);
$self
->
_data
(
display
=>
encode_json
(
$display
));
$self
->
_data
(
display
=>
encode_json
(
$display
))
if
$self
->
is_active
;
}
return
$display
;
}
...
...
@@ -3367,7 +3368,7 @@ sub set_driver_id {
$sth
->
finish
;
}
sub
_listen_ip
($self, $remote_ip) {
sub
_listen_ip
($self, $remote_ip
=undef
) {
return
$self
->
_vm
->
listen_ip
(
$remote_ip
);
}
...
...
lib/Ravada/VM.pm
View file @
4ff5fb5f
...
...
@@ -636,6 +636,8 @@ sub _interface_ip($self, $remote_ip=undef) {
my
(
$network
,
$ip
)
=
(
$
1
,
$
2
);
$route
{
$network
}
=
$ip
;
return
$ip
if
$remote_ip
&&
$remote_ip
eq
$ip
;
my
$netaddr
=
NetAddr::
IP
->
new
(
$network
);
return
$ip
if
$remote_ip_addr
->
within
(
$netaddr
);
...
...
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