Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
8350ac00
Commit
8350ac00
authored
Nov 17, 2011
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement openvz migrate
parent
c0ef5e6a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
131 additions
and
20 deletions
+131
-20
OpenVZ.pm
PVE/API2/OpenVZ.pm
+80
-5
OpenVZ.pm
PVE/OpenVZ.pm
+18
-0
Makefile
www/manager/Makefile
+2
-2
Config.js
www/manager/openvz/Config.js
+14
-1
Config.js
www/manager/qemu/Config.js
+6
-3
Migrate.js
www/manager/window/Migrate.js
+11
-9
No files found.
PVE/API2/OpenVZ.pm
View file @
8350ac00
...
...
@@ -9,6 +9,8 @@ use Cwd 'abs_path';
use
PVE::
SafeSyslog
;
use
PVE::
Tools
qw(extract_param run_command)
;
use
PVE::
Exception
qw(raise raise_param_exc)
;
use
PVE::
INotify
;
use
PVE::
Cluster
qw(cfs_lock_file cfs_read_file)
;
use
PVE::
Storage
;
use
PVE::
RESTHandler
;
...
...
@@ -372,7 +374,7 @@ __PACKAGE__->register_method({
PVE::Cluster::
log_msg
('
info
',
$user
,
"
update CT
$vmid
:
"
.
join
('
',
@$changes
));
PVE::Tools::
run_command
(
$cmd
);
run_command
(
$cmd
);
};
PVE::OpenVZ::
lock_container
(
$vmid
,
$code
);
...
...
@@ -681,7 +683,7 @@ __PACKAGE__->register_method({
my
$realcmd
=
sub
{
my
$cmd
=
['
vzctl
',
'
destroy
',
$vmid
];
PVE::Tools::
run_command
(
$cmd
);
run_command
(
$cmd
);
};
return
$rpcenv
->
fork_worker
('
vzdestroy
',
$vmid
,
$user
,
$realcmd
);
...
...
@@ -756,7 +758,7 @@ __PACKAGE__->register_method ({
'
-timeout
',
$timeout
,
'
-authpath
',
"
/vms/
$vmid
",
'
-perm
',
'
VM.Console
',
'
-c
',
@$remcmd
,
@$shcmd
];
PVE::Tools::
run_command
(
$cmd
);
run_command
(
$cmd
);
return
;
};
...
...
@@ -913,7 +915,9 @@ __PACKAGE__->register_method({
my
$cmd
=
['
vzctl
',
'
start
',
$vmid
];
PVE::Tools::
run_command
(
$cmd
);
run_command
(
$cmd
);
return
;
};
return
$rpcenv
->
fork_worker
('
vzstart
',
$vmid
,
$user
,
$realcmd
);
...
...
@@ -961,7 +965,7 @@ __PACKAGE__->register_method({
push
@$cmd
,
'
--fast
'
if
$param
->
{
fast
};
PVE::Tools::
run_command
(
$cmd
);
run_command
(
$cmd
);
return
;
};
...
...
@@ -971,4 +975,75 @@ __PACKAGE__->register_method({
return
$upid
;
}});
__PACKAGE__
->
register_method
({
name
=>
'
migrate_vm
',
path
=>
'
{vmid}/migrate
',
method
=>
'
POST
',
protected
=>
1
,
proxyto
=>
'
node
',
description
=>
"
Migrate the container to another node. Creates a new migration task.
",
parameters
=>
{
additionalProperties
=>
0
,
properties
=>
{
node
=>
get_standard_option
('
pve-node
'),
vmid
=>
get_standard_option
('
pve-vmid
'),
target
=>
get_standard_option
('
pve-node
',
{
description
=>
"
Target node.
"
}),
online
=>
{
type
=>
'
boolean
',
description
=>
"
Use online/live migration.
",
optional
=>
1
,
},
},
},
returns
=>
{
type
=>
'
string
',
description
=>
"
the task ID.
",
},
code
=>
sub
{
my
(
$param
)
=
@_
;
my
$rpcenv
=
PVE::RPCEnvironment::
get
();
my
$user
=
$rpcenv
->
get_user
();
my
$target
=
extract_param
(
$param
,
'
target
');
my
$localnode
=
PVE::INotify::
nodename
();
raise_param_exc
({
target
=>
"
target is local node.
"})
if
$target
eq
$localnode
;
PVE::Cluster::
check_cfs_quorum
();
PVE::Cluster::
check_node_exists
(
$target
);
my
$targetip
=
PVE::Cluster::
remote_node_ip
(
$target
);
my
$vmid
=
extract_param
(
$param
,
'
vmid
');
# test if VM exists
PVE::OpenVZ::
load_config
(
$vmid
);
# try to detect errors early
if
(
PVE::OpenVZ::
check_running
(
$vmid
))
{
die
"
cant migrate running container without --online
\n
"
if
!
$param
->
{
online
};
}
my
$realcmd
=
sub
{
my
$upid
=
shift
;
my
$cmd
=
['
/usr/sbin/vzmigrate
'];
push
@$cmd
,
'
--online
'
if
$param
->
{
online
};
push
@$cmd
,
$targetip
;
push
@$cmd
,
$vmid
;
run_command
(
$cmd
);
return
;
};
my
$upid
=
$rpcenv
->
fork_worker
('
vzmigrate
',
$vmid
,
$user
,
$realcmd
);
return
$upid
;
}});
1
;
PVE/OpenVZ.pm
View file @
8350ac00
...
...
@@ -72,6 +72,24 @@ sub check_mounted {
return
(
-
d
"
$root
/etc
"
||
-
d
"
$root
/proc
");
}
# warning: this is slow
sub
check_running
{
my
(
$vmid
)
=
@_
;
if
(
my
$fh
=
new
IO::
File
("
/proc/vz/vestat
",
"
r
"))
{
while
(
defined
(
my
$line
=
<
$fh
>
))
{
if
(
$line
=~
m/^\s*(\d+)\s+/
)
{
if
(
$vmid
==
$1
)
{
close
(
$fh
);
return
1
;
}
}
}
close
(
$fh
);
}
return
undef
;
}
sub
get_privatedir
{
my
(
$conf
,
$vmid
)
=
@_
;
...
...
www/manager/Makefile
View file @
8350ac00
...
...
@@ -62,7 +62,7 @@ JSSRC= \
tree/ResourceTree.js
\
panel/ConfigPanel.js
\
grid/BackupView.js
\
panel/LogView.js
\
panel/LogView.js
\
node/DNSEdit.js
\
node/DNSView.js
\
node/TimeView.js
\
...
...
@@ -76,7 +76,7 @@ JSSRC= \
node/Tasks.js
\
node/Config.js
\
qemu/StatusView.js
\
qemu/Migrate.js
\
window/Migrate.js
\
qemu/Monitor.js
\
qemu/Summary.js
\
qemu/OSTypeEdit.js
\
...
...
www/manager/openvz/Config.js
View file @
8350ac00
...
...
@@ -55,6 +55,18 @@ Ext.define('PVE.openvz.Config', {
}
});
var
migrateBtn
=
Ext
.
create
(
'
Ext.Button
'
,
{
text
:
'
Migrate
'
,
handler
:
function
()
{
var
win
=
Ext
.
create
(
'
PVE.window.Migrate
'
,
{
vmtype
:
'
openvz
'
,
nodename
:
nodename
,
vmid
:
vmid
});
win
.
show
();
}
});
var
removeBtn
=
Ext
.
create
(
'
PVE.button.Button
'
,
{
text
:
'
Remove
'
,
confirmMsg
:
'
Are you sure you want to remove VM
'
+
...
...
@@ -84,7 +96,8 @@ Ext.define('PVE.openvz.Config', {
title
:
"
OpenVZ container
"
+
vmid
+
descr
+
"
on node '
"
+
nodename
+
"
'
"
,
hstateid
:
'
ovztab
'
,
tbar
:
[
startBtn
,
stopBtn
,
shutdownBtn
,
removeBtn
,
consoleBtn
],
tbar
:
[
startBtn
,
stopBtn
,
shutdownBtn
,
migrateBtn
,
removeBtn
,
consoleBtn
],
defaults
:
{
statusStore
:
me
.
statusStore
},
items
:
[
{
...
...
www/manager/qemu/Config.js
View file @
8350ac00
...
...
@@ -50,8 +50,10 @@ Ext.define('PVE.qemu.Config', {
var
migrateBtn
=
Ext
.
create
(
'
Ext.Button
'
,
{
text
:
'
Migrate
'
,
handler
:
function
()
{
var
win
=
Ext
.
create
(
'
PVE.qemu.Migrate
'
,
{
pveSelNode
:
me
.
pveSelNode
var
win
=
Ext
.
create
(
'
PVE.window.Migrate
'
,
{
vmtype
:
'
qemu
'
,
nodename
:
nodename
,
vmid
:
vmid
});
win
.
show
();
}
...
...
@@ -102,7 +104,8 @@ Ext.define('PVE.qemu.Config', {
title
:
"
Virtual machine
"
+
descr
+
"
'KVM
"
+
vmid
+
"
' on node '
"
+
nodename
+
"
'
"
,
hstateid
:
'
kvmtab
'
,
tbar
:
[
startBtn
,
stopBtn
,
migrateBtn
,
resetBtn
,
shutdownBtn
,
removeBtn
,
consoleBtn
],
tbar
:
[
startBtn
,
stopBtn
,
resetBtn
,
shutdownBtn
,
migrateBtn
,
removeBtn
,
consoleBtn
],
defaults
:
{
statusStore
:
me
.
statusStore
},
items
:
[
{
...
...
www/manager/
qemu
/Migrate.js
→
www/manager/
window
/Migrate.js
View file @
8350ac00
Ext
.
define
(
'
PVE.
qemu
.Migrate
'
,
{
Ext
.
define
(
'
PVE.
window
.Migrate
'
,
{
extend
:
'
Ext.window.Window
'
,
resizable
:
false
,
migrate
:
function
(
vmid
,
nodename
,
target
,
online
)
{
migrate
:
function
(
target
,
online
)
{
var
me
=
this
;
PVE
.
Utils
.
API2Request
({
params
:
{
target
:
target
,
online
:
online
},
url
:
'
/nodes/
'
+
nodename
+
'
/qemu/
'
+
vmid
+
"
/migrate
"
,
url
:
'
/nodes/
'
+
me
.
nodename
+
'
/
'
+
me
.
vmtype
+
'
/
'
+
me
.
vmid
+
"
/migrate
"
,
waitMsgTarget
:
me
,
method
:
'
POST
'
,
failure
:
function
(
response
,
opts
)
{
...
...
@@ -28,16 +28,18 @@ Ext.define('PVE.qemu.Migrate', {
initComponent
:
function
()
{
var
me
=
this
;
var
nodename
=
me
.
pveSelNode
.
data
.
node
;
if
(
!
nodename
)
{
if
(
!
me
.
nodename
)
{
throw
"
no node name specified
"
;
}
var
vmid
=
me
.
pveSelNode
.
data
.
vmid
;
if
(
!
vmid
)
{
if
(
!
me
.
vmid
)
{
throw
"
no VM ID specified
"
;
}
if
(
!
me
.
vmtype
)
{
throw
"
no VM type specified
"
;
}
me
.
formPanel
=
Ext
.
create
(
'
Ext.form.Panel
'
,
{
bodyPadding
:
10
,
border
:
false
,
...
...
@@ -69,12 +71,12 @@ Ext.define('PVE.qemu.Migrate', {
text
:
'
Migrate
'
,
handler
:
function
()
{
var
values
=
form
.
getValues
();
me
.
migrate
(
v
mid
,
nodename
,
v
alues
.
target
,
values
.
online
);
me
.
migrate
(
values
.
target
,
values
.
online
);
}
});
Ext
.
apply
(
me
,
{
title
:
"
Migrate
KVM
"
+
vmid
,
title
:
"
Migrate
VM
"
+
me
.
vmid
,
width
:
350
,
modal
:
true
,
layout
:
'
auto
'
,
...
...
Write
Preview
Markdown
is supported
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