]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
machine: complete description of io.systemd.Machine.{List, Terminate, Kill, Unregiste...
authorIvan Kruglov <mail@ikruglov.com>
Tue, 8 Oct 2024 16:50:47 +0000 (18:50 +0200)
committerIvan Kruglov <mail@ikruglov.com>
Thu, 10 Oct 2024 10:34:45 +0000 (12:34 +0200)
src/shared/varlink-io.systemd.Machine.c

index 17e0d79ec49a97f5d7d850ebd91877d6c8cdedf6..3beab59e2085d1e9ad8f4b6bf63ec46c2c811163 100644 (file)
@@ -5,6 +5,13 @@
 #include "bus-polkit.h"
 #include "varlink-io.systemd.Machine.h"
 
+#define VARLINK_DEFINE_MACHINE_LOOKUP_AND_POLKIT_INPUT_FIELDS                                                                                  \
+        SD_VARLINK_FIELD_COMMENT("If non-null the name of a machine."),                                                                        \
+        SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),                                                                 \
+        SD_VARLINK_FIELD_COMMENT("If non-null the PID of a machine. Special value 0 means to take pid of the machine the caller is part of."), \
+        SD_VARLINK_DEFINE_INPUT(pid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),                                                                     \
+        VARLINK_DEFINE_POLKIT_INPUT
+
 static SD_VARLINK_DEFINE_METHOD(
                 Register,
                 SD_VARLINK_DEFINE_INPUT(name,              SD_VARLINK_STRING, 0),
@@ -30,18 +37,15 @@ static SD_VARLINK_DEFINE_STRUCT_TYPE(
 
 static SD_VARLINK_DEFINE_METHOD(
                 Unregister,
-                SD_VARLINK_FIELD_COMMENT("The name of a machine to unregister."),
-                SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0));
+                VARLINK_DEFINE_MACHINE_LOOKUP_AND_POLKIT_INPUT_FIELDS);
 
 static SD_VARLINK_DEFINE_METHOD(
                 Terminate,
-                SD_VARLINK_FIELD_COMMENT("The name of a machine to terminate."),
-                SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0));
+                VARLINK_DEFINE_MACHINE_LOOKUP_AND_POLKIT_INPUT_FIELDS);
 
 static SD_VARLINK_DEFINE_METHOD(
                 Kill,
-                SD_VARLINK_FIELD_COMMENT("The name of a machine to send signal to."),
-                SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, 0),
+                VARLINK_DEFINE_MACHINE_LOOKUP_AND_POLKIT_INPUT_FIELDS,
                 SD_VARLINK_FIELD_COMMENT("Identifier that specifies what precisely to send the signal to (either 'leader' or 'all')."),
                 SD_VARLINK_DEFINE_INPUT(whom, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
                 SD_VARLINK_FIELD_COMMENT("Numeric UNIX signal integer."),
@@ -50,10 +54,7 @@ static SD_VARLINK_DEFINE_METHOD(
 static SD_VARLINK_DEFINE_METHOD_FULL(
                 List,
                 SD_VARLINK_SUPPORTS_MORE,
-                SD_VARLINK_FIELD_COMMENT("If non-null the name of a running machine to report details on. If both 'name' and 'pid' are null/unspecified enumerates all running machines."),
-                SD_VARLINK_DEFINE_INPUT(name, SD_VARLINK_STRING, SD_VARLINK_NULLABLE),
-                SD_VARLINK_FIELD_COMMENT("If non-null the PID of a running machine to report details on."),
-                SD_VARLINK_DEFINE_INPUT(pid, SD_VARLINK_INT, SD_VARLINK_NULLABLE),
+                VARLINK_DEFINE_MACHINE_LOOKUP_AND_POLKIT_INPUT_FIELDS,
                 SD_VARLINK_FIELD_COMMENT("Name of the machine"),
                 SD_VARLINK_DEFINE_OUTPUT(name, SD_VARLINK_STRING, 0),
                 SD_VARLINK_FIELD_COMMENT("128bit ID identifying this machine, formatted in hexadecimal"),