augment the compiled in set of unit load paths; see
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. All
units files present in the directories containing the command line arguments will be used in preference
- to the other paths.</para>
+ to the other paths. If a template unit without an instance name is specified (e.g.
+ <filename>foo@.service</filename>), <literal>test_instance</literal> will be used as the instance
+ name, which can be controlled by <option>--instance=</option> option.</para>
<para>The following errors are currently detected:</para>
<itemizedlist>
<xi:include href="version-info.xml" xpointer="v235"/></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--instance=NAME</option></term>
+
+ <listitem>
+ <para>Specifies fallback instance name for template units. This will be used when one or more
+ template units without an instance name (e.g. <filename>foo@.service</filename>) specified for
+ <command>systemd-analyze condition</command> with <option>--unit=</option>,
+ <command>systemd-analyze security</command>, and <command>systemd-analyze verify</command>.
+ If unspecified, <literal>test_instance</literal> will be used.</para>
+
+ <xi:include href="version-info.xml" xpointer="v257"/>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--recursive-errors=<replaceable>MODE</replaceable></option></term>
compiled in set of unit load paths; see
<citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>. All
units files present in the directory containing the specified unit will be used in preference to the
- other paths.</para>
+ other paths. If a template unit without an instance name is specified (e.g.
+ <filename>foo@.service</filename>), <literal>test_instance</literal> will be used as the instance
+ name, which can be controlled by <option>--instance=</option> option.</para>
<xi:include href="version-info.xml" xpointer="v250"/></listitem>
</varlistentry>
*i);
if (unit_name_is_valid(mangled, UNIT_NAME_TEMPLATE)) {
- r = unit_name_replace_instance(mangled, "test-instance", &instance);
+ r = unit_name_replace_instance(mangled, arg_instance, &instance);
if (r < 0)
return log_oom();
#include "all-units.h"
#include "alloc-util.h"
#include "analyze-verify-util.h"
+#include "analyze.h"
#include "bus-error.h"
#include "bus-util.h"
#include "log.h"
return -EINVAL;
if (unit_name_is_valid(name, UNIT_NAME_TEMPLATE)) {
- r = unit_name_replace_instance(name, "i", &with_instance);
+ r = unit_name_replace_instance(name, arg_instance, &with_instance);
if (r < 0)
return r;
}
RecursiveErrors arg_recursive_errors = _RECURSIVE_ERRORS_INVALID;
bool arg_man = true;
bool arg_generators = false;
+const char *arg_instance = "test_instance";
double arg_svg_timescale = 1.0;
bool arg_detailed_svg = false;
char *arg_root = NULL;
" --man[=BOOL] Do [not] check for existence of man pages\n"
" --generators[=BOOL] Do [not] run unit generators\n"
" (requires privileges)\n"
+ " --instance=NAME Specify fallback instance name for template units\n"
" --iterations=N Show the specified number of iterations\n"
" --base-time=TIMESTAMP Calculate calendar times relative to\n"
" specified time\n"
ARG_NO_PAGER,
ARG_MAN,
ARG_GENERATORS,
+ ARG_INSTANCE,
ARG_ITERATIONS,
ARG_BASE_TIME,
ARG_RECURSIVE_ERRORS,
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "man", optional_argument, NULL, ARG_MAN },
{ "generators", optional_argument, NULL, ARG_GENERATORS },
+ { "instance", required_argument, NULL, ARG_INSTANCE },
{ "host", required_argument, NULL, 'H' },
{ "machine", required_argument, NULL, 'M' },
{ "iterations", required_argument, NULL, ARG_ITERATIONS },
return r;
break;
+ case ARG_INSTANCE:
+ arg_instance = optarg;
+ break;
+
case ARG_OFFLINE:
r = parse_boolean_argument("--offline", optarg, &arg_offline);
if (r < 0)
extern RecursiveErrors arg_recursive_errors;
extern bool arg_man;
extern bool arg_generators;
+extern const char *arg_instance;
extern double arg_svg_timescale;
extern bool arg_detailed_svg;
extern char *arg_root;
#include "analyze-verify-util.h"
#include "tests.h"
+const char *arg_instance = "test_instance";
+
TEST(verify_nonexistent) {
/* Negative cases */
assert_se(verify_executable(NULL, &(ExecCommand) {.flags = EXEC_COMMAND_IGNORE_FAILURE, .path = (char*) "/non/existent"}, NULL) == 0);
systemd-analyze smbios11
systemd-analyze smbios11 -q
+systemd-analyze condition --instance=tmp --unit=systemd-growfs@.service
+systemd-analyze verify --instance=tmp --man=no systemd-growfs@.service
+systemd-analyze security --instance=tmp systemd-growfs@.service
+
systemd-analyze log-level info
touch /testok