Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

targetcli: add portal info #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions drgn_tools/targetcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
from drgn import FaultError
from drgn import Object
from drgn import Program
from drgn.helpers.common.format import escape_ascii_string
from drgn.helpers.linux.list import hlist_for_each_entry
from drgn.helpers.linux.list import list_for_each_entry

from drgn_tools.corelens import CorelensModule
from drgn_tools.dentry import dentry_for_each_child
from drgn_tools.module import ensure_debuginfo

######################################
Expand Down Expand Up @@ -49,6 +51,18 @@ def for_each_iscsi_tpg(tiqn: Object) -> Iterable[Object]:
)


def for_each_portal(tpg: Object) -> Iterable[Object]:
"""
Get a list of portals under tpg

:param tpg: ``struct se_portal_group``
:returns: Iterator of str
"""
np_dentry = tpg.tpg_np_group.cg_item.ci_dentry
for portal in dentry_for_each_child(np_dentry):
yield escape_ascii_string(portal.d_name.name.string_())


def print_iscsi_info(prog) -> None:
"""Dump iscsi section info"""

Expand Down Expand Up @@ -106,6 +120,10 @@ def print_iscsi_info(prog) -> None:
):
print_lun_info(lun, nr_indent=4)

print(f"{indent * 3}o- portals")
for portal in for_each_portal(se_tpg):
print(f"{indent * 4}o- {portal}")


######################################
# vhost
Expand Down