From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wta3O-0002i1-0r for qemu-devel@nongnu.org; Sun, 08 Jun 2014 06:10:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wta3J-0007NS-Bs for qemu-devel@nongnu.org; Sun, 08 Jun 2014 06:10:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wta3J-0007NO-3j for qemu-devel@nongnu.org; Sun, 08 Jun 2014 06:10:13 -0400 Date: Sun, 8 Jun 2014 13:10:37 +0300 From: "Michael S. Tsirkin" Message-ID: <20140608101037.GE21677@redhat.com> References: <5f64b90d8707869fa622c0c1b26106ae96895d82.1400049817.git.hutao@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5f64b90d8707869fa622c0c1b26106ae96895d82.1400049817.git.hutao@cn.fujitsu.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3.2 31/31] hmp: add info memdev List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Hu Tao Cc: Paolo Bonzini , qemu-devel@nongnu.org, Igor Mammedov On Wed, May 14, 2014 at 05:43:35PM +0800, Hu Tao wrote: > This is the hmp counterpart of qmp query-memdev. >=20 > Signed-off-by: Hu Tao > --- > hmp.c | 36 ++++++++++++++++++++++++++++++++++++ > hmp.h | 1 + > monitor.c | 7 +++++++ > 3 files changed, 44 insertions(+) >=20 > diff --git a/hmp.c b/hmp.c > index 5c4d612..1d5bf2d 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -22,6 +22,8 @@ > #include "qemu/sockets.h" > #include "monitor/monitor.h" > #include "qapi/opts-visitor.h" > +#include "qapi/string-output-visitor.h" > +#include "qapi-visit.h" > #include "ui/console.h" > #include "block/qapi.h" > #include "qemu-io.h" > @@ -1671,3 +1673,37 @@ void hmp_object_del(Monitor *mon, const QDict *q= dict) > qmp_object_del(id, &err); > hmp_handle_error(mon, &err); > } > + > +void hmp_info_memdev(Monitor *mon, const QDict *qdict) > +{ > + Error *err =3D NULL; > + MemdevList *memdev_list =3D qmp_query_memdev(&err); > + MemdevList *m =3D memdev_list; > + StringOutputVisitor *ov; > + int i =3D 0; > + > + > + while (m) { > + ov =3D string_output_visitor_new(false); > + visit_type_uint16List(string_output_get_visitor(ov), > + &m->value->host_nodes, NULL, NULL); > + monitor_printf(mon, "memory device %d\n", i); > + monitor_printf(mon, " size: %ld\n", m->value->size); Fails build on 32 bit: hmp.c:1696:9: error: format =E2=80=98%ld=E2=80=99 expects argument of typ= e =E2=80=98long int=E2=80=99, but argument 3 has type =E2=80=98uint64_t=E2=80=99 [-Werror=3Dformat=3D] monitor_printf(mon, " size: %ld\n", m->value->size); this must use PRId64. > + monitor_printf(mon, " merge: %s\n", > + m->value->merge ? "true" : "false"); > + monitor_printf(mon, " dump: %s\n", > + m->value->dump ? "true" : "false"); > + monitor_printf(mon, " prealloc: %s\n", > + m->value->prealloc ? "true" : "false"); > + monitor_printf(mon, " policy: %s\n", > + HostMemPolicy_lookup[m->value->policy]); > + monitor_printf(mon, " host nodes: %s\n", > + string_output_get_string(ov)); > + > + string_output_visitor_cleanup(ov); > + m =3D m->next; > + i++; > + } > + > + monitor_printf(mon, "\n"); > +} > diff --git a/hmp.h b/hmp.h > index 20ef454..bc13aae 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -97,5 +97,6 @@ void object_add_completion(ReadLineState *rs, int nb_= args, const char *str); > void object_del_completion(ReadLineState *rs, int nb_args, const char = *str); > void device_add_completion(ReadLineState *rs, int nb_args, const char = *str); > void device_del_completion(ReadLineState *rs, int nb_args, const char = *str); > +void hmp_info_memdev(Monitor *mon, const QDict *qdict); > =20 > #endif > diff --git a/monitor.c b/monitor.c > index 4a3d3dd..4c24696 100644 > --- a/monitor.c > +++ b/monitor.c > @@ -2958,6 +2958,13 @@ static mon_cmd_t info_cmds[] =3D { > .mhandler.cmd =3D hmp_info_tpm, > }, > { > + .name =3D "memdev", > + .args_type =3D "", > + .params =3D "", > + .help =3D "show the memory device", > + .mhandler.cmd =3D hmp_info_memdev, > + }, > + { > .name =3D NULL, > }, > }; > --=20 > 1.8.5.2.229.g4448466 >=20