]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxccontainer: add lxc_config_item_is_supported()
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 May 2017 10:12:22 +0000 (12:12 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 3 May 2017 10:12:22 +0000 (12:12 +0200)
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>
src/lxc/lxccontainer.c
src/lxc/lxccontainer.h

index 47869081382b24087b3994e20665b79d1f99ee0a..3cee18ca782a2fa9c3a3957e34a2ba20d31c2291 100644 (file)
@@ -4522,3 +4522,8 @@ free_ct_name:
        free(ct_name);
        return ret;
 }
+
+bool lxc_config_item_is_supported(const char *key)
+{
+       return !!lxc_getconfig(key);
+}
index 06bec58c6f708233e80947d7e057ab1009397374..57301e658ab7541269e67ebc46ab14d499ca1e8c 100644 (file)
@@ -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