diff mbox series

[3/4] migration/multifd: initialize packet->magic/version once at setup stage

Message ID 20191011085050.17622-4-richardw.yang@linux.intel.com
State New
Headers show
Series migration/multifd: trivial cleanup for multifd | expand

Commit Message

Wei Yang Oct. 11, 2019, 8:50 a.m. UTC
MultiFDPacket_t's magic and version field never changes during
migration, so move these two fields in setup stage.

Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
---
 migration/ram.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Juan Quintela Oct. 11, 2019, 10:20 a.m. UTC | #1
Wei Yang <richardw.yang@linux.intel.com> wrote:
> MultiFDPacket_t's magic and version field never changes during
> migration, so move these two fields in setup stage.
>
> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>

Reviewed-by: Juan Quintela <quintela@redhat.com>

It don't really matter, and is faster your way O:-)
Wei Yang Oct. 11, 2019, 12:17 p.m. UTC | #2
On Fri, Oct 11, 2019 at 12:20:48PM +0200, Juan Quintela wrote:
>Wei Yang <richardw.yang@linux.intel.com> wrote:
>> MultiFDPacket_t's magic and version field never changes during
>> migration, so move these two fields in setup stage.
>>
>> Signed-off-by: Wei Yang <richardw.yang@linux.intel.com>
>
>Reviewed-by: Juan Quintela <quintela@redhat.com>
>
>It don't really matter, and is faster your way O:-)

You are right.

And I am wondering one more thing. Why we need to carry magic/version for each
packet? Would it be better to just carry and check magic/version for the
initial packet only?
diff mbox series

Patch

diff --git a/migration/ram.c b/migration/ram.c
index 6a3bef0434..71d845b851 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -793,8 +793,6 @@  static void multifd_send_fill_packet(MultiFDSendParams *p)
     MultiFDPacket_t *packet = p->packet;
     int i;
 
-    packet->magic = cpu_to_be32(MULTIFD_MAGIC);
-    packet->version = cpu_to_be32(MULTIFD_VERSION);
     packet->flags = cpu_to_be32(p->flags);
     packet->pages_alloc = cpu_to_be32(p->pages->allocated);
     packet->pages_used = cpu_to_be32(p->pages->used);
@@ -1240,6 +1238,8 @@  int multifd_save_setup(void)
         p->packet_len = sizeof(MultiFDPacket_t)
                       + sizeof(ram_addr_t) * page_count;
         p->packet = g_malloc0(p->packet_len);
+        p->packet->magic = cpu_to_be32(MULTIFD_MAGIC);
+        p->packet->version = cpu_to_be32(MULTIFD_VERSION);
         p->name = g_strdup_printf("multifdsend_%d", i);
         socket_send_channel_create(multifd_new_send_channel_async, p);
     }