Skip to content

Commit

Permalink
B #3177 Load max_nbds from running module
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Apr 4, 2019
1 parent 545ec98 commit 6a4d9d0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/vmm_mad/remotes/lib/lxd/mapper/qcow2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ def do_unmap(device, _one_vm, _disk, _directory)

private

# Detects Max number of block devices
def load_nbds_max
cmd = '/sbin/modprobe -c'
rc, mods_conf, e = Command.execute(cmd, false)

if !rc.zero?
OpenNebula.log_error("Cannot load max number of nbd devices\n#{e}")
return 0
end

param = mods_conf[/(nbds_max=)(\d+)/]
param.split('=').last.to_i
end

# Returns the first non-used nbd device
def nbd_device
sys_parts = lsblk('')
nbds = []
Expand All @@ -76,7 +91,7 @@ def nbd_device
nbds << m[1].to_i
end

NBDS_MAX.times do |i|
load_nbds_max.times do |i|
return "/dev/nbd#{i}" unless nbds.include?(i)
end

Expand Down

0 comments on commit 6a4d9d0

Please sign in to comment.