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.
This commit is contained in:
Marek Marczykowski-Górecki 2015-04-14 23:08:52 +02:00
parent e1da1fb3c1
commit 868ee83093

View File

@ -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"""