[pve-devel] [PATCH 8/8] add setup_blockdev_mounts to pve-mount hook
Alexandre Derumier
aderumier at odiso.com
Fri Aug 14 14:56:49 CEST 2015
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
src/PVE/LXCSetup/Base.pm | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/PVE/LXCSetup/Base.pm b/src/PVE/LXCSetup/Base.pm
index 8db5451..4efa9b1 100644
--- a/src/PVE/LXCSetup/Base.pm
+++ b/src/PVE/LXCSetup/Base.pm
@@ -212,11 +212,26 @@ sub setup_blockdev {
$bdev =~ s/\.\.\/\.\.\/devices\/virtual\/block\//\/dev\//;
my $path = $rootdir . $bdev;
PVE::Tools::run_command(['mknod', '-m', '666', $path, 'b', $major, $minor]);
-
}
}
}
+sub setup_blockdev_mounts {
+ my ($self, $vmid) = @_;
+
+ my $rootdir = $self->{rootdir};
+
+ my $config_filename = "/var/lib/lxc/$vmid/config";
+ return undef if ! -f $config_filename;
+ my $raw = PVE::Tools::file_get_contents($config_filename);
+ my @lines = split(/\n/, $raw);
+ foreach my $line (@lines) {
+ if ($line =~ m/lxc\.mount\.entry = (\/dev\/\S+) (\S+)/) {
+ PVE::Tools::run_command(['mount', $1, $rootdir.$2]);
+ }
+ }
+}
+
sub setup_systemd_console {
my ($self, $conf) = @_;
@@ -399,6 +414,7 @@ sub pre_start_hook {
$self->setup_init($conf);
$self->setup_blockdev($vmid);
+ $self->setup_blockdev_mounts($vmid);
$self->setup_network($conf);
$self->set_hostname($conf);
$self->set_dns($conf);
--
2.1.4
More information about the pve-devel
mailing list