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