Commit baa30914 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

protobuf: Convert pipe_entry to PB engine

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ccb254c1
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "protobuf/fown.pb-c.h" #include "protobuf/fown.pb-c.h"
#include "protobuf/fs.pb-c.h" #include "protobuf/fs.pb-c.h"
#include "protobuf/pstree.pb-c.h" #include "protobuf/pstree.pb-c.h"
#include "protobuf/pipe.pb-c.h"
#define DEF_PAGES_PER_LINE 6 #define DEF_PAGES_PER_LINE 6
...@@ -203,19 +204,20 @@ void show_pipes_data(int fd_pipes, struct cr_options *o) ...@@ -203,19 +204,20 @@ void show_pipes_data(int fd_pipes, struct cr_options *o)
void show_pipes(int fd_pipes, struct cr_options *o) void show_pipes(int fd_pipes, struct cr_options *o)
{ {
struct pipe_entry e; PipeEntry *e;
int ret; int ret;
pr_img_head(CR_FD_PIPES); pr_img_head(CR_FD_PIPES);
while (1) { while (1) {
ret = read_img_eof(fd_pipes, &e); ret = pb_read_eof(fd_pipes, &e, pipe_entry);
if (ret <= 0) if (ret <= 0)
goto out; goto out;
pr_msg("id: 0x%8x pipeid: 0x%8x flags: 0x%8x ", pr_msg("id: 0x%8x pipeid: 0x%8x flags: 0x%8x ",
e.id, e.pipe_id, e.flags); e->id, e->pipe_id, e->flags);
show_fown_cont(&e.fown); pb_show_fown_cont(e->fown);
pr_msg("\n"); pr_msg("\n");
pipe_entry__free_unpacked(e, NULL);
} }
out: out:
......
...@@ -75,13 +75,6 @@ typedef struct { ...@@ -75,13 +75,6 @@ typedef struct {
*/ */
#define REMAP_GHOST (1 << 31) #define REMAP_GHOST (1 << 31)
struct pipe_entry {
u32 id;
u32 pipe_id;
u32 flags;
fown_t fown;
} __packed;
struct pipe_data_entry { struct pipe_data_entry {
u32 pipe_id; u32 pipe_id;
u32 bytes; u32 bytes;
......
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include "pipes.h" #include "pipes.h"
#include "util-net.h" #include "util-net.h"
#include "protobuf.h"
#include "protobuf/pipe.pb-c.h"
/* /*
* The sequence of objects which should be restored: * The sequence of objects which should be restored:
* pipe -> files struct-s -> fd-s. * pipe -> files struct-s -> fd-s.
...@@ -19,7 +22,7 @@ ...@@ -19,7 +22,7 @@
*/ */
struct pipe_info { struct pipe_info {
struct pipe_entry *pe; PipeEntry *pe;
struct list_head pipe_list; /* All pipe_info with the same pipe_id struct list_head pipe_list; /* All pipe_info with the same pipe_id
* This is pure circular list without head */ * This is pure circular list without head */
struct list_head list; /* list head for fdinfo_list_entry-s */ struct list_head list; /* list head for fdinfo_list_entry-s */
...@@ -231,7 +234,7 @@ static int recv_pipe_fd(struct pipe_info *pi) ...@@ -231,7 +234,7 @@ static int recv_pipe_fd(struct pipe_info *pi)
close(tmp); close(tmp);
if (fd >= 0) { if (fd >= 0) {
if (restore_fown(fd, &pi->pe->fown)) { if (pb_restore_fown(fd, pi->pe->fown)) {
close(fd); close(fd);
return -1; return -1;
} }
...@@ -288,7 +291,7 @@ static int open_pipe(struct file_desc *d) ...@@ -288,7 +291,7 @@ static int open_pipe(struct file_desc *d)
close(pfd[!(pi->pe->flags & O_WRONLY)]); close(pfd[!(pi->pe->flags & O_WRONLY)]);
tmp = pfd[pi->pe->flags & O_WRONLY]; tmp = pfd[pi->pe->flags & O_WRONLY];
if (rst_file_params(tmp, &pi->pe->fown, pi->pe->flags)) if (pb_rst_file_params(tmp, pi->pe->fown, pi->pe->flags))
return -1; return -1;
return tmp; return tmp;
...@@ -322,12 +325,9 @@ int collect_pipes(void) ...@@ -322,12 +325,9 @@ int collect_pipes(void)
pi = xmalloc(sizeof(*pi)); pi = xmalloc(sizeof(*pi));
if (pi == NULL) if (pi == NULL)
break; break;
pi->pe = xmalloc(sizeof(*pi->pe));
if (pi->pe == NULL)
break;
pi->create = 0; pi->create = 0;
ret = read_img_eof(fd, pi->pe); ret = pb_read_eof(fd, &pi->pe, pipe_entry);
if (ret <= 0) if (ret <= 0)
break; break;
...@@ -348,7 +348,6 @@ int collect_pipes(void) ...@@ -348,7 +348,6 @@ int collect_pipes(void)
list_add_tail(&pi->list, &pipes); list_add_tail(&pi->list, &pipes);
} }
xfree(pi ? pi->pe : NULL);
xfree(pi); xfree(pi);
close(fd); close(fd);
...@@ -433,17 +432,20 @@ static struct pipe_data_dump pd_pipes = { .img_type = CR_FD_PIPES_DATA, }; ...@@ -433,17 +432,20 @@ static struct pipe_data_dump pd_pipes = { .img_type = CR_FD_PIPES_DATA, };
static int dump_one_pipe(int lfd, u32 id, const struct fd_parms *p) static int dump_one_pipe(int lfd, u32 id, const struct fd_parms *p)
{ {
struct pipe_entry pe; PipeEntry pe = PIPE_ENTRY__INIT;
FownEntry fown = FOWN_ENTRY__INIT;
pr_info("Dumping pipe %d with id %#x pipe_id %#x\n", pr_info("Dumping pipe %d with id %#x pipe_id %#x\n",
lfd, id, pipe_id(p)); lfd, id, pipe_id(p));
pb_prep_fown(&fown, &p->fown);
pe.id = id; pe.id = id;
pe.pipe_id = pipe_id(p); pe.pipe_id = pipe_id(p);
pe.flags = p->flags; pe.flags = p->flags;
pe.fown = p->fown; pe.fown = &fown;
if (write_img(fdset_fd(glob_fdset, CR_FD_PIPES), &pe)) if (pb_write(fdset_fd(glob_fdset, CR_FD_PIPES), &pe, pipe_entry))
return -1; return -1;
return dump_one_pipe_data(&pd_pipes, lfd, p); return dump_one_pipe_data(&pd_pipes, lfd, p);
......
...@@ -31,6 +31,7 @@ PROTO_FILES += fh.proto ...@@ -31,6 +31,7 @@ PROTO_FILES += fh.proto
PROTO_FILES += inotify.proto PROTO_FILES += inotify.proto
PROTO_FILES += fs.proto PROTO_FILES += fs.proto
PROTO_FILES += pstree.proto PROTO_FILES += pstree.proto
PROTO_FILES += pipe.proto
HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES)) HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES)) SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
......
import "fown.proto";
message pipe_entry {
required uint32 id = 1;
required uint32 pipe_id = 2;
required uint32 flags = 3;
required fown_entry fown = 4;
}
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