mkfs($path);
}
-my $create_disks = sub {
+sub create_disks {
my ($storecfg, $vmid, $settings, $conf) = @_;
my $vollist = [];
die $err;
}
return $vollist;
-};
+}
__PACKAGE__->register_method({
name => 'vmlist',
}
}
- $vollist = &$create_disks($storage_cfg, $vmid, $param, $conf);
+ $vollist = create_disks($storage_cfg, $vmid, $param, $conf);
PVE::LXC::Create::create_rootfs($storage_cfg, $vmid, $conf, $archive, $password, $restore);
# set some defaults
}
sub print_ct_mountpoint {
- my ($info) = @_;
+ my ($info, $nomp) = @_;
my $opts = '';
foreach my $o ('size', 'backup') {
$opts .= ",$o=$info->{$o}" if defined($info->{$o});
}
+ $opts .= ",mp=$info->{mp}" if !$nomp;
return "$info->{volume}$opts";
}
my @nohotplug;
+ my $new_disks = [];
+
my $rootdir;
if ($running) {
my $pid = find_lxc_pid($vmid);
next if !$running;
my $netid = $1;
PVE::Network::veth_delete("veth${vmid}i$netid");
- } elsif ($opt eq 'rootfs' || $opt =~ m/^mp(\d+)$/) {
+ } elsif ($opt =~ m/^mp(\d+)$/) {
+ delete $conf->{$opt};
+ push @nohotplug, $opt;
+ next if $running;
+ } elsif ($opt eq 'rootfs') {
die "implement me"
} else {
die "implement me"
} else {
update_net($vmid, $conf, $opt, $net, $netid, $rootdir);
}
- } elsif ($opt eq 'rootfs' || $opt =~ m/^mp(\d+)$/) {
+ } elsif ($opt =~ m/^mp(\d+)$/) {
+ $conf->{$opt} = $value;
+ push @$new_disks, $opt;
+ push @nohotplug, $opt;
+ next;
+ } elsif ($opt eq 'rootfs') {
die "implement me: $opt";
} else {
die "implement me: $opt";
if ($running && scalar(@nohotplug)) {
die "unable to modify " . join(',', @nohotplug) . " while container is running\n";
}
+
+ if (@$new_disks) {
+ my $storage_cfg = PVE::Storage::config();
+ PVE::API2::LXC::create_disks($storage_cfg, $vmid, $conf, $conf);
+ mount_all($vmid, $storage_cfg, $conf, $new_disks, 1);
+ umount_all($vmid, $storage_cfg, $conf, 0);
+ }
}
sub has_dev_console {
my $template_volid = PVE::Storage::vdisk_create_base($storecfg, $volid);
$rootinfo->{volume} = $template_volid;
- $conf->{rootfs} = print_ct_mountpoint($rootinfo);
+ $conf->{rootfs} = print_ct_mountpoint($rootinfo, 1);
write_config($vmid, $conf);
}
}
sub mount_all {
- my ($vmid, $storage_cfg, $conf) = @_;
+ my ($vmid, $storage_cfg, $conf, $mkdirs) = @_;
my $rootdir = "/var/lib/lxc/$vmid/rootfs";
die "unable to mount base volume - internal error" if $isBase;
+ File::Path::make_path "$rootdir/$mount" if $mkdirs;
mountpoint_mount($mountpoint, $rootdir, $storage_cfg, $loopdevs);
});
};