If a storage volume's vhost_block_backend_version param is set, then a Ubiblk installation is used instead of SPDK. Let `storage-root=/var/storage/${vm_name}/$disk-index/`. Then: - Ubiblk config is stored at `${storage-root}/vhost-backend.conf`. - Ubiblk metadata is stored at `$storage-root/metadata`. - A systemd-unit `${vm_name}-${disk-idx}-storage` is created to act as VM's storage device. It starts the Ubiblk's vhost-backend binary, stored at `/opt/vhost-block-backend/${version}/`. - Key Encryption Key (KEK) is communicated to the storage service using a pipe created at `${storage-root$}/kek.pipe`. - Storage service creates a vhost-user-blk socket at `${storage-root}/vhost.socket` which Cloud-Hypervisor connects to.
51 lines
1.1 KiB
Ruby
51 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
DEFAULT_STORAGE_DEVICE = "DEFAULT"
|
|
|
|
class StoragePath
|
|
def initialize(vm_name, device, disk_index)
|
|
@vm_name = vm_name
|
|
@device = device
|
|
@disk_index = disk_index
|
|
end
|
|
|
|
def device_path
|
|
@device_path ||=
|
|
(@device == DEFAULT_STORAGE_DEVICE) ?
|
|
File.join("", "var", "storage") :
|
|
File.join("", "var", "storage", "devices", @device)
|
|
end
|
|
|
|
def storage_root
|
|
@storage_root ||= File.join(device_path, @vm_name)
|
|
end
|
|
|
|
def storage_dir
|
|
@storage_dir ||= File.join(storage_root, @disk_index.to_s)
|
|
end
|
|
|
|
def disk_file
|
|
@disk_file ||= File.join(storage_dir, "disk.raw")
|
|
end
|
|
|
|
def data_encryption_key
|
|
@dek_path ||= File.join(storage_dir, "data_encryption_key.json")
|
|
end
|
|
|
|
def vhost_sock
|
|
@vhost_sock ||= File.join(storage_dir, "vhost.sock")
|
|
end
|
|
|
|
def kek_pipe
|
|
@kek_pipe ||= File.join(storage_dir, "kek.pipe")
|
|
end
|
|
|
|
def vhost_backend_config
|
|
@vhost_backend_config ||= File.join(storage_dir, "vhost-backend.conf")
|
|
end
|
|
|
|
def vhost_backend_metadata
|
|
@vhost_backend_metadata ||= File.join(storage_dir, "metadata")
|
|
end
|
|
end
|