[Libct] [PATCH 2/8] process: add a function to create a process descriptor

Andrey Vagin avagin at openvz.org
Wed Nov 5 01:40:19 PST 2014


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 src/include/session.h |  1 +
 src/session.c         | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/src/include/session.h b/src/include/session.h
index 721d217..0feff24 100644
--- a/src/include/session.h
+++ b/src/include/session.h
@@ -17,6 +17,7 @@ struct backend_ops {
 	ct_handler_t (*create_ct)(libct_session_t s, char *name);
 	ct_handler_t (*open_ct)(libct_session_t s, char *name);
 	void	     (*update_ct_state)(libct_session_t s, pid_t pid);
+	ct_process_desc_t (*create_process_desc)(libct_session_t s);
 	void (*close)(libct_session_t s);
 };
 
diff --git a/src/session.c b/src/session.c
index 9c5efff..c0b394d 100644
--- a/src/session.c
+++ b/src/session.c
@@ -3,6 +3,7 @@
 #include "uapi/libct.h"
 
 #include "session.h"
+#include "process.h"
 #include "xmalloc.h"
 #include "libct.h"
 #include "async.h"
@@ -28,6 +29,19 @@ static ct_handler_t create_local_ct(libct_session_t s, char *name)
 		return ct;
 }
 
+static ct_process_desc_t local_process_create_desc(libct_session_t s)
+{
+	struct process_desc *p;
+
+	p = xmalloc(sizeof(*p));
+	if (p == NULL)
+		return NULL;
+
+	local_process_init(p);
+
+	return &p->h;
+}
+
 static void update_local_ct_state(libct_session_t s, pid_t pid)
 {
 	ct_handler_t h;
@@ -46,6 +60,7 @@ static void update_local_ct_state(libct_session_t s, pid_t pid)
 static const struct backend_ops local_session_ops = {
 	.type = BACKEND_LOCAL,
 	.create_ct = create_local_ct,
+	.create_process_desc = local_process_create_desc,
 	.close = close_local_session,
 	.update_ct_state = update_local_ct_state,
 };
@@ -107,6 +122,11 @@ ct_handler_t libct_container_open(libct_session_t ses, char *name)
 	return new_ct(ses, cth);
 }
 
+ct_process_desc_t libct_process_desc_create(libct_session_t ses)
+{
+	return ses->ops->create_process_desc(ses);
+}
+
 void libct_session_close(libct_session_t s)
 {
 	ct_handler_t cth, n;
-- 
1.9.1



More information about the Libct mailing list