qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: marcel.a@redhat.com, stefano.stabellini@eu.citrix.com,
	qemu-devel@nongnu.org, agraf@suse.de, pbonzini@redhat.com,
	afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 1/4] switch RAM_ADDR_FMT format specifier to print decimal
Date: Wed, 25 Jun 2014 14:14:51 +0200	[thread overview]
Message-ID: <20140625141451.3cbbe36e@nial.usersys.redhat.com> (raw)
In-Reply-To: <20140625115115.GA13690@redhat.com>

On Wed, 25 Jun 2014 14:51:15 +0300
"Michael S. Tsirkin" <mst@redhat.com> 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 <imammedo@redhat.com>
> > ---
> >  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

> 
> >                              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	other threads:[~2014-06-25 12:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-25 11:42 [Qemu-devel] [PATCH 0/4] tests for -m option Igor Mammedov
2014-06-25 11:42 ` [Qemu-devel] [PATCH 1/4] switch RAM_ADDR_FMT format specifier to print decimal Igor Mammedov
2014-06-25 11:51   ` Michael S. Tsirkin
2014-06-25 12:14     ` Igor Mammedov [this message]
2014-06-25 15:38       ` Michael S. Tsirkin
2014-06-25 17:47   ` Peter Maydell
2014-06-25 11:42 ` [Qemu-devel] [PATCH 2/4] vl.c: use single local_err throughout main() Igor Mammedov
2014-06-25 11:51   ` Michael S. Tsirkin
2014-06-25 12:16     ` Igor Mammedov
2014-06-25 15:42       ` Michael S. Tsirkin
2014-06-25 11:42 ` [Qemu-devel] [PATCH 3/4] machine: convert ram_size, maxram_size, ram_slots to properties Igor Mammedov
2014-06-25 11:54   ` Michael S. Tsirkin
2014-06-25 13:08     ` Igor Mammedov
2014-06-25 15:37       ` Michael S. Tsirkin
2014-06-25 14:09   ` Kirill Batuzov
2014-06-25 14:45     ` Igor Mammedov
2014-06-25 11:42 ` [Qemu-devel] [PATCH 4/4] test -m option parameters Igor Mammedov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140625141451.3cbbe36e@nial.usersys.redhat.com \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=marcel.a@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefano.stabellini@eu.citrix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).