machinectl.c revision 40e1f4ea7458a0a80eaf1ef356e52bfe0835412e
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2013 Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringstatic bool arg_all = false;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringstatic bool arg_full = false;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringstatic bool arg_no_pager = false;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_legend = true;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringstatic bool arg_read_only = false;
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poetteringstatic bool arg_mkdir = false;
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poetteringstatic bool arg_quiet = false;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstatic bool arg_ask_password = true;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poetteringstatic OutputMode arg_output = OUTPUT_SHORT;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic bool arg_force = false;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringstatic void pager_open_if_enabled(void) {
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringstatic void polkit_agent_open_if_enabled(void) {
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering /* Open the polkit agent as a child process if necessary */
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering if (arg_transport != BUS_TRANSPORT_LOCAL)
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poetteringstatic OutputFlags get_output_flags(void) {
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poettering (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringstatic int compare_machine_info(const void *a, const void *b) {
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering const MachineInfo *x = a, *y = b;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenstatic int list_machines(int argc, char *argv[], void *userdata) {
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen size_t max_name = strlen("MACHINE"), max_class = strlen("CLASS"), max_service = strlen("SERVICE");
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
3e684349c2cead2e6fd2f816c34eb17daba23a49Lennart Poettering const char *name, *class, *service, *object;
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering size_t n_machines = 0, n_allocated = 0, j;
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering "org.freedesktop.machine1",
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering "org.freedesktop.machine1.Manager",
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering "ListMachines",
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersen log_error("Could not get machines: %s", bus_error_message(&error, -r));
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering r = sd_bus_message_enter_container(reply, 'a', "(ssso)");
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering while ((r = sd_bus_message_read(reply, "(ssso)", &name, &class, &service, &object)) > 0) {
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poettering if (!GREEDY_REALLOC(machines, n_allocated, n_machines + 1))
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering r = sd_bus_message_exit_container(reply);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering qsort_safe(machines, n_machines, sizeof(MachineInfo), compare_machine_info);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering for (j = 0; j < n_machines; j++)
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering printf("\n%zu machines listed.\n", n_machines);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringtypedef struct ImageInfo {
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringstatic int compare_image_info(const void *a, const void *b) {
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poettering const ImageInfo *x = a, *y = b;
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringstatic int list_images(int argc, char *argv[], void *userdata) {
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen size_t max_name = strlen("NAME"), max_type = strlen("TYPE"), max_size = strlen("USAGE"), max_crtime = strlen("CREATED"), max_mtime = strlen("MODIFIED");
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering "org.freedesktop.machine1",
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering "org.freedesktop.machine1.Manager",
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering log_error("Could not get images: %s", bus_error_message(&error, -r));
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssbttto)");
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering while ((r = sd_bus_message_read(reply, "(ssbttto)", &name, &type, &read_only, &crtime, &mtime, &size, &object)) > 0) {
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering char buf[MAX(FORMAT_TIMESTAMP_MAX, FORMAT_BYTES_MAX)];
d74fb368b18f0fbd9a4fe6f15691bbea7f3c4a01Tom Gundersen if (!GREEDY_REALLOC(images, n_allocated, n_images + 1))
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering l = strlen(strna(format_timestamp(buf, sizeof(buf), crtime)));
84129d46cd6e95e142973da93aede4c7433c9600Lennart Poettering l = strlen(strna(format_timestamp(buf, sizeof(buf), mtime)));
4e0b8b17a7465653f4e7b819dad5f8e30d64c0c4Tom Gundersen l = strlen(strna(format_bytes(buf, sizeof(buf), size)));
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_bus_message_exit_container(reply);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering qsort_safe(images, n_images, sizeof(ImageInfo), compare_image_info);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering printf("%-*s %-*s %-3s %-*s %-*s %-*s\n",
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering for (j = 0; j < n_images; j++) {
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering char crtime_buf[FORMAT_TIMESTAMP_MAX], mtime_buf[FORMAT_TIMESTAMP_MAX], size_buf[FORMAT_BYTES_MAX];
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering printf("%-*s %-*s %s%-3s%s %-*s %-*s %-*s\n",
b652d4a2099d1c167584dcc1d179d47c58dc38a2Lennart Poettering images[j].read_only ? ansi_highlight_red() : "", yes_no(images[j].read_only), images[j].read_only ? ansi_normal() : "",
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering (int) max_size, strna(format_bytes(size_buf, sizeof(size_buf), images[j].size)),
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering (int) max_crtime, strna(format_timestamp(crtime_buf, sizeof(crtime_buf), images[j].crtime)),
b652d4a2099d1c167584dcc1d179d47c58dc38a2Lennart Poettering (int) max_mtime, strna(format_timestamp(mtime_buf, sizeof(mtime_buf), images[j].mtime)));
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstatic int show_unit_cgroup(sd_bus *bus, const char *unit, pid_t leader) {
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
011842775f750711833526d5bba1b818713947f5Lennart Poettering "ControlGroup",
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen log_error("Failed to query ControlGroup: %s", bus_error_message(&error, -r));
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poettering r = sd_bus_message_read(reply, "s", &cgroup);
6cb08a8930bdaca950b152b1e8b82466ed59511cLennart Poettering if (cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, cgroup) != 0 && leader <= 0)
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, cgroup, "\t\t ", c, false, &leader, leader > 0, get_output_flags());
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poetteringstatic int print_addresses(sd_bus *bus, const char *name, int ifi, const char *prefix, const char *prefix2) {
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering "org.freedesktop.machine1",
6a1a5eec43892dee3ff6e208bceb1931c25c782eLennart Poettering "org.freedesktop.machine1.Manager",
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen "GetMachineAddresses",
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering r = sd_bus_message_enter_container(reply, 'a', "(iay)");
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering while ((r = sd_bus_message_enter_container(reply, 'r', "iay")) > 0) {
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering const void *a;
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering char buffer[MAX(INET6_ADDRSTRLEN, INET_ADDRSTRLEN)];
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering r = sd_bus_message_read(reply, "i", &family);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering r = sd_bus_message_read_array(reply, 'y', &a, &sz);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering fputs(inet_ntop(family, a, buffer, sizeof(buffer)), stdout);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poettering r = sd_bus_message_exit_container(reply);
de54e62b4bd7856fb897c9a2ee93cc228adb2135Lennart Poettering r = sd_bus_message_exit_container(reply);
6bb2c08597c999c429e889cd2403b2fef5f3e1a0Lennart Poetteringstatic int print_os_release(sd_bus *bus, const char *name, const char *prefix) {
011842775f750711833526d5bba1b818713947f5Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen "org.freedesktop.machine1",
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering "org.freedesktop.machine1.Manager",
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering "GetMachineOSRelease",
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering r = sd_bus_message_enter_container(reply, 'a', "{ss}");
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering while ((r = sd_bus_message_read(reply, "{ss}", &k, &v)) > 0) {
519ef04651b07a547f010d6462603669d7fde4e5Lennart Poettering r = sd_bus_message_exit_container(reply);
92ec902aad1ade7acbe50efd7b8ef87fbdc63af3Lennart Poetteringstatic void machine_status_info_clear(MachineStatusInfo *info) {
92ec902aad1ade7acbe50efd7b8ef87fbdc63af3Lennart Poetteringstatic void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
92ec902aad1ade7acbe50efd7b8ef87fbdc63af3Lennart Poettering char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering if (!sd_id128_equal(i->id, SD_ID128_NULL))
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering printf("(" SD_ID128_FORMAT_STR ")\n", SD_ID128_FORMAT_VAL(i->id));
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering s1 = format_timestamp_relative(since1, sizeof(since1), i->timestamp.realtime);
87f5a19343acf8ba697acc5a62bdb1a2b8c9eda3Lennart Poettering s2 = format_timestamp(since2, sizeof(since2), i->timestamp.realtime);
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt if (i->leader > 0) {
d5099efc47d4e6ac60816b5381a5f607ab03f06eMichal Schmidt printf("\t Leader: %u", (unsigned) i->leader);
636e813dc98ea40c58c6c85bc5e7e3c9f0904ea2Lennart Poettering } else if (i->class)
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering printf("\t Root: %s\n", i->root_directory);
636e813dc98ea40c58c6c85bc5e7e3c9f0904ea2Lennart Poettering for (c = 0; c < i->n_netif; c++) {
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering "\t Address: ",
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering print_os_release(bus, i->name, "\t OS: ");
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering show_unit_cgroup(bus, i->unit, i->leader);
4b95f1798f22c1bb75295f448188560cb6ec9eceLennart Poettering if (arg_transport == BUS_TRANSPORT_LOCAL)
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering get_output_flags() | OUTPUT_BEGIN_NEWLINE,
0eac462399c8e87bcce252cf058eba9f2678f2bdLennart Poetteringstatic int map_netif(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering const void *v;
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering assert_cc(sizeof(int32_t) == sizeof(int));
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering r = sd_bus_message_read_array(m, SD_BUS_TYPE_INT32, &v, &l);
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poetteringstatic int show_machine_info(const char *verb, sd_bus *bus, const char *path, bool *new_line) {
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering static const struct bus_properties_map map[] = {
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "Name", "s", NULL, offsetof(MachineStatusInfo, name) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "Class", "s", NULL, offsetof(MachineStatusInfo, class) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "Service", "s", NULL, offsetof(MachineStatusInfo, service) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "Unit", "s", NULL, offsetof(MachineStatusInfo, unit) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "RootDirectory", "s", NULL, offsetof(MachineStatusInfo, root_directory) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "Leader", "u", NULL, offsetof(MachineStatusInfo, leader) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "Timestamp", "t", NULL, offsetof(MachineStatusInfo, timestamp.realtime) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "TimestampMonotonic", "t", NULL, offsetof(MachineStatusInfo, timestamp.monotonic) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "Id", "ay", bus_map_id128, offsetof(MachineStatusInfo, id) },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering { "NetworkInterfaces", "ai", map_netif, 0 },
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering _cleanup_(machine_status_info_clear) MachineStatusInfo info = {};
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering "org.freedesktop.machine1",
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering return log_error_errno(r, "Could not get properties: %m");
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstatic int show_machine_properties(sd_bus *bus, const char *path, bool *new_line) {
*new_line = true;
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
&reply,
return bus_log_parse_error(r);
if (properties)
typedef struct ImageStatusInfo {
char *name;
char *path;
char *type;
int read_only;
if (info) {
assert(i);
if (i->name) {
if (i->type)
if (i->path)
else if (s2)
else if (s2)
s4 = i->usage_exclusive != i->usage ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->usage_exclusive) : NULL;
else if (s3)
s4 = i->limit_exclusive != i->limit ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->limit_exclusive) : NULL;
else if (s3)
path,
map,
&info);
if (*new_line)
*new_line = true;
typedef struct PoolStatusInfo {
char *path;
if (info) {
if (i->path)
"/org/freedesktop/machine1",
map,
&info);
if (*new_line)
*new_line = true;
if (properties)
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
&reply,
return bus_log_parse_error(r);
if (properties)
if (!arg_kill_who)
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
bool copy_from;
if (!abs_host_path)
return log_oom();
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
assert(m);
if (*forward) {
static int process_forward(sd_event *event, PTYForward **forward, int master, PTYForwardFlags flags, const char *name) {
char last_char = 0;
bool machine_died;
int ret = 0, r;
if (machine_died)
return ret;
return -EINVAL;
return -EOPNOTSUPP;
"path='/org/freedesktop/machine1',",
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
&reply,
return bus_log_parse_error(r);
return -EOPNOTSUPP;
return log_oom();
if (arg_uid)
else if (machine) {
const char *at;
if (at) {
"path='/org/freedesktop/machine1',",
bus,
"/org/freedesktop/machine1",
return bus_log_create_error(r);
return bus_log_create_error(r);
return bus_log_create_error(r);
return bus_log_create_error(r);
return bus_log_parse_error(r);
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
return -EINVAL;
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
return -EINVAL;
return log_oom();
return log_oom();
const char *object;
r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
&error,
&reply,
return bus_log_parse_error(r);
return log_oom();
int carries_install_info = 0;
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
method);
return bus_log_create_error(r);
return bus_log_create_error(r);
return bus_log_create_error(r);
r = sd_bus_message_close_container(m);
return bus_log_create_error(r);
return bus_log_create_error(r);
return bus_log_parse_error(r);
r = sd_bus_call_method(
bus,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
&error,
NULL,
NULL);
unsigned priority;
assert(m);
assert(m);
static int transfer_signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
assert(s);
if (!arg_quiet)
log_info("Continuing download in the background. Use \"machinectl cancel-transfer %" PRIu32 "\" to abort transfer.", PTR_TO_UINT32(userdata));
assert(m);
r = sd_bus_add_match(
bus,
"path='/org/freedesktop/import1'",
r = sd_bus_add_match(
bus,
return bus_log_parse_error(r);
if (!arg_quiet)
else if (path)
if (!local) {
return -EINVAL;
return log_oom();
return -EINVAL;
if (path) {
if (fd < 0)
bus,
"/org/freedesktop/import1",
return bus_log_create_error(r);
return bus_log_create_error(r);
else if (path)
if (!local) {
return -EINVAL;
return log_oom();
return -EINVAL;
if (path) {
if (fd < 0)
bus,
"/org/freedesktop/import1",
return bus_log_create_error(r);
return bus_log_create_error(r);
static void determine_compression_from_filename(const char *p) {
if (arg_format)
return -EINVAL;
if (path) {
if (fd < 0)
bus,
"/org/freedesktop/import1",
return bus_log_create_error(r);
return bus_log_create_error(r);
return -EINVAL;
if (path) {
if (fd < 0)
bus,
"/org/freedesktop/import1",
return bus_log_create_error(r);
return bus_log_create_error(r);
return -EINVAL;
local = l;
if (local) {
return log_oom();
return -EINVAL;
bus,
"/org/freedesktop/import1",
return bus_log_create_error(r);
return bus_log_create_error(r);
return -EINVAL;
local = l;
if (local) {
return log_oom();
return -EINVAL;
bus,
"/org/freedesktop/import1",
return bus_log_create_error(r);
return bus_log_create_error(r);
return -EINVAL;
if (tag) {
tag++;
return -EINVAL;
return -EINVAL;
if (local)
local++;
if (local) {
return -EINVAL;
bus,
"/org/freedesktop/import1",
return bus_log_create_error(r);
tag,
return bus_log_create_error(r);
typedef struct TransferInfo {
const char *type;
const char *remote;
const char *local;
double progress;
} TransferInfo;
static int compare_transfer_info(const void *a, const void *b) {
const TransferInfo *x = a, *y = b;
double progress;
r = sd_bus_call_method(
bus,
"/org/freedesktop/import1",
&error,
&reply,
NULL);
return bus_log_parse_error(r);
while ((r = sd_bus_message_read(reply, "(usssdo)", &id, &type, &remote, &local, &progress, &object)) > 0) {
size_t l;
return log_oom();
if (l > max_type)
max_type = l;
if (l > max_remote)
max_remote = l;
if (l > max_local)
max_local = l;
n_transfers ++;
return bus_log_parse_error(r);
return bus_log_parse_error(r);
if (arg_legend)
for (j = 0; j < n_transfers; j++)
if (arg_legend)
r = sd_bus_call_method(
bus,
"/org/freedesktop/import1",
&error,
NULL,
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
r = sd_bus_call_method(
bus,
"/org/freedesktop/machine1",
&error,
NULL,
" show [NAME...] Show properties of one or more VMs/containers\n"
" terminate NAME... Terminate one or more VMs/containers\n"
case ARG_VERSION:
return version();
return log_oom();
arg_all = true;
arg_all = true;
arg_full = true;
return -EINVAL;
if (arg_output < 0) {
return -EINVAL;
case ARG_NO_PAGER:
arg_no_pager = true;
case ARG_NO_LEGEND:
arg_legend = false;
case ARG_KILL_WHO:
if (arg_signal < 0) {
return -EINVAL;
case ARG_NO_ASK_PASSWORD:
arg_ask_password = false;
case ARG_READ_ONLY:
arg_read_only = true;
case ARG_MKDIR:
arg_mkdir = true;
arg_quiet = true;
case ARG_VERIFY:
if (arg_verify < 0) {
return -EINVAL;
case ARG_FORCE:
arg_force = true;
case ARG_DKR_INDEX_URL:
return -EINVAL;
case ARG_FORMAT:
return -EINVAL;
case ARG_UID:
case ARG_SETENV:
return -EINVAL;
return log_oom();
return -EINVAL;
log_open();
goto finish;
goto finish;
pager_close();