machined: switch remaining Varlink overs over to use json_dispatch_pidref() and friends
return r;
Machine *machine;
- r = lookup_machine_by_name_or_pid(link, manager, p.machine_name, p.pid, &machine);
+ r = lookup_machine_by_name_or_pidref(link, manager, p.name, &p.pidref, &machine);
if (r == -ESRCH)
return sd_varlink_error(link, "io.systemd.Machine.NoSuchMachine", NULL);
- if (r < 0)
+ if (r != 0)
return r;
if (isempty(p.swhom))
if (r != 0)
return r;
- if (p.machine_name || pid_is_valid_or_automatic(p.pid)) {
- r = lookup_machine_by_name_or_pid(link, m, p.machine_name, p.pid, &machine);
+ if (p.name || pidref_is_set(&p.pidref) || pidref_is_automatic(&p.pidref)) {
+ r = lookup_machine_by_name_or_pidref(link, m, p.name, &p.pidref, &machine);
if (r == -ESRCH)
return sd_varlink_error(link, "io.systemd.Machine.NoSuchMachine", NULL);
- if (r < 0)
+ if (r != 0)
return r;
return list_machine_one(link, machine, /* more= */ false);
if (r != 0)
return r;
- r = lookup_machine_by_name_or_pid(link, manager, p.machine_name, p.pid, &machine);
+ r = lookup_machine_by_name_or_pidref(link, manager, p.name, &p.pidref, &machine);
if (r == -ESRCH)
return sd_varlink_error(link, "io.systemd.Machine.NoSuchMachine", NULL);
- if (r < 0)
+ if (r != 0)
return r;
return method(link, parameters, flags, machine);
varlinkctl --more call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{}' | grep '.host'
varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name":"long-running"}'
- pid=$(varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name":"long-running"}' | jq '.leader.pid')
+ pid=$(varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name":"long-running"}' | jq '.leader')
varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name":"long-running"}' >/tmp/expected
-varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List "{\"pid\":$pid}" >/tmp/got
-diff -u /tmp/expected /tmp/got
-
-varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List "{\"name\":\"long-running\", \"pid\":$pid}"
+varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List "{\"pid\":$pid}" | diff /tmp/expected -
+varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List "{\"name\":\"long-running\", \"pid\":$pid}" | diff /tmp/expected -
(! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List "{\"name\":\"non-existent\", \"pid\":$pid}")
+(! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name":""}')
+(! varlinkctl call /run/systemd/machine/io.systemd.Machine io.systemd.Machine.List '{"name":"ah@??.hmm"}')
# test io.systemd.Machine.Kill
# sending TRAP signal