summaryrefslogtreecommitdiff
path: root/src/machine/machine-dbus.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-19 18:42:50 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-19 19:19:29 +0100
commitcd61c3bfd718fb398cc53ced906266a9297782c9 (patch)
treed727549baccec28d473212b85c55f2e24af25678 /src/machine/machine-dbus.c
parent8eebf6ad553adb22d7ea5d291de0b0da38606f4d (diff)
machined/machinectl: add logic to show list of available images
This adds a new bus call to machined that enumerates /var/lib/container and returns all trees stored in it, distuingishing three types: - GPT disk images, which are files suffixed with ".gpt" - directory trees - btrfs subvolumes
Diffstat (limited to 'src/machine/machine-dbus.c')
-rw-r--r--src/machine/machine-dbus.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index f6fd9cf361..163c73d451 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -32,6 +32,7 @@
#include "fileio.h"
#include "in-addr-util.h"
#include "local-addresses.h"
+#include "image.h"
#include "machine.h"
static int property_get_id(
@@ -475,9 +476,11 @@ char *machine_bus_path(Machine *m) {
}
int machine_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
+ _cleanup_(image_hashmap_freep) Hashmap *images = NULL;
_cleanup_strv_free_ char **l = NULL;
Machine *machine = NULL;
Manager *m = userdata;
+ Image *image;
Iterator i;
int r;
@@ -497,6 +500,26 @@ int machine_node_enumerator(sd_bus *bus, const char *path, void *userdata, char
return r;
}
+ images = hashmap_new(&string_hash_ops);
+ if (!images)
+ return -ENOMEM;
+
+ r = image_discover(images);
+ if (r < 0)
+ return r;
+
+ HASHMAP_FOREACH(image, images, i) {
+ char *p;
+
+ p = image_bus_path(image->name);
+ if (!p)
+ return -ENOMEM;
+
+ r = strv_consume(&l, p);
+ if (r < 0)
+ return r;
+ }
+
*nodes = l;
l = NULL;