From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:a05:6000:188:0:0:0:0 with SMTP id p8csp8526309wrx; Fri, 8 Mar 2019 07:50:58 -0800 (PST) X-Google-Smtp-Source: APXvYqxco4weleSaERIhOAVq6Lj3r5t0Y4ay0Havp+rD/rQ93Xx4OklF1zjYymyL5FffFVz+GiTs X-Received: by 2002:a81:5d82:: with SMTP id r124mr15689135ywb.109.1552060258576; Fri, 08 Mar 2019 07:50:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552060258; cv=none; d=google.com; s=arc-20160816; b=RqJz+XdLLDHZ1Setk0xoJVUv9MDjpyYmzxtsYyMmpyysJMnrf9cCadbeCFvJJ5//3l Bj4o138MT/aaaJpZ1giav9Jd7tqlcsncmnpGMp7ZQk29hUkiQ4zvNx0UfVu6oXEA5CQT gDkPFj0GdR6oVaEkiej7PNJCWyPY/tBEUHJL8PGzbRLfX/SHoAyAz/O6qXTwJZTyfD4b ETST8TQFFrgzpkUGimN9bqVQonVWMzrRXao/nsrx1dIV/Isy04DNT0ZxwyiHMN99xhSB eoZyfxFLxwTwE7YPUp2uZDeAx00mQG6EcqZiN/HD89oYYeEwNakkiDg0TkJb2kZ+duph sZSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:to:from:date; bh=HzUuIFeRwq07mbyUNodaOfSEiaiOkGx17Z7gwBfkSxo=; b=RUGwxZRCKM2i8iARV67X76Vx+qipcqwBcXRUTadc6EF3uuRMVIEuvI6XZfnPzSmLY3 ZX0TvtCkW2aNqfLdXGfGikerpawFawgsiyZ8SqQlsPIPd2p4koDwSCdjLXd9a4yZOngM 9rYZ5w6IxTxw0RJts07APxZl7lIzekHsI5Z/xb5fjqQmRXbM3yeYwcyx6aeTFAik2pIi dC+Lft/8E23zaLK3xt7DnX7xAvIXiOjXdgF/VsWdfBJ/OzWSR6VV/AS6acpxUt27B32e wm/wFY1pAHHyrRD5URXPajcc4xGj1Kuzz4i1Vw4N/lEgNCB32eRvr4DU8OWM5JE5yqFm iyWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c7si4886857yba.176.2019.03.08.07.50.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 08 Mar 2019 07:50:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([127.0.0.1]:45928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2Hlx-0006Cx-SI for alex.bennee@linaro.org; Fri, 08 Mar 2019 10:50:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2HlL-0005tY-L6 for qemu-arm@nongnu.org; Fri, 08 Mar 2019 10:50:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2HlE-000155-UO for qemu-arm@nongnu.org; Fri, 08 Mar 2019 10:50:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56694) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h2HlB-0000ct-AH; Fri, 08 Mar 2019 10:50:11 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20F55C07EFD8; Fri, 8 Mar 2019 15:49:55 +0000 (UTC) Received: from work-vm (ovpn-117-233.ams2.redhat.com [10.36.117.233]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F419F2A2EE; Fri, 8 Mar 2019 15:49:30 +0000 (UTC) Date: Fri, 8 Mar 2019 15:49:28 +0000 From: "Dr. David Alan Gilbert" To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Message-ID: <20190308154927.GA2834@work-vm> References: <20190308013222.12524-1-philmd@redhat.com> <20190308013222.12524-15-philmd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20190308013222.12524-15-philmd@redhat.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 08 Mar 2019 15:49:55 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-arm] [PATCH v2 14/18] hw/nvram/fw_cfg: Add HMP 'info fw_cfg' command X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , "Daniel P . Berrange" , Eduardo Habkost , "Michael S. Tsirkin" , Eric Blake , Mark Cave-Ayland , qemu-devel@nongnu.org, Markus Armbruster , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Gerd Hoffmann , Marcel Apfelbaum , Igor Mammedov , Paolo Bonzini , David Gibson , Laszlo Ersek , Artyom Tarasenko , Richard Henderson Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: sPg97C1EpEus * Philippe Mathieu-Daud=E9 (philmd@redhat.com) wrote: > When debugging a paravirtualized guest firmware, it results very > useful to dump the fw_cfg table. > Add a HMP command which displays the most useful fields. > We display each fw_cfg item data in hexadecimal (only the first 8 > bytes): >=20 > $ (echo info fw_cfg; echo q) | qemu-system-x86_64 -S -monitor stdio > (qemu) info fw_cfg > Selector Well-Known Key Pathname ArchSpec Perm Size Order Hex Data > 0x0000 signature RO 4 51454d55 > 0x0001 id RO 4 03000000 > 0x0002 uuid RO 16 000000000= 0000000.. > 0x0003 ram_size RO 8 000000080= 0000000 > 0x0004 nographic RO 2 0000 > 0x0005 nb_cpus RO 2 0100 > 0x000d numa RO 16 000000000= 0000000.. > 0x000e boot_menu RO 2 0000 > 0x000f max_cpus RO 2 0100 > 0x0019 file_dir RO 2052 0000000b0= 0000000.. > 0x0021 file: etc/acpi/rsdp RO 20 160 525344205= 0545220.. > 0x0022 file: etc/acpi/tables RO 131072 130 464143534= 0000000.. > 0x0023 file: etc/boot-fail-wait RO 4 15 ffffffff > 0x0024 file: etc/e820 RO 20 40 000000000= 0000000.. > 0x0025 file: etc/smbios/smbios-anchor RO 31 30 5f534d5f0= 01f0208.. > 0x0026 file: etc/smbios/smbios-tables RO 321 20 011b00010= 1020300.. > 0x0027 file: etc/system-states RO 6 90 800000818= 280 > 0x0028 file: etc/table-loader RO 4096 140 010000006= 574632f.. > 0x002a file: genroms/kvmvapic.bin RO 9216 55 55aa12060= e0731c0.. > 0x0002 irq0_override * RO 4 01000000 > 0x0003 e820_tables * RO 324 000000000= 0000000.. > 0x0004 hpet * RO 121 0101a2868= 00000d0.. > (qemu) q >=20 > $ (echo info fw_cfg; echo q) | qemu-system-mips -S -monitor stdio > (qemu) info fw_cfg > This machine does not use fw_cfg > (qemu) q >=20 > $ (echo info fw_cfg; echo q) | qemu-system-ppc -S -monitor stdio > (qemu) info fw_cfg > Selector Well-Known Key Pathname ArchSpec Perm Size Order Hex Data > 0x0000 signature RO 4 51454d55 > 0x0001 id RO 4 01000000 > 0x0002 uuid RO 16 000000000= 0000000.. > 0x0003 ram_size RO 8 000000080= 0000000 > 0x0004 nographic RO 2 0000 > 0x0005 nb_cpus RO 2 0100 > 0x0006 machine_id RO 2 0200 > 0x0007 kernel_addr RO 4 00000000 > 0x0008 kernel_size RO 4 00000000 > 0x0009 kernel_cmdline RO 4 00000000 > 0x000a initrd_addr RO 4 00000000 > 0x000b initdr_size RO 4 00000000 > 0x000c boot_device RO 2 6300 > 0x000e boot_menu RO 2 0000 > 0x000f max_cpus RO 2 0100 > 0x0019 file_dir RO 2052 000000020= 0000000.. > 0x0021 file: etc/boot-fail-wait RO 4 15 ffffffff > 0x0000 width * RO 2 2003 > 0x0001 height * RO 2 5802 > 0x0002 depth * RO 2 2000 > 0x0003 tbfreq * RO 4 c04bfd00 > 0x0004 clockfreq * RO 4 80d6da0f > 0x0005 is_kvm * RO 4 00000000 > 0x0009 busfreq * RO 4 8014ef03 > (qemu) q >=20 > Signed-off-by: Philippe Mathieu-Daud=E9 I think this is fine from an HMP view; one thought of something that might be useful is an optional parameter to specify a particular key that dumps the whole object; then if you're particularly desperate to look at an acpi table you could do something like: info fw_cfg "file: etc/acpi/tables" and get a fun block of hex back. But that's just a suggestion, so: Reviewed-by: Dr. David Alan Gilbert > --- > v2: Check fw_cfg !=3D NULL (Michael) > Rename keys, display data in hexa (Laszlo) > --- > hmp-commands-info.hx | 17 ++++++++++ > hw/nvram/fw_cfg.c | 71 ++++++++++++++++++++++++++++++++++++++- > include/hw/nvram/fw_cfg.h | 2 ++ > 3 files changed, 89 insertions(+), 1 deletion(-) >=20 > diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx > index cbee8b944d..2c9538c8da 100644 > --- a/hmp-commands-info.hx > +++ b/hmp-commands-info.hx > @@ -916,6 +916,23 @@ STEXI > @item info sev > @findex info sev > Show SEV information. > +ETEXI > + > + { > + .name =3D "fw_cfg", > + .args_type =3D "", > + .params =3D "", > + .help =3D "Display the table firmware configuration entr= ies " > + "registered by a paravirtualized machine. Helpfu= l " > + "when debugging guest firmwares.", > + .cmd =3D hmp_info_fw_cfg, > + }, > + > +STEXI > +@item info fw_cfg > +@findex info fw_cfg > +Display the table firmware configuration entries registered by a parav= irtualized > +machine. This information is useful when debugging guest firmwares. > ETEXI > =20 > STEXI > diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c > index 2a8d69ba07..4c82dcc125 100644 > --- a/hw/nvram/fw_cfg.c > +++ b/hw/nvram/fw_cfg.c > @@ -35,6 +35,7 @@ > #include "qemu/config-file.h" > #include "qemu/cutils.h" > #include "qapi/error.h" > +#include "monitor/monitor.h" > #include "qapi/qapi-commands-misc.h" > =20 > #define FW_CFG_FILE_SLOTS_DFLT 0x20 > @@ -1273,7 +1274,18 @@ static FirmwareConfigurationItem *create_qmp_fw_= cfg_item(FWCfgState *s, > return item; > } > =20 > -FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) > +/** > + * query_fw_cfg_items: > + * > + * @use_hexdump: Whether to populate the @data field with the hexadeci= mal > + * representation of the item data. > + * @errp: Pointer to a NULL initialized error object. > + * > + * Returns: A list of @FirmwareConfigurationItem, reverse sorted by th= e > + * item selector key. > + */ > +static FirmwareConfigurationItemList *query_fw_cfg_items(bool use_hexd= ump, > + Error **errp) > { > FirmwareConfigurationItemList *item_list =3D NULL; > uint32_t max_entries; > @@ -1294,6 +1306,9 @@ FirmwareConfigurationItemList *qmp_query_fw_cfg_i= tems(Error **errp) > if (!e->len) { > continue; > } > + if (use_hexdump) { > + qmp_hex_length =3D MIN(e->len, 8); > + } > =20 > info =3D g_malloc0(sizeof(*info)); > info->value =3D create_qmp_fw_cfg_item(s, e, arch, key, > @@ -1305,3 +1320,57 @@ FirmwareConfigurationItemList *qmp_query_fw_cfg_= items(Error **errp) > =20 > return item_list; > } > + > +FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) > +{ > + return query_fw_cfg_items(false, errp); > +} > + > +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict) > +{ > + FirmwareConfigurationItemList *item_list, *method; > + Error *err =3D NULL; > + > + item_list =3D query_fw_cfg_items(true, &err); > + if (!item_list) { > + monitor_printf(mon, "This machine does not use fw_cfg\n"); > + return; > + } > + if (err) { > + monitor_printf(mon, "Could not query fw_cfg entries: %s\n", > + error_get_pretty(err)); > + error_free(err); > + return; > + } > + > + monitor_printf(mon, "Selector Well-Known Key Pathname" > + " ArchSpec Perm Size Order Hex Data\n"); > + for (method =3D item_list; method; method =3D method->next) { > + if (method->value->has_path) { > + monitor_printf(mon, > + " 0x%04x file: %-28s %2s %7" PRId64 > + " %3" PRId64 " %-16s%s\n", > + method->value->key, > + method->value->path, > + method->value->writeable ? "RW" : "RO", > + method->value->size, > + method->value->order, > + method->value->data, > + method->value->size > 8 ? ".." : ""); > + } else { > + monitor_printf(mon, > + " 0x%04x %-30s %c %2s %7" PRId64 > + " %-16s%s\n", > + method->value->key, > + method->value->has_keyname > + ? method->value->keyname : "", > + method->value->architecture_specific ? '*' = : ' ', > + method->value->writeable ? "RW" : "RO", > + method->value->size, > + method->value->data, > + method->value->size > 8 ? ".." : ""); > + } > + } > + > + qapi_free_FirmwareConfigurationItemList(item_list); > +} > diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h > index 83a0540b6c..5ac9adfe1f 100644 > --- a/include/hw/nvram/fw_cfg.h > +++ b/include/hw/nvram/fw_cfg.h > @@ -243,4 +243,6 @@ bool fw_cfg_dma_enabled(void *opaque); > */ > const char *fw_cfg_arch_key_name(uint16_t key); > =20 > +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict); > + > #endif > --=20 > 2.20.1 >=20 -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:45243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h2HlT-0005xm-7Z for qemu-devel@nongnu.org; Fri, 08 Mar 2019 10:50:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h2HlP-0001KE-2Z for qemu-devel@nongnu.org; Fri, 08 Mar 2019 10:50:25 -0500 Date: Fri, 8 Mar 2019 15:49:28 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20190308154927.GA2834@work-vm> References: <20190308013222.12524-1-philmd@redhat.com> <20190308013222.12524-15-philmd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20190308013222.12524-15-philmd@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 14/18] hw/nvram/fw_cfg: Add HMP 'info fw_cfg' command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= Cc: Laszlo Ersek , Gerd Hoffmann , "Michael S. Tsirkin" , qemu-devel@nongnu.org, Marcel Apfelbaum , Eduardo Habkost , Paolo Bonzini , Richard Henderson , Artyom Tarasenko , Peter Maydell , David Gibson , Igor Mammedov , Eric Blake , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, Markus Armbruster , Mark Cave-Ayland , Thomas Huth , "Daniel P . Berrange" * Philippe Mathieu-Daud=E9 (philmd@redhat.com) wrote: > When debugging a paravirtualized guest firmware, it results very > useful to dump the fw_cfg table. > Add a HMP command which displays the most useful fields. > We display each fw_cfg item data in hexadecimal (only the first 8 > bytes): >=20 > $ (echo info fw_cfg; echo q) | qemu-system-x86_64 -S -monitor stdio > (qemu) info fw_cfg > Selector Well-Known Key Pathname ArchSpec Perm Size Order Hex Data > 0x0000 signature RO 4 51454d55 > 0x0001 id RO 4 03000000 > 0x0002 uuid RO 16 000000000= 0000000.. > 0x0003 ram_size RO 8 000000080= 0000000 > 0x0004 nographic RO 2 0000 > 0x0005 nb_cpus RO 2 0100 > 0x000d numa RO 16 000000000= 0000000.. > 0x000e boot_menu RO 2 0000 > 0x000f max_cpus RO 2 0100 > 0x0019 file_dir RO 2052 0000000b0= 0000000.. > 0x0021 file: etc/acpi/rsdp RO 20 160 525344205= 0545220.. > 0x0022 file: etc/acpi/tables RO 131072 130 464143534= 0000000.. > 0x0023 file: etc/boot-fail-wait RO 4 15 ffffffff > 0x0024 file: etc/e820 RO 20 40 000000000= 0000000.. > 0x0025 file: etc/smbios/smbios-anchor RO 31 30 5f534d5f0= 01f0208.. > 0x0026 file: etc/smbios/smbios-tables RO 321 20 011b00010= 1020300.. > 0x0027 file: etc/system-states RO 6 90 800000818= 280 > 0x0028 file: etc/table-loader RO 4096 140 010000006= 574632f.. > 0x002a file: genroms/kvmvapic.bin RO 9216 55 55aa12060= e0731c0.. > 0x0002 irq0_override * RO 4 01000000 > 0x0003 e820_tables * RO 324 000000000= 0000000.. > 0x0004 hpet * RO 121 0101a2868= 00000d0.. > (qemu) q >=20 > $ (echo info fw_cfg; echo q) | qemu-system-mips -S -monitor stdio > (qemu) info fw_cfg > This machine does not use fw_cfg > (qemu) q >=20 > $ (echo info fw_cfg; echo q) | qemu-system-ppc -S -monitor stdio > (qemu) info fw_cfg > Selector Well-Known Key Pathname ArchSpec Perm Size Order Hex Data > 0x0000 signature RO 4 51454d55 > 0x0001 id RO 4 01000000 > 0x0002 uuid RO 16 000000000= 0000000.. > 0x0003 ram_size RO 8 000000080= 0000000 > 0x0004 nographic RO 2 0000 > 0x0005 nb_cpus RO 2 0100 > 0x0006 machine_id RO 2 0200 > 0x0007 kernel_addr RO 4 00000000 > 0x0008 kernel_size RO 4 00000000 > 0x0009 kernel_cmdline RO 4 00000000 > 0x000a initrd_addr RO 4 00000000 > 0x000b initdr_size RO 4 00000000 > 0x000c boot_device RO 2 6300 > 0x000e boot_menu RO 2 0000 > 0x000f max_cpus RO 2 0100 > 0x0019 file_dir RO 2052 000000020= 0000000.. > 0x0021 file: etc/boot-fail-wait RO 4 15 ffffffff > 0x0000 width * RO 2 2003 > 0x0001 height * RO 2 5802 > 0x0002 depth * RO 2 2000 > 0x0003 tbfreq * RO 4 c04bfd00 > 0x0004 clockfreq * RO 4 80d6da0f > 0x0005 is_kvm * RO 4 00000000 > 0x0009 busfreq * RO 4 8014ef03 > (qemu) q >=20 > Signed-off-by: Philippe Mathieu-Daud=E9 I think this is fine from an HMP view; one thought of something that might be useful is an optional parameter to specify a particular key that dumps the whole object; then if you're particularly desperate to look at an acpi table you could do something like: info fw_cfg "file: etc/acpi/tables" and get a fun block of hex back. But that's just a suggestion, so: Reviewed-by: Dr. David Alan Gilbert > --- > v2: Check fw_cfg !=3D NULL (Michael) > Rename keys, display data in hexa (Laszlo) > --- > hmp-commands-info.hx | 17 ++++++++++ > hw/nvram/fw_cfg.c | 71 ++++++++++++++++++++++++++++++++++++++- > include/hw/nvram/fw_cfg.h | 2 ++ > 3 files changed, 89 insertions(+), 1 deletion(-) >=20 > diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx > index cbee8b944d..2c9538c8da 100644 > --- a/hmp-commands-info.hx > +++ b/hmp-commands-info.hx > @@ -916,6 +916,23 @@ STEXI > @item info sev > @findex info sev > Show SEV information. > +ETEXI > + > + { > + .name =3D "fw_cfg", > + .args_type =3D "", > + .params =3D "", > + .help =3D "Display the table firmware configuration entr= ies " > + "registered by a paravirtualized machine. Helpfu= l " > + "when debugging guest firmwares.", > + .cmd =3D hmp_info_fw_cfg, > + }, > + > +STEXI > +@item info fw_cfg > +@findex info fw_cfg > +Display the table firmware configuration entries registered by a parav= irtualized > +machine. This information is useful when debugging guest firmwares. > ETEXI > =20 > STEXI > diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c > index 2a8d69ba07..4c82dcc125 100644 > --- a/hw/nvram/fw_cfg.c > +++ b/hw/nvram/fw_cfg.c > @@ -35,6 +35,7 @@ > #include "qemu/config-file.h" > #include "qemu/cutils.h" > #include "qapi/error.h" > +#include "monitor/monitor.h" > #include "qapi/qapi-commands-misc.h" > =20 > #define FW_CFG_FILE_SLOTS_DFLT 0x20 > @@ -1273,7 +1274,18 @@ static FirmwareConfigurationItem *create_qmp_fw_= cfg_item(FWCfgState *s, > return item; > } > =20 > -FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) > +/** > + * query_fw_cfg_items: > + * > + * @use_hexdump: Whether to populate the @data field with the hexadeci= mal > + * representation of the item data. > + * @errp: Pointer to a NULL initialized error object. > + * > + * Returns: A list of @FirmwareConfigurationItem, reverse sorted by th= e > + * item selector key. > + */ > +static FirmwareConfigurationItemList *query_fw_cfg_items(bool use_hexd= ump, > + Error **errp) > { > FirmwareConfigurationItemList *item_list =3D NULL; > uint32_t max_entries; > @@ -1294,6 +1306,9 @@ FirmwareConfigurationItemList *qmp_query_fw_cfg_i= tems(Error **errp) > if (!e->len) { > continue; > } > + if (use_hexdump) { > + qmp_hex_length =3D MIN(e->len, 8); > + } > =20 > info =3D g_malloc0(sizeof(*info)); > info->value =3D create_qmp_fw_cfg_item(s, e, arch, key, > @@ -1305,3 +1320,57 @@ FirmwareConfigurationItemList *qmp_query_fw_cfg_= items(Error **errp) > =20 > return item_list; > } > + > +FirmwareConfigurationItemList *qmp_query_fw_cfg_items(Error **errp) > +{ > + return query_fw_cfg_items(false, errp); > +} > + > +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict) > +{ > + FirmwareConfigurationItemList *item_list, *method; > + Error *err =3D NULL; > + > + item_list =3D query_fw_cfg_items(true, &err); > + if (!item_list) { > + monitor_printf(mon, "This machine does not use fw_cfg\n"); > + return; > + } > + if (err) { > + monitor_printf(mon, "Could not query fw_cfg entries: %s\n", > + error_get_pretty(err)); > + error_free(err); > + return; > + } > + > + monitor_printf(mon, "Selector Well-Known Key Pathname" > + " ArchSpec Perm Size Order Hex Data\n"); > + for (method =3D item_list; method; method =3D method->next) { > + if (method->value->has_path) { > + monitor_printf(mon, > + " 0x%04x file: %-28s %2s %7" PRId64 > + " %3" PRId64 " %-16s%s\n", > + method->value->key, > + method->value->path, > + method->value->writeable ? "RW" : "RO", > + method->value->size, > + method->value->order, > + method->value->data, > + method->value->size > 8 ? ".." : ""); > + } else { > + monitor_printf(mon, > + " 0x%04x %-30s %c %2s %7" PRId64 > + " %-16s%s\n", > + method->value->key, > + method->value->has_keyname > + ? method->value->keyname : "", > + method->value->architecture_specific ? '*' = : ' ', > + method->value->writeable ? "RW" : "RO", > + method->value->size, > + method->value->data, > + method->value->size > 8 ? ".." : ""); > + } > + } > + > + qapi_free_FirmwareConfigurationItemList(item_list); > +} > diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h > index 83a0540b6c..5ac9adfe1f 100644 > --- a/include/hw/nvram/fw_cfg.h > +++ b/include/hw/nvram/fw_cfg.h > @@ -243,4 +243,6 @@ bool fw_cfg_dma_enabled(void *opaque); > */ > const char *fw_cfg_arch_key_name(uint16_t key); > =20 > +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict); > + > #endif > --=20 > 2.20.1 >=20 -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK