Commit 71e9d057 authored by Dietmar Maurer's avatar Dietmar Maurer

fix openvz create (use vzctl to create new container)

parent 6277f9ac
...@@ -295,41 +295,41 @@ __PACKAGE__->register_method({ ...@@ -295,41 +295,41 @@ __PACKAGE__->register_method({
} }
PVE::OpenVZ::update_ovz_config($vmid, $conf, $param); PVE::OpenVZ::update_ovz_config($vmid, $conf, $param);
if (!$param->{restore}) {
$conf->{ostemplate}->{value} = $archive;
$conf->{ostemplate}->{value} =~ s|^.*/||;
$conf->{ostemplate}->{value} =~ s/\.tar\.(gz|bz2)$//;
$conf->{ve_private}->{value} = $private;
}
my $rawconf = PVE::OpenVZ::generate_raw_config($pve_base_ovz_config, $conf); my $rawconf = PVE::OpenVZ::generate_raw_config($pve_base_ovz_config, $conf);
PVE::Cluster::check_cfs_quorum(); PVE::Cluster::check_cfs_quorum();
my $realcmd = sub { my $realcmd = sub {
if ($param->{restore}) {
&$restore_openvz($private, $archive, $vmid, $param->{force}); &$restore_openvz($private, $archive, $vmid, $param->{force});
PVE::Tools::file_set_contents($basecfg_fn, $rawconf)
if !$param->{restore};
# 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? # is this really needed?
my $cmd = ['vzctl', '--skiplock', '--quiet', 'set', $vmid, my $cmd = ['vzctl', '--skiplock', '--quiet', 'set', $vmid,
'--applyconfig_map', 'name', '--save']; '--applyconfig_map', 'name', '--save'];
run_command($cmd); run_command($cmd);
# reload config # reload config
my $conf = PVE::OpenVZ::load_config($vmid); $conf = PVE::OpenVZ::load_config($vmid);
# and initialize quota # and initialize quota
my $disk_quota = $conf->{disk_quota}->{value}; my $disk_quota = $conf->{disk_quota}->{value};
if (!defined($disk_quota) || ($disk_quota != 0)) { if (!defined($disk_quota) || ($disk_quota != 0)) {
my $cmd = ['vzctl', '--skiplock', 'quotainit', $vmid]; $cmd = ['vzctl', '--skiplock', 'quotainit', $vmid];
run_command($cmd); run_command($cmd);
} }
} else {
PVE::Tools::file_set_contents($basecfg_fn, $rawconf);
my $cmd = ['vzctl', '--skiplock', 'create', $vmid,
'--ostemplate', $archive, '--private', $private];
run_command($cmd);
# hack: vzctl '--userpasswd' starts the CT, but we want
# to avoid that for create
PVE::OpenVZ::set_rootpasswd($private, $password)
if defined($password);
}
}; };
return $rpcenv->fork_worker($param->{restore} ? 'vzrestore' : 'vzcreate', return $rpcenv->fork_worker($param->{restore} ? 'vzrestore' : 'vzcreate',
......
...@@ -104,7 +104,7 @@ sub get_rootdir { ...@@ -104,7 +104,7 @@ sub get_rootdir {
my ($conf, $vmid) = @_; my ($conf, $vmid) = @_;
my $root = $global_vzconf->{rootdir}; my $root = $global_vzconf->{rootdir};
if ($conf->{ve_root} && $conf->{ve_root}->{value}) { if ($conf && $conf->{ve_root} && $conf->{ve_root}->{value}) {
$root = $conf->{ve_root}->{value}; $root = $conf->{ve_root}->{value};
} }
$root =~ s/\$VEID/$vmid/; $root =~ s/\$VEID/$vmid/;
......
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