ソースを参照

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
Marek Marczykowski-Górecki 7 年 前
コミット
ba4dec5383
2 ファイル変更4 行追加1 行削除
  1. 3 1
      core/qubesutils.py
  2. 1 0
      qvm-tools/qvm-block

+ 3 - 1
core/qubesutils.py

@@ -372,7 +372,9 @@ def block_check_attached(qvmc, device):
                                         "VM '%s'" % (source.get('type'),
                                                      vm.name)
                     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 {
                         "frontend": disk.find('target').get('dev'),
                         "vm": vm}

+ 1 - 0
qvm-tools/qvm-block

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