Dynamically generate a service file in openbmc

81 views Asked by At

I need to implement the BIOS update functionality in the openbmc's phosphor-software-manager. In the following code snippet, versionId is a variable that can change dynamically. How can I dynamically generate a service file? or where will service file be generated?

void Activation::flashWriteHost()
{
    auto method = bus.new_method_call(SYSTEMD_BUSNAME, SYSTEMD_PATH,
                                      SYSTEMD_INTERFACE, "StartUnit");
    auto biosServiceFile = "obmc-flash-host-bios@" + versionId + ".service";
    method.append(biosServiceFile, "replace");
    try
    {
        auto reply = bus.call(method);
    }
    catch (const sdbusplus::exception_t& e)
    {
        error("Error in trying to upgrade Host Bios: {ERROR}", "ERROR", e);
        report<InternalFailure>();
    }
}
1

There are 1 answers

0
user1686 On

Systemd itself generates the unit in memory from the [email protected] template unit. The value specified after the @ (called the "instance name" in systemd) will be automatically substituted wherever the unit has a %i or %I expansion.

Compare with [email protected], which is automatically produced out of [email protected].