@contextlib.contextmanager<EOL>def guestfs_conn_ro(disk):
disk_path = os.path.expandvars(disk)<EOL>conn = guestfs.GuestFS(python_return_dict=True)<EOL>conn.add_drive_ro(disk_path)<EOL>conn.set_backend(os.environ.get('<STR_LIT>', '<STR_LIT>'))<EOL>try:<EOL><INDENT>conn.launch()<EOL><DEDENT>except RuntimeError as err:<EOL><INDENT>LOGGER.debug(err)<EOL>raise GuestFSError(<EOL>'<STR_LIT>'.<EOL>format(disk)<EOL>)<EOL><DEDENT>try:<EOL><INDENT>yield conn<EOL><DEDENT>finally:<EOL><INDENT>conn.shutdown()<EOL>conn.close()<EOL><DEDENT>
Open a GuestFS handle and add `disk` in read only mode.

Args:
    disk(disk path): Path to the disk.

Yields:
    guestfs.GuestFS: Open GuestFS handle

Raises:
    :exc:`GuestFSError`: On any guestfs operation failure