Message ID | 20240722175914.24022-4-farosas@suse.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | migration/multifd: Remove multifd_send_state->pages | expand |
On Mon, Jul 22, 2024 at 02:59:08PM -0300, Fabiano Rosas wrote: > 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. > > Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com>
diff --git a/migration/multifd.h b/migration/multifd.h index 0ecd6f47d7..c7b1ebe099 100644 --- a/migration/multifd.h +++ b/migration/multifd.h @@ -16,6 +16,7 @@ #include "ram.h" typedef struct MultiFDRecvData MultiFDRecvData; +typedef struct MultiFDSendData MultiFDSendData; bool multifd_send_setup(void); void multifd_send_shutdown(void); @@ -89,6 +90,29 @@ struct MultiFDRecvData { off_t file_offset; }; +typedef enum { + MULTIFD_PAYLOAD_NONE, + MULTIFD_PAYLOAD_RAM, +} MultiFDPayloadType; + +struct MultiFDSendData { + MultiFDPayloadType type; + union { + MultiFDPages_t ram; + } 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 */
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. Signed-off-by: Fabiano Rosas <farosas@suse.de> --- migration/multifd.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)