[CRIU] [PATCH 4/4] libcriu: Add add_veth_pair call

Pavel Emelyanov xemul at parallels.com
Wed Jun 25 06:46:49 PDT 2014


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 lib/criu.c | 35 +++++++++++++++++++++++++++++++++++
 lib/criu.h |  1 +
 2 files changed, 36 insertions(+)

diff --git a/lib/criu.c b/lib/criu.c
index 4a6ee2a..9a08de5 100644
--- a/lib/criu.c
+++ b/lib/criu.c
@@ -205,6 +205,41 @@ er:
 	return -ENOMEM;
 }
 
+int criu_add_veth_pair(char *in, char *out)
+{
+	int nr;
+	CriuVethPair **a, *p;
+
+	p = malloc(sizeof(*p));
+	if (!p)
+		goto er;
+	p->if_in = strdup(in);
+	if (!p->if_in)
+		goto er_p;
+	p->if_out = strdup(out);
+	if (!p->if_out)
+		goto er_i;
+
+	nr = opts->n_veths + 1;
+	a = realloc(opts->veths, nr * sizeof(p));
+	if (!a)
+		goto er_o;
+
+	a[nr - 1] = p;
+	opts->veths = a;
+	opts->n_veths = nr;
+	return 0;
+
+er_o:
+	free(p->if_out);
+er_i:
+	free(p->if_in);
+er_p:
+	free(p);
+er:
+	return -ENOMEM;
+}
+
 static CriuResp *recv_resp(int socket_fd)
 {
 	unsigned char buf[CR_MAX_MSG_SIZE];
diff --git a/lib/criu.h b/lib/criu.h
index 37ad072..c950a43 100644
--- a/lib/criu.h
+++ b/lib/criu.h
@@ -49,6 +49,7 @@ void criu_set_cpu_cap(unsigned int cap);
 void criu_set_root(char *root);
 int criu_set_exec_cmd(int argc, char *argv[]);
 int criu_add_ext_mount(char *key, char *val);
+int criu_add_veth_pair(char *in, char *out);
 
 /* Here is a table of return values and errno's of functions
  * from the list down below.
-- 
1.8.4.2




More information about the CRIU mailing list