mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
machine: switch to BusLocator-oriented helpers
Mechanical substitution reducing some verbosity
This commit is contained in:
parent
5d990cc571
commit
14456f7607
@ -552,14 +552,7 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu
|
||||
|
||||
getty = strjoina("container-getty@", p, ".service");
|
||||
|
||||
r = sd_bus_call_method(
|
||||
container_bus,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"StartUnit",
|
||||
error, NULL,
|
||||
"ss", getty, "replace");
|
||||
r = bus_call_method(container_bus, bus_systemd_mgr, "StartUnit", error, NULL, "ss", getty, "replace");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -668,13 +661,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
|
||||
|
||||
container_bus = allocated_bus ?: m->manager->bus;
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
container_bus,
|
||||
&tm,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"StartTransientUnit");
|
||||
r = bus_message_new_method_call(container_bus, &tm, bus_systemd_mgr, "StartTransientUnit");
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -108,14 +108,7 @@ static int call_get_os_release(sd_bus *bus, const char *method, const char *name
|
||||
awaited_args++;
|
||||
query_res = newa0(const char *, awaited_args);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
method,
|
||||
&error,
|
||||
&reply, "s", name);
|
||||
r = bus_call_method(bus, bus_machine_mgr, method, &error, &reply, "s", name);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to call '%s()': %s", method, bus_error_message(&error, r));
|
||||
|
||||
@ -179,14 +172,7 @@ static int call_get_addresses(
|
||||
assert(prefix);
|
||||
assert(prefix2);
|
||||
|
||||
r = sd_bus_call_method(bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetMachineAddresses",
|
||||
NULL,
|
||||
&reply,
|
||||
"s", name);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetMachineAddresses", NULL, &reply, "s", name);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Could not get addresses: %s", bus_error_message(&error, r));
|
||||
|
||||
@ -283,14 +269,7 @@ static int list_machines(int argc, char *argv[], void *userdata) {
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_call_method(bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"ListMachines",
|
||||
&error,
|
||||
&reply,
|
||||
NULL);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "ListMachines", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not get machines: %s", bus_error_message(&error, r));
|
||||
|
||||
@ -369,14 +348,7 @@ static int list_images(int argc, char *argv[], void *userdata) {
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_call_method(bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"ListImages",
|
||||
&error,
|
||||
&reply,
|
||||
NULL);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "ListImages", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not get images: %s", bus_error_message(&error, r));
|
||||
|
||||
@ -493,14 +465,7 @@ static int print_uid_shift(sd_bus *bus, const char *name) {
|
||||
assert(bus);
|
||||
assert(name);
|
||||
|
||||
r = sd_bus_call_method(bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetMachineUIDShift",
|
||||
&error,
|
||||
&reply,
|
||||
"s", name);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetMachineUIDShift", &error, &reply, "s", name);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to query UID/GID shift: %s", bus_error_message(&error, r));
|
||||
|
||||
@ -751,14 +716,7 @@ static int show_machine(int argc, char *argv[], void *userdata) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
const char *path = NULL;
|
||||
|
||||
r = sd_bus_call_method(bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetMachine",
|
||||
&error,
|
||||
&reply,
|
||||
"s", argv[i]);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetMachine", &error, &reply, "s", argv[i]);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not get path to machine: %s", bus_error_message(&error, -r));
|
||||
|
||||
@ -780,13 +738,7 @@ static int print_image_hostname(sd_bus *bus, const char *name) {
|
||||
const char *hn;
|
||||
int r;
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetImageHostname",
|
||||
NULL, &reply, "s", name);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetImageHostname", NULL, &reply, "s", name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -807,13 +759,7 @@ static int print_image_machine_id(sd_bus *bus, const char *name) {
|
||||
size_t size;
|
||||
int r;
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetImageMachineID",
|
||||
NULL, &reply, "s", name);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetImageMachineID", NULL, &reply, "s", name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -834,13 +780,7 @@ static int print_image_machine_info(sd_bus *bus, const char *name) {
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
|
||||
int r;
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetImageMachineInfo",
|
||||
NULL, &reply, "s", name);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetImageMachineInfo", NULL, &reply, "s", name);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -1093,15 +1033,7 @@ static int show_image(int argc, char *argv[], void *userdata) {
|
||||
for (int i = 1; i < argc; i++) {
|
||||
const char *path = NULL;
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetImage",
|
||||
&error,
|
||||
&reply,
|
||||
"s", argv[i]);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetImage", &error, &reply, "s", argv[i]);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not get path to image: %s", bus_error_message(&error, -r));
|
||||
|
||||
@ -1131,11 +1063,9 @@ static int kill_machine(int argc, char *argv[], void *userdata) {
|
||||
arg_kill_who = "all";
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
r = sd_bus_call_method(
|
||||
r = bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
bus_machine_mgr,
|
||||
"KillMachine",
|
||||
&error,
|
||||
NULL,
|
||||
@ -1171,15 +1101,7 @@ static int terminate_machine(int argc, char *argv[], void *userdata) {
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"TerminateMachine",
|
||||
&error,
|
||||
NULL,
|
||||
"s", argv[i]);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "TerminateMachine", &error, NULL, "s", argv[i]);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not terminate machine: %s", bus_error_message(&error, -r));
|
||||
}
|
||||
@ -1213,12 +1135,10 @@ static int copy_files(int argc, char *argv[], void *userdata) {
|
||||
host_path = abs_host_path;
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
r = bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
bus_machine_mgr,
|
||||
copy_from ? "CopyFromMachine" : "CopyToMachine");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
@ -1249,11 +1169,9 @@ static int bind_mount(int argc, char *argv[], void *userdata) {
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
r = bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
bus_machine_mgr,
|
||||
"BindMountMachine",
|
||||
&error,
|
||||
NULL,
|
||||
@ -1425,15 +1343,7 @@ static int login_machine(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to request machine removal match: %m");
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"OpenMachineLogin",
|
||||
&error,
|
||||
&reply,
|
||||
"s", machine);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "OpenMachineLogin", &error, &reply, "s", machine);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get login PTY: %s", bus_error_message(&error, -r));
|
||||
|
||||
@ -1498,13 +1408,7 @@ static int shell_machine(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to request machine removal match: %m");
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"OpenMachineShell");
|
||||
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "OpenMachineShell");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -1545,13 +1449,7 @@ static int remove_image(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"RemoveImage");
|
||||
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "RemoveImage");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -1577,11 +1475,9 @@ static int rename_image(int argc, char *argv[], void *userdata) {
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
r = bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
bus_machine_mgr,
|
||||
"RenameImage",
|
||||
&error,
|
||||
NULL,
|
||||
@ -1602,13 +1498,7 @@ static int clone_image(int argc, char *argv[], void *userdata) {
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"CloneImage");
|
||||
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CloneImage");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -1641,15 +1531,7 @@ static int read_only_image(int argc, char *argv[], void *userdata) {
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"MarkImageReadOnly",
|
||||
&error,
|
||||
NULL,
|
||||
"sb", argv[1], b);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "MarkImageReadOnly", &error, NULL, "sb", argv[1], b);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not mark image read-only: %s", bus_error_message(&error, -r));
|
||||
|
||||
@ -1663,15 +1545,7 @@ static int image_exists(sd_bus *bus, const char *name) {
|
||||
assert(bus);
|
||||
assert(name);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"GetImage",
|
||||
&error,
|
||||
NULL,
|
||||
"s", name);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "GetImage", &error, NULL, "s", name);
|
||||
if (r < 0) {
|
||||
if (sd_bus_error_has_name(&error, BUS_ERROR_NO_SUCH_IMAGE))
|
||||
return 0;
|
||||
@ -1933,12 +1807,10 @@ static int transfer_image_common(sd_bus *bus, sd_bus_message *m) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach bus to event loop: %m");
|
||||
|
||||
r = sd_bus_match_signal_async(
|
||||
r = bus_match_signal_async(
|
||||
bus,
|
||||
&slot_job_removed,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
bus_import_mgr,
|
||||
"TransferRemoved",
|
||||
match_transfer_removed, NULL, &path);
|
||||
if (r < 0)
|
||||
@ -2022,13 +1894,7 @@ static int import_tar(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(errno, "Failed to open %s: %m", path);
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"ImportTar");
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportTar");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -2089,13 +1955,7 @@ static int import_raw(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(errno, "Failed to open %s: %m", path);
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"ImportRaw");
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportRaw");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -2150,13 +2010,7 @@ static int import_fs(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(errno, "Failed to open directory '%s': %m", path);
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"ImportFileSystem");
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ImportFileSystem");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -2215,13 +2069,7 @@ static int export_tar(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(errno, "Failed to open %s: %m", path);
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"ExportTar");
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ExportTar");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -2264,13 +2112,7 @@ static int export_raw(int argc, char *argv[], void *userdata) {
|
||||
return log_error_errno(errno, "Failed to open %s: %m", path);
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"ExportRaw");
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "ExportRaw");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -2326,13 +2168,7 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"PullTar");
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullTar");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -2389,13 +2225,7 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"PullRaw");
|
||||
r = bus_message_new_method_call(bus, &m, bus_import_mgr, "PullRaw");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
@ -2438,14 +2268,7 @@ static int list_transfers(int argc, char *argv[], void *userdata) {
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
|
||||
r = sd_bus_call_method(bus,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"ListTransfers",
|
||||
&error,
|
||||
&reply,
|
||||
NULL);
|
||||
r = bus_call_method(bus, bus_import_mgr, "ListTransfers", &error, &reply, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not get transfers: %s", bus_error_message(&error, -r));
|
||||
|
||||
@ -2542,15 +2365,7 @@ static int cancel_transfer(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse transfer id: %s", argv[i]);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.import1",
|
||||
"/org/freedesktop/import1",
|
||||
"org.freedesktop.import1.Manager",
|
||||
"CancelTransfer",
|
||||
&error,
|
||||
NULL,
|
||||
"u", id);
|
||||
r = bus_call_method(bus, bus_import_mgr, "CancelTransfer", &error, NULL, "u", id);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not cancel transfer: %s", bus_error_message(&error, -r));
|
||||
}
|
||||
@ -2577,26 +2392,10 @@ static int set_limit(int argc, char *argv[], void *userdata) {
|
||||
if (argc > 2)
|
||||
/* With two arguments changes the quota limit of the
|
||||
* specified image */
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"SetImageLimit",
|
||||
&error,
|
||||
NULL,
|
||||
"st", argv[1], limit);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "SetImageLimit", &error, NULL, "st", argv[1], limit);
|
||||
else
|
||||
/* With one argument changes the pool quota limit */
|
||||
r = sd_bus_call_method(
|
||||
bus,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"SetPoolLimit",
|
||||
&error,
|
||||
NULL,
|
||||
"t", limit);
|
||||
r = bus_call_method(bus, bus_machine_mgr, "SetPoolLimit", &error, NULL, "t", limit);
|
||||
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not set limit: %s", bus_error_message(&error, r));
|
||||
@ -2616,13 +2415,7 @@ static int clean_images(int argc, char *argv[], void *userdata) {
|
||||
|
||||
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
|
||||
|
||||
r = sd_bus_message_new_method_call(
|
||||
bus,
|
||||
&m,
|
||||
"org.freedesktop.machine1",
|
||||
"/org/freedesktop/machine1",
|
||||
"org.freedesktop.machine1.Manager",
|
||||
"CleanPool");
|
||||
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CleanPool");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
|
@ -1577,16 +1577,7 @@ int manager_unref_unit(
|
||||
assert(m);
|
||||
assert(unit);
|
||||
|
||||
return sd_bus_call_method(
|
||||
m->bus,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"UnrefUnit",
|
||||
error,
|
||||
NULL,
|
||||
"s",
|
||||
unit);
|
||||
return bus_call_method(m->bus, bus_systemd_mgr, "UnrefUnit", error, NULL, "s", unit);
|
||||
}
|
||||
|
||||
int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, char **job) {
|
||||
@ -1596,15 +1587,7 @@ int manager_stop_unit(Manager *manager, const char *unit, sd_bus_error *error, c
|
||||
assert(manager);
|
||||
assert(unit);
|
||||
|
||||
r = sd_bus_call_method(
|
||||
manager->bus,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"StopUnit",
|
||||
error,
|
||||
&reply,
|
||||
"ss", unit, "fail");
|
||||
r = bus_call_method(manager->bus, bus_systemd_mgr, "StopUnit", error, &reply, "ss", unit, "fail");
|
||||
if (r < 0) {
|
||||
if (sd_bus_error_has_name(error, BUS_ERROR_NO_SUCH_UNIT) ||
|
||||
sd_bus_error_has_name(error, BUS_ERROR_LOAD_FAILED)) {
|
||||
@ -1641,15 +1624,7 @@ int manager_kill_unit(Manager *manager, const char *unit, int signo, sd_bus_erro
|
||||
assert(manager);
|
||||
assert(unit);
|
||||
|
||||
return sd_bus_call_method(
|
||||
manager->bus,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"KillUnit",
|
||||
error,
|
||||
NULL,
|
||||
"ssi", unit, "all", signo);
|
||||
return bus_call_method(manager->bus, bus_systemd_mgr, "KillUnit", error, NULL, "ssi", unit, "all", signo);
|
||||
}
|
||||
|
||||
int manager_unit_is_active(Manager *manager, const char *unit) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "bus-error.h"
|
||||
#include "bus-log-control-api.h"
|
||||
#include "bus-polkit.h"
|
||||
#include "bus-util.h"
|
||||
#include "cgroup-util.h"
|
||||
#include "dirent-util.h"
|
||||
#include "fd-util.h"
|
||||
@ -193,25 +194,11 @@ static int manager_connect_bus(Manager *m) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_match_signal_async(
|
||||
m->bus,
|
||||
NULL,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"JobRemoved",
|
||||
match_job_removed, NULL, m);
|
||||
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "JobRemoved", match_job_removed, NULL, m);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add match for JobRemoved: %m");
|
||||
|
||||
r = sd_bus_match_signal_async(
|
||||
m->bus,
|
||||
NULL,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"UnitRemoved",
|
||||
match_unit_removed, NULL, m);
|
||||
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "UnitRemoved", match_unit_removed, NULL, m);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to request match for UnitRemoved: %m");
|
||||
|
||||
@ -226,26 +213,11 @@ static int manager_connect_bus(Manager *m) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to request match for PropertiesChanged: %m");
|
||||
|
||||
r = sd_bus_match_signal_async(
|
||||
m->bus,
|
||||
NULL,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"Reloading",
|
||||
match_reloading, NULL, m);
|
||||
r = bus_match_signal_async(m->bus, NULL, bus_systemd_mgr, "Reloading", match_reloading, NULL, m);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to request match for Reloading: %m");
|
||||
|
||||
r = sd_bus_call_method_async(
|
||||
m->bus,
|
||||
NULL,
|
||||
"org.freedesktop.systemd1",
|
||||
"/org/freedesktop/systemd1",
|
||||
"org.freedesktop.systemd1.Manager",
|
||||
"Subscribe",
|
||||
NULL, NULL,
|
||||
NULL);
|
||||
r = bus_call_method_async(m->bus, NULL, bus_systemd_mgr, "Subscribe", NULL, NULL, NULL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to enable subscription: %m");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user