Skip to content

Commit

Permalink
lxccontainer: add lxc_config_item_is_supported()
Browse files Browse the repository at this point in the history
This adds lxc_config_item_is_supported() as API extension. It allows to check
whether a given config item (e.g. lxc.autodev) is supported by this LXC
instance. The function is useful in the following scenarios:
1. Users have compiled liblxc from source and have removed a config items from
   the corresponding struct in confile.c. (For example, embedded users might
   decide to gut a bunch of options that they cannot use.)
2. Callers that want to check for a specific configuration item independent of
   the version numbers exposed in our version.h header.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed May 3, 2017
1 parent 2c0807c commit 1246142
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/lxc/lxccontainer.c
Expand Up @@ -4522,3 +4522,8 @@ int list_all_containers(const char *lxcpath, char ***nret,
free(ct_name);
return ret;
}

bool lxc_config_item_is_supported(const char *key)
{
return !!lxc_getconfig(key);
}
7 changes: 7 additions & 0 deletions src/lxc/lxccontainer.h
Expand Up @@ -1022,6 +1022,13 @@ int list_all_containers(const char *lxcpath, char ***names, struct lxc_container
*/
void lxc_log_close(void);

/*!
* \brief Check if the configuration item is supported by this LXC instance.
*
* \param key Configuration item to check for.
*/
bool lxc_config_item_is_supported(const char *key);

#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit 1246142

Please sign in to comment.