[pve-devel] [PATCH] mountpoint: add support for host /dev/xxx block device passthrough

Alexandre Derumier aderumier at odiso.com
Tue Aug 18 10:24:24 CEST 2015


example:
mp0: volume=/dev/sda,mp=/home/

Fix this request:
http://forum.proxmox.com/threads/23256-LXC-Cannot-assign-a-block-device-to-container

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/LXC.pm            | 2 +-
 src/lxc-pve-mount-hook    | 5 +++++
 src/lxc-pve-prestart-hook | 2 ++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 53e9cee..3f02ae9 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -996,7 +996,7 @@ sub update_lxc_config {
 	my ($ms, $mountpoint) = @_;
 
 	my $volid = $mountpoint->{volume};
-	return if !$volid;
+	return if !$volid || $volid =~ m|^/dev/.+|;
 
 	my ($storage, $volname) = PVE::Storage::parse_volume_id($volid);
 
diff --git a/src/lxc-pve-mount-hook b/src/lxc-pve-mount-hook
index 11aeb01..cae4eaa 100755
--- a/src/lxc-pve-mount-hook
+++ b/src/lxc-pve-mount-hook
@@ -94,6 +94,11 @@ __PACKAGE__->register_method ({
 	    my $volid = $mountpoint->{volume};
 	    return if !$volid;
 
+	    if ($volid =~ m|^/dev/.+| && $mountpoint->{mp} && $ms ne 'rootfs') {
+		PVE::Tools::run_command(['mount', $volid, "$rootdir$mountpoint->{mp}"]);
+		return;
+	    }
+
 	    my ($storage, $volname) = PVE::Storage::parse_volume_id($volid);
 
 	    my $scfg = PVE::Storage::storage_config($storage_cfg, $storage);
diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook
index 6f8a775..312a5d1 100755
--- a/src/lxc-pve-prestart-hook
+++ b/src/lxc-pve-prestart-hook
@@ -83,6 +83,8 @@ __PACKAGE__->register_method ({
 	    my ($ms, $mountpoint) = @_;
 
 	    my $volid = $mountpoint->{volume};
+	    return if !$volid || $volid =~ m|^/dev/.+|;
+
 	    PVE::Storage::activate_volumes($storage_cfg, [$volid]);
 
 	    my ($storage, $volname) = PVE::Storage::parse_volume_id($volid);
-- 
2.1.4




More information about the pve-devel mailing list