[CRIU] [PATCHv4 3/4] libcriu: add criu_dump_me() and libcriu header

Pavel Emelyanov xemul at parallels.com
Tue Sep 3 14:50:38 EDT 2013


On 09/03/2013 06:44 PM, Ruslan Kuprieiev wrote:
> criu_dump_me() can be used by program to dump itself.
> Program need to call criu_allocate_args() to prepare arguments and then 
> it can set them using criu_set* functions. criu_set* functions are used 
> instead of give user access to arguments itself, so user will not mess 
> with protobuf. libcriu.h is to be used by user program.
> 
> 


> @@ -1,3 +1,158 @@
> +#include <unistd.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <errno.h>
> +#include <string.h>
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <sys/un.h>
> +#include <stdint.h>
> +#include <stdbool.h>
> +
> +#include <google/protobuf-c/protobuf-c.h>
> +
> +#include "libcriu.h"
>  #include "version.h"
> +#include "util-pie.h"
> +#include "protobuf/criu-dump-args.pb-c.h"
>  
>  const char *criu_lib_version = version;
> +
> +static CriuDumpArgs *args;

No way. The criu_alloc_args() should alloc and _return_ the
pointer to the CriuDumpArgs to the caller. This pointer should
be used allover the criu_xxx() calls below.

> +static char *service_addr;
> +
> +int criu_alloc_args(void)
> +{
> +	args = malloc(sizeof(CriuDumpArgs));
> +	if (args == NULL) {
> +		perror("Can't allocate memory");

I doubt that library should emit any messages.

> +		return -1;
> +	}
> +
> +	criu_dump_args__init(args);
> +
> +	args->version_major = CRIU_VERSION_MAJOR;
> +	args->version_minor = CRIU_VERSION_MINOR;
> +	args->images_dir_fd = 0;
> +	args->flags = CRIU_DUMP_AND_KILL;
> +
> +	return 0;
> +}


More information about the CRIU mailing list