From d7d3a0aed168be92652b6ef2fb69fe9da4eefd95 Mon Sep 17 00:00:00 2001 From: "Andrea C. Granata" Date: Sun, 4 May 2014 19:38:33 +0200 Subject: [PATCH 01/31] Allow passing of bdevspecs to Container#create --- ext/lxc/lxc.c | 68 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 7 deletions(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index b3ad0fc..679eb41 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -51,6 +51,20 @@ struct container_data { struct lxc_container *container; }; +struct bdev_specs { + char *fstype; + uint64_t fssize; // fs size in bytes + struct { + char *zfsroot; + } zfs; + struct { + char *vg; + char *lv; + char *thinpool; // lvm thin pool to use, if any + } lvm; + char *dir; +}; + static char ** ruby_to_c_string_array(VALUE rb_arr) { @@ -1010,6 +1024,7 @@ struct container_create_without_gvl_args { struct container_data *data; char *template; char *bdevtype; + struct bdev_specs *bdevspecs; int flags; char **args; }; @@ -1021,14 +1036,14 @@ container_create_without_gvl(void *args_void) (struct container_create_without_gvl_args *)args_void; RETURN_WITHOUT_GVL( args->data->container->create(args->data->container, args->template, - args->bdevtype, NULL, args->flags, + args->bdevtype, args->bdevspecs, args->flags, args->args) ); } /* * call-seq: - * container.create(template, bdevtype = nil, flags = 0, args = []) + * container.create(template, bdevtype = nil, bdevspecs = {}, flags = 0, args = []) * * Creates a structure for the container according to the given template. * This usually consists of downloading and installing a Linux distribution @@ -1040,17 +1055,57 @@ static VALUE container_create(int argc, VALUE *argv, VALUE self) { int ret; - VALUE rb_template, rb_bdevtype, rb_flags, rb_args; + struct bdev_specs spec; struct container_create_without_gvl_args args; char **default_args = { NULL }; + VALUE rb_template, rb_bdevtype, rb_bdevspecs, rb_flags, rb_args; + VALUE fstype, fssize, zfsroot, lvname, vgname, thinpool, dir; args.args = default_args; - rb_scan_args(argc, argv, "13", - &rb_template, &rb_bdevtype, &rb_flags, &rb_args); + rb_scan_args(argc, argv, "14", + &rb_template, &rb_bdevtype, &rb_bdevspecs, &rb_flags, + &rb_args); + + if (!NIL_P(rb_bdevspecs)) { + memset(&spec, 0, sizeof(spec)); + + fstype = rb_hash_aref(rb_bdevspecs, SYMBOL("fstype")); + if (!NIL_P(fstype)) + spec.fstype = StringValuePtr(fstype); + + fssize = rb_hash_aref(rb_bdevspecs, SYMBOL("fssize")); + if (!NIL_P(fssize)) + spec.fssize = NUM2ULONG(fssize); + + zfsroot = rb_hash_aref(rb_bdevspecs, SYMBOL("zfsroot")); + if (!NIL_P(zfsroot)) + spec.zfs.zfsroot = StringValuePtr(zfsroot); + + lvname = rb_hash_aref(rb_bdevspecs, SYMBOL("lvname")); + if (!NIL_P(lvname)) + spec.lvm.lv = StringValuePtr(lvname); + + vgname = rb_hash_aref(rb_bdevspecs, SYMBOL("vgname")); + if (!NIL_P(vgname)) + spec.lvm.vg = StringValuePtr(vgname); + + thinpool = rb_hash_aref(rb_bdevspecs, SYMBOL("thinpool")); + if (!NIL_P(thinpool)) + spec.lvm.thinpool = StringValuePtr(thinpool); + + dir = rb_hash_aref(rb_bdevspecs, SYMBOL("dir")); + if (!NIL_P(dir)) + spec.dir = StringValuePtr(dir); + + args.bdevspecs = &spec; + + } else { + args.bdevspecs = NULL; + } args.template = StringValuePtr(rb_template); args.bdevtype = NIL_P(rb_bdevtype) ? NULL : StringValuePtr(rb_bdevtype); - args.flags = NIL_P(rb_flags) ? 0 : NUM2INT(rb_flags); + args.flags = NIL_P(rb_flags) ? 0 : NUM2INT(rb_flags); if (!NIL_P(rb_args)) args.args = ruby_to_c_string_array(rb_args); @@ -1067,7 +1122,6 @@ container_create(int argc, VALUE *argv, VALUE self) return self; } - static RETURN_WITHOUT_GVL_TYPE destroy_without_gvl(void *data_void) { From d600c76f04401677202287c0312bffc112081440 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Tue, 20 May 2014 09:44:26 -0300 Subject: [PATCH 02/31] Add debian directory --- debian/changelog | 5 +++++ debian/compat | 1 + debian/control | 14 ++++++++++++++ debian/copyright | 9 +++++++++ debian/rules | 12 ++++++++++++ debian/source/format | 1 + debian/watch | 1 + 7 files changed, 43 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/watch diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..a948a98 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +ruby-lxc (1.1.0-0digirati1) trusty; urgency=low + + * Version 1.1.0. + + -- Andre Nathan Tue, 20 May 2014 09:37:12 -0300 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..922a2c7 --- /dev/null +++ b/debian/control @@ -0,0 +1,14 @@ +Source: ruby-lxc +Section: ruby +Priority: optional +Maintainer: Andre Nathan +Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.2.3~) +Standards-Version: 3.9.5 +XS-Ruby-Versions: all + +Package: ruby-lxc +Architecture: any +XB-Ruby-Versions: ${ruby:Versions} +Depends: ${misc:Depends}, ${shlibs:Depends}, ruby | ruby-interpreter, lxc-dev +Description: Ruby bindings for liblxc + This package provides liblxc bindings for the Ruby programming language. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..b9c9e9f --- /dev/null +++ b/debian/copyright @@ -0,0 +1,9 @@ +Format: http://anonscm.debian.org/viewvc/dep/web/deps/dep5.mdwn?revision=173 +Upstream-Name: ruby-lxc + +Files: * +Copyright: Copyright 2014 Andre Nathan +License: LGPL-2.1 + On Debian systems, the full text of the GNU General Public + License version 2 can be found in the file + `/usr/share/common-licenses/LGPL-2.1'. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..a4b9e28 --- /dev/null +++ b/debian/rules @@ -0,0 +1,12 @@ +#!/usr/bin/make -f +#export DH_VERBOSE=1 +# +# Uncomment to ignore all test failures (but the tests will run anyway) +#export DH_RUBY_IGNORE_TESTS=all +# +# Uncomment to ignore some test failures (but the tests will run anyway). +# Valid values: +#export DH_RUBY_IGNORE_TESTS=ruby1.8 ruby1.9.1 require-rubygems + +%: + dh $@ --buildsystem=ruby --with ruby diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..9e7c0da --- /dev/null +++ b/debian/watch @@ -0,0 +1 @@ +version=3 From 14b589c042997c80e1fe7c48aaf9752be3d53a62 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Tue, 20 May 2014 09:34:23 -0300 Subject: [PATCH 03/31] Bump version to 1.1.0 --- lib/lxc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lxc/version.rb b/lib/lxc/version.rb index 1584e3a..0c293a0 100644 --- a/lib/lxc/version.rb +++ b/lib/lxc/version.rb @@ -1,3 +1,3 @@ module LXC - VERSION = '1.0.2' + VERSION = '1.1.0' end From d545c94e083dfda2e3cc116d3541c4e6812e9983 Mon Sep 17 00:00:00 2001 From: uu59 Date: Sat, 24 May 2014 13:42:20 +0900 Subject: [PATCH 04/31] Fix README for 1.1.0 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 44d3f85..6bb374e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,8 @@ simply run the commands below ```sh bundle install bundle exec rake compile -gem install pkg/ruby-lxc-1.0.2.gem +bundle exec rake gem +gem install pkg/ruby-lxc-1.1.0.gem ``` or just add this to your ```Gemfile``` ```ruby From 8a69bc7bfdac4ed26f7c979a3428df4026e5bab8 Mon Sep 17 00:00:00 2001 From: uu59 Date: Sat, 24 May 2014 13:49:54 +0900 Subject: [PATCH 05/31] Fix require path on sample --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bb374e..82b1c2f 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ gem install pkg/ruby-lxc-1.1.0.gem ``` or just add this to your ```Gemfile``` ```ruby -gem "ruby-lxc", github: "lxc/ruby-lxc" +gem "ruby-lxc", github: "lxc/ruby-lxc", require: "lxc" ``` ## Usage From 755609c059a6883822985bed8a066a91cd4d9be5 Mon Sep 17 00:00:00 2001 From: NiR- Date: Fri, 6 Jun 2014 10:24:18 +0200 Subject: [PATCH 06/31] Fix clear_config method. --- ext/lxc/lxc.c | 2 +- test/test_lxc_created.rb | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index 679eb41..d71b7ac 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -2121,7 +2121,7 @@ Init_lxc(void) rb_define_method(Container, "add_device_node", container_add_device_node, -1); rb_define_method(Container, "attach", container_attach, -1); - rb_define_method(Container, "clear_config", container_clear_config, -1); + rb_define_method(Container, "clear_config", container_clear_config, 0); rb_define_method(Container, "clear_config_item", container_clear_config_item, 1); rb_define_method(Container, "clone", container_clone, -1); diff --git a/test/test_lxc_created.rb b/test/test_lxc_created.rb index 120e1cf..a49875c 100644 --- a/test/test_lxc_created.rb +++ b/test/test_lxc_created.rb @@ -28,6 +28,7 @@ class TestLXCCreated < Test::Unit::TestCase def test_container_configuration capdrop = @container.config_item('lxc.cap.drop') + assert_instance_of(Array, @container.config_item('lxc.cap.drop')) @container.clear_config_item('lxc.cap.drop') @container.set_config_item('lxc.cap.drop', capdrop[0...-1]) @container.set_config_item('lxc.cap.drop', capdrop[-1]) @@ -40,6 +41,15 @@ class TestLXCCreated < Test::Unit::TestCase assert_match(/^00:16:3e:/, @container.config_item('lxc.network.0.hwaddr')) end + def test_clear_config + assert_not_nil(@container.config_item('lxc.utsname')) + assert(@container.clear_config) + + assert_raise(LXC::Error) do + @container.config_item('lxc.utsname').nil? + end + end + def test_container_mount_points assert_instance_of(Array, @container.config_item('lxc.mount.entry')) end From 2b9f45f8a58f05c4183a7e3af3ca4e7b2597bef1 Mon Sep 17 00:00:00 2001 From: NiR- Date: Fri, 6 Jun 2014 10:31:39 +0200 Subject: [PATCH 07/31] Adding early nil return in config_item (when value is empty). --- ext/lxc/lxc.c | 3 +++ test/test_lxc_created.rb | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index d71b7ac..b43732c 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -1238,6 +1238,9 @@ container_config_item(VALUE self, VALUE rb_key) if (len1 < 0) rb_raise(Error, "invalid configuration key: %s", key); + if (len1 == 0) + return Qnil; + value = malloc(sizeof(char) * len1 + 1); if (value == NULL) rb_raise(rb_eNoMemError, "unable to allocate configuration value"); diff --git a/test/test_lxc_created.rb b/test/test_lxc_created.rb index a49875c..5784855 100644 --- a/test/test_lxc_created.rb +++ b/test/test_lxc_created.rb @@ -41,6 +41,26 @@ class TestLXCCreated < Test::Unit::TestCase assert_match(/^00:16:3e:/, @container.config_item('lxc.network.0.hwaddr')) end + def test_container_fstab + config_path = @container.config_path + '/' + @name + '/config' + fstab_path = @container.config_path + '/' + @name + '/fstab' + + @container.set_config_item('lxc.mount', fstab_path) + @container.save_config(config_path) + + assert_instance_of(String, @container.config_item('lxc.mount')) + assert_not_nil(@container.config_item('lxc.mount')) + + f = File.readlines(config_path) + f.reject! { |l| /^lxc\.mount = (.*)$/ =~ l } + File.write(config_path, f.join) + + @container.clear_config + @container.load_config(config_path) + + assert(@container.config_item('lxc.mount').nil?) + end + def test_clear_config assert_not_nil(@container.config_item('lxc.utsname')) assert(@container.clear_config) From 3de05419851e3384e74dcb8dd81477503be14ba2 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Fri, 6 Jun 2014 11:23:48 -0300 Subject: [PATCH 08/31] Bump version to 1.1.1 --- README.md | 2 +- debian/changelog | 6 ++++++ lib/lxc/version.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82b1c2f..42bed99 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ simply run the commands below bundle install bundle exec rake compile bundle exec rake gem -gem install pkg/ruby-lxc-1.1.0.gem +gem install pkg/ruby-lxc-1.1.1.gem ``` or just add this to your ```Gemfile``` ```ruby diff --git a/debian/changelog b/debian/changelog index a948a98..759ca47 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ruby-lxc (1.1.1-0digirati1) trusty; urgency=low + + * Version 1.1.1. + + -- Andre Nathan Fri, 06 Jun 2014 11:23:11 -0300 + ruby-lxc (1.1.0-0digirati1) trusty; urgency=low * Version 1.1.0. diff --git a/lib/lxc/version.rb b/lib/lxc/version.rb index 0c293a0..0a84461 100644 --- a/lib/lxc/version.rb +++ b/lib/lxc/version.rb @@ -1,3 +1,3 @@ module LXC - VERSION = '1.1.0' + VERSION = '1.1.1' end From 8e8d8cc25373ae92606fda4b3081abf26653039e Mon Sep 17 00:00:00 2001 From: NiR- Date: Mon, 9 Jun 2014 08:21:45 +0200 Subject: [PATCH 09/31] Correcting compilation for the last lxc development version. --- ext/lxc/lxc.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index b43732c..bb4df28 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -51,20 +51,6 @@ struct container_data { struct lxc_container *container; }; -struct bdev_specs { - char *fstype; - uint64_t fssize; // fs size in bytes - struct { - char *zfsroot; - } zfs; - struct { - char *vg; - char *lv; - char *thinpool; // lvm thin pool to use, if any - } lvm; - char *dir; -}; - static char ** ruby_to_c_string_array(VALUE rb_arr) { From 25b91f2c7f5b1cf5915e6451cdc6b4ba738d82e8 Mon Sep 17 00:00:00 2001 From: NiR- Date: Mon, 9 Jun 2014 05:24:09 +0200 Subject: [PATCH 10/31] Adding all possible states in the doc and clarifying what keys method does. --- ext/lxc/lxc.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index b43732c..36c4961 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -440,6 +440,15 @@ container_running_p(VALUE self) * container.state * * Returns a symbol representing the state of the container. + * + * * +:stopped+ + * * +:starting+ + * * +:running+ + * * +:stopping+ + * * +:aborting+ + * * +:freezing+ + * * +:frozen+ + * * +:thawed+ */ static VALUE container_state(VALUE self) @@ -1277,6 +1286,10 @@ container_config_path(VALUE self) * container.keys(key) * * Returns a list of valid sub-keys for the given configuration key. + * + * Keys can be in the format 'lxc.network.', (eg. 'lxc.network.0', + * 'lxc.network.1'). The result shows which keys are valid according to + * type of network interface. */ static VALUE container_keys(VALUE self, VALUE rb_key) From e69f956f1e1a2670c5b6832e225b3b838c337127 Mon Sep 17 00:00:00 2001 From: NiR- Date: Mon, 9 Jun 2014 18:13:58 +0200 Subject: [PATCH 11/31] Fixing liblxc name in travis conf. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0cd65ed..7d6722d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,6 @@ before_install: - sudo apt-get install -y python-software-properties - sudo add-apt-repository -y ppa:ubuntu-lxc/daily - sudo apt-get update -y - - sudo apt-get install -y liblxc0 lxc lxc-dbg lxc-dev lxc-templates lxc-tests lxctl python3-lxc + - sudo apt-get install -y liblxc1 lxc lxc-dbg lxc-dev lxc-templates lxc-tests lxctl python3-lxc script: - bundle exec rake clean package From 06cbff1bcf7ceeda65c0c22b770eca1cbd221eb8 Mon Sep 17 00:00:00 2001 From: NiR- Date: Mon, 9 Jun 2014 21:26:53 +0200 Subject: [PATCH 12/31] Removing unused packages from travis conf --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7d6722d..0813e2e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,6 @@ before_install: - sudo apt-get install -y python-software-properties - sudo add-apt-repository -y ppa:ubuntu-lxc/daily - sudo apt-get update -y - - sudo apt-get install -y liblxc1 lxc lxc-dbg lxc-dev lxc-templates lxc-tests lxctl python3-lxc + - sudo apt-get install -y liblxc1 script: - bundle exec rake clean package From f1aef98626137bfa274a9089d1e2af4b9f74d23b Mon Sep 17 00:00:00 2001 From: NiR- Date: Mon, 9 Jun 2014 21:45:28 +0200 Subject: [PATCH 13/31] Adding rdoc dependencies for ruby 1.8 --- ruby-lxc.gemspec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ruby-lxc.gemspec b/ruby-lxc.gemspec index 2802efa..4df7fcb 100644 --- a/ruby-lxc.gemspec +++ b/ruby-lxc.gemspec @@ -13,6 +13,8 @@ Gem::Specification.new do |s| s.extensions = 'ext/lxc/extconf.rb' s.has_rdoc = true + s.add_development_dependency "rdoc" + s.add_development_dependency "rdoc-data" s.add_development_dependency "rake-compiler" s.homepage = 'https://github.com/lxc/ruby-lxc' From 0914af29140c2a6209e44b714bfc472c9e2f843b Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Wed, 11 Jun 2014 09:29:57 -0300 Subject: [PATCH 14/31] Next version will be 1.2.0 --- lib/lxc/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/lxc/version.rb b/lib/lxc/version.rb index 0a84461..1b94970 100644 --- a/lib/lxc/version.rb +++ b/lib/lxc/version.rb @@ -1,3 +1,3 @@ module LXC - VERSION = '1.1.1' + VERSION = '1.2.0' end From 9d231bc99ef1cdcfe264d738c39cbde8b454a232 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Fri, 13 Jun 2014 14:38:05 -0300 Subject: [PATCH 15/31] Version 1.2.0 --- README.md | 2 +- debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 42bed99..c4dad30 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ simply run the commands below bundle install bundle exec rake compile bundle exec rake gem -gem install pkg/ruby-lxc-1.1.1.gem +gem install pkg/ruby-lxc-1.2.0.gem ``` or just add this to your ```Gemfile``` ```ruby diff --git a/debian/changelog b/debian/changelog index 759ca47..72e7c0e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ruby-lxc (1.2.0-0digirati1) trusty; urgency=low + + * Version 1.2.0. + + -- Andre Nathan Fri, 13 Jun 2014 14:37:26 -0300 + ruby-lxc (1.1.1-0digirati1) trusty; urgency=low * Version 1.1.1. From 850b1f4b8a81b23c6bc0d24c674fc96c36c93bad Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Fri, 13 Jun 2014 14:49:54 -0300 Subject: [PATCH 16/31] Add notifications --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0813e2e..00b9d3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,3 +14,7 @@ before_install: - sudo apt-get install -y liblxc1 script: - bundle exec rake clean package + +notifications: + email: + - andrenth@gmail.com From 6024d0e40beb8d12aa16a6f916a7e66b9127cceb Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Mon, 16 Jun 2014 14:17:40 -0300 Subject: [PATCH 17/31] Add travis build status --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index c4dad30..9c85a18 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Ruby-LXC +[![Build Status](https://travis-ci.org/lxc/ruby-lxc.svg?branch=master)](https://travis-ci.org/lxc/ruby-lxc) + ## Introduction Ruby-LXC is a Ruby binding for liblxc. It allows the creation and management From 10ff154014469b45a91df12daf3676951c15315d Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Wed, 24 Sep 2014 10:28:22 -0300 Subject: [PATCH 18/31] Better check for std{in,out,err} attach options --- ext/lxc/lxc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index cb07d07..e176dd7 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -546,10 +546,10 @@ is_string_array(VALUE v) } static int -is_io(VALUE v) +has_file_descriptor(VALUE v) { - return rb_respond_to(v, rb_intern("sysread")) && - rb_respond_to(v, rb_intern("syswrite")); + return rb_respond_to(v, rb_intern("fileno")) && + rb_funcall(v, rb_intern("fileno"), 0) != Qnil; } static void @@ -648,21 +648,21 @@ lxc_attach_parse_options(VALUE rb_opts) } rb_stdin = rb_hash_aref(rb_opts, SYMBOL("stdin")); if (!NIL_P(rb_stdin)) { - if (is_io(rb_stdin)) + if (has_file_descriptor(rb_stdin)) opts->stdin_fd = io_fileno(rb_stdin); else goto err; } rb_stdout = rb_hash_aref(rb_opts, SYMBOL("stdout")); if (!NIL_P(rb_stdout)) { - if (is_io(rb_stdout)) + if (has_file_descriptor(rb_stdout)) opts->stdout_fd = io_fileno(rb_stdout); else goto err; } rb_stderr = rb_hash_aref(rb_opts, SYMBOL("stderr")); if (!NIL_P(rb_stderr)) { - if (is_io(rb_stderr)) + if (has_file_descriptor(rb_stderr)) opts->stderr_fd = io_fileno(rb_stderr); else goto err; From 9bbf0444a759456ddc83d9db1a8d7cc88d60ebe5 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Wed, 24 Sep 2014 10:43:18 -0300 Subject: [PATCH 19/31] Raise errors for attach options --- ext/lxc/lxc.c | 80 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index e176dd7..d1664c7 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -569,6 +569,7 @@ lxc_attach_free_options(lxc_attach_options_t *opts) static lxc_attach_options_t * lxc_attach_parse_options(VALUE rb_opts) { + char *error = NULL; lxc_attach_options_t default_opts = LXC_ATTACH_OPTIONS_DEFAULT; lxc_attach_options_t *opts; VALUE rb_attach_flags, rb_namespaces, rb_personality, rb_initial_cwd; @@ -583,96 +584,125 @@ lxc_attach_parse_options(VALUE rb_opts) if (NIL_P(rb_opts)) return opts; + error = NULL; + rb_attach_flags = rb_hash_aref(rb_opts, SYMBOL("flags")); if (!NIL_P(rb_attach_flags)) { - if (is_integer(rb_attach_flags)) + if (is_integer(rb_attach_flags)) { opts->attach_flags = NUM2INT(rb_attach_flags); - else + } else { + error = "flags must be an integer"; goto err; + } } rb_namespaces = rb_hash_aref(rb_opts, SYMBOL("namespaces")); if (!NIL_P(rb_namespaces)) { - if (is_integer(rb_namespaces)) + if (is_integer(rb_namespaces)) { opts->namespaces = NUM2INT(rb_namespaces); - else + } else { + error = "namespaces must be an integer"; goto err; + } } rb_personality = rb_hash_aref(rb_opts, SYMBOL("personality")); if (!NIL_P(rb_personality)) { - if (is_integer(rb_personality)) + if (is_integer(rb_personality)) { opts->personality = NUM2INT(rb_personality); - else + } else { + error = "personality must be an integer"; goto err; + } } rb_initial_cwd = rb_hash_aref(rb_opts, SYMBOL("initial_cwd")); if (!NIL_P(rb_initial_cwd)) { - if (is_string(rb_initial_cwd)) + if (is_string(rb_initial_cwd)) { opts->initial_cwd = StringValuePtr(rb_initial_cwd); - else + } else { + error = "initial_cwd must be a string"; goto err; + } } rb_uid = rb_hash_aref(rb_opts, SYMBOL("uid")); if (!NIL_P(rb_uid)) { - if (is_integer(rb_uid)) + if (is_integer(rb_uid)) { opts->uid = NUM2INT(rb_uid); - else + } else { + error = "uid must be an integer"; goto err; + } } rb_gid = rb_hash_aref(rb_opts, SYMBOL("gid")); if (!NIL_P(rb_gid)) { - if (is_integer(rb_gid)) + if (is_integer(rb_gid)) { opts->gid = NUM2INT(rb_gid); - else + } else { + error = "gid must be an integer"; goto err; + } } rb_env_policy = rb_hash_aref(rb_opts, SYMBOL("env_policy")); if (!NIL_P(rb_env_policy)) { - if (is_integer(rb_env_policy)) + if (is_integer(rb_env_policy)) { opts->env_policy = NUM2INT(rb_env_policy); - else + } else { + error = "env_policy must be an integer"; goto err; + } } rb_extra_env_vars = rb_hash_aref(rb_opts, SYMBOL("extra_env_vars")); if (!NIL_P(rb_extra_env_vars)) { - if (is_string_array(rb_extra_env_vars)) + if (is_string_array(rb_extra_env_vars)) { opts->extra_env_vars = ruby_to_c_string_array(rb_extra_env_vars); - else + } else { + error = "extra_env_vars must be a array of strings"; goto err; + } } rb_extra_keep_env = rb_hash_aref(rb_opts, SYMBOL("extra_keep_env")); if (!NIL_P(rb_extra_keep_env)) { - if (is_string_array(rb_extra_keep_env)) + if (is_string_array(rb_extra_keep_env)) { opts->extra_keep_env = ruby_to_c_string_array(rb_extra_keep_env); - else + } else { + error = "extra_keep_env must be a array of strings"; goto err; + } } rb_stdin = rb_hash_aref(rb_opts, SYMBOL("stdin")); if (!NIL_P(rb_stdin)) { - if (has_file_descriptor(rb_stdin)) + if (has_file_descriptor(rb_stdin)) { opts->stdin_fd = io_fileno(rb_stdin); - else + } else { + error = "stdin object must have a file descriptor"; goto err; + } } rb_stdout = rb_hash_aref(rb_opts, SYMBOL("stdout")); if (!NIL_P(rb_stdout)) { - if (has_file_descriptor(rb_stdout)) + if (has_file_descriptor(rb_stdout)) { opts->stdout_fd = io_fileno(rb_stdout); - else + } else { + error = "stdout object must have a file descriptor"; goto err; + } } rb_stderr = rb_hash_aref(rb_opts, SYMBOL("stderr")); if (!NIL_P(rb_stderr)) { - if (has_file_descriptor(rb_stderr)) + if (has_file_descriptor(rb_stderr)) { opts->stderr_fd = io_fileno(rb_stderr); - else + } else { + error = "stderr object must have a file descriptor"; goto err; + } } return opts; err: lxc_attach_free_options(opts); - return NULL; + if (error != NULL) + rb_raise(rb_eArgError, "%s", error); + else + return NULL; } static RETURN_WITHOUT_GVL_TYPE From 03584f60c5b6db46c00f1d30214452076c8283dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 23 Feb 2015 18:41:18 -0500 Subject: [PATCH 20/31] Update Travis configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 00b9d3c..5eec734 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,5 +16,6 @@ script: - bundle exec rake clean package notifications: + webhooks: https://linuxcontainers.org/webhook-lxcbot/ email: - andrenth@gmail.com From 75c0db54a8b4aed727531b4f51e6483b114b8b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E5=BC=A0=E7=BA=B8?= Date: Fri, 6 Mar 2015 12:22:51 +0800 Subject: [PATCH 21/31] Update README.md you need to install ruby-dev/lxc-dev(debian/ubuntu) before $(gem install ruby-lxc) --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 9c85a18..26d2c53 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ Assuming a current installation of LXC is available, to install Ruby-LXC simply run the commands below ```sh +sudo apt-get install ruby-dev lxc-dev + bundle install bundle exec rake compile bundle exec rake gem @@ -27,6 +29,7 @@ gem "ruby-lxc", github: "lxc/ruby-lxc", require: "lxc" - Container lifecycle management (create, start, stop and destroy containers) ```ruby +require 'lxc' c = LXC::Container.new('foo') c.create('ubuntu') # create a container named foo with ubuntu template c.start From b262a3f5ad10dfbead8b0cb20e427f2e243ed05d Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Mon, 4 Jan 2016 11:22:21 -0200 Subject: [PATCH 22/31] Avoid rb_std{in,out,err} name clash with rubinius --- ext/lxc/lxc.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index d1664c7..2fd5a62 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -574,7 +574,7 @@ lxc_attach_parse_options(VALUE rb_opts) lxc_attach_options_t *opts; VALUE rb_attach_flags, rb_namespaces, rb_personality, rb_initial_cwd; VALUE rb_uid, rb_gid, rb_env_policy, rb_extra_env_vars, rb_extra_keep_env; - VALUE rb_stdin, rb_stdout, rb_stderr; + VALUE rb_stdin_opt, rb_stdout_opt, rb_stderr_opt; opts = malloc(sizeof(*opts)); if (opts == NULL) @@ -667,28 +667,28 @@ lxc_attach_parse_options(VALUE rb_opts) goto err; } } - rb_stdin = rb_hash_aref(rb_opts, SYMBOL("stdin")); - if (!NIL_P(rb_stdin)) { - if (has_file_descriptor(rb_stdin)) { - opts->stdin_fd = io_fileno(rb_stdin); + rb_stdin_opt = rb_hash_aref(rb_opts, SYMBOL("stdin")); + if (!NIL_P(rb_stdin_opt)) { + if (has_file_descriptor(rb_stdin_opt)) { + opts->stdin_fd = io_fileno(rb_stdin_opt); } else { error = "stdin object must have a file descriptor"; goto err; } } - rb_stdout = rb_hash_aref(rb_opts, SYMBOL("stdout")); - if (!NIL_P(rb_stdout)) { - if (has_file_descriptor(rb_stdout)) { - opts->stdout_fd = io_fileno(rb_stdout); + rb_stdout_opt = rb_hash_aref(rb_opts, SYMBOL("stdout")); + if (!NIL_P(rb_stdout_opt)) { + if (has_file_descriptor(rb_stdout_opt)) { + opts->stdout_fd = io_fileno(rb_stdout_opt); } else { error = "stdout object must have a file descriptor"; goto err; } } - rb_stderr = rb_hash_aref(rb_opts, SYMBOL("stderr")); - if (!NIL_P(rb_stderr)) { - if (has_file_descriptor(rb_stderr)) { - opts->stderr_fd = io_fileno(rb_stderr); + rb_stderr_opt = rb_hash_aref(rb_opts, SYMBOL("stderr")); + if (!NIL_P(rb_stderr_opt)) { + if (has_file_descriptor(rb_stderr_opt)) { + opts->stderr_fd = io_fileno(rb_stderr_opt); } else { error = "stderr object must have a file descriptor"; goto err; From 9dbd2e901a34100ff6fcf5207a055b8a87896e2a Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Mon, 4 Jan 2016 11:41:36 -0200 Subject: [PATCH 23/31] Fix debian dependencies --- debian/control | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index 922a2c7..96283e8 100644 --- a/debian/control +++ b/debian/control @@ -2,13 +2,13 @@ Source: ruby-lxc Section: ruby Priority: optional Maintainer: Andre Nathan -Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.2.3~) +Build-Depends: debhelper (>= 7.0.50~), gem2deb (>= 0.2.3~), lxc-dev Standards-Version: 3.9.5 XS-Ruby-Versions: all Package: ruby-lxc Architecture: any XB-Ruby-Versions: ${ruby:Versions} -Depends: ${misc:Depends}, ${shlibs:Depends}, ruby | ruby-interpreter, lxc-dev +Depends: ${misc:Depends}, ${shlibs:Depends}, ruby | ruby-interpreter, liblxc1 Description: Ruby bindings for liblxc This package provides liblxc bindings for the Ruby programming language. From 5039b493c589882ab00e5503a66f443cf4414aed Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Mon, 4 Jan 2016 11:43:50 -0200 Subject: [PATCH 24/31] Version 1.2.1 --- debian/changelog | 6 ++++++ lib/lxc/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 72e7c0e..36d0736 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ruby-lxc (1.2.1-0digirati1) trusty; urgency=low + + * Version 1.2.1. + + -- Andre Nathan Fri, 04 Jan 2016 11:43:33 -0200 + ruby-lxc (1.2.0-0digirati1) trusty; urgency=low * Version 1.2.0. diff --git a/lib/lxc/version.rb b/lib/lxc/version.rb index 1b94970..bee56ac 100644 --- a/lib/lxc/version.rb +++ b/lib/lxc/version.rb @@ -1,3 +1,3 @@ module LXC - VERSION = '1.2.0' + VERSION = '1.2.1' end From c0712e16d639471d07bda2e7728f7173ff4c8d58 Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Thu, 13 Oct 2016 13:07:05 -0500 Subject: [PATCH 25/31] Fix: undefined symbol error when loading lxc.so lxc_strerror() doesn't not exist, it is nothing more than an idea. LXC folks don't have plans to add it any time soon Signed-off-by: Jafar Al-Gharaibeh --- ext/lxc/lxc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index 2fd5a62..b45a141 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -42,7 +42,6 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1, extern int lxc_wait_for_pid_status(pid_t pid); extern long lxc_config_parse_arch(const char *arch); -extern const char *lxc_strerror(int error); static VALUE Container; static VALUE Error; @@ -2069,7 +2068,7 @@ container_unfreeze(VALUE self) ret = RELEASING_GVL(unfreeze_without_gvl, data); if (!ret) - rb_raise(Error, "unable to unfreeze container: %s", lxc_strerror(ret)); + rb_raise(Error, "unable to unfreeze container"); return self; } From e4f78ad7f8c8013ffba3f4276bb9a33b10cc3800 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Mon, 24 Oct 2016 10:55:25 -0200 Subject: [PATCH 26/31] Version 1.2.2 --- debian/changelog | 6 ++++++ lib/lxc/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 36d0736..13520ef 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ruby-lxc (1.2.2-0digirati1) trusty; urgency=low + + * Version 1.2.2. + + -- Andre Nathan Mon, 24 Oct 2016 10:55:05 -0200 + ruby-lxc (1.2.1-0digirati1) trusty; urgency=low * Version 1.2.1. diff --git a/lib/lxc/version.rb b/lib/lxc/version.rb index bee56ac..efc2bc1 100644 --- a/lib/lxc/version.rb +++ b/lib/lxc/version.rb @@ -1,3 +1,3 @@ module LXC - VERSION = '1.2.1' + VERSION = '1.2.2' end From 0eb378c2914b0a345d3aa321b1a63011dede6150 Mon Sep 17 00:00:00 2001 From: Jakub Skokan Date: Thu, 12 Apr 2018 12:29:36 +0200 Subject: [PATCH 27/31] Fix build with LXC 3.0 --- ext/lxc/lxc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index b45a141..b0ec634 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -6,6 +6,7 @@ #include #include #include +#include #define SYMBOL(s) ID2SYM(rb_intern(s)) From b3f43f273914fd37af8c10fa9a20a25591b1df07 Mon Sep 17 00:00:00 2001 From: Andre Nathan Date: Tue, 10 Jul 2018 10:29:23 -0300 Subject: [PATCH 28/31] Version 1.2.3 --- debian/changelog | 6 ++++++ lib/lxc/version.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 13520ef..43c1c39 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ruby-lxc (1.2.3-0digirati1) trusty; urgency=low + + * Version 1.2.3. + + -- Andre Nathan Mon, 10 Jul 2018 10:29:03 -0300 + ruby-lxc (1.2.2-0digirati1) trusty; urgency=low * Version 1.2.2. diff --git a/lib/lxc/version.rb b/lib/lxc/version.rb index efc2bc1..15bb139 100644 --- a/lib/lxc/version.rb +++ b/lib/lxc/version.rb @@ -1,3 +1,3 @@ module LXC - VERSION = '1.2.2' + VERSION = '1.2.3' end From 6bddbee7a5cb5c61108f7c5fd8e77dbd3b9e0e12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Wed, 21 Jun 2023 21:43:46 -0400 Subject: [PATCH 29/31] github: Add DCO/target tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .github/workflows/commits.yml | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/commits.yml diff --git a/.github/workflows/commits.yml b/.github/workflows/commits.yml new file mode 100644 index 0000000..57f5d69 --- /dev/null +++ b/.github/workflows/commits.yml @@ -0,0 +1,40 @@ +name: Commits +on: + - pull_request + +permissions: + contents: read + +jobs: + dco-check: + permissions: + pull-requests: read # for tim-actions/get-pr-commits to get list of commits from the PR + name: Signed-off-by (DCO) + runs-on: ubuntu-20.04 + steps: + - name: Get PR Commits + id: 'get-pr-commits' + uses: tim-actions/get-pr-commits@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Check that all commits are signed-off + uses: tim-actions/dco@master + with: + commits: ${{ steps.get-pr-commits.outputs.commits }} + + target-branch: + permissions: + contents: none + name: Branch target + runs-on: ubuntu-20.04 + steps: + - name: Check branch target + env: + TARGET: ${{ github.event.pull_request.base.ref }} + run: | + set -x + [ "${TARGET}" = "master" ] && exit 0 + + echo "Invalid branch target: ${TARGET}" + exit 1 From cf94855c8ef74cba3d657f0f5bc70ab8a9a96ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 24 Jul 2023 11:07:35 -0400 Subject: [PATCH 30/31] github: Update for main branch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber --- .github/workflows/commits.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commits.yml b/.github/workflows/commits.yml index 57f5d69..541a8f9 100644 --- a/.github/workflows/commits.yml +++ b/.github/workflows/commits.yml @@ -34,7 +34,7 @@ jobs: TARGET: ${{ github.event.pull_request.base.ref }} run: | set -x - [ "${TARGET}" = "master" ] && exit 0 + [ "${TARGET}" = "main" ] && exit 0 echo "Invalid branch target: ${TARGET}" exit 1 From 2902c02478f0a921942cda39c887aed68c7797fb Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Tue, 10 Oct 2023 15:31:34 +0200 Subject: [PATCH 31/31] arch_to_personality removed (lxc_config_parse_arch is not provided in API). lxc_wait_for_pid_status implementation added (not provided in API) --- ext/lxc/lxc.c | 64 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/ext/lxc/lxc.c b/ext/lxc/lxc.c index b0ec634..6a1f394 100644 --- a/ext/lxc/lxc.c +++ b/ext/lxc/lxc.c @@ -41,8 +41,28 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1, #define RELEASING_GVL2(func, arg, killfunc, killarg) func(arg) #endif -extern int lxc_wait_for_pid_status(pid_t pid); -extern long lxc_config_parse_arch(const char *arch); +//extern int lxc_wait_for_pid_status(pid_t pid); +#include +#include +int lxc_wait_for_pid_status(pid_t pid) +{ + int status, ret; + +again: + ret = waitpid(pid, &status, 0); + if (ret == -1) { + if (errno == EINTR) + goto again; + + return -1; + } + + if (ret != pid) + goto again; + + return status; +} +//extern long lxc_config_parse_arch(const char *arch); static VALUE Container; static VALUE Error; @@ -98,24 +118,24 @@ free_c_string_array(char **arr) * "personality", either +:linux32+ or +:linux+, for the 32-bit and 64-bit * architectures, respectively. */ -static VALUE -lxc_arch_to_personality(VALUE self, VALUE rb_arch) -{ - int ret; - char *arch; - - arch = StringValuePtr(rb_arch); - ret = lxc_config_parse_arch(arch); - - switch (ret) { - case PER_LINUX32: - return SYMBOL("linux32"); - case PER_LINUX: - return SYMBOL("linux"); - default: - rb_raise(Error, "unknown personality"); - } -} +//static VALUE +//lxc_arch_to_personality(VALUE self, VALUE rb_arch) +//{ +// int ret; +// char *arch; +// +// arch = StringValuePtr(rb_arch); +// ret = lxc_config_parse_arch(arch); +// +// switch (ret) { +// case PER_LINUX32: +// return SYMBOL("linux32"); +// case PER_LINUX: +// return SYMBOL("linux"); +// default: +// rb_raise(Error, "unknown personality"); +// } +//} /* * call-seq: @@ -2127,8 +2147,8 @@ Init_lxc(void) { VALUE LXC = rb_define_module("LXC"); - rb_define_singleton_method(LXC, "arch_to_personality", - lxc_arch_to_personality, 1); + //rb_define_singleton_method(LXC, "arch_to_personality", + // lxc_arch_to_personality, 1); rb_define_singleton_method(LXC, "run_command", lxc_run_command, 1); rb_define_singleton_method(LXC, "run_shell", lxc_run_shell, 0); rb_define_singleton_method(LXC, "global_config_item",