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

fix openvz create (use vzctl to create new container)

parent 6277f9ac
......@@ -295,40 +295,40 @@ __PACKAGE__->register_method({
}
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);
PVE::Cluster::check_cfs_quorum();
my $realcmd = sub {
&$restore_openvz($private, $archive, $vmid, $param->{force});
PVE::Tools::file_set_contents($basecfg_fn, $rawconf)
if !$param->{restore};
if ($param->{restore}) {
&$restore_openvz($private, $archive, $vmid, $param->{force});
# 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);
# is this really needed?
my $cmd = ['vzctl', '--skiplock', '--quiet', 'set', $vmid,
'--applyconfig_map', 'name', '--save'];
run_command($cmd);
# reload config
$conf = PVE::OpenVZ::load_config($vmid);
# reload config
my $conf = PVE::OpenVZ::load_config($vmid);
# and initialize quota
my $disk_quota = $conf->{disk_quota}->{value};
if (!defined($disk_quota) || ($disk_quota != 0)) {
$cmd = ['vzctl', '--skiplock', 'quotainit', $vmid];
run_command($cmd);
}
# and initialize quota
my $disk_quota = $conf->{disk_quota}->{value};
if (!defined($disk_quota) || ($disk_quota != 0)) {
my $cmd = ['vzctl', '--skiplock', 'quotainit', $vmid];
} 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);
}
};
......
......@@ -104,7 +104,7 @@ sub get_rootdir {
my ($conf, $vmid) = @_;
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 =~ 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