[CRIU] [PATCH cr 07/10] cr-dump: lock network before dump and
unlock in case of errors
Andrey Vagin
avagin at openvz.org
Thu Sep 13 09:10:27 EDT 2012
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
cr-dump.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 38 insertions(+), 1 deletions(-)
diff --git a/cr-dump.c b/cr-dump.c
index a41fab1..c508cb6 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1576,6 +1576,40 @@ err_cure_fdset:
goto err;
}
+static int network_lock()
+{
+ pr_info("Lock network\n");
+
+ /* Each connection will be locked on dump */
+ if (!(opts.namespaces_flags & CLONE_NEWNET))
+ return 0;
+
+ if (opts.lock_network == NULL)
+ return 0;
+
+ if (system(opts.lock_network))
+ return -1;
+
+ return 0;
+
+}
+
+static void network_unlock()
+{
+ pr_info("Unlock network\n");
+
+ if (!(opts.namespaces_flags & CLONE_NEWNET)) {
+ tcp_unlock_all();
+ return;
+ }
+
+ if (opts.unlock_network == NULL)
+ return;
+
+ if (system(opts.unlock_network))
+ pr_err("Unlock of network failed\n");
+}
+
int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
{
struct pstree_item *item;
@@ -1585,6 +1619,9 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
pr_info("Dumping processes (pid: %d)\n", pid);
pr_info("========================================\n");
+ if (network_lock())
+ goto err;
+
if (write_img_inventory())
goto err;
@@ -1642,7 +1679,7 @@ err:
* don't, just close them silently.
*/
if (ret)
- tcp_unlock_all();
+ network_unlock();
pstree_switch_state(root_item,
ret ? TASK_ALIVE : opts->final_state);
free_pstree(root_item);
--
1.7.1
More information about the CRIU
mailing list