summaryrefslogtreecommitdiff
path: root/src/machine/machinectl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-03 17:50:55 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-03 17:54:24 +0200
commit717603e391b52983ca1fd218e7333a1b9dfc5c05 (patch)
tree1a4da5a932aeaa9da207d46e4f71b8bc566e2c27 /src/machine/machinectl.c
parent98be1a746ac0d7a17e69ccb05936a4d6b3223e97 (diff)
machinectl: show /etc/os-release information of container in status output
Diffstat (limited to 'src/machine/machinectl.c')
-rw-r--r--src/machine/machinectl.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index c2bf7e5197..022a4ebe50 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -224,6 +224,48 @@ static int print_addresses(sd_bus *bus, const char *name, const char *prefix, co
return 0;
}
+static int print_os_release(sd_bus *bus, const char *name, const char *prefix) {
+ _cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
+ const char *k, *v, *pretty = NULL;
+ int r;
+
+ assert(bus);
+ assert(name);
+ assert(prefix);
+
+ r = sd_bus_call_method(bus,
+ "org.freedesktop.machine1",
+ "/org/freedesktop/machine1",
+ "org.freedesktop.machine1.Manager",
+ "GetMachineOSRelease",
+ NULL,
+ &reply,
+ "s", name);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_enter_container(reply, 'a', "{ss}");
+ if (r < 0)
+ return bus_log_parse_error(r);
+
+ while ((r = sd_bus_message_read(reply, "{ss}", &k, &v)) > 0) {
+ if (streq(k, "PRETTY_NAME"))
+ pretty = v;
+
+ }
+ if (r < 0)
+ return bus_log_parse_error(r);
+
+ r = sd_bus_message_exit_container(reply);
+ if (r < 0)
+ return bus_log_parse_error(r);
+
+ if (pretty)
+ printf("%s%s\n", prefix, pretty);
+
+ return 0;
+}
+
typedef struct MachineStatusInfo {
char *name;
sd_id128_t id;
@@ -284,6 +326,8 @@ static void print_machine_status_info(sd_bus *bus, MachineStatusInfo *i) {
"\t Address: ",
"\t ");
+ print_os_release(bus, i->name, "\t OS: ");
+
if (i->unit) {
printf("\t Unit: %s\n", i->unit);
show_unit_cgroup(bus, i->unit, i->leader);