From 868ee83093e05de2399ed76cef84b9d14a812a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 14 Apr 2015 23:08:52 +0200 Subject: [PATCH] block: trigger QubesDB watches after attaching/detaching device Since libvirt do not support such events (at least for libxl driver), we need some way to notify qubes-manager when device is attached/detached. Use the same protocol as for connect/disconnect but on the target domain. --- core/qubesutils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/qubesutils.py b/core/qubesutils.py index 8e50db8c..130faf8a 100644 --- a/core/qubesutils.py +++ b/core/qubesutils.py @@ -420,6 +420,13 @@ def block_attach(qvmc, vm, device, frontend=None, mode="w", auto_detach=False, w if backend_vm.qid != 0: SubElement(disk, 'backenddomain').set('name', device['vm']) vm.libvirt_domain.attachDevice(etree.tostring(disk, encoding='utf-8')) + try: + # trigger watches to update device status + # FIXME: this should be removed once libvirt will report such + # events itself + vm.qdb.write('/qubes-block-devices', '') + except Error: + pass def block_detach(vm, frontend = "xvdi"): @@ -437,6 +444,13 @@ def block_detach(vm, frontend = "xvdi"): "qubes_base_dir"]): continue vm.libvirt_domain.detachDevice(etree.tostring(disk, encoding='utf-8')) + try: + # trigger watches to update device status + # FIXME: this should be removed once libvirt will report such + # events itself + vm.qdb.write('/qubes-block-devices', '') + except Error: + pass def block_detach_all(vm): """ Detach all non-system devices"""