Commit 25ac9b68 authored by Dietmar Maurer's avatar Dietmar Maurer

implemente openvz migration

parent 784729f4
......@@ -16,6 +16,7 @@ use PVE::Storage;
use PVE::RESTHandler;
use PVE::RPCEnvironment;
use PVE::OpenVZ;
use PVE::OpenVZMigrate;
use PVE::JSONSchema qw(get_standard_option);
use base qw(PVE::RESTHandler);
......@@ -139,7 +140,7 @@ my $restore_openvz = sub {
if (-f $backup_cfg) {
print "restore configuration to '$conffile'\n";
$conf = PVE::Tools::file_get_contents($backup_cfg);
my $conf = PVE::Tools::file_get_contents($backup_cfg);
$conf =~ s/VE_ROOT=.*/VE_ROOT=\"$root\"/;
$conf =~ s/VE_PRIVATE=.*/VE_PRIVATE=\"$private\"/;
......@@ -251,7 +252,7 @@ __PACKAGE__->register_method({
my $basecfg_fn = PVE::OpenVZ::config_file($vmid);
if ($param->{force}) {
die "cant overwrite mounted container\n" if PVE::OpenVZ::check_mounted($vmid);
die "cant overwrite mounted container\n" if PVE::OpenVZ::check_mounted($conf, $vmid);
} else {
die "container $vmid already exists\n" if -f $basecfg_fn;
}
......@@ -314,6 +315,11 @@ __PACKAGE__->register_method({
# hack: vzctl '--userpasswd' starts the CT, but we want
# to avoid that for create
PVE::OpenVZ::set_rootpasswd($private, $password) if defined($password);
# is this really needed?
my $cmd = ['vzctl', '--skiplock', '--quiet', 'set', $vmid,
'--applyconfig_map', 'name', '--save'];
run_command($cmd);
};
return $rpcenv->fork_worker($param->{restore} ? 'vzrestore' : 'vzcreate',
......@@ -614,8 +620,8 @@ __PACKAGE__->register_method({
my $stcfg = cfs_read_file("storage.cfg");
if ($veconf->{ve_private} && $veconf->{ve_private}->{value}) {
my $path = $veconf->{ve_private}->{value};
if ($veconf->{ve_private} && $conf->{ve_private}->{value}) {
my $path = PVE::OpenVZ::get_privatedir($veconf, $param->{vmid});
my ($vtype, $volid) = PVE::Storage::path_to_volume_id($stcfg, $path);
my ($sid, $volname) = PVE::Storage::parse_volume_id($volid, 1) if $volid;
$conf->{storage} = $sid || $path;
......@@ -1031,14 +1037,7 @@ __PACKAGE__->register_method({
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);
PVE::OpenVZMigrate::migrate($target, $targetip, $vmid, $param->{online});
return;
};
......
......@@ -8,6 +8,7 @@ PERLSOURCE = \
APIDaemon.pm \
REST.pm \
OpenVZ.pm \
OpenVZMigrate.pm \
VZDump.pm \
APLInfo.pm
......
......@@ -15,7 +15,7 @@ use PVE::JSONSchema;
use Digest::SHA1;
use Encode;
use constant SCRIPT_EXT => qw (start stop mount umount);
use constant SCRIPT_EXT => qw (start stop mount umount premount postumount);
my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
my $nodename = PVE::INotify::nodename();
......@@ -64,11 +64,9 @@ sub load_config {
}
sub check_mounted {
my ($vmid) = @_;
my $root = $global_vzconf->{rootdir};
$root =~ s/\$VEID/$vmid/;
my ($conf, $vmid) = @_;
my $root = get_rootdir($conf, $vmid);
return (-d "$root/etc" || -d "$root/proc");
}
......@@ -102,6 +100,18 @@ sub get_privatedir {
return $private;
}
sub get_rootdir {
my ($conf, $vmid) = @_;
my $root = $global_vzconf->{rootdir};
if ($conf->{ve_root} && $conf->{ve_root}->{value}) {
$root = $conf->{ve_root}->{value};
}
$root =~ s/\$VEID/$vmid/;
return $root;
}
sub read_user_beancounters {
my $ubc = {};
if (my $fh = IO::File->new ("/proc/user_beancounters", "r")) {
......@@ -222,20 +232,14 @@ sub vmstatus {
} else {
$d->{ip} = '-';
}
$d->{status} = 'mounted' if check_mounted($conf, $vmid);
} else {
delete $list->{$vmid};
}
}
if (my $fh = IO::File->new ("/proc/mounts", "r")) {
while (defined (my $line = <$fh>)) {
if ($line =~ m|/private/(\d+)\s+/var/lib/vz/root/\d+\s|) {
$list->{$1}->{status} = 'mounted' if defined($list->{$1});
}
}
close($fh);
}
my $ubchash = read_user_beancounters();
foreach my $vmid (keys %$ubchash) {
my $d = $list->{$vmid};
......@@ -731,7 +735,7 @@ my $ovz_ressources = {
dgramrcvbuf => \&parse_res_bytes_bytes,
dcachesize => \&parse_res_bytes_bytes,
diskquota => \&parse_boolean,
disk_quota => \&parse_boolean,
diskspace => \&parse_res_block_block,
diskinodes => \&parse_res_num_num,
quotatime => \&parse_integer,
......
This diff is collapsed.
......@@ -54,8 +54,8 @@ my $cmddef = {
}
} ],
create => [ 'PVE::API2::OpenVZ', 'create_vm', ['vmid', 'ostemplate'], { node => $nodename } ],
destroy => [ 'PVE::API2::OpenVZ', 'destroy_vm', ['vmid'], { node => $nodename } ],
create => [ 'PVE::API2::OpenVZ', 'create_vm', ['vmid', 'ostemplate'], { node => $nodename }, $upid_exit ],
destroy => [ 'PVE::API2::OpenVZ', 'destroy_vm', ['vmid'], { node => $nodename }, $upid_exit ],
set => [ "PVE::API2::OpenVZ", 'update_vm', ['vmid'], { node => $nodename } ],
......@@ -74,6 +74,7 @@ my $cmddef = {
start => [ 'PVE::API2::OpenVZ', 'vm_start', ['vmid'], { node => $nodename }, $upid_exit],
stop => [ 'PVE::API2::OpenVZ', 'vm_stop', ['vmid'], { node => $nodename }, $upid_exit],
migrate => [ "PVE::API2::OpenVZ", 'migrate_vm', ['target', 'vmid'], { node => $nodename }, $upid_exit],
};
......
pve-manager (2.0-13) unstable; urgency=low
* implemente openvz migration ('pvectl migrate')
-- Proxmox Support Team <support@proxmox.com> Fri, 02 Dec 2011 10:37:28 +0100
pve-manager (2.0-12) unstable; urgency=low
* minor bug fixes
......
......@@ -2,7 +2,7 @@ RELEASE=2.0
VERSION=2.0
PACKAGE=pve-manager
PACKAGERELEASE=12
PACKAGERELEASE=13
BINDIR=${DESTDIR}/usr/bin
PERLLIBDIR=${DESTDIR}/usr/share/perl5
......
Markdown is supported
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