<div dir="ltr"><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>2015-12-22 11:56 GMT+01:00 Cyrill Gorcunov <span dir="ltr"><<a href="mailto:gorcunov@gmail.com" target="_blank">gorcunov@gmail.com</a>></span>:<br></div></div></div></div></div></div></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Tue, Dec 22, 2015 at 11:37:55AM +0100, Federico Reghenzani wrote:<br>
> Ok, I'm trying to restore in a new namespace (I would prefer this solution<br>
> to start the orted directly in a dedicated namespace), but I can't do it<br>
> with C API. From command line via ssh:<br>
><br>
> ssh <a href="mailto:root@10.10.1.2">root@10.10.1.2</a> unshare -p --fork criu restore -D /tmp/ckpt_B2BLJ<br>
><br>
> it works (even if it provides some error messages), but using orted-restore<br>
> in C API:<br>
><br>
> unshare(CLONE_NEWPID);<br>
</span> fork();<br>
<br>
After unshare you need to call a fork as far as I remember<br>
and continue inside child.<br>
<span class=""><br></span></blockquote><div><br></div><div>Yes sorry, the fork is there, it's a copy-and-paste error.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">
> if (pid != 0) {<br>
> ...<br>
> }<br>
> // getpid == 1 now<br>
> dir = ...<br>
> criu_init_opts();<br>
> criu_set_images_dir_fd(dir);<br>
> criu_set_log_file("criu_restore.log");<br>
> criu_set_log_level(4);<br>
> int status = criu_restore_child();<br>
> //or int status = criu_restore();<br>
><br>
> I obtain:<br>
><br>
> Error (image.c:405): Can't open dir /proc/1/fd/11: No such device or<br>
> address<br>
> Error (cr-service.c:254): Can't open images directory: No such device<br>
> or address<br>
><br>
> I've never used unshare, so I probably missed something ;-)<br>
><br>
> ----<br>
><br>
> P.S. the tty problem happens only when I open an ssh session and then<br>
> execute the command (sshd: root@pts/0), no problem if I call criu restore<br>
> directly from ssh command (sshd: root@notty).<br>
<br>
</span>So you borrow the 0 index for sshd itself I guess, that;s why criu<br>
is complaining. I think you shouldn't do that (but I'm not sure<br>
how internally sshd operates with pty devices)<br>
</blockquote></div><br></div><div class="gmail_extra">Ok, anyway it's not currently a problem.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr">2015-12-22 11:52 GMT+01:00 Pavel Emelyanov <span dir="ltr"><<a href="mailto:xemul@parallels.com" target="_blank">xemul@parallels.com</a>></span>:<br></div></div></div></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On 12/22/2015 01:37 PM, Federico Reghenzani wrote:<br>> Ok, I'm trying to restore in a new namespace (I would prefer this solution to start the<br>> orted directly in a dedicated namespace), but I can't do it with C API.<br><br></span>Well, yes, the C API is not yet up to this.<br><br>You can try to call unshare() glibc function by hands before fork()-ing and<br>exec()-ing criu. This would be good approximation of what my --unshare patchset<br>does. Or pick one up and add respective calls to lib/criu.c, this contribution<br>will be accepted with gratitude :)<br></blockquote><div> </div><div>Ok, I guess I can try to add them :)</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">> From command line via ssh:<br>><br></span>> ssh <a href="mailto:root@10.10.1.2">root@10.10.1.2</a> <mailto:<a href="mailto:root@10.10.1.2">root@10.10.1.2</a>> unshare -p --fork criu restore -D /tmp/ckpt_B2BLJ<br><span class="">><br>> it works (even if it provides some error messages), but using orted-restore in C API:<br>><br>> unshare(CLONE_NEWPID);<br>> if (pid != 0) {<br>> ...<br>> }<br>> // getpid == 1 now<br>> dir = ...<br>> criu_init_opts();<br>> criu_set_images_dir_fd(dir);<br>> criu_set_log_file("criu_restore.log");<br>> criu_set_log_level(4);<br>> int status = criu_restore_child();<br>> //or int status = criu_restore();<br>><br>> I obtain:<br>><br>> Error (image.c:405): Can't open dir /proc/1/fd/11: No such device or address<br><br></span>That's because you only spawned new pid namespace, but the /proc remained the same<br>showing pids from wrong (previous) namespace. If you use -m and --mount-proc that<br>would help.<br></blockquote><div><br></div><div>Thanks I will try it in a few hours.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><br>> Error (cr-service.c:254): Can't open images directory: No such device or address<br>><br>> I've never used unshare, so I probably missed something ;-)<br>><br>> ----<br>><br>> P.S. the tty problem happens only when I open an ssh session and then execute the command (sshd: root@pts/0), no problem if I call criu restore directly from ssh command (sshd: root@notty).<br>><br>> Cheers,<br>> Federico<br>> __<br>> Federico Reghenzani<br>> M.Eng. Student @ Politecnico di Milano<br>> Computer Science and Engineering<br><br></div></div><span class=""><font color="#888888">-- Pavel</font></span></blockquote><div><br></div><div>Cheers,</div><div>Federico </div></div></div></div>