Skip to content

Commit

Permalink
libtcmu: allow multiple daemons co-exist
Browse files Browse the repository at this point in the history
As we support libtcmu again users could want to run several
daemons at the same time. So don't fail the device addition
via netlink reply when can't find a handler in ctx to handle
the device. This just means the device addition event is not
for this ctx so give other daemons a chance to try.

Signed-off-by: Yaowei Bai <[email protected]>
  • Loading branch information
Yaowei Bai committed Dec 25, 2018
1 parent 98fa105 commit 5853939
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions libtcmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ static int handle_netlink(struct nl_cache_ops *unused, struct genl_cmd *cmd,
ret = add_device(ctx, buf,
nla_get_string(info->attrs[TCMU_ATTR_DEVICE]),
false);
if (ret == 1)
return 0;
break;
case TCMU_CMD_REMOVED_DEVICE:
reply_cmd = TCMU_CMD_REMOVED_DEVICE_DONE;
Expand Down Expand Up @@ -432,8 +434,8 @@ static int add_device(struct tcmulib_context *ctx, char *dev_name,

dev->handler = find_handler(ctx, dev->cfgstring);
if (!dev->handler) {
tcmu_err("could not find handler for %s\n", dev->dev_name);
goto err_free;
tcmu_dbg("could not find handler for %s\n", dev->dev_name);
goto err_nohandler;
}

if (dev->handler->check_config &&
Expand Down Expand Up @@ -536,8 +538,11 @@ static int add_device(struct tcmulib_context *ctx, char *dev_name,
tcmu_cfgfs_dev_exec_action(dev, "block_dev", 0);
err_free:
free(dev);

return -ENOENT;
err_nohandler:
free(dev);

return 1;
}

static void close_devices(struct tcmulib_context *ctx)
Expand Down

0 comments on commit 5853939

Please sign in to comment.