qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/4] switch RAM_ADDR_FMT format specifier to pri


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH 1/4] switch RAM_ADDR_FMT format specifier to print decimal
Date: Wed, 25 Jun 2014 18:38:41 +0300

On Wed, Jun 25, 2014 at 02:14:51PM +0200, Igor Mammedov wrote:
> On Wed, 25 Jun 2014 14:51:15 +0300
> "Michael S. Tsirkin" <address@hidden> wrote:
> 
> > On Wed, Jun 25, 2014 at 01:42:20PM +0200, Igor Mammedov wrote:
> > > ... and add RAM_ADDR_FMTX for hex format. In addition fix
> > > places to print sizes/lengths as decimal and addresses as hex.
> > 
> > ugh.
> > maybe both - though I really think most people will find
> > it easier to parse he hex variant.
> > 
> > > Also drop "%" from RAM_ADDR_FMT macro and use it like other
> > > PRIfoo format placeholders specifying "%" explicitly.
> > > 
> > > Signed-off-by: Igor Mammedov <address@hidden>
> > > ---
> > >  arch_init.c               |   14 +++++++-------
> > >  exec.c                    |    4 ++--
> > >  hw/i386/pc.c              |    4 ++--
> > >  hw/ppc/ppc405_boards.c    |    2 +-
> > >  include/exec/cpu-common.h |    6 ++++--
> > >  numa.c                    |    2 +-
> > >  vl.c                      |    6 +++---
> > >  xen-hvm.c                 |   11 +++++------
> > >  8 files changed, 25 insertions(+), 24 deletions(-)
> > > 
> > > diff --git a/arch_init.c b/arch_init.c
> > > index 8ddaf35..7562325 100644
> > > --- a/arch_init.c
> > > +++ b/arch_init.c
> > > @@ -1072,8 +1072,8 @@ static int ram_load(QEMUFile *f, void *opaque, int 
> > > version_id)
> > >                  QTAILQ_FOREACH(block, &ram_list.blocks, next) {
> > >                      if (!strncmp(id, block->idstr, sizeof(id))) {
> > >                          if (block->length != length) {
> > > -                            error_report("Length mismatch: %s: " 
> > > RAM_ADDR_FMT
> > > -                                         " in != " RAM_ADDR_FMT, id, 
> > > length,
> > > +                            error_report("Length mismatch: %s: %" 
> > > RAM_ADDR_FMT
> > > +                                         " in != %" RAM_ADDR_FMT, id, 
> > > length,
> > >                                           block->length);
> > 
> > Not sure I like this.
> > length values are often powers of two.
> > Parsing them in decimal is hard.
> Problem is that when user specifies on CLI size in decimal and then sees error
> message where it's hex or mix of decimal and/or hex values.
> 
> But I don't care much about it, we can drop this patch

User likely does something like 5G.
Seeing size in decimal bytes is unlikely to be helpful.

> > 
> > >                              ret =  -EINVAL;
> > >                          }
> > > @@ -1098,7 +1098,7 @@ static int ram_load(QEMUFile *f, void *opaque, int 
> > > version_id)
> > >  
> > >              host = host_from_stream_offset(f, addr, flags);
> > >              if (!host) {
> > > -                error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
> > > +                error_report("Illegal RAM offset %" RAM_ADDR_FMTX, addr);
> > >                  ret = -EINVAL;
> > >                  break;
> > >              }
> > > @@ -1110,7 +1110,7 @@ static int ram_load(QEMUFile *f, void *opaque, int 
> > > version_id)
> > >  
> > >              host = host_from_stream_offset(f, addr, flags);
> > >              if (!host) {
> > > -                error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
> > > +                error_report("Illegal RAM offset %" RAM_ADDR_FMTX, addr);
> > >                  ret = -EINVAL;
> > >                  break;
> > >              }
> > > @@ -1119,14 +1119,14 @@ static int ram_load(QEMUFile *f, void *opaque, 
> > > int version_id)
> > >          } else if (flags & RAM_SAVE_FLAG_XBZRLE) {
> > >              void *host = host_from_stream_offset(f, addr, flags);
> > >              if (!host) {
> > > -                error_report("Illegal RAM offset " RAM_ADDR_FMT, addr);
> > > +                error_report("Illegal RAM offset %" RAM_ADDR_FMTX, addr);
> > >                  ret = -EINVAL;
> > >                  break;
> > >              }
> > >  
> > >              if (load_xbzrle(f, addr, host) < 0) {
> > > -                error_report("Failed to decompress XBZRLE page at "
> > > -                             RAM_ADDR_FMT, addr);
> > > +                error_report("Failed to decompress XBZRLE page at %"
> > > +                             RAM_ADDR_FMTX, addr);
> > >                  ret = -EINVAL;
> > >                  break;
> > >              }
> > > diff --git a/exec.c b/exec.c
> > > index c849405..f9ae8a4 100644
> > > --- a/exec.c
> > > +++ b/exec.c
> > > @@ -1435,8 +1435,8 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t 
> > > length)
> > >                                  flags, -1, 0);
> > >                  }
> > >                  if (area != vaddr) {
> > > -                    fprintf(stderr, "Could not remap addr: "
> > > -                            RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",
> > > +                    fprintf(stderr, "Could not remap addr: %"
> > > +                            RAM_ADDR_FMTX "@%" RAM_ADDR_FMTX "\n",
> > >                              length, addr);
> > >                      exit(1);
> > >                  }
> > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> > > index 2cf22b1..a6e7ef3 100644
> > > --- a/hw/i386/pc.c
> > > +++ b/hw/i386/pc.c
> > > @@ -1257,8 +1257,8 @@ FWCfgState *pc_memory_init(MachineState *machine,
> > >  
> > >          if ((pcms->hotplug_memory_base + hotplug_mem_size) <
> > >              hotplug_mem_size) {
> > > -            error_report("unsupported amount of maximum memory: " 
> > > RAM_ADDR_FMT,
> > > -                         machine->maxram_size);
> > > +            error_report("unsupported amount of maximum memory: %"
> > > +                         RAM_ADDR_FMT, machine->maxram_size);
> > >              exit(EXIT_FAILURE);
> > >          }
> > >  
> > > diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
> > > index 98ad2d7..2b1b4fe 100644
> > > --- a/hw/ppc/ppc405_boards.c
> > > +++ b/hw/ppc/ppc405_boards.c
> > > @@ -358,7 +358,7 @@ static void ref405ep_init(MachineState *machine)
> > >          bdloc = 0;
> > >      }
> > >  #ifdef DEBUG_BOARD_INIT
> > > -    printf("bdloc " RAM_ADDR_FMT "\n", bdloc);
> > > +    printf("bdloc %" RAM_ADDR_FMTX "\n", bdloc);
> > >      printf("%s: Done\n", __func__);
> > >  #endif
> > >  }
> > > diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> > > index e3ec4c8..6899d0c 100644
> > > --- a/include/exec/cpu-common.h
> > > +++ b/include/exec/cpu-common.h
> > > @@ -38,11 +38,13 @@ enum device_endian {
> > >  #if defined(CONFIG_XEN_BACKEND)
> > >  typedef uint64_t ram_addr_t;
> > >  #  define RAM_ADDR_MAX UINT64_MAX
> > > -#  define RAM_ADDR_FMT "%" PRIx64
> > > +#  define RAM_ADDR_FMTX PRIx64
> > > +#  define RAM_ADDR_FMT PRIu64
> > >  #else
> > >  typedef uintptr_t ram_addr_t;
> > >  #  define RAM_ADDR_MAX UINTPTR_MAX
> > > -#  define RAM_ADDR_FMT "%" PRIxPTR
> > > +#  define RAM_ADDR_FMTX PRIxPTR
> > > +#  define RAM_ADDR_FMT PRIuPTR
> > >  #endif
> > >  
> > >  extern ram_addr_t ram_size;
> > > diff --git a/numa.c b/numa.c
> > > index e471afe..d9f2655 100644
> > > --- a/numa.c
> > > +++ b/numa.c
> > > @@ -189,7 +189,7 @@ void set_numa_nodes(void)
> > >          }
> > >          if (numa_total != ram_size) {
> > >              error_report("total memory for NUMA nodes (%" PRIu64 ")"
> > > -                         " should equal RAM size (" RAM_ADDR_FMT ")",
> > > +                         " should equal RAM size (%" RAM_ADDR_FMT ")",
> > >                           numa_total, ram_size);
> > >              exit(1);
> > >          }
> > > diff --git a/vl.c b/vl.c
> > > index a1686ef..6b09220 100644
> > > --- a/vl.c
> > > +++ b/vl.c
> > > @@ -3319,7 +3319,7 @@ int main(int argc, char **argv, char **envp)
> > >                      sz = qemu_opt_get_size(opts, "maxmem", 0);
> > >                      if (sz < ram_size) {
> > >                          fprintf(stderr, "qemu: invalid -m option value: 
> > > maxmem "
> > > -                                "(%" PRIu64 ") <= initial memory ("
> > > +                                "(%" PRIu64 ") <= initial memory (%"
> > >                                  RAM_ADDR_FMT ")\n", sz, ram_size);
> > >                          exit(EXIT_FAILURE);
> > >                      }
> > > @@ -3327,7 +3327,7 @@ int main(int argc, char **argv, char **envp)
> > >                      slots = qemu_opt_get_number(opts, "slots", 0);
> > >                      if ((sz > ram_size) && !slots) {
> > >                          fprintf(stderr, "qemu: invalid -m option value: 
> > > maxmem "
> > > -                                "(%" PRIu64 ") more than initial memory 
> > > ("
> > > +                                "(%" PRIu64 ") more than initial memory 
> > > (%"
> > >                                  RAM_ADDR_FMT ") but no hotplug slots 
> > > where "
> > >                                  "specified\n", sz, ram_size);
> > >                          exit(EXIT_FAILURE);
> > > @@ -3336,7 +3336,7 @@ int main(int argc, char **argv, char **envp)
> > >                      if ((sz <= ram_size) && slots) {
> > >                          fprintf(stderr, "qemu: invalid -m option value:  
> > > %"
> > >                                  PRIu64 " hotplug slots where specified 
> > > but "
> > > -                                "maxmem (%" PRIu64 ") <= initial memory 
> > > ("
> > > +                                "maxmem (%" PRIu64 ") <= initial memory 
> > > (%"
> > >                                  RAM_ADDR_FMT ")\n", slots, sz, ram_size);
> > >                          exit(EXIT_FAILURE);
> > >                      }
> > > diff --git a/xen-hvm.c b/xen-hvm.c
> > > index bafdf12..e7b4b76 100644
> > > --- a/xen-hvm.c
> > > +++ b/xen-hvm.c
> > > @@ -221,8 +221,8 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t 
> > > size, MemoryRegion *mr)
> > >  
> > >      if (runstate_check(RUN_STATE_INMIGRATE)) {
> > >          /* RAM already populated in Xen */
> > > -        fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT
> > > -                " bytes of ram at "RAM_ADDR_FMT" when runstate is 
> > > INMIGRATE\n",
> > > +        fprintf(stderr, "%s: do not alloc %"RAM_ADDR_FMT" bytes"
> > > +                " of ram at %"RAM_ADDR_FMTX" when runstate is 
> > > INMIGRATE\n",
> > >                  __func__, size, ram_addr); 
> > >          return;
> > >      }
> > > @@ -241,7 +241,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t 
> > > size, MemoryRegion *mr)
> > >      }
> > >  
> > >      if (xc_domain_populate_physmap_exact(xen_xc, xen_domid, nr_pfn, 0, 
> > > 0, pfn_list)) {
> > > -        hw_error("xen: failed to populate ram at " RAM_ADDR_FMT, 
> > > ram_addr);
> > > +        hw_error("xen: failed to populate ram at %" RAM_ADDR_FMTX, 
> > > ram_addr);
> > >      }
> > >  
> > >      g_free(pfn_list);
> > > @@ -1127,9 +1127,8 @@ void xen_modified_memory(ram_addr_t start, 
> > > ram_addr_t length)
> > >              - start_pfn;
> > >          rc = xc_hvm_modified_memory(xen_xc, xen_domid, start_pfn, 
> > > nb_pages);
> > >          if (rc) {
> > > -            fprintf(stderr,
> > > -                    "%s failed for "RAM_ADDR_FMT" ("RAM_ADDR_FMT"): %i, 
> > > %s\n",
> > > -                    __func__, start, nb_pages, rc, strerror(-rc));
> > > +            fprintf(stderr, "%s failed for %"RAM_ADDR_FMTX" 
> > > (%"RAM_ADDR_FMT"):"
> > > +                    " %i, %s\n", __func__, start, nb_pages, rc, 
> > > strerror(-rc));
> > >          }
> > >      }
> > >  }
> > > -- 
> > > 1.7.1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]