Skip to content

AIESW-28663 : Add syslog equivalent message dispatcher for Windows#9837

Open
rbramand-xilinx wants to merge 5 commits into
Xilinx:masterfrom
rbramand-xilinx:event_log
Open

AIESW-28663 : Add syslog equivalent message dispatcher for Windows#9837
rbramand-xilinx wants to merge 5 commits into
Xilinx:masterfrom
rbramand-xilinx:event_log

Conversation

@rbramand-xilinx
Copy link
Copy Markdown
Collaborator

Problem solved by the commit

XRT's syslog message dispatcher was Linux-only — on Windows it used to throw an exception ("syslog not supported on windows").
This PR adds changes to dispatch messages to Event log on Windows using same xrt ini option runtime_log = syslog

Bug / issue (if any) fixed, which PR introduced the bug, how it was discovered

This is a new feature addition. The gap was identified when working on ticket - https://jira.xilinx.com/browse/AIESW-27330

How problem was solved, alternative solutions (if any) and why they were rejected

The syslog_dispatch class is split into two platform-specific definitions under a single #ifdef _WIN32 / #else / #endif block, both sharing the same class name and interface:

Linux: unchanged — uses POSIX openlog / syslog / closelog
Windows: new implementation using the Windows Event Log API (RegisterEventSourceA / ReportEventA / DeregisterEventSource) writing under source name AMD_XRT in the Application log
The syslog config value now works transparently on both platforms — no xrt.ini change needed when moving between Linux and Windows.

INF change dependency: The Event Viewer filter UI (Source: AMD_XRT) only works if the driver INF file is changed to add new registry key.
Note: Events are still written correctly without the INF change — only the filter dropdown is affected.
cc : @arpitxilinx , @satishra-xilinx

The following inf file changes are needed for filtering of xrt messages -

[Npu2McdmDriver.NT]
FeatureScore=FB
AddReg = IpuMcdmDriver.AddReg
AddReg = XRT_EventLog.AddReg
CopyFiles = Npu2McdmDriver.Miniport, IpuMcdmDriver.UserMode, IpuMcdmDriver.UserModeAMD

[XRT_EventLog.AddReg]
; Register AMD_XRT as a known source under the Windows Application event log.
; This allows filtering by source in Event Viewer: Windows Logs -> Application -> Filter -> Source: AMD_XRT
; EventMessageFile points to EventCreate.exe which has a pass-through message entry (ID=1, format="%1")
; so Event Viewer displays XRT message text directly without a "description cannot be found" warning.
; This key persists after uninstall which is acceptable - reinstall simply overwrites with same values.
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Application\AMD_XRT","TypesSupported",%REG_DWORD%,7
HKLM,"SYSTEM\CurrentControlSet\Services\EventLog\Application\AMD_XRT","EventMessageFile",%REG_EXPAND_SZ%,"%%SystemRoot%%\System32\EventCreate.exe"

Risks (if any) associated the changes in the commit

Low

What has been tested and how, request additional testing if necessary

  • Verified on Windows that setting runtime_log = syslog in xrt.ini routes XRT messages to the Windows Application Event Log under source AMD_XRT.
  • Verified events appear in Event Viewer with correct Level icons.
  • Verified source filter works in Event Viewer after driver INF installation applies the XRT_EventLog.AddReg registry entries.

Documentation impact (if any)

src/runtime_src/doc/toc/xrt_ini.rst: Added a new Runtime Log Sinks section documenting all runtime_log values, their platform availability, and Windows-specific filtering commands (Event Viewer, PowerShell, wevtutil).

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/runtime_src/core/common/message.cpp Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a Windows implementation for the existing runtime_log = syslog message sink so that XRT can route runtime messages to the OS-native centralized logging facility on both major platforms (POSIX syslog on Linux, Windows Application Event Log on Windows).

Changes:

  • Implement Windows syslog_dispatch using the Windows Event Log API (source AMD_XRT) and enable it under the existing runtime_log = syslog setting.
  • Link the required Windows system library (Advapi32) for the new Event Log calls.
  • Document runtime_log sink options and Windows Event Viewer / CLI filtering for the new behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/runtime_src/doc/toc/xrt_ini.rst Adds documentation for runtime_log sinks, including Windows Event Log usage and filtering commands.
src/runtime_src/core/include/xrt/experimental/xrt_message.h Updates public API documentation to describe supported message sinks including Windows syslog behavior.
src/runtime_src/core/common/message.cpp Adds a Windows syslog_dispatch implementation that writes to the Windows Application Event Log.
src/runtime_src/core/common/CMakeLists.txt Adds Advapi32 link dependency on Windows for Event Log API usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/runtime_src/core/common/message.cpp Outdated
Comment thread src/runtime_src/core/common/message.cpp Outdated
Comment thread src/runtime_src/doc/toc/xrt_ini.rst Outdated
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/runtime_src/doc/toc/xrt_ini.rst:55

  • The **API Support** paragraph was moved to column 0, but the following list item is still indented, which makes it render as a block-quoted/nested list in reST. Consider aligning the bullet list indentation with surrounding lists (e.g., unindent the `- ``xrt::ini::set``` line, or re-indent the paragraph) to keep formatting consistent.
**API Support**: From 2020.2 release the runtime configuration options can also be provided through Native XRT APIs.


    - ``xrt::ini::set``

Copy link
Copy Markdown
Collaborator

@stsoe stsoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM.

Only comment I have is that for message.cpp we could have used common/detail/linux and common/detail/windows to hide platform specific differences. We could have detail/syslog.h to include details/windows/syslog.h or detail/linux/syslog.h. All code could be inline. No need to change now, just what I think I would have done.

@rbramand-xilinx
Copy link
Copy Markdown
Collaborator Author

This LGTM.

Only comment I have is that for message.cpp we could have used common/detail/linux and common/detail/windows to hide platform specific differences. We could have detail/syslog.h to include details/windows/syslog.h or detail/linux/syslog.h. All code could be inline. No need to change now, just what I think I would have done.

Hi @stsoe, Thanks for the comment. I have added separate headers for platform specific code. Please review.

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/runtime_src/core/common/detail/linux/syslog.h
Comment thread src/runtime_src/core/common/detail/linux/syslog.h Outdated
Comment thread src/runtime_src/core/common/detail/linux/syslog.h
Comment thread src/runtime_src/core/common/detail/windows/syslog.h
Comment thread src/runtime_src/core/common/detail/windows/syslog.h Outdated
Comment thread src/runtime_src/core/common/detail/windows/syslog.h Outdated
Comment thread src/runtime_src/core/common/detail/windows/syslog.h Outdated
Comment thread src/runtime_src/core/common/detail/windows/syslog.h Outdated
Comment thread src/runtime_src/core/common/message.cpp Outdated
Comment thread src/runtime_src/core/common/message.h
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/runtime_src/core/common/detail/windows/syslog.h
:: Command prompt - errors and warnings (Level=2 or Level=3)
wevtutil qe Application /q:"*[System[Provider[@Name='AMD_XRT'] and (Level=2 or Level=3)]]" /f:text

* - ``<filename>``
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rbramand-xilinx I am assuming if user has configured this option, then ASCII strings are written into this file and no other parser is required, correct?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @arpitxilinx, yes we already parse data and dump to file
That said there is also an ini option to dump bin data as well - Debug.uc_log_bin_format (this is disabled by default)

@arpitxilinx
Copy link
Copy Markdown
Collaborator

Created subtask AIESW-34366 for INF changes

@rbramand-xilinx
Copy link
Copy Markdown
Collaborator Author

Created subtask AIESW-34366 for INF changes

Thanks Arpit

Comment on lines +145 to +147
# Advapi32 is required for Windows Event Log API used in syslog_dispatch (message.cpp)
target_link_libraries(xrt_coreutil PRIVATE Advapi32)
target_link_libraries(xrt_coreutil_static INTERFACE Advapi32)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do #pragma comment (lib, advai32.lib) instead? I think there should be examples in other files, definitely in XRT-MCDM

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Soren, this should simplify things. Made changes accordingly. Please review.

Signed-off-by: Rahul Bramandlapalli <rbramand@amd.com>
Signed-off-by: Rahul Bramandlapalli <rbramand@amd.com>
Signed-off-by: Rahul Bramandlapalli <rbramand@amd.com>
Signed-off-by: Rahul Bramandlapalli <rbramand@amd.com>
Signed-off-by: Rahul Bramandlapalli <rbramand@amd.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants