'Returns the disk metadata with dual disk buses - ide and xen. More
details about Xen device number can be found in
http://xenbits.xen.org/docs/4.2-testing/misc/vbd-interface.txt'

@staticmethod
def _prepare_disk_metadata(bdm):

    path = bdm.device_name
    disk_num = volume_utils.get_device_number(path)
    xen0 = objects.XenDeviceBus(address=('00%02d00' % disk_num))
    registry = 'HKLM\\SYSTEM\\ControlSet001\\Enum\\SCSI\\Disk&Ven_XENSRC&Prod_PVDISK\\'
    vbd_prefix = '/sys/devices/vbd-'
    if (disk_num < 4):
        ide = objects.IDEDeviceBus(address=('%d:%d' % ((disk_num / 2), (disk_num % 2))))
        xen1 = objects.XenDeviceBus(address=('%d' % ((202 << 8) | (disk_num << 4))))
        xen2 = objects.XenDeviceBus()
        if (disk_num < 2):
            xen2.address = ('%d' % ((3 << 8) | (disk_num << 6)))
        else:
            xen2.address = ('%d' % ((22 << 8) | ((disk_num - 2) << 6)))
        return [objects.DiskMetadata(path=path, bus=ide, tags=[bdm.tag]), objects.DiskMetadata(path=(registry + xen0.address), bus=xen0, tags=[bdm.tag]), objects.DiskMetadata(path=(vbd_prefix + xen1.address), bus=xen1, tags=[bdm.tag]), objects.DiskMetadata(path=(vbd_prefix + xen2.address), bus=xen2, tags=[bdm.tag])]
    else:
        xen1 = objects.XenDeviceBus()
        if (disk_num < 16):
            xen1.address = ('%d' % ((202 << 8) | (disk_num << 4)))
        else:
            xen1.address = ('%d' % ((1 << 28) | (disk_num << 8)))
        return [objects.DiskMetadata(path=(registry + xen0.address), bus=xen0, tags=[bdm.tag]), objects.DiskMetadata(path=(vbd_prefix + xen1.address), bus=xen1, tags=[bdm.tag])]
