xref: /qemu/include/migration/cpr.h (revision 563ac3d18129a2770a285cc16c20ad50c8adc7c0)
1 /*
2  * Copyright (c) 2021, 2024 Oracle and/or its affiliates.
3  *
4  * This work is licensed under the terms of the GNU GPL, version 2 or later.
5  * See the COPYING file in the top-level directory.
6  */
7 
8 #ifndef MIGRATION_CPR_H
9 #define MIGRATION_CPR_H
10 
11 #include "qapi/qapi-types-migration.h"
12 #include "qemu/queue.h"
13 
14 #define MIG_MODE_NONE           -1
15 
16 #define QEMU_CPR_FILE_MAGIC     0x51435052
17 #define QEMU_CPR_FILE_VERSION   0x00000001
18 #define CPR_STATE "CprState"
19 
20 typedef QLIST_HEAD(CprFdList, CprFd) CprFdList;
21 typedef QLIST_HEAD(CprVFIODeviceList, CprVFIODevice) CprVFIODeviceList;
22 
23 typedef struct CprState {
24     CprFdList fds;
25     CprVFIODeviceList vfio_devices;
26 } CprState;
27 
28 extern CprState cpr_state;
29 
30 void cpr_save_fd(const char *name, int id, int fd);
31 void cpr_delete_fd(const char *name, int id);
32 int cpr_find_fd(const char *name, int id);
33 void cpr_resave_fd(const char *name, int id, int fd);
34 int cpr_open_fd(const char *path, int flags, const char *name, int id,
35                 Error **errp);
36 
37 MigMode cpr_get_incoming_mode(void);
38 void cpr_set_incoming_mode(MigMode mode);
39 bool cpr_is_incoming(void);
40 
41 int cpr_state_save(MigrationChannel *channel, Error **errp);
42 int cpr_state_load(MigrationChannel *channel, Error **errp);
43 void cpr_state_close(void);
44 struct QIOChannel *cpr_state_ioc(void);
45 
46 bool cpr_incoming_needed(void *opaque);
47 int cpr_get_fd_param(const char *name, const char *fdname, int index,
48                      Error **errp);
49 
50 QEMUFile *cpr_transfer_output(MigrationChannel *channel, Error **errp);
51 QEMUFile *cpr_transfer_input(MigrationChannel *channel, Error **errp);
52 
53 #endif
54