1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
| | /* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright (c) 2025 Red Hat GmbH
* Author: Stefano Brivio <sbrivio@redhat.com>
*/
#ifndef MIGRATE_H
#define MIGRATE_H
/**
* struct migrate_meta - Migration metadata
* @v: Chosen migration data version, host order
* @bswap: Source has opposite endianness
* @peer_64b: Source uses 64-bit void *
* @time_64b: Source uses 64-bit time_t
* @flow_size: Size of union flow in source
* @flow_sidx_size: Size of struct flow_sidx in source
*/
struct migrate_meta {
uint32_t v;
bool bswap;
bool source_64b;
bool time_64b;
size_t flow_size;
size_t flow_sidx_size;
};
/**
* union migrate_header - Migration header from source
* @magic: 0xB1BB1D1B0BB1D1B0, host order
* @version: Source sends highest known, target aborts if unsupported
* @voidp_size: sizeof(void *), network order
* @time_t_size: sizeof(time_t), network order
* @flow_size: sizeof(union flow), network order
* @flow_sidx_size: sizeof(struct flow_sidx_t), network order
* @unused: Go figure
*/
union migrate_header {
struct {
uint64_t magic;
uint32_t version;
uint32_t voidp_size;
uint32_t time_t_size;
uint32_t flow_size;
uint32_t flow_sidx_size;
};
uint8_t unused[65536];
};
/**
* struct migrate_data - Data sections for given source version
* @v: Source version this applies to, host order
* @sections: Array of data sections, NULL-terminated
*/
struct migrate_data {
uint32_t v;
struct iovec *sections;
};
/**
* struct migrate_handler - Function to handle a specific data section
* @fn: Function pointer taking pointer to context and metadata
*/
struct migrate_handler {
int (*fn)(struct ctx *c, struct migrate_meta *m);
};
/**
* struct migrate_target_handlers - Versioned sets of migration target handlers
* @v: Source version this applies to, host order
* @pre: Set of functions to execute in target before data copy
* @post: Set of functions to execute in target after data copy
*/
struct migrate_target_handlers {
uint32_t v;
struct migrate_handler *pre;
struct migrate_handler *post;
};
int migrate_source_pre(struct ctx *c, struct migrate_meta *m);
int migrate_source(int fd, const struct migrate_meta *m);
void migrate_source_post(struct ctx *c, struct migrate_meta *m);
int migrate_target_read_header(int fd, struct migrate_meta *m);
int migrate_target_pre(struct ctx *c, struct migrate_meta *m);
int migrate_target(int fd, const struct migrate_meta *m);
void migrate_target_post(struct ctx *c, struct migrate_meta *m);
#endif /* MIGRATE_H */
|