target/arm: Check aa32_pan in take_aarch32_exception(), not aa64_pan
[qemu/ar7.git] / migration / multifd.h
blobd8b0205977a6cadc8978babef0a6bb4396a85e56
1 /*
2 * Multifd common functions
4 * Copyright (c) 2019-2020 Red Hat Inc
6 * Authors:
7 * Juan Quintela <quintela@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef QEMU_MIGRATION_MULTIFD_H
14 #define QEMU_MIGRATION_MULTIFD_H
16 int multifd_save_setup(Error **errp);
17 void multifd_save_cleanup(void);
18 int multifd_load_setup(Error **errp);
19 int multifd_load_cleanup(Error **errp);
20 bool multifd_recv_all_channels_created(void);
21 bool multifd_recv_new_channel(QIOChannel *ioc, Error **errp);
22 void multifd_recv_sync_main(void);
23 void multifd_send_sync_main(QEMUFile *f);
24 int multifd_queue_page(QEMUFile *f, RAMBlock *block, ram_addr_t offset);
26 #define MULTIFD_FLAG_SYNC (1 << 0)
28 /* This value needs to be a multiple of qemu_target_page_size() */
29 #define MULTIFD_PACKET_SIZE (512 * 1024)
31 typedef struct {
32 uint32_t magic;
33 uint32_t version;
34 uint32_t flags;
35 /* maximum number of allocated pages */
36 uint32_t pages_alloc;
37 uint32_t pages_used;
38 /* size of the next packet that contains pages */
39 uint32_t next_packet_size;
40 uint64_t packet_num;
41 uint64_t unused[4]; /* Reserved for future use */
42 char ramblock[256];
43 uint64_t offset[];
44 } __attribute__((packed)) MultiFDPacket_t;
46 typedef struct {
47 /* number of used pages */
48 uint32_t used;
49 /* number of allocated pages */
50 uint32_t allocated;
51 /* global number of generated multifd packets */
52 uint64_t packet_num;
53 /* offset of each page */
54 ram_addr_t *offset;
55 /* pointer to each page */
56 struct iovec *iov;
57 RAMBlock *block;
58 } MultiFDPages_t;
60 typedef struct {
61 /* this fields are not changed once the thread is created */
62 /* channel number */
63 uint8_t id;
64 /* channel thread name */
65 char *name;
66 /* channel thread id */
67 QemuThread thread;
68 /* communication channel */
69 QIOChannel *c;
70 /* sem where to wait for more work */
71 QemuSemaphore sem;
72 /* this mutex protects the following parameters */
73 QemuMutex mutex;
74 /* is this channel thread running */
75 bool running;
76 /* should this thread finish */
77 bool quit;
78 /* thread has work to do */
79 int pending_job;
80 /* array of pages to sent */
81 MultiFDPages_t *pages;
82 /* packet allocated len */
83 uint32_t packet_len;
84 /* pointer to the packet */
85 MultiFDPacket_t *packet;
86 /* multifd flags for each packet */
87 uint32_t flags;
88 /* size of the next packet that contains pages */
89 uint32_t next_packet_size;
90 /* global number of generated multifd packets */
91 uint64_t packet_num;
92 /* thread local variables */
93 /* packets sent through this channel */
94 uint64_t num_packets;
95 /* pages sent through this channel */
96 uint64_t num_pages;
97 /* syncs main thread and channels */
98 QemuSemaphore sem_sync;
99 } MultiFDSendParams;
101 typedef struct {
102 /* this fields are not changed once the thread is created */
103 /* channel number */
104 uint8_t id;
105 /* channel thread name */
106 char *name;
107 /* channel thread id */
108 QemuThread thread;
109 /* communication channel */
110 QIOChannel *c;
111 /* this mutex protects the following parameters */
112 QemuMutex mutex;
113 /* is this channel thread running */
114 bool running;
115 /* should this thread finish */
116 bool quit;
117 /* array of pages to receive */
118 MultiFDPages_t *pages;
119 /* packet allocated len */
120 uint32_t packet_len;
121 /* pointer to the packet */
122 MultiFDPacket_t *packet;
123 /* multifd flags for each packet */
124 uint32_t flags;
125 /* global number of generated multifd packets */
126 uint64_t packet_num;
127 /* thread local variables */
128 /* size of the next packet that contains pages */
129 uint32_t next_packet_size;
130 /* packets sent through this channel */
131 uint64_t num_packets;
132 /* pages sent through this channel */
133 uint64_t num_pages;
134 /* syncs main thread and channels */
135 QemuSemaphore sem_sync;
136 } MultiFDRecvParams;
138 #endif