使用busctl创建日志条目

问题描述

正在使用openbmc,正在尝试通过busctl创建日志条目。我看到“创建”呼叫需要ssa {ss}:

# busctl introspect xyz.openbmc_project.Logging
/xyz/openbmc_project/logging xyz.openbmc_project.Logging.Create      
interface -              -             - .Create                      
method    ssa{ss}        -             -

但是,我拨打电话的尝试失败了:

# busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging xyz.openbmc_project.Logging.Create Create ssa{ss} 1 "This is a Test" "xyz.openbmc_project.Logging.Entry.Level.Error" "ARG1" "ARG2"
Failed to parse 'xyz.openbmc_project.Logging.Entry.Level.Error' number of array entries: Invalid argument

猜测问题与参数的格式有关。有什么想法吗?

解决方法

我没有openbmc,所以我无法对其进行测试,但是您的陈述可能有些错误。

ssa{ss}之后的数字是指数组的长度,因此我认为它在错误的位置。我希望它位于两个字符串之后(在您的示例中为"This is a Test""xyz.openbmc_project.Logging.Entry.Level.Error"

例如

busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging xyz.openbmc_project.Logging.Create Create ssa{ss} "This is a Test" "xyz.openbmc_project.Logging.Entry.Level.Error" 1 "ARG1" "ARG2"

我在https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/xyz/openbmc_project/Logging/Create.interface.yaml#L7找到了我认为的文档

如果"ARG1""ARG2""KEY1""VALUE1",那么您的示例可能会更清楚。我认为,如果您有两个键/值对,以下内容将是正确的:

busctl call xyz.openbmc_project.Logging /xyz/openbmc_project/logging xyz.openbmc_project.Logging.Create Create ssa{ss} "This is a Test" "xyz.openbmc_project.Logging.Entry.Level.Error" 2 "KEY1" "VALUE1" "KEY2" "VALUE2"

使用busctl时,要使此正确无误,总是需要我反复试验。在运行dbus-monitor的另一个终端中,有时可能有助于调试。