1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-28 17:57:22 +03:00

F #5260: Add device mapper for LXC

It allows to use LVM and RDM drivers.
This commit is contained in:
Christian González 2021-05-12 10:58:46 +02:00 committed by Ruben S. Montero
parent 17025ead9d
commit aa6b6f5941
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 35 additions and 0 deletions

View File

@ -25,6 +25,7 @@ require 'storageutils'
require 'qcow2'
require 'raw'
require 'rbd'
require 'device'
require_relative '../lib/xmlparser'
require_relative '../lib/opennebula_vm'
@ -339,6 +340,8 @@ class Disk
Qcow2Mapper.new
elsif @xml['DISK_TYPE'].downcase == 'rbd'
RBDMapper.new(self)
elsif @xml['DISK_TYPE'].downcase == 'block'
DeviceMapper.new
else
RawMapper.new
end

View File

@ -0,0 +1,32 @@
#!/usr/bin/ruby
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'command'
# Mapping utilities for raw devices (e.g LVM, RDM)
class DeviceMapper
# Maps raw image file to linux loopdevice
def map(disk)
ds_path = source(disk)
if File.symlink?(ds_path)
return File.readlink(ds_path) # Raw device path
end
nil
end
def unmap(_device)
true
end
private
# Returns the source file for the disk
def source(disk)
"#{disk.sysds_path}/#{disk.vm_id}/disk.#{disk.id}"
end
end