def find_disk(virt_dom):
    xml_desc = virt_dom.XMLDesc(0)
    domain = etree.fromstring(xml_desc)
    os_type = domain.find('os/type').text
    driver = None
    if CONF.libvirt.virt_type == 'lxc':
        filesystem = domain.find('devices/filesystem')
        driver = filesystem.find('driver')

        source = filesystem.find('source')
        disk_path = source.get('dir')
        disk_path = disk_path[0:disk_path.rfind('rootfs')]
        disk_path = os.path.join(disk_path, 'disk')
    elif CONF.libvirt.virt_type == 'parallels' and os_type == vm_mode.EXE:
        filesystem = domain.find('devices/filesystem')
        driver = filesystem.find('driver')

        source = filesystem.find('source')
        disk_path = source.get('file')
    else:
        disk = domain.find('devices/disk')
        driver = disk.find('driver')

        source = disk.find('source')
        disk_path = source.get('file') or source.get('dev')
        if not disk_path and CONF.libvirt.images_type == 'rbd':
            disk_path = source.get('name')
            if disk_path:
                disk_path = 'rbd:' + disk_path

    if not disk_path:
        raise RuntimeError(_("Can't retrieve root device path "
                             "from instance libvirt configuration"))

    if driver is not None:
        format = driver.get('type')
        # This is a legacy quirk of libvirt/xen. Everything else should
        # report the on-disk format in type.
        if format == 'aio':
            format = 'raw'
    else:
        format = None
    return (disk_path, format)
Find root device path for instance
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/virt/libvirt/utils.py/find_disk