[Devel] [PATCH 02/12] Add ability to register checkpoint obj ops
Matt Helsley
matthltc at us.ibm.com
Fri Feb 26 00:45:03 PST 2010
The array indices are allocated staticly by the CKPT_OBJ_* enums in
include/linux/checkpoint_hdr.h. There's no sanity checking here but
if it's desirable we can do checks like:
BUG_ON(ops->obj_type >= CKPT_OBJ_MAX); /* bounds check */
BUG_ON(ckpt_obj_ops[ops->obj_type] != NULL); /* Something has
already registered or (also bad) re-registration is occurring. */
Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
---
checkpoint/objhash.c | 16 +++++-----------
include/linux/checkpoint.h | 6 ++++++
include/linux/checkpoint_types.h | 11 +++++++++++
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/checkpoint/objhash.c b/checkpoint/objhash.c
index 1ca7f47..832520d 100644
--- a/checkpoint/objhash.c
+++ b/checkpoint/objhash.c
@@ -25,17 +25,6 @@
#include <linux/checkpoint_hdr.h>
#include <net/sock.h>
-/* object operations */
-struct ckpt_obj_ops {
- char *obj_name;
- enum obj_type obj_type;
- void (*ref_drop)(void *ptr, int lastref);
- int (*ref_grab)(void *ptr);
- int (*ref_users)(void *ptr);
- int (*checkpoint)(struct ckpt_ctx *ctx, void *ptr);
- void *(*restore)(struct ckpt_ctx *ctx);
-};
-
struct ckpt_obj {
int users;
int objref;
@@ -571,6 +560,11 @@ static const struct ckpt_obj_ops *ckpt_obj_ops[] = {
[CKPT_OBJ_SECURITY] = &ckpt_obj_security_strings_ops,
};
+void register_checkpoint_obj(const struct ckpt_obj_ops *ops)
+{
+ ckpt_obj_ops[ops->obj_type] = ops;
+}
+
#define CKPT_OBJ_HASH_NBITS 10
#define CKPT_OBJ_HASH_TOTAL (1UL << CKPT_OBJ_HASH_NBITS)
diff --git a/include/linux/checkpoint.h b/include/linux/checkpoint.h
index 7101d6f..e4d668a 100644
--- a/include/linux/checkpoint.h
+++ b/include/linux/checkpoint.h
@@ -485,6 +485,12 @@ extern void _ckpt_msg_complete(struct ckpt_ctx *ctx);
_do_ckpt_msg(ctx, err, "[E @ %s:%d]" fmt, __func__, __LINE__, ##args); \
} while (0)
+struct ckpt_obj_ops;
+extern void register_checkpoint_obj(const struct ckpt_obj_ops *ops);
+#else
+struct ckpt_obj_ops;
+static inline void register_checkpoint_obj(const struct ckpt_obj_ops *ops)
+{}
#endif /* CONFIG_CHECKPOINT */
#endif /* __KERNEL__ */
diff --git a/include/linux/checkpoint_types.h b/include/linux/checkpoint_types.h
index 5d5e00d..94e6e37 100644
--- a/include/linux/checkpoint_types.h
+++ b/include/linux/checkpoint_types.h
@@ -23,6 +23,17 @@
#include <linux/wait.h>
#include <linux/security.h>
+/* object operations */
+struct ckpt_obj_ops {
+ char *obj_name;
+ int obj_type;
+ void (*ref_drop)(void *ptr, int lastref);
+ int (*ref_grab)(void *ptr);
+ int (*ref_users)(void *ptr);
+ int (*checkpoint)(struct ckpt_ctx *ctx, void *ptr);
+ void *(*restore)(struct ckpt_ctx *ctx);
+};
+
struct ckpt_stats {
int uts_ns;
int ipc_ns;
--
1.6.3.3
_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers
More information about the Devel
mailing list