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:
parent
e1da1fb3c1
commit
868ee83093
@ -420,6 +420,13 @@ def block_attach(qvmc, vm, device, frontend=None, mode="w", auto_detach=False, w
|
|||||||
if backend_vm.qid != 0:
|
if backend_vm.qid != 0:
|
||||||
SubElement(disk, 'backenddomain').set('name', device['vm'])
|
SubElement(disk, 'backenddomain').set('name', device['vm'])
|
||||||
vm.libvirt_domain.attachDevice(etree.tostring(disk, encoding='utf-8'))
|
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"):
|
def block_detach(vm, frontend = "xvdi"):
|
||||||
|
|
||||||
@ -437,6 +444,13 @@ def block_detach(vm, frontend = "xvdi"):
|
|||||||
"qubes_base_dir"]):
|
"qubes_base_dir"]):
|
||||||
continue
|
continue
|
||||||
vm.libvirt_domain.detachDevice(etree.tostring(disk, encoding='utf-8'))
|
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):
|
def block_detach_all(vm):
|
||||||
""" Detach all non-system devices"""
|
""" Detach all non-system devices"""
|
||||||
|
Loading…
Reference in New Issue
Block a user