diff options
author | Fabiano Rosas <farosas@suse.de> | 2024-08-27 14:45:52 -0300 |
---|---|---|
committer | Fabiano Rosas <farosas@suse.de> | 2024-09-03 16:24:35 -0300 |
commit | addd7d15816f2ee65911d30a38357cc2004f22eb (patch) | |
tree | 882f5aa81ef7c2e65316635b2fa86485e3620235 | |
parent | 112f7d1b752543de06ae96210a14abbed7913922 (diff) | |
download | qemu-addd7d15816f2ee65911d30a38357cc2004f22eb.zip qemu-addd7d15816f2ee65911d30a38357cc2004f22eb.tar.gz qemu-addd7d15816f2ee65911d30a38357cc2004f22eb.tar.bz2 |
migration/multifd: Introduce MultiFDSendData
Add a new data structure to replace p->pages in the multifd
channel. This new structure will hide the multifd payload type behind
an union, so we don't need to add a new field to the channel each time
we want to handle a different data type.
This also allow us to keep multifd_send_pages() as is, without needing
to complicate the pointer switching.
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
-rw-r--r-- | migration/multifd.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/migration/multifd.h b/migration/multifd.h index 660a988..7bb4a2c 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -17,6 +17,7 @@ #include "ram.h" typedef struct MultiFDRecvData MultiFDRecvData; +typedef struct MultiFDSendData MultiFDSendData; bool multifd_send_setup(void); void multifd_send_shutdown(void); @@ -88,6 +89,31 @@ struct MultiFDRecvData { off_t file_offset; }; +typedef enum { + MULTIFD_PAYLOAD_NONE, + MULTIFD_PAYLOAD_RAM, +} MultiFDPayloadType; + +typedef union MultiFDPayload { + MultiFDPages_t ram; +} MultiFDPayload; + +struct MultiFDSendData { + MultiFDPayloadType type; + MultiFDPayload u; +}; + +static inline bool multifd_payload_empty(MultiFDSendData *data) +{ + return data->type == MULTIFD_PAYLOAD_NONE; +} + +static inline void multifd_set_payload_type(MultiFDSendData *data, + MultiFDPayloadType type) +{ + data->type = type; +} + typedef struct { /* Fields are only written at creating/deletion time */ /* No lock required for them, they are read only */ |