qvm-block: fix checking attached status of disk image files

Libvirt do not show actual block device (loop*) choosen for the device -
only original (file) path. But file path is available in device
description. Please note that VM can provide any description (withing
allowed limits), effectively breaking this check again (hidding the
attachment status). But even without this bug it could do that - by
hidding the whole device from QubesDB.

Fixes QubesOS/qubes-issues#2453
This commit is contained in:
Marek Marczykowski-Górecki 2016-11-23 03:25:03 +01:00
父節點 68a116e8a3
當前提交 ba4dec5383
沒有發現已知的金鑰在資料庫的簽署中
GPG 金鑰 ID: 063938BA42CFA724
共有 2 個檔案被更改,包括 4 行新增1 行删除

查看文件

@ -372,7 +372,9 @@ def block_check_attached(qvmc, device):
"VM '%s'" % (source.get('type'), "VM '%s'" % (source.get('type'),
vm.name) vm.name)
continue continue
if backend_name == device['vm'] and path == device['device']: if backend_name == device['vm'] and (path == device['device']
or not path.startswith('/dev/') and path == device[
'desc']):
return { return {
"frontend": disk.find('target').get('dev'), "frontend": disk.find('target').get('dev'),
"vm": vm} "vm": vm}

查看文件

@ -87,6 +87,7 @@ def main():
if options.do_file_attach: if options.do_file_attach:
dev = {} dev = {}
(dev['vm'], dev['device']) = args[1].split(":") (dev['vm'], dev['device']) = args[1].split(":")
dev['desc'] = dev['device']
dev['mode'] = 'w' dev['mode'] = 'w'
else: else:
dev_list = block_list(qvm_collection) dev_list = block_list(qvm_collection)