4841a6
From b21f18afceba8231c78d29e66f58516e12c28d22 Mon Sep 17 00:00:00 2001
719b13
From: Juan Quintela <quintela@redhat.com>
719b13
Date: Wed, 18 May 2022 02:52:23 -0300
4841a6
Subject: [PATCH 10/37] migration: All this fields are unsigned
719b13
MIME-Version: 1.0
719b13
Content-Type: text/plain; charset=UTF-8
719b13
Content-Transfer-Encoding: 8bit
719b13
719b13
RH-Author: Leonardo Brás <leobras@redhat.com>
4841a6
RH-MergeRequest: 191: MSG_ZEROCOPY + Multifd @ rhel8.7
4841a6
RH-Commit: [10/26] 2c3ee27aae334db3b283ab7ef580f58e396e569d
4841a6
RH-Bugzilla: 2072049
719b13
RH-Acked-by: Peter Xu <peterx@redhat.com>
4841a6
RH-Acked-by: Daniel P. Berrangé <berrange@redhat.com>
4841a6
RH-Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
719b13
719b13
So printing it as %d is wrong.  Notice that for the channel id, that
719b13
is an uint8_t, but I changed it anyways for consistency.
719b13
719b13
Signed-off-by: Juan Quintela <quintela@redhat.com>
719b13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
719b13
Reviewed-by: Peter Xu <peterx@redhat.com>
719b13
(cherry picked from commit 04e114049406dbb69fc9043c795ddd28fdba31a6)
719b13
Signed-off-by: Leonardo Bras <leobras@redhat.com>
719b13
---
719b13
 migration/multifd-zlib.c | 20 ++++++++++----------
719b13
 migration/multifd-zstd.c | 24 ++++++++++++------------
719b13
 migration/multifd.c      | 16 ++++++++--------
719b13
 migration/trace-events   | 26 +++++++++++++-------------
719b13
 4 files changed, 43 insertions(+), 43 deletions(-)
719b13
719b13
diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c
719b13
index a1950a4588..a987e4a26c 100644
719b13
--- a/migration/multifd-zlib.c
719b13
+++ b/migration/multifd-zlib.c
719b13
@@ -52,7 +52,7 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **errp)
719b13
     zs->opaque = Z_NULL;
719b13
     if (deflateInit(zs, migrate_multifd_zlib_level()) != Z_OK) {
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: deflate init failed", p->id);
719b13
+        error_setg(errp, "multifd %u: deflate init failed", p->id);
719b13
         return -1;
719b13
     }
719b13
     /* We will never have more than page_count pages */
719b13
@@ -62,7 +62,7 @@ static int zlib_send_setup(MultiFDSendParams *p, Error **errp)
719b13
     if (!z->zbuff) {
719b13
         deflateEnd(&z->zs);
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: out of memory for zbuff", p->id);
719b13
+        error_setg(errp, "multifd %u: out of memory for zbuff", p->id);
719b13
         return -1;
719b13
     }
719b13
     p->data = z;
719b13
@@ -134,12 +134,12 @@ static int zlib_send_prepare(MultiFDSendParams *p, Error **errp)
719b13
             ret = deflate(zs, flush);
719b13
         } while (ret == Z_OK && zs->avail_in && zs->avail_out);
719b13
         if (ret == Z_OK && zs->avail_in) {
719b13
-            error_setg(errp, "multifd %d: deflate failed to compress all input",
719b13
+            error_setg(errp, "multifd %u: deflate failed to compress all input",
719b13
                        p->id);
719b13
             return -1;
719b13
         }
719b13
         if (ret != Z_OK) {
719b13
-            error_setg(errp, "multifd %d: deflate returned %d instead of Z_OK",
719b13
+            error_setg(errp, "multifd %u: deflate returned %d instead of Z_OK",
719b13
                        p->id, ret);
719b13
             return -1;
719b13
         }
719b13
@@ -193,7 +193,7 @@ static int zlib_recv_setup(MultiFDRecvParams *p, Error **errp)
719b13
     zs->avail_in = 0;
719b13
     zs->next_in = Z_NULL;
719b13
     if (inflateInit(zs) != Z_OK) {
719b13
-        error_setg(errp, "multifd %d: inflate init failed", p->id);
719b13
+        error_setg(errp, "multifd %u: inflate init failed", p->id);
719b13
         return -1;
719b13
     }
719b13
     /* We will never have more than page_count pages */
719b13
@@ -203,7 +203,7 @@ static int zlib_recv_setup(MultiFDRecvParams *p, Error **errp)
719b13
     z->zbuff = g_try_malloc(z->zbuff_len);
719b13
     if (!z->zbuff) {
719b13
         inflateEnd(zs);
719b13
-        error_setg(errp, "multifd %d: out of memory for zbuff", p->id);
719b13
+        error_setg(errp, "multifd %u: out of memory for zbuff", p->id);
719b13
         return -1;
719b13
     }
719b13
     return 0;
719b13
@@ -252,7 +252,7 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
     int i;
719b13
 
719b13
     if (flags != MULTIFD_FLAG_ZLIB) {
719b13
-        error_setg(errp, "multifd %d: flags received %x flags expected %x",
719b13
+        error_setg(errp, "multifd %u: flags received %x flags expected %x",
719b13
                    p->id, flags, MULTIFD_FLAG_ZLIB);
719b13
         return -1;
719b13
     }
719b13
@@ -289,19 +289,19 @@ static int zlib_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
         } while (ret == Z_OK && zs->avail_in
719b13
                              && (zs->total_out - start) < page_size);
719b13
         if (ret == Z_OK && (zs->total_out - start) < page_size) {
719b13
-            error_setg(errp, "multifd %d: inflate generated too few output",
719b13
+            error_setg(errp, "multifd %u: inflate generated too few output",
719b13
                        p->id);
719b13
             return -1;
719b13
         }
719b13
         if (ret != Z_OK) {
719b13
-            error_setg(errp, "multifd %d: inflate returned %d instead of Z_OK",
719b13
+            error_setg(errp, "multifd %u: inflate returned %d instead of Z_OK",
719b13
                        p->id, ret);
719b13
             return -1;
719b13
         }
719b13
     }
719b13
     out_size = zs->total_out - out_size;
719b13
     if (out_size != expected_size) {
719b13
-        error_setg(errp, "multifd %d: packet size received %d size expected %d",
719b13
+        error_setg(errp, "multifd %u: packet size received %u size expected %u",
719b13
                    p->id, out_size, expected_size);
719b13
         return -1;
719b13
     }
719b13
diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c
719b13
index d9ed42622b..2185a83eac 100644
719b13
--- a/migration/multifd-zstd.c
719b13
+++ b/migration/multifd-zstd.c
719b13
@@ -56,7 +56,7 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **errp)
719b13
     z->zcs = ZSTD_createCStream();
719b13
     if (!z->zcs) {
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: zstd createCStream failed", p->id);
719b13
+        error_setg(errp, "multifd %u: zstd createCStream failed", p->id);
719b13
         return -1;
719b13
     }
719b13
 
719b13
@@ -64,7 +64,7 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **errp)
719b13
     if (ZSTD_isError(res)) {
719b13
         ZSTD_freeCStream(z->zcs);
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: initCStream failed with error %s",
719b13
+        error_setg(errp, "multifd %u: initCStream failed with error %s",
719b13
                    p->id, ZSTD_getErrorName(res));
719b13
         return -1;
719b13
     }
719b13
@@ -75,7 +75,7 @@ static int zstd_send_setup(MultiFDSendParams *p, Error **errp)
719b13
     if (!z->zbuff) {
719b13
         ZSTD_freeCStream(z->zcs);
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: out of memory for zbuff", p->id);
719b13
+        error_setg(errp, "multifd %u: out of memory for zbuff", p->id);
719b13
         return -1;
719b13
     }
719b13
     return 0;
719b13
@@ -146,12 +146,12 @@ static int zstd_send_prepare(MultiFDSendParams *p, Error **errp)
719b13
         } while (ret > 0 && (z->in.size - z->in.pos > 0)
719b13
                          && (z->out.size - z->out.pos > 0));
719b13
         if (ret > 0 && (z->in.size - z->in.pos > 0)) {
719b13
-            error_setg(errp, "multifd %d: compressStream buffer too small",
719b13
+            error_setg(errp, "multifd %u: compressStream buffer too small",
719b13
                        p->id);
719b13
             return -1;
719b13
         }
719b13
         if (ZSTD_isError(ret)) {
719b13
-            error_setg(errp, "multifd %d: compressStream error %s",
719b13
+            error_setg(errp, "multifd %u: compressStream error %s",
719b13
                        p->id, ZSTD_getErrorName(ret));
719b13
             return -1;
719b13
         }
719b13
@@ -201,7 +201,7 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Error **errp)
719b13
     z->zds = ZSTD_createDStream();
719b13
     if (!z->zds) {
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: zstd createDStream failed", p->id);
719b13
+        error_setg(errp, "multifd %u: zstd createDStream failed", p->id);
719b13
         return -1;
719b13
     }
719b13
 
719b13
@@ -209,7 +209,7 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Error **errp)
719b13
     if (ZSTD_isError(ret)) {
719b13
         ZSTD_freeDStream(z->zds);
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: initDStream failed with error %s",
719b13
+        error_setg(errp, "multifd %u: initDStream failed with error %s",
719b13
                    p->id, ZSTD_getErrorName(ret));
719b13
         return -1;
719b13
     }
719b13
@@ -222,7 +222,7 @@ static int zstd_recv_setup(MultiFDRecvParams *p, Error **errp)
719b13
     if (!z->zbuff) {
719b13
         ZSTD_freeDStream(z->zds);
719b13
         g_free(z);
719b13
-        error_setg(errp, "multifd %d: out of memory for zbuff", p->id);
719b13
+        error_setg(errp, "multifd %u: out of memory for zbuff", p->id);
719b13
         return -1;
719b13
     }
719b13
     return 0;
719b13
@@ -270,7 +270,7 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
     int i;
719b13
 
719b13
     if (flags != MULTIFD_FLAG_ZSTD) {
719b13
-        error_setg(errp, "multifd %d: flags received %x flags expected %x",
719b13
+        error_setg(errp, "multifd %u: flags received %x flags expected %x",
719b13
                    p->id, flags, MULTIFD_FLAG_ZSTD);
719b13
         return -1;
719b13
     }
719b13
@@ -302,19 +302,19 @@ static int zstd_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
         } while (ret > 0 && (z->in.size - z->in.pos > 0)
719b13
                          && (z->out.pos < page_size));
719b13
         if (ret > 0 && (z->out.pos < page_size)) {
719b13
-            error_setg(errp, "multifd %d: decompressStream buffer too small",
719b13
+            error_setg(errp, "multifd %u: decompressStream buffer too small",
719b13
                        p->id);
719b13
             return -1;
719b13
         }
719b13
         if (ZSTD_isError(ret)) {
719b13
-            error_setg(errp, "multifd %d: decompressStream returned %s",
719b13
+            error_setg(errp, "multifd %u: decompressStream returned %s",
719b13
                        p->id, ZSTD_getErrorName(ret));
719b13
             return ret;
719b13
         }
719b13
         out_size += z->out.pos;
719b13
     }
719b13
     if (out_size != expected_size) {
719b13
-        error_setg(errp, "multifd %d: packet size received %d size expected %d",
719b13
+        error_setg(errp, "multifd %u: packet size received %u size expected %u",
719b13
                    p->id, out_size, expected_size);
719b13
         return -1;
719b13
     }
719b13
diff --git a/migration/multifd.c b/migration/multifd.c
719b13
index 0533da154a..d0d19470f9 100644
719b13
--- a/migration/multifd.c
719b13
+++ b/migration/multifd.c
719b13
@@ -148,7 +148,7 @@ static int nocomp_recv_pages(MultiFDRecvParams *p, Error **errp)
719b13
     uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK;
719b13
 
719b13
     if (flags != MULTIFD_FLAG_NOCOMP) {
719b13
-        error_setg(errp, "multifd %d: flags received %x flags expected %x",
719b13
+        error_setg(errp, "multifd %u: flags received %x flags expected %x",
719b13
                    p->id, flags, MULTIFD_FLAG_NOCOMP);
719b13
         return -1;
719b13
     }
719b13
@@ -212,8 +212,8 @@ static int multifd_recv_initial_packet(QIOChannel *c, Error **errp)
719b13
     }
719b13
 
719b13
     if (msg.version != MULTIFD_VERSION) {
719b13
-        error_setg(errp, "multifd: received packet version %d "
719b13
-                   "expected %d", msg.version, MULTIFD_VERSION);
719b13
+        error_setg(errp, "multifd: received packet version %u "
719b13
+                   "expected %u", msg.version, MULTIFD_VERSION);
719b13
         return -1;
719b13
     }
719b13
 
719b13
@@ -229,8 +229,8 @@ static int multifd_recv_initial_packet(QIOChannel *c, Error **errp)
719b13
     }
719b13
 
719b13
     if (msg.id > migrate_multifd_channels()) {
719b13
-        error_setg(errp, "multifd: received channel version %d "
719b13
-                   "expected %d", msg.version, MULTIFD_VERSION);
719b13
+        error_setg(errp, "multifd: received channel version %u "
719b13
+                   "expected %u", msg.version, MULTIFD_VERSION);
719b13
         return -1;
719b13
     }
719b13
 
719b13
@@ -303,7 +303,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
719b13
     packet->version = be32_to_cpu(packet->version);
719b13
     if (packet->version != MULTIFD_VERSION) {
719b13
         error_setg(errp, "multifd: received packet "
719b13
-                   "version %d and expected version %d",
719b13
+                   "version %u and expected version %u",
719b13
                    packet->version, MULTIFD_VERSION);
719b13
         return -1;
719b13
     }
719b13
@@ -317,7 +317,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
719b13
      */
719b13
     if (packet->pages_alloc > pages_max * 100) {
719b13
         error_setg(errp, "multifd: received packet "
719b13
-                   "with size %d and expected a maximum size of %d",
719b13
+                   "with size %u and expected a maximum size of %u",
719b13
                    packet->pages_alloc, pages_max * 100) ;
719b13
         return -1;
719b13
     }
719b13
@@ -333,7 +333,7 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
719b13
     p->pages->num = be32_to_cpu(packet->pages_used);
719b13
     if (p->pages->num > packet->pages_alloc) {
719b13
         error_setg(errp, "multifd: received packet "
719b13
-                   "with %d pages and expected maximum pages are %d",
719b13
+                   "with %u pages and expected maximum pages are %u",
719b13
                    p->pages->num, packet->pages_alloc) ;
719b13
         return -1;
719b13
     }
719b13
diff --git a/migration/trace-events b/migration/trace-events
719b13
index b48d873b8a..5172cb3b3d 100644
719b13
--- a/migration/trace-events
719b13
+++ b/migration/trace-events
719b13
@@ -115,23 +115,23 @@ ram_write_tracking_ramblock_start(const char *block_id, size_t page_size, void *
719b13
 ram_write_tracking_ramblock_stop(const char *block_id, size_t page_size, void *addr, size_t length) "%s: page_size: %zu addr: %p length: %zu"
719b13
 
719b13
 # multifd.c
719b13
-multifd_new_send_channel_async(uint8_t id) "channel %d"
719b13
-multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %d packet_num %" PRIu64 " pages %d flags 0x%x next packet size %d"
719b13
-multifd_recv_new_channel(uint8_t id) "channel %d"
719b13
+multifd_new_send_channel_async(uint8_t id) "channel %u"
719b13
+multifd_recv(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u flags 0x%x next packet size %u"
719b13
+multifd_recv_new_channel(uint8_t id) "channel %u"
719b13
 multifd_recv_sync_main(long packet_num) "packet num %ld"
719b13
-multifd_recv_sync_main_signal(uint8_t id) "channel %d"
719b13
-multifd_recv_sync_main_wait(uint8_t id) "channel %d"
719b13
+multifd_recv_sync_main_signal(uint8_t id) "channel %u"
719b13
+multifd_recv_sync_main_wait(uint8_t id) "channel %u"
719b13
 multifd_recv_terminate_threads(bool error) "error %d"
719b13
-multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel %d packets %" PRIu64 " pages %" PRIu64
719b13
-multifd_recv_thread_start(uint8_t id) "%d"
719b13
-multifd_send(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %d packet_num %" PRIu64 " pages %d flags 0x%x next packet size %d"
719b13
-multifd_send_error(uint8_t id) "channel %d"
719b13
+multifd_recv_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel %u packets %" PRIu64 " pages %" PRIu64
719b13
+multifd_recv_thread_start(uint8_t id) "%u"
719b13
+multifd_send(uint8_t id, uint64_t packet_num, uint32_t used, uint32_t flags, uint32_t next_packet_size) "channel %u packet_num %" PRIu64 " pages %u flags 0x%x next packet size %u"
719b13
+multifd_send_error(uint8_t id) "channel %u"
719b13
 multifd_send_sync_main(long packet_num) "packet num %ld"
719b13
-multifd_send_sync_main_signal(uint8_t id) "channel %d"
719b13
-multifd_send_sync_main_wait(uint8_t id) "channel %d"
719b13
+multifd_send_sync_main_signal(uint8_t id) "channel %u"
719b13
+multifd_send_sync_main_wait(uint8_t id) "channel %u"
719b13
 multifd_send_terminate_threads(bool error) "error %d"
719b13
-multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel %d packets %" PRIu64 " pages %"  PRIu64
719b13
-multifd_send_thread_start(uint8_t id) "%d"
719b13
+multifd_send_thread_end(uint8_t id, uint64_t packets, uint64_t pages) "channel %u packets %" PRIu64 " pages %"  PRIu64
719b13
+multifd_send_thread_start(uint8_t id) "%u"
719b13
 multifd_tls_outgoing_handshake_start(void *ioc, void *tioc, const char *hostname) "ioc=%p tioc=%p hostname=%s"
719b13
 multifd_tls_outgoing_handshake_error(void *ioc, const char *err) "ioc=%p err=%s"
719b13
 multifd_tls_outgoing_handshake_complete(void *ioc) "ioc=%p"
719b13
-- 
719b13
2.35.3
719b13