/* SPDX-License-Identifier: GPL-2.0-or-later * Copyright (c) 2025 Red Hat GmbH * Author: Stefano Brivio */ #ifndef MIGRATE_H #define MIGRATE_H struct migrate_version; /** * struct migrate_meta - Migration metadata * @version: Chosen migration data version, host order * @v: Migration version information * @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 version; const struct migrate_version *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[4096]; } __attribute__((packed)); struct migrate_stage; /** * migrate_cb_t - Callback function to implement one migration stage */ typedef int (*migrate_cb_t)(struct ctx *c, struct migrate_meta *m, const struct migrate_stage *stage, int fd); /** * struct migrate_stage - Callbacks and parameters for one stage of migration * @name: Stage name (for debugging) * @source: Callback to implement this stage on the source * @target: Callback to implement this stage on the target * @v: Source version this applies to, host order * @sections: Array of data sections, NULL-terminated */ struct migrate_stage { const char *name; migrate_cb_t source; migrate_cb_t target; /* FIXME: rollback callbacks? */ union { struct iovec iov; }; }; /** * struct migrate_version - Stages for a particular protocol version * @version: Version number this implements * @stages: Ordered array of stages * @nstages: Length of @stages */ struct migrate_version { uint32_t version; const struct migrate_stage *stages; unsigned nstages; }; int migrate_source(struct ctx *c, int fd); int migrate_target(struct ctx *c, int fd); #endif /* MIGRATE_H */