machinectl.c revision e721d697db20c976c9eebd32c461d2b957efa437
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek This file is part of systemd.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Copyright 2013 Lennart Poettering
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek (at your option) any later version.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
3ffd4af22052963e7a29431721ee204e634bea75Lennart Poetteringstatic bool arg_all = false;
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poetteringstatic bool arg_full = false;
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poetteringstatic bool arg_no_pager = false;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic bool arg_legend = true;
4e731273edfe852a3eee2949cd20f49fd5b4f6d7Lennart Poetteringstatic BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic bool arg_read_only = false;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic bool arg_mkdir = false;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic bool arg_quiet = false;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic bool arg_ask_password = true;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringstatic OutputMode arg_output = OUTPUT_SHORT;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic bool arg_force = false;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic ImportVerify arg_verify = IMPORT_VERIFY_SIGNATURE;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic const char* arg_dkr_index_url = NULL;
7f1ad696a273703789b624fe0b209fb63e953016Lennart Poetteringstatic void pager_open_if_enabled(void) {
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poetteringstatic void polkit_agent_open_if_enabled(void) {
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering /* Open the polkit agent as a child process if necessary */
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering if (arg_transport != BUS_TRANSPORT_LOCAL)
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poetteringstatic OutputFlags get_output_flags(void) {
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering (!on_tty() || pager_have()) * OUTPUT_FULL_WIDTH |
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poetteringstatic int compare_machine_info(const void *a, const void *b) {
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering const MachineInfo *x = a, *y = b;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return strcmp(x->name, y->name);
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poetteringstatic int list_machines(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek size_t max_name = strlen("MACHINE"), max_class = strlen("CLASS"), max_service = strlen("SERVICE");
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_free_ MachineInfo *machines = NULL;
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering const char *name, *class, *service, *object;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek size_t n_machines = 0, n_allocated = 0, j;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Could not get machines: %s", bus_error_message(&error, -r));
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering r = sd_bus_message_enter_container(reply, 'a', "(ssso)");
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering while ((r = sd_bus_message_read(reply, "(ssso)", &name, &class, &service, &object)) > 0) {
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering if (!GREEDY_REALLOC(machines, n_allocated, n_machines + 1))
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering r = sd_bus_message_exit_container(reply);
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering qsort_safe(machines, n_machines, sizeof(MachineInfo), compare_machine_info);
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering for (j = 0; j < n_machines; j++)
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering printf("\n%zu machines listed.\n", n_machines);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int compare_image_info(const void *a, const void *b) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek const ImageInfo *x = a, *y = b;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return strcmp(x->name, y->name);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int list_images(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek size_t max_name = strlen("NAME"), max_type = strlen("TYPE"), max_size = strlen("USAGE"), max_crtime = strlen("CREATED"), max_mtime = strlen("MODIFIED");
34c10968cbe3b5591b3c0ce225b8694edd9709d0Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_free_ ImageInfo *images = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek size_t n_images = 0, n_allocated = 0, j;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek const char *name, *type, *object;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
0fb398316c6705dfc168733361650fdb6824896dLennart Poettering "org.freedesktop.machine1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Could not get images: %s", bus_error_message(&error, -r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "(ssbttto)");
709f6e46a35ec492b70eb92943d82a8d838ce918Michal Schmidt while ((r = sd_bus_message_read(reply, "(ssbttto)", &name, &type, &read_only, &crtime, &mtime, &size, &object)) > 0) {
709f6e46a35ec492b70eb92943d82a8d838ce918Michal Schmidt char buf[MAX(FORMAT_TIMESTAMP_MAX, FORMAT_BYTES_MAX)];
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!GREEDY_REALLOC(images, n_allocated, n_images + 1))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek images[n_images].read_only = read_only;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek images[n_images].crtime = crtime;
f7dc3ab9f43b67abcbd34062b9352ab42debec49Lennart Poettering l = strlen(strna(format_timestamp(buf, sizeof(buf), crtime)));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek l = strlen(strna(format_timestamp(buf, sizeof(buf), mtime)));
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek l = strlen(strna(format_bytes(buf, sizeof(buf), size)));
cbd671772c9ce053a7050ddd29de170eb9efac7eZbigniew Jędrzejewski-Szmek r = sd_bus_message_exit_container(reply);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek qsort_safe(images, n_images, sizeof(ImageInfo), compare_image_info);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("%-*s %-*s %-3s %-*s %-*s %-*s\n",
ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1Lennart Poettering for (j = 0; j < n_images; j++) {
ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1Lennart Poettering char crtime_buf[FORMAT_TIMESTAMP_MAX], mtime_buf[FORMAT_TIMESTAMP_MAX], size_buf[FORMAT_BYTES_MAX];
ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1Lennart Poettering printf("%-*s %-*s %s%-3s%s %-*s %-*s %-*s\n",
ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1Lennart Poettering images[j].read_only ? ansi_highlight_red() : "", yes_no(images[j].read_only), images[j].read_only ? ansi_highlight_off() : "",
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek (int) max_size, strna(format_bytes(size_buf, sizeof(size_buf), images[j].size)),
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek (int) max_crtime, strna(format_timestamp(crtime_buf, sizeof(crtime_buf), images[j].crtime)),
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek (int) max_mtime, strna(format_timestamp(mtime_buf, sizeof(mtime_buf), images[j].mtime)));
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek printf("\n%zu images listed.\n", n_images);
ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1Lennart Poetteringstatic int show_unit_cgroup(sd_bus *bus, const char *unit, pid_t leader) {
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (arg_transport == BUS_TRANSPORT_REMOTE)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek path = unit_dbus_path_from_name(unit);
fc55baee9964a118afbddbf82b8e667a0ad80b99Zbigniew Jędrzejewski-Szmek endswith(unit, ".scope") ? "org.freedesktop.systemd1.Scope" : "org.freedesktop.systemd1.Service",
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk log_error("Failed to query ControlGroup: %s", bus_error_message(&error, -r));
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk r = sd_bus_message_read(reply, "s", &cgroup);
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk if (cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, cgroup, false) != 0 && leader <= 0)
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering show_cgroup_and_extra(SYSTEMD_CGROUP_CONTROLLER, cgroup, "\t\t ", c, false, &leader, leader > 0, get_output_flags());
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchukstatic int print_addresses(sd_bus *bus, const char *name, int ifi, const char *prefix, const char *prefix2) {
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering "org.freedesktop.machine1",
ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1Lennart Poettering "org.freedesktop.machine1.Manager",
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering "GetMachineAddresses",
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering r = sd_bus_message_enter_container(reply, 'a', "(iay)");
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering while ((r = sd_bus_message_enter_container(reply, 'r', "iay")) > 0) {
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering const void *a;
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering char buffer[MAX(INET6_ADDRSTRLEN, INET_ADDRSTRLEN)];
63c8666b824e8762ffb73647e1caee165dfbc868Zbigniew Jędrzejewski-Szmek r = sd_bus_message_read(reply, "i", &family);
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering r = sd_bus_message_read_array(reply, 'y', &a, &sz);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek fputs(inet_ntop(family, a, buffer, sizeof(buffer)), stdout);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (family == AF_INET6 && ifi > 0)
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering r = sd_bus_message_exit_container(reply);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering r = sd_bus_message_exit_container(reply);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poetteringstatic int print_os_release(sd_bus *bus, const char *name, const char *prefix) {
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering "org.freedesktop.machine1",
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering "org.freedesktop.machine1.Manager",
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering "GetMachineOSRelease",
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering r = sd_bus_message_enter_container(reply, 'a', "{ss}");
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering while ((r = sd_bus_message_read(reply, "{ss}", &k, &v)) > 0) {
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering r = sd_bus_message_exit_container(reply);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("%s%s\n", prefix, pretty);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmektypedef struct MachineStatusInfo {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek struct dual_timestamp timestamp;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek char since2[FORMAT_TIMESTAMP_MAX], *s2;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!sd_id128_equal(i->id, SD_ID128_NULL))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("(" SD_ID128_FORMAT_STR ")\n", SD_ID128_FORMAT_VAL(i->id));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek s1 = format_timestamp_relative(since1, sizeof(since1), i->timestamp.realtime);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek s2 = format_timestamp(since2, sizeof(since2), i->timestamp.realtime);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("\t Since: %s; %s\n", s2, s1);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("\t Leader: %u", (unsigned) i->leader);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek get_process_comm(i->leader, &t);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("\t Service: %s", i->service);
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk } else if (i->class)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("\t Class: %s\n", i->class);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek printf("\t Root: %s\n", i->root_directory);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek for (c = 0; c < i->n_netif; c++) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (if_indextoname(i->netif[c], name)) {
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering print_os_release(bus, i->name, "\t OS: ");
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek show_unit_cgroup(bus, i->unit, i->leader);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (arg_transport == BUS_TRANSPORT_LOCAL) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek get_output_flags() | OUTPUT_BEGIN_NEWLINE,
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int map_netif(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek MachineStatusInfo *i = userdata;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek assert_cc(sizeof(int32_t) == sizeof(int));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read_array(m, SD_BUS_TYPE_INT32, &v, &l);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek i->n_netif = l / sizeof(int32_t);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmekstatic int show_machine_info(const char *verb, sd_bus *bus, const char *path, bool *new_line) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek static const struct bus_properties_map map[] = {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Name", "s", NULL, offsetof(MachineStatusInfo, name) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Class", "s", NULL, offsetof(MachineStatusInfo, class) },
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poettering { "Service", "s", NULL, offsetof(MachineStatusInfo, service) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Unit", "s", NULL, offsetof(MachineStatusInfo, unit) },
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek { "RootDirectory", "s", NULL, offsetof(MachineStatusInfo, root_directory) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Leader", "u", NULL, offsetof(MachineStatusInfo, leader) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Timestamp", "t", NULL, offsetof(MachineStatusInfo, timestamp.realtime) },
9bdbc2e2ec523dbefe1c1c7e164b5544aff0b185Lukas Nykryn { "TimestampMonotonic", "t", NULL, offsetof(MachineStatusInfo, timestamp.monotonic) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Id", "ay", bus_map_id128, offsetof(MachineStatusInfo, id) },
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poettering { "NetworkInterfaces", "ai", map_netif, 0 },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return log_error_errno(r, "Could not get properties: %m");
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poetteringstatic int show_machine_properties(sd_bus *bus, const char *path, bool *new_line) {
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poettering r = bus_print_all_properties(bus, "org.freedesktop.machine1", path, arg_property, arg_all);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering log_error_errno(r, "Could not get properties: %m");
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poetteringstatic int show_machine(int argc, char *argv[], void *userdata) {
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek bool properties, new_line = false;
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering /* If no argument is specified, inspect the manager
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poettering r = show_machine_properties(bus, "/org/freedesktop/machine1", &new_line);
d682b3a7e7c7c2941a4d3e193f1e330dbc9fae89Lennart Poettering "org.freedesktop.machine1",
d682b3a7e7c7c2941a4d3e193f1e330dbc9fae89Lennart Poettering "org.freedesktop.machine1.Manager",
d682b3a7e7c7c2941a4d3e193f1e330dbc9fae89Lennart Poettering log_error("Could not get path to machine: %s", bus_error_message(&error, -r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(reply, "o", &path);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = show_machine_properties(bus, path, &new_line);
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek r = show_machine_info(argv[0], bus, path, &new_line);
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poetteringstatic void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek char ts_relative[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek char ts_absolute[FORMAT_TIMESTAMP_MAX], *s2;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek char bs_exclusive[FORMAT_BYTES_MAX], *s4;
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek printf("\t Type: %s\n", i->type);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek printf("\t Path: %s\n", i->path);
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek i->read_only ? ansi_highlight_red() : "",
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek i->read_only ? "read-only" : "writable",
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek i->read_only ? ansi_highlight_off() : "");
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek s1 = format_timestamp_relative(ts_relative, sizeof(ts_relative), i->crtime);
e9174f29c7e3ee45137537b126458718913a3ec5Lennart Poettering s2 = format_timestamp(ts_absolute, sizeof(ts_absolute), i->crtime);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek s1 = format_timestamp_relative(ts_relative, sizeof(ts_relative), i->mtime);
63c372cb9df3bee01e3bf8cd7f96f336bddda846Lennart Poettering s2 = format_timestamp(ts_absolute, sizeof(ts_absolute), i->mtime);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek printf("\tModified: %s; %s\n", s2, s1);
de0671ee7fe465e108f62dcbbbe9366f81dd9e9aZbigniew Jędrzejewski-Szmek s3 = format_bytes(bs, sizeof(bs), i->usage);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek s4 = i->usage_exclusive != i->usage ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->usage_exclusive) : NULL;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek printf("\t Usage: %s (exclusive: %s)\n", s3, s4);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering s3 = format_bytes(bs, sizeof(bs), i->limit);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering s4 = i->limit_exclusive != i->limit ? format_bytes(bs_exclusive, sizeof(bs_exclusive), i->limit_exclusive) : NULL;
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering printf("\t Limit: %s (exclusive: %s)\n", s3, s4);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmekstatic int show_image_info(sd_bus *bus, const char *path, bool *new_line) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek static const struct bus_properties_map map[] = {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek { "Name", "s", NULL, offsetof(ImageStatusInfo, name) },
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek { "Path", "s", NULL, offsetof(ImageStatusInfo, path) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Type", "s", NULL, offsetof(ImageStatusInfo, type) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "ReadOnly", "b", NULL, offsetof(ImageStatusInfo, read_only) },
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering { "CreationTimestamp", "t", NULL, offsetof(ImageStatusInfo, crtime) },
a569398925430de1f8479262e8ab39502054f2e9Lennart Poettering { "ModificationTimestamp", "t", NULL, offsetof(ImageStatusInfo, mtime) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Usage", "t", NULL, offsetof(ImageStatusInfo, usage) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "Limit", "t", NULL, offsetof(ImageStatusInfo, limit) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "UsageExclusive", "t", NULL, offsetof(ImageStatusInfo, usage_exclusive) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "LimitExclusive", "t", NULL, offsetof(ImageStatusInfo, limit_exclusive) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
edc3797f7cd9e37c24e5241cac3263e7c918f732Lennart Poettering return log_error_errno(r, "Could not get properties: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic void print_pool_status_info(sd_bus *bus, PoolStatusInfo *i) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek s = format_bytes(bs, sizeof(bs), i->usage);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek s = format_bytes(bs, sizeof(bs), i->limit);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek static const struct bus_properties_map map[] = {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "PoolPath", "s", NULL, offsetof(PoolStatusInfo, path) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "PoolUsage", "t", NULL, offsetof(PoolStatusInfo, usage) },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "PoolLimit", "t", NULL, offsetof(PoolStatusInfo, limit) },
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering return log_error_errno(r, "Could not get properties: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek print_pool_status_info(bus, &info);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int show_image_properties(sd_bus *bus, const char *path, bool *new_line) {
7027ff61a34a12487712b382a061c654acc3a679Lennart Poettering r = bus_print_all_properties(bus, "org.freedesktop.machine1", path, arg_property, arg_all);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error_errno(r, "Could not get properties: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int show_image(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek bool properties, new_line = false;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek properties = !strstr(argv[0], "status");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* If no argument is specified, inspect the manager
db91ea32aa223d1b087d99811226a9c59a1bb281Zbigniew Jędrzejewski-Szmek r = show_image_properties(bus, "/org/freedesktop/machine1", &new_line);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
caa2f4c0c9613b2e02aafa308c8fb092576014a9Zbigniew Jędrzejewski-Szmek "org.freedesktop.machine1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Could not get path to image: %s", bus_error_message(&error, -r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(reply, "o", &path);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = show_image_properties(bus, path, &new_line);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = show_image_info(bus, path, &new_line);
433dd100442e8197868def975c6fd38b48dc6439Lukas Nykrynstatic int kill_machine(int argc, char *argv[], void *userdata) {
433dd100442e8197868def975c6fd38b48dc6439Lukas Nykryn _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1.Manager",
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt "KillMachine",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "ssi", argv[i], arg_kill_who, arg_signal);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Could not kill machine: %s", bus_error_message(&error, -r));
fc1d70af2101e16c9e6f3c5bfd5ab315ee9e6daeLennart Poetteringstatic int reboot_machine(int argc, char *argv[], void *userdata) {
23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41Michal Schmidt arg_signal = SIGINT; /* sysvinit + systemd */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return kill_machine(argc, argv, userdata);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int poweroff_machine(int argc, char *argv[], void *userdata) {
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering arg_signal = SIGRTMIN+4; /* only systemd */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return kill_machine(argc, argv, userdata);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int terminate_machine(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "TerminateMachine",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Could not terminate machine: %s", bus_error_message(&error, -r));
00a168618906bea43c3c57e20b9152582c324bf8Olivier Brunelstatic int copy_files(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek copy_from = streq(argv[0], "copy-from");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
fbb634117d0b0ebd5b105e65b141e75ae9af7f8fLennart Poettering "org.freedesktop.machine1.Manager",
fbb634117d0b0ebd5b105e65b141e75ae9af7f8fLennart Poettering copy_from ? "CopyFromMachine" : "CopyToMachine",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to copy: %s", bus_error_message(&error, -r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int bind_mount(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt "org.freedesktop.machine1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "BindMountMachine",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to bind mount: %s", bus_error_message(&error, -r));
fbb634117d0b0ebd5b105e65b141e75ae9af7f8fLennart Poetteringstatic int on_machine_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek PTYForward ** forward = (PTYForward**) userdata;
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering /* If the forwarder is already initialized, tell it to
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering * exit on the next vhangup(), so that we still flush
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering * out what might be queued and exit then. */
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering r = pty_forward_set_ignore_vhangup(*forward, false);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering log_error_errno(r, "Failed to set ignore_vhangup flag: %m");
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering /* On error, or when the forwarder is not initialized yet, quit immediately */
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering sd_event_exit(sd_bus_get_event(bus), EXIT_FAILURE);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poetteringstatic int login_machine(int argc, char *argv[], void *userdata) {
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering _cleanup_bus_slot_unref_ sd_bus_slot *slot = NULL;
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering _cleanup_(pty_forward_freep) PTYForward *forward = NULL;
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering _cleanup_event_unref_ sd_event *event = NULL;
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering if (arg_transport != BUS_TRANSPORT_LOCAL &&
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering arg_transport != BUS_TRANSPORT_MACHINE) {
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering log_error("Login only supported on local machines.");
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering return log_error_errno(r, "Failed to get event loop: %m");
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering return log_error_errno(r, "Failed to attach bus to event loop: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek match = strjoina("type='signal',"
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering "sender='org.freedesktop.machine1',"
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering "interface='org.freedesktop.machine1.Manager',"
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering "member='MachineRemoved',"
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering r = sd_bus_add_match(bus, &slot, match, on_machine_removed, &forward);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return log_error_errno(r, "Failed to add machine removal match: %m");
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering "org.freedesktop.machine1",
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering "org.freedesktop.machine1.Manager",
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering "OpenMachineLogin",
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering log_error("Failed to get machine PTY: %s", bus_error_message(&error, -r));
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering r = sd_bus_message_read(reply, "hs", &master, &pty);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering sigprocmask_many(SIG_BLOCK, SIGWINCH, SIGTERM, SIGINT, -1);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering log_info("Connected to machine %s. Press ^] three times within 1s to exit session.", argv[1]);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering sd_event_add_signal(event, NULL, SIGINT, NULL, NULL);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering sd_event_add_signal(event, NULL, SIGTERM, NULL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = pty_forward_new(event, master, true, false, &forward);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return log_error_errno(r, "Failed to create PTY forwarder: %m");
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering return log_error_errno(r, "Failed to run event loop: %m");
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering pty_forward_get_last_char(forward, &last_char);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering machine_died = pty_forward_get_ignore_vhangup(forward) == 0;
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering log_info("Machine %s terminated.", argv[1]);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering log_info("Connection to machine %s terminated.", argv[1]);
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poetteringstatic int remove_image(int argc, char *argv[], void *userdata) {
a315ac4e076c4ce7ce3e5c95792cf916d5e918c5Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1.Manager",
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering "RemoveImage",
74055aa76278232ff05574fc47c4e6b3560554a7Lennart Poettering log_error("Could not remove image: %s", bus_error_message(&error, -r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int rename_image(int argc, char *argv[], void *userdata) {
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering "org.freedesktop.machine1",
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering "org.freedesktop.machine1.Manager",
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering "RenameImage",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Could not rename image: %s", bus_error_message(&error, -r));
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poetteringstatic int clone_image(int argc, char *argv[], void *userdata) {
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poettering "org.freedesktop.machine1",
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poettering "org.freedesktop.machine1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "ssb", argv[1], argv[2], arg_read_only);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Could not clone image: %s", bus_error_message(&error, -r));
151b9b9662a90455262ce575a8a8ae74bf4ff336Lennart Poetteringstatic int read_only_image(int argc, char *argv[], void *userdata) {
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek int b = true, r;
b374689c02c681671a3c3c0b0fd3add32386b442Lennart Poettering log_error("Failed to parse boolean argument: %s", argv[2]);
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering "org.freedesktop.machine1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.machine1.Manager",
b374689c02c681671a3c3c0b0fd3add32386b442Lennart Poettering "MarkImageReadOnly",
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poettering log_error("Could not mark image read-only: %s", bus_error_message(&error, -r));
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poetteringstatic int start_machine(int argc, char *argv[], void *userdata) {
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
94b6551662e0db8eb09768ed70f77759f322b4c6Lennart Poettering _cleanup_(bus_wait_for_jobs_freep) BusWaitForJobs *w = NULL;
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_free_ char *e = NULL, *unit = NULL;
d581d9d91fa5c42ce7828a7d0b1334d370cf1670Susant Sahani log_error("Invalid machine name %s.", argv[i]);
d581d9d91fa5c42ce7828a7d0b1334d370cf1670Susant Sahani unit = unit_name_build("systemd-nspawn", e, ".service");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.systemd1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to start unit: %s", bus_error_message(&error, -r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(reply, "o", &object);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_wait_for_jobs(w, arg_quiet);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int enable_machine(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk method = streq(argv[0], "enable") ? "EnableUnitFiles" : "DisableUnitFiles";
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering "org.freedesktop.systemd1.Manager",
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering r = sd_bus_message_open_container(m, 'a', "s");
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering _cleanup_free_ char *e = NULL, *unit = NULL;
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk log_error("Invalid machine name %s.", argv[i]);
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering unit = unit_name_build("systemd-nspawn", e, ".service");
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering r = sd_bus_message_append(m, "bb", false, false);
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering r = sd_bus_message_append(m, "b", false);
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk r = sd_bus_call(bus, m, 0, &error, &reply);
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk log_error("Failed to enable or disable unit: %s", bus_error_message(&error, -r));
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk r = sd_bus_message_read(reply, "b", carries_install_info);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering r = bus_deserialize_and_dump_unit_file_changes(reply, arg_quiet);
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering "org.freedesktop.systemd1.Manager",
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering log_error("Failed to reload daemon: %s", bus_error_message(&error, -r));
03e334a1c7dc8c20c38902aa039440763acc9b17Lennart Poetteringstatic int match_log_message(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41Michal Schmidt r = sd_bus_message_read(m, "us", &priority, &line);
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering if (!streq_ptr(*our_path, sd_bus_message_get_path(m)))
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering if (arg_quiet && LOG_PRI(priority) >= LOG_INFO)
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poetteringstatic int match_transfer_removed(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_error *error) {
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering const char **our_path = userdata, *path, *result;
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering r = sd_bus_message_read(m, "uos", &id, &path, &result);
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering sd_event_exit(sd_bus_get_event(bus), !streq_ptr(result, "done"));
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poetteringstatic int transfer_signal_handler(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering log_info("Continuing download in the background. Use \"machinectl cancel-transfer %" PRIu32 "\" to abort transfer.", PTR_TO_UINT32(userdata));
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering sd_event_exit(sd_event_source_get_event(s), EINTR);
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poetteringstatic int pull_image_common(sd_bus *bus, sd_bus_message *m) {
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering _cleanup_bus_slot_unref_ sd_bus_slot *slot_job_removed = NULL, *slot_log_message = NULL;
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering _cleanup_event_unref_ sd_event* event = NULL;
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering return log_error_errno(r, "Failed to get event loop: %m");
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering return log_error_errno(r, "Failed to attach bus to event loop: %m");
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "type='signal',"
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "sender='org.freedesktop.import1',"
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "interface='org.freedesktop.import1.Manager',"
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "member='TransferRemoved',"
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering return log_error_errno(r, "Failed to install match: %m");
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "type='signal',"
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "sender='org.freedesktop.import1',"
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "interface='org.freedesktop.import1.Transfer',"
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering "member='LogMessage'",
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering return log_error_errno(r, "Failed to install match: %m");
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering r = sd_bus_call(bus, m, 0, &error, &reply);
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering log_error("Failed acquire image: %s", bus_error_message(&error, -r));
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering r = sd_bus_message_read(reply, "uo", &id, &path);
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering sigprocmask_many(SIG_BLOCK, SIGTERM, SIGINT, -1);
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering log_info("Enqueued transfer job %u. Press C-c to continue download in background.", id);
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering sd_event_add_signal(event, NULL, SIGINT, transfer_signal_handler, UINT32_TO_PTR(id));
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering sd_event_add_signal(event, NULL, SIGTERM, transfer_signal_handler, UINT32_TO_PTR(id));
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering return log_error_errno(r, "Failed to run event loop: %m");
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poetteringstatic int import_tar(int argc, char *argv[], void *userdata) {
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering log_error("Need either path or local name.");
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering log_error("Local name %s is not a suitable machine name.", local);
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
119e9655dc36f18ed74f9a256d5c693b5aeb43abLennart Poettering return log_error_errno(errno, "Failed to open %s: %m", path);
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering "org.freedesktop.import1",
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering "org.freedesktop.import1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int import_raw(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek const char *local = NULL, *path = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (isempty(path) || streq(path, "-"))
d288f79fb4a2fe4a93cf99f74dacd2cebd3f2440Zbigniew Jędrzejewski-Szmek if (isempty(local) || streq(local, "-"))
d288f79fb4a2fe4a93cf99f74dacd2cebd3f2440Zbigniew Jędrzejewski-Szmek log_error("Need either path or local name.");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!machine_name_is_valid(local)) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Local name %s is not a suitable machine name.", local);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek fd = open(path, O_RDONLY|O_CLOEXEC|O_NOCTTY);
23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41Michal Schmidt return log_error_errno(errno, "Failed to open %s: %m", path);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_new_method_call(
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.import1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.import1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int pull_tar(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_free_ char *l = NULL, *ll = NULL;
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering log_error("URL '%s' is not valid.", remote);
13790add4bf648fed816361794d8277a75253410Lennart Poettering r = import_url_last_component(remote, &l);
13790add4bf648fed816361794d8277a75253410Lennart Poettering return log_error_errno(r, "Failed to get final component of URL: %m");
15d91bff36c61d38df8edff258d1702a017a0e66Zbigniew Jędrzejewski-Szmek r = tar_strip_suffixes(local, &ll);
13790add4bf648fed816361794d8277a75253410Lennart Poettering log_error("Local name %s is not a suitable machine name.", local);
37b7affefde5443680d73642a990ce86776e28afZbigniew Jędrzejewski-Szmek r = sd_bus_message_new_method_call(
15d91bff36c61d38df8edff258d1702a017a0e66Zbigniew Jędrzejewski-Szmek "org.freedesktop.import1",
37b7affefde5443680d73642a990ce86776e28afZbigniew Jędrzejewski-Szmek "org.freedesktop.import1.Manager",
37b7affefde5443680d73642a990ce86776e28afZbigniew Jędrzejewski-Szmek import_verify_to_string(arg_verify),
7d18d348da26fdbb392c76b0f5edb7f06282afbbZbigniew Jędrzejewski-Szmek return pull_image_common(bus, m);
7d18d348da26fdbb392c76b0f5edb7f06282afbbZbigniew Jędrzejewski-Szmekstatic int pull_raw(int argc, char *argv[], void *userdata) {
7d18d348da26fdbb392c76b0f5edb7f06282afbbZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
7d18d348da26fdbb392c76b0f5edb7f06282afbbZbigniew Jędrzejewski-Szmek _cleanup_free_ char *l = NULL, *ll = NULL;
0c24bb2346b6b6232d67aacd5236b56ea4989de4Lennart Poettering log_error("URL '%s' is not valid.", remote);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = import_url_last_component(remote, &l);
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering return log_error_errno(r, "Failed to get final component of URL: %m");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!machine_name_is_valid(local)) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Local name %s is not a suitable machine name.", local);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_new_method_call(
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.import1",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.import1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek import_verify_to_string(arg_verify),
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return pull_image_common(bus, m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int pull_dkr(int argc, char *argv[], void *userdata) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (arg_verify != IMPORT_VERIFY_NO) {
f9a810bedacf1da7c505c1786a2416d592665926Lennart Poettering log_error("Imports from DKR do not support image verification, please pass --verify=no.");
e22aa3d3284709234f086ebebc13a905a295b7a7Lennart Poettering log_error("DKR name '%s' is invalid.", remote);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (tag && !dkr_tag_is_valid(tag)) {
03e334a1c7dc8c20c38902aa039440763acc9b17Lennart Poettering log_error("DKR tag '%s' is invalid.", remote);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (isempty(local) || streq(local, "-"))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!machine_name_is_valid(local)) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Local name %s is not a suitable machine name.", local);
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering "org.freedesktop.import1",
8580d1f73db36e9383e674e388b4fb55828c0c66Lennart Poettering "org.freedesktop.import1.Manager",
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 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;
return -EINVAL;
log_open();
goto finish;
goto finish;
pager_close();