def METHOD_NAME(ova_path, offset, image_path, image_format):
    start_time = time.time()
    while True:
        try:
            output = check_output(['losetup', '--find', '--show', '-o',
                                   str(offset), ova_path])
        except CalledProcessError:
            if time.time() - start_time > 10:
                raise
            time.sleep(1)
        else:
            break
    loop = from_bytes(output.splitlines()[0])
    call(['udevadm', 'settle'])
    loop_stat = os.stat(loop)
    vdsm_user = pwd.getpwnam('vdsm')
    os.chown(loop, vdsm_user.pw_uid, vdsm_user.pw_gid)
    try:
        qemu_cmd = ("qemu-img convert -O %s '%s' '%s'"
                    % (image_format, loop, image_path))
        check_call(['su', '-p', '-c', qemu_cmd, 'vdsm'])
    except CalledProcessError as exc:
        print("qemu-img conversion failed with error: ", exc.returncode)
        raise
    finally:
        os.chown(loop, loop_stat.st_uid, loop_stat.st_gid)
        call(['losetup', '-d', loop])