mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 22:05:36 +00:00
protobuf: Start switching our image entries to Google's protobuf
A short story -- there were a long conversation on which format should be used to keep checkpointed data on disk image. We ended up in using Google's Protocol Buffers (see https://developers.google.com/protocol-buffers/ for detailed description). Thus image entries should be convered to PB. This patch converts fdinfo_entry to PB "message fdinfo_entry". Build note: one should have protobuf and protobuf-c installed to be able to build crtools. - http://code.google.com/p/protobuf/ - http://code.google.com/p/protobuf-c/ Inspired-by: Pavel Emelianov <xemul@parallels.com> Inspired-by: Kinsbursky Stanislav <skinsbursky@openvz.org> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
c75b4b70fc
commit
a1fe3caf04
24
files.c
24
files.c
@@ -24,6 +24,8 @@
|
||||
#include "sockets.h"
|
||||
#include "pstree.h"
|
||||
|
||||
#include "protobuf.h"
|
||||
|
||||
static struct fdinfo_list_entry *fdinfo_list;
|
||||
static int nr_fdinfo_list;
|
||||
|
||||
@@ -71,7 +73,7 @@ struct file_desc *find_file_desc_raw(int type, u32 id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct file_desc *find_file_desc(struct fdinfo_entry *fe)
|
||||
static inline struct file_desc *find_file_desc(FdinfoEntry *fe)
|
||||
{
|
||||
return find_file_desc_raw(fe->type, fe->id);
|
||||
}
|
||||
@@ -152,7 +154,7 @@ int rst_file_params(int fd, fown_t *fown, int flags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int collect_fd(int pid, struct fdinfo_entry *e, struct rst_info *rst_info)
|
||||
static int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
|
||||
{
|
||||
struct fdinfo_list_entry *l, *le = &fdinfo_list[nr_fdinfo_list];
|
||||
struct file_desc *fdesc;
|
||||
@@ -206,19 +208,17 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info)
|
||||
}
|
||||
|
||||
while (1) {
|
||||
struct fdinfo_entry *e = xmalloc(sizeof(*e));
|
||||
if (!e) {
|
||||
ret = -1;
|
||||
break;
|
||||
}
|
||||
FdinfoEntry *e;
|
||||
|
||||
ret = read_img_eof(fdinfo_fd, e);
|
||||
ret = pb_read_eof(fdinfo_fd, &e, fdinfo_entry);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
|
||||
ret = collect_fd(pid, e, rst_info);
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
fdinfo_entry__free_unpacked(e, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
close(fdinfo_fd);
|
||||
@@ -255,7 +255,7 @@ static void transport_name_gen(struct sockaddr_un *addr, int *len,
|
||||
*addr->sun_path = '\0';
|
||||
}
|
||||
|
||||
static int should_open_transport(struct fdinfo_entry *fe, struct file_desc *fd)
|
||||
static int should_open_transport(FdinfoEntry *fe, struct file_desc *fd)
|
||||
{
|
||||
if (fd->ops->want_transport)
|
||||
return fd->ops->want_transport(fe, fd);
|
||||
@@ -326,7 +326,7 @@ int send_fd_to_peer(int fd, struct fdinfo_list_entry *fle, int tsk)
|
||||
return send_fd(tsk, &saddr, len, fd);
|
||||
}
|
||||
|
||||
static int open_fd(int pid, struct fdinfo_entry *fe, struct file_desc *d)
|
||||
static int open_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
|
||||
{
|
||||
int tmp;
|
||||
int sock;
|
||||
@@ -383,7 +383,7 @@ static int open_fd(int pid, struct fdinfo_entry *fe, struct file_desc *d)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int receive_fd(int pid, struct fdinfo_entry *fe, struct file_desc *d)
|
||||
static int receive_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
|
||||
{
|
||||
int tmp;
|
||||
struct fdinfo_list_entry *fle;
|
||||
|
Reference in New Issue
Block a user