dom0/qvm-block: detect 'connecting' devices as 'connected'
This is needed to not allow connecting the same backend to more than one VMs at the same time.
This commit is contained in:
parent
a60671c55d
commit
1683a0b815
@ -214,13 +214,21 @@ def block_check_attached(backend_vm, device, backend_xid = None):
|
|||||||
device_majorminor = block_name_to_majorminor(device)
|
device_majorminor = block_name_to_majorminor(device)
|
||||||
for vm_xid in vm_list:
|
for vm_xid in vm_list:
|
||||||
for devid in xs.ls('', '/local/domain/%d/backend/vbd/%s' % (backend_xid, vm_xid)):
|
for devid in xs.ls('', '/local/domain/%d/backend/vbd/%s' % (backend_xid, vm_xid)):
|
||||||
|
(tmp_major, tmp_minor) = (0, 0)
|
||||||
phys_device = xs.read('', '/local/domain/%d/backend/vbd/%s/%s/physical-device' % (backend_xid, vm_xid, devid))
|
phys_device = xs.read('', '/local/domain/%d/backend/vbd/%s/%s/physical-device' % (backend_xid, vm_xid, devid))
|
||||||
if phys_device is None or not phys_device.find(':'):
|
if phys_device and phys_device.find(':'):
|
||||||
# Skip not-phy devices
|
(tmp_major, tmp_minor) = phys_device.split(":")
|
||||||
continue
|
tmp_major = int(tmp_major, 16)
|
||||||
(tmp_major, tmp_minor) = phys_device.split(":")
|
tmp_minor = int(tmp_minor, 16)
|
||||||
tmp_major = int(tmp_major, 16)
|
else:
|
||||||
tmp_minor = int(tmp_minor, 16)
|
# perhaps not ready yet - check params
|
||||||
|
dev_params = xs.read('', '/local/domain/%d/backend/vbd/%s/%s/params' % (backend_xid, vm_xid, devid))
|
||||||
|
if not dev_params or not dev_params.startswith('/dev/'):
|
||||||
|
# Skip not-phy devices
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
(tmp_major, tmp_minor) = block_name_to_majorminor(dev_params.lstrip('/dev/'))
|
||||||
|
|
||||||
if (tmp_major, tmp_minor) == device_majorminor:
|
if (tmp_major, tmp_minor) == device_majorminor:
|
||||||
vm_name = xl_ctx.domid_to_name(int(vm_xid))
|
vm_name = xl_ctx.domid_to_name(int(vm_xid))
|
||||||
frontend = block_devid_to_name(int(devid))
|
frontend = block_devid_to_name(int(devid))
|
||||||
|
Loading…
Reference in New Issue
Block a user