The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/go-lxc/pull/77
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Christian Brauner <[email protected]>
From 0a9c896303e8734f97c8b7e6357204cfd946fd4b Mon Sep 17 00:00:00 2001 From: Christian Brauner <[email protected]> Date: Thu, 4 May 2017 01:39:52 +0200 Subject: [PATCH] lxc: support for lxc_config_item_is_supported() Signed-off-by: Christian Brauner <[email protected]> --- lxc-binding.c | 9 +++++++++ lxc-binding.go | 6 ++++++ lxc-binding.h | 1 + lxc_test.go | 12 ++++++++++++ 4 files changed, 28 insertions(+) diff --git a/lxc-binding.c b/lxc-binding.c index d8841ef..406801c 100644 --- a/lxc-binding.c +++ b/lxc-binding.c @@ -446,3 +446,12 @@ bool go_lxc_detach_interface(struct lxc_container *c, const char *dev, const cha return false; #endif } + +bool go_lxc_config_item_is_supported(const char *key) +{ +#if VERSION_AT_LEAST(2, 1, 0) + return lxc_config_item_is_supported(key); +#else + return false; +#endif +} diff --git a/lxc-binding.go b/lxc-binding.go index 8737ffd..986b9ef 100644 --- a/lxc-binding.go +++ b/lxc-binding.go @@ -227,3 +227,9 @@ func VersionAtLeast(major int, minor int, micro int) bool { return true } + +func IsSupportedConfigItem(key string) bool { + configItem := C.CString(key) + defer C.free(unsafe.Pointer(configItem)) + return go_lxc_config_item_is_supported(configItem) +} diff --git a/lxc-binding.h b/lxc-binding.h index 46ad5c9..11a22df 100644 --- a/lxc-binding.h +++ b/lxc-binding.h @@ -77,6 +77,7 @@ extern int go_lxc_snapshot(struct lxc_container *c); extern pid_t go_lxc_init_pid(struct lxc_container *c); extern bool go_lxc_checkpoint(struct lxc_container *c, char *directory, bool stop, bool verbose); extern bool go_lxc_restore(struct lxc_container *c, char *directory, bool verbose); +extern bool go_lxc_config_item_is_supported(const char *key); /* n.b. that we're just adding the fields here to shorten the definition * of go_lxc_migrate; in the case where we don't have the ->migrate API call, diff --git a/lxc_test.go b/lxc_test.go index 800bf9b..3cd8f9b 100644 --- a/lxc_test.go +++ b/lxc_test.go @@ -1457,3 +1457,15 @@ func TestState(t *testing.T) { t.Error("zero value of State should be invalid") } } + +func TestSupportedConfigItems(t *testing.T) { + if VersionAtLeast(2, 1, 0) { + if !IsSupportedConfigItem("lxc.arch") { + t.Errorf("IsSupportedConfigItem failed to detect \"lxc.arch\" as supported config item...") + } + + if IsSupportedConfigItem("lxc.nonsense") { + t.Errorf("IsSupportedConfigItem failed to detect \"lxc.nonsense\" as unsupported config item...") + } + } +}
_______________________________________________ lxc-devel mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-devel
