From 58539392a1abf4fa5b4310190ec0b90a5d346a76 Mon Sep 17 00:00:00 2001 From: Yaowei Bai Date: Tue, 25 Dec 2018 11:31:52 +0800 Subject: [PATCH] libtcmu: allow multiple daemons co-exist 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 --- libtcmu.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libtcmu.c b/libtcmu.c index a1b705b8..bcc0731c 100644 --- a/libtcmu.c +++ b/libtcmu.c @@ -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; @@ -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 && @@ -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)