summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-24 17:54:55 -0300
committerLennart Poettering <lennart@poettering.net>2013-04-24 19:02:13 -0300
commite10375f2c0f5dd0dc8508f3ca165eb8aa63c64fb (patch)
tree56ac57f76308167c9fba789c52e268c9e2fcc2b0 /src
parenta20affe2f0fb4c8d488155a0b860549e9389f32a (diff)
login: allow watching virtual machines with sd_get_machine_names()
Diffstat (limited to 'src')
-rw-r--r--src/login/sd-login.c21
-rw-r--r--src/systemd/sd-login.h3
2 files changed, 23 insertions, 1 deletions
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index 35deb85f2d..bc8cd8ae8c 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -677,6 +677,27 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) {
good = true;
}
+ if (!category || streq(category, "machine")) {
+ _cleanup_free_ char *md = NULL, *p = NULL;
+ int r;
+
+ r = cg_get_machine_path(&md);
+ if (r < 0)
+ return r;
+
+ r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, md, NULL, &p);
+ if (r < 0)
+ return r;
+
+ k = inotify_add_watch(fd, p, IN_MOVED_TO|IN_CREATE|IN_DELETE);
+ if (k < 0) {
+ close_nointr_nofail(fd);
+ return -errno;
+ }
+
+ good = true;
+ }
+
if (!good) {
close_nointr(fd);
return -EINVAL;
diff --git a/src/systemd/sd-login.h b/src/systemd/sd-login.h
index 2415039410..4855e327a1 100644
--- a/src/systemd/sd-login.h
+++ b/src/systemd/sd-login.h
@@ -157,7 +157,8 @@ int sd_get_machine_names(char ***machines);
typedef struct sd_login_monitor sd_login_monitor;
/* Create a new monitor. Category must be NULL, "seat", "session",
- * "uid" to get monitor events for the specific category (or all). */
+ * "uid", "machine" to get monitor events for the specific category
+ * (or all). */
int sd_login_monitor_new(const char *category, sd_login_monitor** ret);
/* Destroys the passed monitor. Returns NULL. */