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

protobuf: Convert eventfd data to protobuf engine

Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1abf969d
......@@ -21,8 +21,11 @@
#include "util.h"
#include "log.h"
#include "protobuf.h"
#include "protobuf/eventfd.pb-c.h"
struct eventfd_file_info {
struct eventfd_file_entry *efe;
EventfdFileEntry *efe;
struct file_desc d;
};
......@@ -32,7 +35,7 @@ int is_eventfd_link(int lfd)
return is_anon_link_type(lfd, "[eventfd]");
}
static void pr_info_eventfd(char *action, struct eventfd_file_entry *efe)
static void pr_info_eventfd(char *action, EventfdFileEntry *efe)
{
pr_info("%seventfd: id %#08x flags %#04x counter %#016lx\n",
action, efe->id, efe->flags, efe->counter);
......@@ -40,20 +43,21 @@ static void pr_info_eventfd(char *action, struct eventfd_file_entry *efe)
void show_eventfds(int fd, struct cr_options *o)
{
struct eventfd_file_entry efe;
EventfdFileEntry *efe;
pr_img_head(CR_FD_EVENTFD);
while (1) {
int ret;
ret = read_img_eof(fd, &efe);
ret = pb_read_eof(fd, &efe, eventfd_file_entry);
if (ret <= 0)
goto out;
pr_msg("id: %#08x flags %#04x counter: %#016lx ",
efe.id, efe.flags, efe.counter);
show_fown_cont(&efe.fown);
efe->id, efe->flags, efe->counter);
pb_show_fown_cont(efe->fown);
pr_msg("\n");
eventfd_file_entry__free_unpacked(efe, NULL);
}
out:
......@@ -69,21 +73,23 @@ struct eventfd_dump_arg {
static int dump_eventfd_entry(union fdinfo_entries *e, void *arg)
{
struct eventfd_dump_arg *da = arg;
struct eventfd_file_entry *efe = &e->efd;
FownEntry fown;
if (da->dumped) {
pr_err("Several counters in a file?\n");
return -1;
}
da->dumped = true;
efe->id = da->id;
efe->flags = da->p->flags;
efe->fown = da->p->fown;
pb_prep_fown(&fown, &da->p->fown);
pr_info_eventfd("Dumping ", efe);
da->dumped = true;
e->efd.id = da->id;
e->efd.flags = da->p->flags;
e->efd.fown = &fown;
return write_img(fdset_fd(glob_fdset, CR_FD_EVENTFD), efe);
pr_info_eventfd("Dumping ", &e->efd);
return pb_write(fdset_fd(glob_fdset, CR_FD_EVENTFD),
&e->efd, eventfd_file_entry);
}
static int dump_one_eventfd(int lfd, u32 id, const struct fd_parms *p)
......@@ -117,7 +123,7 @@ static int eventfd_open(struct file_desc *d)
return -1;
}
if (rst_file_params(tmp, &info->efe->fown, info->efe->flags)) {
if (pb_rst_file_params(tmp, info->efe->fown, info->efe->flags)) {
pr_perror("Can't restore params on eventfd %#08x",
info->efe->id);
goto err_close;
......@@ -151,11 +157,7 @@ int collect_eventfd(void)
if (!info)
break;
info->efe = xmalloc(sizeof(*info->efe));
if (!info->efe)
break;
ret = read_img_eof(image_fd, info->efe);
ret = pb_read_eof(image_fd, &info->efe, eventfd_file_entry);
if (ret < 0)
goto err;
else if (!ret)
......
......@@ -75,13 +75,6 @@ typedef struct {
*/
#define REMAP_GHOST (1 << 31)
struct eventfd_file_entry {
u32 id;
u16 flags;
fown_t fown;
u64 counter;
} __packed;
struct eventpoll_tfd_entry {
u32 id;
u32 tfd;
......
......@@ -6,6 +6,8 @@
#include "image.h"
#include "list.h"
#include "../protobuf/eventfd.pb-c.h"
#define PROC_TASK_COMM_LEN 32
#define PROC_TASK_COMM_LEN_FMT "(%31s"
......@@ -118,7 +120,7 @@ extern int parse_smaps(pid_t pid, struct list_head *vma_area_list, bool use_map_
extern int parse_pid_status(pid_t pid, struct proc_status_creds *);
union fdinfo_entries {
struct eventfd_file_entry efd;
EventfdFileEntry efd;
struct eventpoll_tfd_entry epl;
struct inotify_wd_entry ify;
};
......
......@@ -728,6 +728,8 @@ int parse_fdinfo(int fd, int type,
continue;
if (fdinfo_field(str, "eventfd-count")) {
eventfd_file_entry__init(&entry.efd);
if (type != FDINFO_EVENTFD)
goto parse_err;
ret = sscanf(str, "eventfd-count: %lx",
......
......@@ -25,6 +25,7 @@ PROTO_FILES += regfile.proto
PROTO_FILES += ghost-file.proto
PROTO_FILES += fifo.proto
PROTO_FILES += remap-file-path.proto
PROTO_FILES += eventfd.proto
HDRS := $(patsubst %.proto,%.pb-c.h,$(PROTO_FILES))
SRCS := $(patsubst %.proto,%.pb-c.c,$(PROTO_FILES))
......
import "fown.proto";
message eventfd_file_entry {
required uint32 id = 1;
required uint32 flags = 2;
required fown_entry fown = 3;
required uint64 counter = 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