From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
To: dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org
Cc: Containers
<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 4/6][v3][lxc] Move get_init_pid() into checkpoint.c
Date: Wed, 31 Mar 2010 18:56:33 -0700 [thread overview]
Message-ID: <20100401015633.GD25712@us.ibm.com> (raw)
In-Reply-To: <20100401015503.GA25228-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
From: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Date: Mon, 29 Mar 2010 23:53:55 -0700
Subject: [PATCH 4/6][v3][lxc] Move get_init_pid() into checkpoint.c
lxc_attach.c is currently not included in liblxc.so. In afollowon
patch, checkpoint() function needs to also use the get_init_pid()
interface. So move the defintions into checkpoint.c - which would
then be accessible to both lxc_attach and lxc-checkpoint.
Signed-off-by: Sukadev Bhattiprolu <sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
---
src/lxc/checkpoint.c | 29 +++++++++++++++++++++++++++++
src/lxc/lxc.h | 6 ++++++
src/lxc/lxc_attach.c | 29 +----------------------------
3 files changed, 36 insertions(+), 28 deletions(-)
diff --git a/src/lxc/checkpoint.c b/src/lxc/checkpoint.c
index 7e8a93e..4e75cb6 100644
--- a/src/lxc/checkpoint.c
+++ b/src/lxc/checkpoint.c
@@ -22,9 +22,38 @@
*/
#include <lxc/lxc.h>
#include <lxc/log.h>
+#include <lxc/commands.h>
lxc_log_define(lxc_checkpoint, lxc);
+pid_t get_init_pid(const char *name)
+{
+ struct lxc_command command = {
+ .request = { .type = LXC_COMMAND_PID },
+ };
+
+ int ret, stopped = 0;
+
+ ret = lxc_command(name, &command, &stopped);
+ if (ret < 0 && stopped) {
+ INFO("'%s' is already stopped", name);
+ return 0;
+ }
+
+ if (ret < 0) {
+ ERROR("failed to send command");
+ return -1;
+ }
+
+ if (command.answer.ret) {
+ ERROR("failed to retrieve the init pid: %s",
+ strerror(-command.answer.ret));
+ return -1;
+ }
+
+ return command.answer.pid;
+}
+
int lxc_checkpoint(const char *name, const char *statefile, int flags)
{
return 0;
diff --git a/src/lxc/lxc.h b/src/lxc/lxc.h
index b0b9f4e..bd87bdb 100644
--- a/src/lxc/lxc.h
+++ b/src/lxc/lxc.h
@@ -27,6 +27,7 @@
extern "C" {
#endif
+#include <unistd.h>
#include <stddef.h>
#include <lxc/state.h>
@@ -56,6 +57,11 @@ extern int lxc_start(const char *name, char *const argv[], struct lxc_conf *);
extern int lxc_stop(const char *name);
/*
+ * Get the pid of the root application process tree in parent-pid namespace
+ */
+extern pid_t get_init_pid(const char *name);
+
+/*
* Open the monitoring mechanism for a specific container
* The function will return an fd corresponding to the events
* Returns a file descriptor on success, < 0 otherwise
diff --git a/src/lxc/lxc_attach.c b/src/lxc/lxc_attach.c
index a012c2c..3d2cdd5 100644
--- a/src/lxc/lxc_attach.c
+++ b/src/lxc/lxc_attach.c
@@ -28,6 +28,7 @@
#include "commands.h"
#include "arguments.h"
#include "namespace.h"
+#include "lxc.h"
#include "log.h"
lxc_log_define(lxc_attach_ui, lxc);
@@ -50,34 +51,6 @@ Options :\n\
.checker = NULL,
};
-pid_t get_init_pid(const char *name)
-{
- struct lxc_command command = {
- .request = { .type = LXC_COMMAND_PID },
- };
-
- int ret, stopped = 0;
-
- ret = lxc_command(name, &command, &stopped);
- if (ret < 0 && stopped) {
- INFO("'%s' is already stopped", name);
- return 0;
- }
-
- if (ret < 0) {
- ERROR("failed to send command");
- return -1;
- }
-
- if (command.answer.ret) {
- ERROR("failed to retrieve the init pid: %s",
- strerror(-command.answer.ret));
- return -1;
- }
-
- return command.answer.pid;
-}
-
int main(int argc, char *argv[], char *envp[])
{
int ret;
--
1.6.0.4
next prev parent reply other threads:[~2010-04-01 1:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-01 1:55 [PATCH 0/6][v3][lxc] Link LXC with USERCR Sukadev Bhattiprolu
[not found] ` <20100401015503.GA25228-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-01 1:55 ` [PATCH 1/6][v3][lxc] Add --with-libcr configure option Sukadev Bhattiprolu
2010-04-01 1:55 ` [PATCH 2/6][v3][lxc] lxc_restart: Add --statefile option Sukadev Bhattiprolu
2010-04-01 1:56 ` [PATCH 3/6][v3][lxc] lxc_checkpoint: " Sukadev Bhattiprolu
2010-04-01 1:56 ` Sukadev Bhattiprolu [this message]
2010-04-01 1:56 ` [PATCH 5/6][v3][lxc] Hook up lxc_restart() with app_restart() Sukadev Bhattiprolu
2010-04-01 1:57 ` [PATCH 6/6][v3][lxc] Hook up lxc_checkpoint() with app_checkpoint() Sukadev Bhattiprolu
2010-04-01 13:24 ` [PATCH 0/6][v3][lxc] Link LXC with USERCR Cedric Le Goater
[not found] ` <4BB49E8D.1010205-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
2010-04-01 16:37 ` Sukadev Bhattiprolu
[not found] ` <20100401163735.GA23231-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-04-01 23:36 ` Oren Laadan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100401015633.GD25712@us.ibm.com \
--to=sukadev-23vcf4htsmix0ybbhkvfkdbpr1lh4cv8@public.gmane.org \
--cc=clg-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=dlezcano-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox