[lxc-devel] [go-lxc/v2] migrate: add new CRIU feature check support
adrianreber on Github
lxc-bot at linuxcontainers.org
Fri Dec 15 16:07:01 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 577 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20171215/6784c914/attachment.bin>
-------------- next part --------------
From c781b5f7015684750130c1823b0b690a928264cb Mon Sep 17 00:00:00 2001
From: Adrian Reber <areber at redhat.com>
Date: Fri, 15 Dec 2017 17:01:04 +0100
Subject: [PATCH] migrate: add new CRIU feature check support
This adds support to use the newly added MIGRATE_FEATURE_CHECK command
in the migrate() call. With this change LXD can query LXC if CRIU
supports features like dirty memory tracking or userfaultfd based
process migration.
Signed-off-by: Adrian Reber <areber at redhat.com>
---
container.go | 7 ++++---
lxc-binding.c | 3 +++
lxc-binding.h | 1 +
options.go | 1 +
type.go | 14 +++++++++++---
5 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/container.go b/container.go
index 230a2f4..fb443f7 100644
--- a/container.go
+++ b/container.go
@@ -1779,9 +1779,10 @@ func (c *Container) Migrate(cmd uint, opts MigrateOptions) error {
}
extras := C.struct_extra_migrate_opts{
- preserves_inodes: C.bool(opts.PreservesInodes),
- action_script: cActionScript,
- ghost_limit: C.uint64_t(opts.GhostLimit),
+ preserves_inodes: C.bool(opts.PreservesInodes),
+ action_script: cActionScript,
+ ghost_limit: C.uint64_t(opts.GhostLimit),
+ features_to_check: C.uint64_t(opts.FeaturesToCheck),
}
ret := C.int(C.go_lxc_migrate(c.container, C.uint(cmd), &copts, &extras))
diff --git a/lxc-binding.c b/lxc-binding.c
index 9ac5bc5..937feeb 100644
--- a/lxc-binding.c
+++ b/lxc-binding.c
@@ -410,6 +410,9 @@ bool go_lxc_restore(struct lxc_container *c, char *directory, bool verbose) {
}
int go_lxc_migrate(struct lxc_container *c, unsigned int cmd, struct migrate_opts *opts, struct extra_migrate_opts *extras) {
+#if VERSION_AT_LEAST(3, 0, 0)
+ opts->features_to_check = extras->features_to_check;
+#endif
#if VERSION_AT_LEAST(2, 0, 4)
opts->action_script = extras->action_script;
opts->ghost_limit = extras->ghost_limit;
diff --git a/lxc-binding.h b/lxc-binding.h
index 6412f70..5deba03 100644
--- a/lxc-binding.h
+++ b/lxc-binding.h
@@ -108,6 +108,7 @@ struct extra_migrate_opts {
bool preserves_inodes;
char *action_script;
uint64_t ghost_limit;
+ uint64_t features_to_check;
};
int go_lxc_migrate(struct lxc_container *c, unsigned int cmd, struct migrate_opts *opts, struct extra_migrate_opts *extras);
diff --git a/options.go b/options.go
index df5ee22..23d1bc0 100644
--- a/options.go
+++ b/options.go
@@ -197,6 +197,7 @@ type MigrateOptions struct {
Stop bool
PreservesInodes bool
GhostLimit uint64
+ FeaturesToCheck CriuFeatures
}
// ConsoleLogOptioins type is used for defining console log options.
diff --git a/type.go b/type.go
index 3ab04cd..b32f7a4 100644
--- a/type.go
+++ b/type.go
@@ -260,7 +260,15 @@ const (
)
const (
- MIGRATE_PRE_DUMP = 0
- MIGRATE_DUMP = 1
- MIGRATE_RESTORE = 2
+ MIGRATE_PRE_DUMP = 0
+ MIGRATE_DUMP = 1
+ MIGRATE_RESTORE = 2
+ MIGRATE_FEATURE_CHECK = 3
+)
+
+type CriuFeatures uint64
+
+const (
+ FEATURE_MEM_TRACK CriuFeatures = 1 << iota
+ FEATURE_LAZY_PAGES
)
More information about the lxc-devel
mailing list