Merge 2d171f980f
into 6bddbee7a5
This commit is contained in:
commit
241d515caf
2 changed files with 24 additions and 41 deletions
|
@ -41,9 +41,6 @@ extern void *rb_thread_call_without_gvl(void *(*func)(void *), void *data1,
|
||||||
#define RELEASING_GVL2(func, arg, killfunc, killarg) func(arg)
|
#define RELEASING_GVL2(func, arg, killfunc, killarg) func(arg)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int lxc_wait_for_pid_status(pid_t pid);
|
|
||||||
extern long lxc_config_parse_arch(const char *arch);
|
|
||||||
|
|
||||||
static VALUE Container;
|
static VALUE Container;
|
||||||
static VALUE Error;
|
static VALUE Error;
|
||||||
|
|
||||||
|
@ -90,33 +87,6 @@ free_c_string_array(char **arr)
|
||||||
* container-specific methods are contained in the +LXC::Container+ class.
|
* container-specific methods are contained in the +LXC::Container+ class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* LXC.arch_to_personality(arch)
|
|
||||||
*
|
|
||||||
* Converts an architecture string (x86, i686, x86_64 or amd64) to a
|
|
||||||
* "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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* LXC.run_command(command)
|
* LXC.run_command(command)
|
||||||
|
@ -705,10 +675,30 @@ err:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RETURN_WITHOUT_GVL_TYPE
|
static int
|
||||||
lxc_wait_for_pid_status_without_gvl(void *pid)
|
wait_for_pid_status(pid_t pid)
|
||||||
{
|
{
|
||||||
RETURN_WITHOUT_GVL(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;
|
||||||
|
}
|
||||||
|
|
||||||
|
static RETURN_WITHOUT_GVL_TYPE
|
||||||
|
wait_for_pid_status_without_gvl(void *pid)
|
||||||
|
{
|
||||||
|
RETURN_WITHOUT_GVL(wait_for_pid_status(*(pid_t*)pid));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) || defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) || defined(HAVE_RB_THREAD_BLOCKING_REGION)
|
||||||
|
@ -776,7 +766,7 @@ container_attach(int argc, VALUE *argv, VALUE self)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (wait) {
|
if (wait) {
|
||||||
ret = RELEASING_GVL2(lxc_wait_for_pid_status_without_gvl, &pid,
|
ret = RELEASING_GVL2(wait_for_pid_status_without_gvl, &pid,
|
||||||
kill_pid_without_gvl, &pid);
|
kill_pid_without_gvl, &pid);
|
||||||
/* handle case where attach fails */
|
/* handle case where attach fails */
|
||||||
if (WIFEXITED(ret) && WEXITSTATUS(ret) == 255)
|
if (WIFEXITED(ret) && WEXITSTATUS(ret) == 255)
|
||||||
|
@ -2127,8 +2117,6 @@ Init_lxc(void)
|
||||||
{
|
{
|
||||||
VALUE LXC = rb_define_module("LXC");
|
VALUE LXC = rb_define_module("LXC");
|
||||||
|
|
||||||
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_command", lxc_run_command, 1);
|
||||||
rb_define_singleton_method(LXC, "run_shell", lxc_run_shell, 0);
|
rb_define_singleton_method(LXC, "run_shell", lxc_run_shell, 0);
|
||||||
rb_define_singleton_method(LXC, "global_config_item",
|
rb_define_singleton_method(LXC, "global_config_item",
|
||||||
|
|
|
@ -17,9 +17,4 @@ class TestLXCClassMethods < Test::Unit::TestCase
|
||||||
def test_list_containers
|
def test_list_containers
|
||||||
assert(LXC.list_containers.include?('test'))
|
assert(LXC.list_containers.include?('test'))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_arch_to_personality
|
|
||||||
assert_equal(:linux32, LXC.arch_to_personality('x86'))
|
|
||||||
assert_equal(:linux, LXC.arch_to_personality('x86_64'))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue