[CRIU] [PATCH RFC 7/8] criu: uffd: add --lazy-addr option
Mike Rapoport
mike.rapoport at gmail.com
Tue Jun 14 22:36:34 PDT 2016
On Fri, May 27, 2016 at 10:33 PM, Pavel Emelyanov <xemul at virtuozzo.com> wrote:
> On 05/21/2016 01:49 PM, Mike Rapoport wrote:
>> to distinguish between UNIX socket address for passing uffd and the address
>> of the remote dump
>
> Would you show when the --addredd and --lazy-addr confusion may occur?
Well, we can skip --lazy-addr if we will fork() lazy-pages from
cr-restore. Then the unix socket will be created in cr-restore and
inherited by lazy-pages daemon.
Another possibility is to make lazy-pages daemon a variation of the
page-server that does not depend on existing checkpoint directory,
like Adrian suggested a while ago.
Then it will get the required information via the unix socket. For
instance, in addition to pid and uffd, lazy-pages daemon will receive
the path to relevant checkpoint directory.
>> Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
>> ---
>> criu/crtools.c | 4 ++++
>> criu/include/cr_options.h | 1 +
>> criu/uffd.c | 26 +++++++++++++-------------
>> 3 files changed, 18 insertions(+), 13 deletions(-)
>>
>> diff --git a/criu/crtools.c b/criu/crtools.c
>> index b35a4b0..b3962e5 100644
>> --- a/criu/crtools.c
>> +++ b/criu/crtools.c
>> @@ -322,6 +322,7 @@ int main(int argc, char *argv[], char *envp[])
>> { "all", no_argument, 0, 1079 },
>> { "cgroup-props", required_argument, 0, 1080 },
>> { "cgroup-props-file", required_argument, 0, 1081 },
>> + { "lazy-addr", required_argument, 0, 1082 },
>> { },
>> };
>>
>> @@ -627,6 +628,9 @@ int main(int argc, char *argv[], char *envp[])
>> case 1081:
>> opts.cgroup_props_file = optarg;
>> break;
>> + case 1082:
>> + opts.lazy_addr = optarg;
>> + break;
>> case 'V':
>> pr_msg("Version: %s\n", CRIU_VERSION);
>> if (strcmp(CRIU_GITID, "0"))
>> diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
>> index e36c362..641f0e5 100644
>> --- a/criu/include/cr_options.h
>> +++ b/criu/include/cr_options.h
>> @@ -111,6 +111,7 @@ struct cr_options {
>> unsigned int timeout;
>> unsigned int empty_ns;
>> bool lazy_pages;
>> + char *lazy_addr;
>> };
>>
>> extern struct cr_options opts;
>> diff --git a/criu/uffd.c b/criu/uffd.c
>> index 1dadc23..ef1ff89 100644
>> --- a/criu/uffd.c
>> +++ b/criu/uffd.c
>> @@ -115,18 +115,18 @@ static int send_uffd(int sendfd, int pid)
>> int ret = -1;
>> struct sockaddr_un sun;
>>
>> - if (!opts.addr) {
>> + if (!opts.lazy_addr) {
>> pr_info("Please specify a file name for the unix domain socket\n");
>> pr_info("used to communicate between the lazy-pages server\n");
>> - pr_info("and the restore process. Use the --address option like\n");
>> - pr_info("criu restore --lazy-pages --address /tmp/userfault.socket\n");
>> + pr_info("and the restore process. Use the --lazy-addr option like\n");
>> + pr_info("criu restore --lazy-pages --lazy-addr /tmp/uffd.sock\n");
>> return -1;
>> }
>>
>> if (sendfd < 0)
>> return -1;
>>
>> - if (strlen(opts.addr) >= sizeof(sun.sun_path)) {
>> + if (strlen(opts.lazy_addr) >= sizeof(sun.sun_path)) {
>> return -1;
>> }
>>
>> @@ -135,10 +135,10 @@ static int send_uffd(int sendfd, int pid)
>>
>> memset(&sun, 0, sizeof(sun));
>> sun.sun_family = AF_UNIX;
>> - strcpy(sun.sun_path, opts.addr);
>> - len = offsetof(struct sockaddr_un, sun_path) + strlen(opts.addr);
>> + strcpy(sun.sun_path, opts.lazy_addr);
>> + len = offsetof(struct sockaddr_un, sun_path) + strlen(opts.lazy_addr);
>> if (connect(fd, (struct sockaddr *) &sun, len) < 0) {
>> - pr_perror("connect to %s failed", opts.addr);
>> + pr_perror("connect to %s failed", opts.lazy_addr);
>> goto out;
>> }
>>
>> @@ -225,19 +225,19 @@ static int server_listen(struct sockaddr_un *saddr)
>> int fd;
>> int len;
>>
>> - if (strlen(opts.addr) >= sizeof(saddr->sun_path)) {
>> + if (strlen(opts.lazy_addr) >= sizeof(saddr->sun_path)) {
>> return -1;
>> }
>>
>> if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
>> return -1;
>>
>> - unlink(opts.addr);
>> + unlink(opts.lazy_addr);
>>
>> memset(saddr, 0, sizeof(struct sockaddr_un));
>> saddr->sun_family = AF_UNIX;
>> - strcpy(saddr->sun_path, opts.addr);
>> - len = offsetof(struct sockaddr_un, sun_path) + strlen(opts.addr);
>> + strcpy(saddr->sun_path, opts.lazy_addr);
>> + len = offsetof(struct sockaddr_un, sun_path) + strlen(opts.lazy_addr);
>>
>> if (bind(fd, (struct sockaddr *) saddr, len) < 0) {
>> goto out;
>> @@ -808,7 +808,7 @@ static int prepare_uffds(int epollfd)
>> int listen;
>> struct sockaddr_un saddr;
>>
>> - pr_debug("Waiting for incoming connections on %s\n", opts.addr);
>> + pr_debug("Waiting for incoming connections on %s\n", opts.lazy_addr);
>> if ((listen = server_listen(&saddr)) < 0) {
>> pr_perror("server_listen error");
>> return -1;
>> @@ -841,7 +841,7 @@ int cr_lazy_pages()
>> if (check_for_uffd())
>> return -1;
>>
>> - if (!opts.addr) {
>> + if (!opts.lazy_addr) {
>> pr_info("Please specify a file name for the unix domain socket\n");
>> pr_info("used to communicate between the lazy-pages server\n");
>> pr_info("and the restore process. Use the --address option like\n");
>>
>
--
Sincerely yours,
Mike.
More information about the CRIU
mailing list