RPC: make status-fd option available via RPC

Submitted by Adrian Reber on Feb. 6, 2017, 8:52 a.m.

Details

Message ID 20170206085216.4657-1-adrian@lisas.de
State New
Series "RPC: make status-fd option available via RPC"
Headers show

Commit Message

Adrian Reber Feb. 6, 2017, 8:52 a.m.
From: Adrian Reber <areber@redhat.com>

As runc uses the RPC interface to run criu it is necessary to expose
the newly added status-fd feature via RPC. Using the status-fd interface
makes it possible to use lazy migration with runc.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 criu/cr-service.c | 8 ++++++++
 images/rpc.proto  | 1 +
 2 files changed, 9 insertions(+)

Patch hide | download patch | download mbox

diff --git a/criu/cr-service.c b/criu/cr-service.c
index 4bac50d..12cef70 100644
--- a/criu/cr-service.c
+++ b/criu/cr-service.c
@@ -227,6 +227,7 @@  static int setup_opts_from_req(int sk, CriuOpts *req)
 	socklen_t ids_len = sizeof(struct ucred);
 	char images_dir_path[PATH_MAX];
 	char work_dir_path[PATH_MAX];
+	char status_fd[PATH_MAX];
 	int i;
 
 	if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
@@ -511,6 +512,13 @@  static int setup_opts_from_req(int sk, CriuOpts *req)
 		}
 	}
 
+	if (req->has_status_fd) {
+		sprintf(status_fd, "/proc/%d/fd/%d", ids.pid, req->status_fd);
+		opts.status_fd = open(status_fd, O_WRONLY | O_CREAT, 0600);
+		if (opts.status_fd < 0)
+			goto err;
+	}
+
 	if (check_namespace_opts())
 		goto err;
 
diff --git a/images/rpc.proto b/images/rpc.proto
index 4811738..9ed5331 100644
--- a/images/rpc.proto
+++ b/images/rpc.proto
@@ -109,6 +109,7 @@  message criu_opts {
 	optional bool			tcp_skip_in_flight	= 46;
 	optional bool			weak_sysctls		= 47;
 	optional bool			lazy_pages		= 48;
+	optional int32			status_fd		= 49;
 }
 
 message criu_dump_resp {

Comments

Pavel Emelyanov Feb. 6, 2017, 10:23 a.m.
On 02/06/2017 11:52 AM, Adrian Reber wrote:
> From: Adrian Reber <areber@redhat.com>
> 
> As runc uses the RPC interface to run criu it is necessary to expose
> the newly added status-fd feature via RPC. Using the status-fd interface
> makes it possible to use lazy migration with runc.
> 
> Signed-off-by: Adrian Reber <areber@redhat.com>
> ---
>  criu/cr-service.c | 8 ++++++++
>  images/rpc.proto  | 1 +
>  2 files changed, 9 insertions(+)
> 
> diff --git a/criu/cr-service.c b/criu/cr-service.c
> index 4bac50d..12cef70 100644
> --- a/criu/cr-service.c
> +++ b/criu/cr-service.c
> @@ -227,6 +227,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
>  	socklen_t ids_len = sizeof(struct ucred);
>  	char images_dir_path[PATH_MAX];
>  	char work_dir_path[PATH_MAX];
> +	char status_fd[PATH_MAX];
>  	int i;
>  
>  	if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
> @@ -511,6 +512,13 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
>  		}
>  	}
>  
> +	if (req->has_status_fd) {
> +		sprintf(status_fd, "/proc/%d/fd/%d", ids.pid, req->status_fd);
> +		opts.status_fd = open(status_fd, O_WRONLY | O_CREAT, 0600);

But why O_CREAT is needed here? The path in question should exist.

> +		if (opts.status_fd < 0)
> +			goto err;
> +	}
> +
>  	if (check_namespace_opts())
>  		goto err;
>  
> diff --git a/images/rpc.proto b/images/rpc.proto
> index 4811738..9ed5331 100644
> --- a/images/rpc.proto
> +++ b/images/rpc.proto
> @@ -109,6 +109,7 @@ message criu_opts {
>  	optional bool			tcp_skip_in_flight	= 46;
>  	optional bool			weak_sysctls		= 47;
>  	optional bool			lazy_pages		= 48;
> +	optional int32			status_fd		= 49;
>  }
>  
>  message criu_dump_resp {
>
Adrian Reber Feb. 6, 2017, 5:03 p.m.
On Mon, Feb 06, 2017 at 01:23:21PM +0300, Pavel Emelyanov wrote:
> On 02/06/2017 11:52 AM, Adrian Reber wrote:
> > From: Adrian Reber <areber@redhat.com>
> > 
> > As runc uses the RPC interface to run criu it is necessary to expose
> > the newly added status-fd feature via RPC. Using the status-fd interface
> > makes it possible to use lazy migration with runc.
> > 
> > Signed-off-by: Adrian Reber <areber@redhat.com>
> > ---
> >  criu/cr-service.c | 8 ++++++++
> >  images/rpc.proto  | 1 +
> >  2 files changed, 9 insertions(+)
> > 
> > diff --git a/criu/cr-service.c b/criu/cr-service.c
> > index 4bac50d..12cef70 100644
> > --- a/criu/cr-service.c
> > +++ b/criu/cr-service.c
> > @@ -227,6 +227,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
> >  	socklen_t ids_len = sizeof(struct ucred);
> >  	char images_dir_path[PATH_MAX];
> >  	char work_dir_path[PATH_MAX];
> > +	char status_fd[PATH_MAX];
> >  	int i;
> >  
> >  	if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
> > @@ -511,6 +512,13 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
> >  		}
> >  	}
> >  
> > +	if (req->has_status_fd) {
> > +		sprintf(status_fd, "/proc/%d/fd/%d", ids.pid, req->status_fd);
> > +		opts.status_fd = open(status_fd, O_WRONLY | O_CREAT, 0600);
> 
> But why O_CREAT is needed here? The path in question should exist.

Too many attempts for such a simple change ;-) You are right. That is
not necessary and a left-over from a previous test. New patch coming.

		Adrian