summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2020-07-28 23:41:32 +0000
committerDaniel Golle2020-07-29 09:24:47 +0000
commit08133b8e1dc7d095d1dad1994d3e46bff1eb466f (patch)
tree36fe6b50ba5d4b4c558dc8492ea87b1bf71e2e0b
parent2d811a4b8816e65b89afdde92371dfef1857144c (diff)
downloadprocd-08133b8e1dc7d095d1dad1994d3e46bff1eb466f.tar.gz
uxc: use new container.%s kill ubus API
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--uxc.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/uxc.c b/uxc.c
index 5d06aa1..a0fd310 100644
--- a/uxc.c
+++ b/uxc.c
@@ -203,11 +203,13 @@ static void get_ocistate(struct blob_attr **ocistate, const char *name)
{
char *objname;
unsigned int id;
-
+ int ret;
*ocistate = NULL;
asprintf(&objname, "container.%s", name);
- if (ubus_lookup_id(ctx, objname, &id))
+ ret = ubus_lookup_id(ctx, objname, &id);
+ free(objname);
+ if (ret)
return;
ubus_invoke(ctx, id, "state", NULL, ocistate_cb, ocistate, 3000);
@@ -469,7 +471,8 @@ static int uxc_kill(char *name, int signal)
static struct blob_buf req;
struct blob_attr *cur, *tb[__CONF_MAX];
int rem, ret;
- uint32_t id;
+ char *objname;
+ unsigned int id;
struct runtime_state *s = NULL;
bool found = false;
@@ -494,17 +497,20 @@ static int uxc_kill(char *name, int signal)
return ENOENT;
blob_buf_init(&req, 0);
- blobmsg_add_string(&req, "name", name);
- blobmsg_add_string(&req, "instance", s->instance_name);
blobmsg_add_u32(&req, "signal", signal);
+ blobmsg_add_string(&req, "name", name);
+ printf("%s\n", blobmsg_format_json_indent(req.head, true, 0));
- ret = 0;
- if (ubus_lookup_id(ctx, "container", &id) ||
- ubus_invoke(ctx, id, "signal", req.head, NULL, NULL, 3000)) {
- ret = EIO;
- }
+ asprintf(&objname, "container.%s", name);
+ ret = ubus_lookup_id(ctx, objname, &id);
+ free(objname);
+ if (ret)
+ return ENOENT;
- return ret;
+ if (ubus_invoke(ctx, id, "kill", req.head, NULL, NULL, 3000))
+ return EIO;
+
+ return 0;
}