summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl.c
diff options
context:
space:
mode:
authorDavid Strauss <david@davidstrauss.net>2014-04-28 12:08:32 -0700
committerLennart Poettering <lennart@poettering.net>2014-05-19 00:50:30 +0900
commitcdc06ed7b6120c1049305fa7033f228ee9d86043 (patch)
tree7eb02c8810976d419861f65ebc81691f230aa116 /src/systemctl/systemctl.c
parentd3152a09ac5804ec8603daee12f98cf03523cce0 (diff)
core: Filter by state behind the D-Bus API, not in the systemctl client.
Diffstat (limited to 'src/systemctl/systemctl.c')
-rw-r--r--src/systemctl/systemctl.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index a99759f2dd..b11fee515c 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -319,12 +319,6 @@ static int compare_unit_info(const void *a, const void *b) {
static bool output_show_unit(const UnitInfo *u, char **patterns) {
const char *dot;
- if (!strv_isempty(arg_states))
- return
- strv_contains(arg_states, u->load_state) ||
- strv_contains(arg_states, u->sub_state) ||
- strv_contains(arg_states, u->active_state);
-
if (!strv_isempty(patterns)) {
char **pattern;
@@ -513,6 +507,7 @@ static int get_unit_list(
int c,
sd_bus_message **_reply) {
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
size_t size = c;
@@ -523,15 +518,22 @@ static int get_unit_list(
assert(unit_infos);
assert(_reply);
- r = sd_bus_call_method(
+ r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.systemd1",
"/org/freedesktop/systemd1",
"org.freedesktop.systemd1.Manager",
- "ListUnits",
- &error,
- &reply,
- NULL);
+ "ListUnitsFiltered");
+
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_message_append_strv(m, arg_states);
+ if (r < 0)
+ return bus_log_create_error(r);
+
+ r = sd_bus_call(bus, m, 0, &error, &reply);
if (r < 0) {
log_error("Failed to list units: %s", bus_error_message(&error, r));
return r;