Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
2744a722
Commit
2744a722
authored
Oct 26, 2016
by
Francesc Guasch
Browse files
[#8] enforce minimal disk and memory size on creation
parent
a582b061
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/Ravada/VM.pm
View file @
2744a722
...
...
@@ -53,7 +53,7 @@ has 'readonly' => (
# Method Modifiers
#
#
before
'
create_domain
'
=>
\
&_check_rea
donly
;
before
'
create_domain
'
=>
\
&_check_
c
rea
te_domain
;
sub
_check_readonly
{
my
$self
=
shift
;
...
...
@@ -159,4 +159,30 @@ sub ip {
return
'
127.0.0.1
';
}
sub
_check_memory
{
my
$self
=
shift
;
my
%args
=
@_
;
return
if
!
exists
$args
{
memory
};
die
"
ERROR: Low memory '
$args
{memory}' required 128 Mb
"
if
$args
{
memory
}
<
128
*
1024
;
}
sub
_check_disk
{
my
$self
=
shift
;
my
%args
=
@_
;
return
if
!
exists
$args
{
disk
};
die
"
ERROR: Low Disk '
$args
{disk}' required 1 Gb
"
if
$args
{
disk
}
<
1024
*
1024
;
}
sub
_check_create_domain
{
my
$self
=
shift
;
$self
->
_check_readonly
(
@
_
);
$self
->
_check_memory
(
@
_
);
$self
->
_check_disk
(
@
_
);
}
1
;
lib/Ravada/VM/KVM.pm
View file @
2744a722
...
...
@@ -245,6 +245,8 @@ sub create_volume {
if
(
$size
)
{
my
(
$prev_size
)
=
$doc
->
findnodes
('
/volume/capacity/text()
')
->
[
0
]
->
getData
();
confess
"
Size '
$size
' too small
"
if
$size
<
1024
*
512
;
warn
"
Creating a disk
"
.
int
(
$prev_size
/(1024*1024*1024))." -> ".int($size/
(
1024
*
1024
*
1024
));
$doc
->
findnodes
('
/volume/allocation/text()
')
->
[
0
]
->
setData
(
int
(
$size
*
0.9
));
$doc
->
findnodes
('
/volume/capacity/text()
')
->
[
0
]
->
setData
(
$size
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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