Skip to contentSkip to conversation

Clean up 32bit compilation for Migration

PATCH In review Juan Quintela 2 participants 5 messages Nov 10, 2015

lore
Share & tools
lore
#0 lore raw

cover Clean up 32bit compilation for Migration

Hi

We had two warnings on 32bit targets. With this change I am able to compile with -Werror on:
- linux 64bit
- linux 32bit
- windows 32bit (cross-compile with Fedora mingw64)
- windows 64bit (cross-compile with Fedora mingw64)
I am lying in this one, really my crosscompiler for windows 64 bit barf at

CXX disas/libvixl/a64/disasm-a64.o
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc: In member function 'virtual void vixl::Disassembler::AppendPCRelativeOffsetToOutput(const vixl::Instruction*, int64_t)':
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc:1365:57: error: unknown conversion type character 'l' in format [-Werror=format=]

   AppendToOutput("#%c0x%" PRIx64, sign, std::abs(offset));
                                                         ^
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc:1365:57: error: too many arguments for format [-Werror=format-extra-args]
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc: In member function 'virtual void vixl::Disassembler::AppendAddressToOutput(const vixl::Instruction*, const void*)':
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc:1372:76: error: unknown conversion type character 'l' in format [-Werror=format=]
   AppendToOutput("(addr 0x%" PRIxPTR ")", reinterpret_cast<uintptr_t>(addr));
                                                                            ^
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc:1372:76: error: too many arguments for format [-Werror=format-extra-args]
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc: In member function 'virtual void vixl::Disassembler::AppendCodeRelativeAddressToOutput(const vixl::Instruction*, const void*)':
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc:1393:52: error: unknown conversion type character 'l' in format [-Werror=format=]
     AppendToOutput("(addr 0x%" PRIx64 ")", rel_addr);
                                                    ^
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc:1393:52: error: too many arguments for format [-Werror=format-extra-args]
/mnt/kvm/qemu/next/disas/libvixl/a64/disasm-a64.cc:1395:54: error: unknown conversion type character 'l' in format [-Werror=format=]
     AppendToOutput("(addr -0x%" PRIx64 ")", -rel_addr);
                                                      ^

.....

I am wondering if it really understand PRI*64 at all.

Please, review.

Juan.

Juan Quintela (2):
migration: print ram_addr_t as RAM_ADDR_FMT not %zx
migration: Make 32bit linux compile with RDMA

 migration/ram.c  | 5 +++--
 migration/rdma.c | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/2 migration: print ram_addr_t as RAM_ADDR_FMT not %zx

Not all the wold is 64bits (yet).

---
 migration/ram.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
migration/ram.c +3 -2
index 62cf42b..d8d5a50 100644
@@ -1184,7 +1184,8 @@ int ram_save_queue_pages(MigrationState *ms, const char *rbname,
     }
     trace_ram_save_queue_pages(ramblock->idstr, start, len);
     if (start+len > ramblock->used_length) {
-        error_report("%s request overrun start=%zx len=%zx blocklen=%zx",
+        error_report("%s request overrun start=" RAM_ADDR_FMT " len="
+                     RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT,
                      __func__, start, len, ramblock->used_length);
         goto err;
     }
@@ -1845,7 +1846,7 @@ int ram_discard_range(MigrationIncomingState *mis,
         ret = postcopy_ram_discard_range(mis, host_startaddr, length);
     } else {
         error_report("ram_discard_range: Overrun block '%s' (%" PRIu64
-                     "/%zu/%zu)",
+                     "/%zx/" RAM_ADDR_FMT")",
                      block_name, start, length, rb->used_length);
     }
 
Signature · 1 line
2.5.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] migration: print ram_addr_t as RAM_ADDR_FMT not %zx

Quoted 3 lines · * Juan Quintela ([email protected]) wrote:

Not all the wold is 64bits (yet).

Yep that's my fault.

Quoted 30 lines
---
 migration/ram.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
migration/ram.c +3 -2
index 62cf42b..d8d5a50 100644
@@ -1184,7 +1184,8 @@ int ram_save_queue_pages(MigrationState *ms, const char *rbname,
     }
     trace_ram_save_queue_pages(ramblock->idstr, start, len);
     if (start+len > ramblock->used_length) {
-        error_report("%s request overrun start=%zx len=%zx blocklen=%zx",
+        error_report("%s request overrun start=" RAM_ADDR_FMT " len="
+                     RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT,
                      __func__, start, len, ramblock->used_length);
         goto err;
     }
@@ -1845,7 +1846,7 @@ int ram_discard_range(MigrationIncomingState *mis,
         ret = postcopy_ram_discard_range(mis, host_startaddr, length);
     } else {
         error_report("ram_discard_range: Overrun block '%s' (%" PRIu64
-                     "/%zu/%zu)",
+                     "/%zx/" RAM_ADDR_FMT")",
                      block_name, start, length, rb->used_length);
     }
 
Signature · 1 line
2.5.0

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#3 lore raw

PATCH 2/2 migration: Make 32bit linux compile with RDMA

In reply to Juan Quintela

Rest of the file already use that trick. 64bit offsets make no sense in 32bit archs, but that is ram_addr_t for you.

---
 migration/rdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/rdma.c +1 -1
index 553fbd7..dcabb91 100644
@@ -577,7 +577,7 @@ static int rdma_add_block(RDMAContext *rdma, const char *block_name,
     block->is_ram_block = local->init ? false : true;
 
     if (rdma->blockmap) {
-        g_hash_table_insert(rdma->blockmap, (void *) block_offset, block);
+        g_hash_table_insert(rdma->blockmap, (void *)(uintptr_t)block_offset, block);
     }
 
     trace_rdma_add_block(block_name, local->nb_blocks,
Signature · 1 line
2.5.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [Qemu-devel] [PATCH 2/2] migration: Make 32bit linux compile with RDMA

Quoted 13 lines · * Juan Quintela ([email protected]) wrote:

Rest of the file already use that trick. 64bit offsets make no sense in 32bit archs, but that is ram_addr_t for you.

---
 migration/rdma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/rdma.c +0 -0
index 553fbd7..dcabb91 100644

migration/rdma.c static int rdma_add_block(RDMAContext *rdma, const char *block_name, · line 580

Quoted 5 lines
migration/rdma.c +1 -1
@@ -577,7 +577,7 @@ static int rdma_add_block(RDMAContext *rdma, const char *block_name,
     block->is_ram_block = local->init ? false : true;
 
     if (rdma->blockmap) {
-        g_hash_table_insert(rdma->blockmap, (void *) block_offset, block);
+        g_hash_table_insert(rdma->blockmap, (void *)(uintptr_t)block_offset, block);

Dave

Quoted 6 lines
migration/rdma.c +0 -0
     }
 
     trace_rdma_add_block(block_name, local->nb_blocks,
Signature · 1 line
2.5.0

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK