qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] multifd: Be consistente about using uint64_t
@ 2020-01-17 13:56 Juan Quintela
  2020-01-17 14:03 ` Philippe Mathieu-Daudé
  2020-01-17 14:56 ` Dr. David Alan Gilbert
  0 siblings, 2 replies; 3+ messages in thread
From: Juan Quintela @ 2020-01-17 13:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Dr. David Alan Gilbert, Juan Quintela

We transmit ram_addr_t always as uint64_t.  Be consistent in its
use (on 64bit system, it is always uint64_t problem is 32bits).

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 migration/ram.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/migration/ram.c b/migration/ram.c
index 96feb4062c..f7482b1b35 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -803,7 +803,10 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
     }
 
     for (i = 0; i < p->pages->used; i++) {
-        packet->offset[i] = cpu_to_be64(p->pages->offset[i]);
+        /* there are architectures where ram_addr_t is 32 bit */
+        uint64_t temp = p->pages->offset[i];
+
+        packet->offset[i] = cpu_to_be64(temp);
     }
 }
 
@@ -877,10 +880,10 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
     }
 
     for (i = 0; i < p->pages->used; i++) {
-        ram_addr_t offset = be64_to_cpu(packet->offset[i]);
+        uint64_t offset = be64_to_cpu(packet->offset[i]);
 
         if (offset > (block->used_length - TARGET_PAGE_SIZE)) {
-            error_setg(errp, "multifd: offset too long " RAM_ADDR_FMT
+            error_setg(errp, "multifd: offset too long %" PRId64
                        " (max " RAM_ADDR_FMT ")",
                        offset, block->max_length);
             return -1;
@@ -1236,7 +1239,7 @@ int multifd_save_setup(void)
         p->id = i;
         p->pages = multifd_pages_init(page_count);
         p->packet_len = sizeof(MultiFDPacket_t)
-                      + sizeof(ram_addr_t) * page_count;
+                      + sizeof(uint64_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);
@@ -1447,7 +1450,7 @@ int multifd_load_setup(void)
         p->id = i;
         p->pages = multifd_pages_init(page_count);
         p->packet_len = sizeof(MultiFDPacket_t)
-                      + sizeof(ram_addr_t) * page_count;
+                      + sizeof(uint64_t) * page_count;
         p->packet = g_malloc0(p->packet_len);
         p->name = g_strdup_printf("multifdrecv_%d", i);
     }
-- 
2.24.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] multifd: Be consistente about using uint64_t
  2020-01-17 13:56 [PATCH] multifd: Be consistente about using uint64_t Juan Quintela
@ 2020-01-17 14:03 ` Philippe Mathieu-Daudé
  2020-01-17 14:56 ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-01-17 14:03 UTC (permalink / raw)
  To: Juan Quintela, qemu-devel; +Cc: Dr. David Alan Gilbert

On 1/17/20 2:56 PM, Juan Quintela wrote:
> We transmit ram_addr_t always as uint64_t.  Be consistent in its
> use (on 64bit system, it is always uint64_t problem is 32bits).
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>   migration/ram.c | 13 ++++++++-----
>   1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 96feb4062c..f7482b1b35 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -803,7 +803,10 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
>       }
>   
>       for (i = 0; i < p->pages->used; i++) {
> -        packet->offset[i] = cpu_to_be64(p->pages->offset[i]);
> +        /* there are architectures where ram_addr_t is 32 bit */
> +        uint64_t temp = p->pages->offset[i];

Using a temp variable is clearer than a cast, good.

> +
> +        packet->offset[i] = cpu_to_be64(temp);
>       }
>   }
>   
> @@ -877,10 +880,10 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
>       }
>   
>       for (i = 0; i < p->pages->used; i++) {
> -        ram_addr_t offset = be64_to_cpu(packet->offset[i]);
> +        uint64_t offset = be64_to_cpu(packet->offset[i]);
>   
>           if (offset > (block->used_length - TARGET_PAGE_SIZE)) {
> -            error_setg(errp, "multifd: offset too long " RAM_ADDR_FMT
> +            error_setg(errp, "multifd: offset too long %" PRId64

Nitpick: PRIu64 for uint64_t.

Using PRIu64:
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>                          " (max " RAM_ADDR_FMT ")",
>                          offset, block->max_length);
>               return -1;
> @@ -1236,7 +1239,7 @@ int multifd_save_setup(void)
>           p->id = i;
>           p->pages = multifd_pages_init(page_count);
>           p->packet_len = sizeof(MultiFDPacket_t)
> -                      + sizeof(ram_addr_t) * page_count;
> +                      + sizeof(uint64_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);
> @@ -1447,7 +1450,7 @@ int multifd_load_setup(void)
>           p->id = i;
>           p->pages = multifd_pages_init(page_count);
>           p->packet_len = sizeof(MultiFDPacket_t)
> -                      + sizeof(ram_addr_t) * page_count;
> +                      + sizeof(uint64_t) * page_count;
>           p->packet = g_malloc0(p->packet_len);
>           p->name = g_strdup_printf("multifdrecv_%d", i);
>       }
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] multifd: Be consistente about using uint64_t
  2020-01-17 13:56 [PATCH] multifd: Be consistente about using uint64_t Juan Quintela
  2020-01-17 14:03 ` Philippe Mathieu-Daudé
@ 2020-01-17 14:56 ` Dr. David Alan Gilbert
  1 sibling, 0 replies; 3+ messages in thread
From: Dr. David Alan Gilbert @ 2020-01-17 14:56 UTC (permalink / raw)
  To: Juan Quintela; +Cc: qemu-devel

* Juan Quintela (quintela@redhat.com) wrote:
> We transmit ram_addr_t always as uint64_t.  Be consistent in its
> use (on 64bit system, it is always uint64_t problem is 32bits).
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>

(Note typo in subject )

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/ram.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/migration/ram.c b/migration/ram.c
> index 96feb4062c..f7482b1b35 100644
> --- a/migration/ram.c
> +++ b/migration/ram.c
> @@ -803,7 +803,10 @@ static void multifd_send_fill_packet(MultiFDSendParams *p)
>      }
>  
>      for (i = 0; i < p->pages->used; i++) {
> -        packet->offset[i] = cpu_to_be64(p->pages->offset[i]);
> +        /* there are architectures where ram_addr_t is 32 bit */
> +        uint64_t temp = p->pages->offset[i];
> +
> +        packet->offset[i] = cpu_to_be64(temp);
>      }
>  }
>  
> @@ -877,10 +880,10 @@ static int multifd_recv_unfill_packet(MultiFDRecvParams *p, Error **errp)
>      }
>  
>      for (i = 0; i < p->pages->used; i++) {
> -        ram_addr_t offset = be64_to_cpu(packet->offset[i]);
> +        uint64_t offset = be64_to_cpu(packet->offset[i]);
>  
>          if (offset > (block->used_length - TARGET_PAGE_SIZE)) {
> -            error_setg(errp, "multifd: offset too long " RAM_ADDR_FMT
> +            error_setg(errp, "multifd: offset too long %" PRId64
>                         " (max " RAM_ADDR_FMT ")",
>                         offset, block->max_length);
>              return -1;
> @@ -1236,7 +1239,7 @@ int multifd_save_setup(void)
>          p->id = i;
>          p->pages = multifd_pages_init(page_count);
>          p->packet_len = sizeof(MultiFDPacket_t)
> -                      + sizeof(ram_addr_t) * page_count;
> +                      + sizeof(uint64_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);
> @@ -1447,7 +1450,7 @@ int multifd_load_setup(void)
>          p->id = i;
>          p->pages = multifd_pages_init(page_count);
>          p->packet_len = sizeof(MultiFDPacket_t)
> -                      + sizeof(ram_addr_t) * page_count;
> +                      + sizeof(uint64_t) * page_count;
>          p->packet = g_malloc0(p->packet_len);
>          p->name = g_strdup_printf("multifdrecv_%d", i);
>      }
> -- 
> 2.24.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-17 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-17 13:56 [PATCH] multifd: Be consistente about using uint64_t Juan Quintela
2020-01-17 14:03 ` Philippe Mathieu-Daudé
2020-01-17 14:56 ` Dr. David Alan Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).