From 8f05162bb4ce8eb45224cdeb8b7594064f4cdf0b Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 25 Jun 2014 17:37:50 +0400 Subject: [PATCH] libcriu: Add add_veth_pair call Signed-off-by: Pavel Emelyanov --- lib/criu.c | 35 +++++++++++++++++++++++++++++++++++ lib/criu.h | 1 + 2 files changed, 36 insertions(+) diff --git a/lib/criu.c b/lib/criu.c index 4a6ee2a5e..9a08de57a 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 37ad07235..c950a43bb 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.