X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fsnapshot.c;h=b1d8448771d9fe6ef290448bc44ef4fb3456f28d;hb=f5b51ea7fcb0b6380c3ceb4d4f3f22f647c6fd32;hp=21e89ac9964a7f07ed7caee2c962b3563909f928;hpb=718db96199eb307751264e4163555662c9a389fa;p=elogind.git diff --git a/src/core/snapshot.c b/src/core/snapshot.c index 21e89ac99..b1d844877 100644 --- a/src/core/snapshot.c +++ b/src/core/snapshot.c @@ -25,7 +25,7 @@ #include "snapshot.h" #include "unit-name.h" #include "dbus-snapshot.h" -#include "bus-errors.h" +#include "bus-common-errors.h" static const UnitActiveState state_translation_table[_SNAPSHOT_STATE_MAX] = { [SNAPSHOT_DEAD] = UNIT_INACTIVE, @@ -51,10 +51,11 @@ static void snapshot_set_state(Snapshot *s, SnapshotState state) { s->state = state; if (state != old_state) - log_debug("%s changed %s -> %s", - UNIT(s)->id, - snapshot_state_to_string(old_state), - snapshot_state_to_string(state)); + log_unit_debug(UNIT(s)->id, + "%s changed %s -> %s", + UNIT(s)->id, + snapshot_state_to_string(old_state), + snapshot_state_to_string(state)); unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], true); } @@ -74,7 +75,7 @@ static int snapshot_load(Unit *u) { return 0; } -static int snapshot_coldplug(Unit *u) { +static int snapshot_coldplug(Unit *u, Hashmap *deferred_work) { Snapshot *s = SNAPSHOT(u); assert(s); @@ -110,7 +111,7 @@ static int snapshot_start(Unit *u) { if (s->cleanup) unit_add_to_cleanup_queue(u); - return 0; + return 1; } static int snapshot_stop(Unit *u) { @@ -120,7 +121,7 @@ static int snapshot_stop(Unit *u) { assert(s->state == SNAPSHOT_ACTIVE); snapshot_set_state(s, SNAPSHOT_DEAD); - return 0; + return 1; } static int snapshot_serialize(Unit *u, FILE *f, FDSet *fds) { @@ -154,7 +155,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value state = snapshot_state_from_string(value); if (state < 0) - log_debug("Failed to parse state value %s", value); + log_unit_debug(u->id, "Failed to parse state value %s", value); else s->deserialized_state = state; @@ -162,7 +163,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value r = parse_boolean(value); if (r < 0) - log_debug("Failed to parse cleanup value %s", value); + log_unit_debug(u->id, "Failed to parse cleanup value %s", value); else s->cleanup = r; @@ -172,7 +173,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value if (r < 0) return r; } else - log_debug("Unknown serialization key '%s'", key); + log_unit_debug(u->id, "Unknown serialization key '%s'", key); return 0; } @@ -200,14 +201,14 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e, assert(_s); if (name) { - if (!unit_name_is_valid(name, false)) + if (!unit_name_is_valid(name, TEMPLATE_INVALID)) return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s is not valid.", name); if (unit_name_to_type(name) != UNIT_SNAPSHOT) return sd_bus_error_setf(e, SD_BUS_ERROR_INVALID_ARGS, "Unit name %s lacks snapshot suffix.", name); if (manager_get_unit(m, name)) - sd_bus_error_setf(e, BUS_ERROR_UNIT_EXISTS, "Snapshot %s exists already.", name); + return sd_bus_error_setf(e, BUS_ERROR_UNIT_EXISTS, "Snapshot %s exists already.", name); } else { @@ -257,6 +258,8 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e, SNAPSHOT(u)->cleanup = cleanup; *_s = SNAPSHOT(u); + log_unit_info(u->id, "Created snapshot %s.", u->id); + return 0; fail: @@ -269,6 +272,8 @@ fail: void snapshot_remove(Snapshot *s) { assert(s); + log_unit_info(UNIT(s)->id, "Removing snapshot %s.", UNIT(s)->id); + unit_add_to_cleanup_queue(UNIT(s)); }