Commit 7861d32d authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

protobuf: Convert struct pipe_data_entry to PB engine

Note, at moment we don't use "data" from proto declaration,
it's reserved to implement later (simply because it's easier
to use current code for a while).
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 786012e8
......@@ -34,6 +34,7 @@
#include "protobuf/fs.pb-c.h"
#include "protobuf/pstree.pb-c.h"
#include "protobuf/pipe.pb-c.h"
#include "protobuf/pipe-data.pb-c.h"
#define DEF_PAGES_PER_LINE 6
......@@ -185,13 +186,14 @@ void show_ghost_file(int fd, struct cr_options *o)
void __show_pipes_data(int fd, struct cr_options *o)
{
struct pipe_data_entry e;
PipeDataEntry *e;
while (1) {
if (read_img_eof(fd, &e) <= 0)
if (pb_read_eof(fd, &e, pipe_data_entry) <= 0)
break;
pr_msg("pipeid: 0x%8x bytes: 0x%8x\n", e.pipe_id, e.bytes);
lseek(fd, e.bytes, SEEK_CUR);
pr_msg("pipeid: 0x%8x bytes: 0x%8x\n", e->pipe_id, e->bytes);
lseek(fd, e->bytes, SEEK_CUR);
pipe_data_entry__free_unpacked(e, NULL);
}
}
......
......@@ -75,12 +75,6 @@ typedef struct {
*/
#define REMAP_GHOST (1 << 31)
struct pipe_data_entry {
u32 pipe_id;
u32 bytes;
u8 data[0];
} __packed;
#define USK_EXTERN (1 << 0)
struct sk_opts_entry {
......
#ifndef __CR_PIPES_H__
#define __CR_PIPES_H__
#include "../protobuf/pipe-data.pb-c.h"
extern int collect_pipes(void);
extern void mark_pipe_master(void);
int dump_pipe(struct fd_parms *p, int lfd,
......@@ -21,7 +24,7 @@ struct pipe_data_dump {
extern int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms *p);
struct pipe_data_rst {
struct pipe_data_entry *pde;
PipeDataEntry *pde;
void *data;
struct pipe_data_rst *next;
};
......
......@@ -13,6 +13,7 @@
#include "protobuf.h"
#include "protobuf/pipe.pb-c.h"
#include "protobuf/pipe-data.pb-c.h"
/*
* The sequence of objects which should be restored:
......@@ -76,11 +77,8 @@ int collect_pipe_data(int img_type, struct pipe_data_rst **hash)
r = xmalloc(sizeof(*r));
if (!r)
break;
r->pde = xmalloc(sizeof(*r->pde));
if (!r->pde)
break;
ret = read_img_eof(fd, r->pde);
ret = pb_read_eof(fd, &r->pde, pipe_data_entry);
if (ret <= 0)
break;
......@@ -96,10 +94,9 @@ int collect_pipe_data(int img_type, struct pipe_data_rst **hash)
r->pde->pipe_id, ret);
}
if (r) {
xfree(r->pde);
if (r && r->pde)
pipe_data_entry__free_unpacked(r->pde, NULL);
xfree(r);
}
close(fd);
return ret;
......@@ -394,13 +391,13 @@ int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms
bytes = tee(lfd, steal_pipe[1], pipe_size, SPLICE_F_NONBLOCK);
if (bytes > 0) {
struct pipe_data_entry pde;
PipeDataEntry pde = PIPE_DATA_ENTRY__INIT;
int wrote;
pde.pipe_id = pipe_id(p);
pde.bytes = bytes;
if (write_img(img, &pde))
if (pb_write(img, &pde, pipe_data_entry))
goto err_close;
wrote = splice(steal_pipe[0], NULL, img, NULL, bytes, 0);
......
......@@ -35,6 +35,7 @@ PROTO_FILES += pipe.proto
PROTO_FILES += tcp-stream.proto
PROTO_FILES += sk-packet.proto
PROTO_FILES += mnt.proto
PROTO_FILES += pipe-data.proto
HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
......
message pipe_data_entry {
required uint32 pipe_id = 1;
required uint32 bytes = 2;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment