From: Alexandre Derumier Date: Wed, 12 Aug 2015 09:08:02 +0000 (+0200) Subject: add rbd storage type support X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=63f2ddfb6ee47a1b963a001a1edbb0c04cfeff77;p=pve-container.git add rbd storage type support Signed-off-by: Alexandre Derumier --- diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index 4819295..7a65402 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -72,7 +72,12 @@ my $alloc_rootfs = sub { } elsif ($scfg->{type} eq 'drbd') { $volid = PVE::Storage::vdisk_alloc($storage_conf, $storage, $vmid, 'raw', undef, $size); - + + } elsif ($scfg->{type} eq 'rbd') { + + die "krbd option must be enabled on storage type '$scfg->{type}'\n" if !$scfg->{krbd}; + $volid = PVE::Storage::vdisk_alloc($storage_conf, $storage, $vmid, 'raw', undef, $size); + } else { die "unable to create containers on storage type '$scfg->{type}'\n"; } diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index dadaaf7..a1a5197 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -943,7 +943,7 @@ sub update_lxc_config { } elsif ($scfg->{type} eq 'zfspool') { my $rootfs = PVE::Storage::path($storage_cfg, $volid); $raw .= "lxc.rootfs = $rootfs\n"; - } elsif ($scfg->{type} eq 'drbd') { + } elsif ($scfg->{type} eq 'drbd' || $scfg->{type} eq 'rbd') { my $rootdev = PVE::Storage::path($storage_cfg, $volid); $raw .= "lxc.rootfs = $rootdev\n"; } else { diff --git a/src/PVE/LXCCreate.pm b/src/PVE/LXCCreate.pm index 8847edc..4e742c0 100644 --- a/src/PVE/LXCCreate.pm +++ b/src/PVE/LXCCreate.pm @@ -289,13 +289,16 @@ sub create_rootfs { create_rootfs_subvol($storage_cfg, $storage, $volid, $vmid, $conf, $archive, $password, $restore); } elsif ($format eq 'raw') { my $scfg = PVE::Storage::storage_config($storage_cfg, $storage); + PVE::Storage::activate_storage($storage_cfg, $storage); + PVE::Storage::activate_volumes($storage_cfg, [$volid]); if ($scfg->{path}) { create_rootfs_dir_loop($storage_cfg, $storage, $volid, $vmid, $conf, $archive, $password, $restore); - } elsif ($scfg->{type} eq 'drbd') { + } elsif ($scfg->{type} eq 'drbd' || $scfg->{type} eq 'rbd') { create_rootfs_dev($storage_cfg, $storage, $volid, $vmid, $conf, $archive, $password, $restore); } else { die "unable to create containers on storage type '$scfg->{type}'\n"; } + PVE::Storage::deactivate_volumes($storage_cfg, [$volid]); } else { die "unsupported image format '$format'\n"; }