From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Michael S . Tsirkin" <mst@redhat.com>,
Laszlo Ersek <lersek@redhat.com>,
qemu-devel@nongnu.org, Igor Mammedov <imammedo@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 5/6] hw/nvram/fw_cfg: Add HMP 'info fw_cfg' command
Date: Mon, 10 Dec 2018 11:42:54 +0000 [thread overview]
Message-ID: <20181210114254.GB2372@work-vm> (raw)
In-Reply-To: <20181207170400.5129-6-philmd@redhat.com>
* Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> $ qemu-system-x86_64 -S -monitor stdio
> (qemu) info fw_cfg
> Type Perm Size Specific Order Info
> signature RO 4 QEMU
> id RO 4 0x00000003
> uuid RO 16 00000000-0000-0000-0000-000000000000
> ram_size RO 8 0x0000000008000000
> nographic RO 2 0x0000
> nb_cpus RO 2 0x0001
> numa RO 16
> boot_menu RO 2 0x0000
> max_cpus RO 2 0x0001
> file_dir RO 2052
> file (id 1) RO 36 160 etc/acpi/rsdp
> file (id 2) RO 131072 130 etc/acpi/tables
> file (id 3) RO 4 15 etc/boot-fail-wait
> file (id 4) RO 20 40 etc/e820
> file (id 5) RO 31 30 etc/smbios/smbios-anchor
> file (id 6) RO 320 20 etc/smbios/smbios-tables
> file (id 7) RO 6 90 etc/system-states
> file (id 8) RO 4096 140 etc/table-loader
> file (id 10) RO 9216 55 genroms/kvmvapic.bin
> uuid RO 4 (arch spec) 01000000-0000-0000-0000-000000000000
> ram_size RO 324 (arch spec)
> nographic RO 121 (arch spec)
> (qemu)
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hmp-commands-info.hx | 14 +++++
> hw/nvram/fw_cfg.c | 115 ++++++++++++++++++++++++++++++++++++++
> include/hw/nvram/fw_cfg.h | 2 +
> 3 files changed, 131 insertions(+)
>
> diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx
> index cbee8b944d..9e86dceeb4 100644
> --- a/hmp-commands-info.hx
> +++ b/hmp-commands-info.hx
> @@ -916,6 +916,20 @@ STEXI
> @item info sev
> @findex info sev
> Show SEV information.
> +ETEXI
> +
> + {
> + .name = "fw_cfg",
> + .args_type = "",
> + .params = "",
> + .help = "Display the table of the fw_cfg entries registered",
> + .cmd = hmp_info_fw_cfg,
> + },
> +
> +STEXI
> +@item info fw_cfg
> +@findex info fw_cfg
> +Show roms.
> ETEXI
>
> STEXI
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 582653f07e..50525ec1dd 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -36,6 +36,7 @@
> #include "qemu/config-file.h"
> #include "qemu/cutils.h"
> #include "qapi/error.h"
> +#include "monitor/monitor.h"
>
> #define FW_CFG_FILE_SLOTS_DFLT 0x20
>
> @@ -1164,3 +1165,117 @@ static void fw_cfg_register_types(void)
> }
>
> type_init(fw_cfg_register_types)
> +
> +static const char *fw_cfg_wellknown_entries[0x20] = {
That magic 0x20 is a shame; we should probably have a #define
for that max, or perhaps it can just be removed.
> + [FW_CFG_SIGNATURE] = "signature",
> + [FW_CFG_ID] = "id",
> + [FW_CFG_UUID] = "uuid",
> + [FW_CFG_RAM_SIZE] = "ram_size",
> + [FW_CFG_NOGRAPHIC] = "nographic",
> + [FW_CFG_NB_CPUS] = "nb_cpus",
> + [FW_CFG_MACHINE_ID] = "machine_id",
> + [FW_CFG_KERNEL_ADDR] = "kernel_addr",
> + [FW_CFG_KERNEL_SIZE] = "kernel_size",
> + [FW_CFG_KERNEL_CMDLINE] = "kernel_cmdline",
> + [FW_CFG_INITRD_ADDR] = "initrd_addr",
> + [FW_CFG_INITRD_SIZE] = "initdr_size",
> + [FW_CFG_BOOT_DEVICE] = "boot_device",
> + [FW_CFG_NUMA] = "numa",
> + [FW_CFG_BOOT_MENU] = "boot_menu",
> + [FW_CFG_MAX_CPUS] = "max_cpus",
> + [FW_CFG_KERNEL_ENTRY] = "kernel_entry",
> + [FW_CFG_KERNEL_DATA] = "kernel_data",
> + [FW_CFG_INITRD_DATA] = "initrd_data",
> + [FW_CFG_CMDLINE_ADDR] = "cmdline_addr",
> + [FW_CFG_CMDLINE_SIZE] = "cmdline_size",
> + [FW_CFG_CMDLINE_DATA] = "cmdline_data",
> + [FW_CFG_SETUP_ADDR] = "setup_addr",
> + [FW_CFG_SETUP_SIZE] = "setup_size",
> + [FW_CFG_SETUP_DATA] = "setup_data",
> + [FW_CFG_FILE_DIR] = "file_dir",
> +};
> +
> +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict)
> +{
> + FWCfgState *s = fw_cfg_find();
> + int arch, key;
> +
> + monitor_printf(mon, "%12s %5s %7s %9s %6s %-24s\n",
> + "Type", "Perm", "Size", "Specific", "Order", "Info");
> + for (arch = 0; arch < ARRAY_SIZE(s->entries); ++arch) {
> + for (key = 0; key < fw_cfg_max_entry(s); ++key) {
> + FWCfgEntry *e = &s->entries[arch][key];
> + const char *perm = e->allow_write ? "RW" : "RO";
> + const char *arch_spec = arch ? "arch_spec" : "";
> + char *type, *info = NULL;
> +
> + if (!e->len) {
> + continue;
> + }
> + if (key >= FW_CFG_FILE_FIRST) {
> + int id = key - FW_CFG_FILE_FIRST;
> + const char *path = s->files->f[id].name;
> +
> + type = g_strdup_printf("file (id %d)", id);
> + monitor_printf(mon, "%12s %5s %7d %10s %5d %-24s\n",
> + type, perm, e->len, arch_spec,
> + get_fw_cfg_order(s, path), path);
> + g_free(type);
> + continue;
> + }
> + type = g_strdup(fw_cfg_wellknown_entries[key]);
> + if (!type) {
> + type = g_strdup_printf("entry_%d", key);
> + }
> +
> + switch (key) {
> + case FW_CFG_SIGNATURE:
> + info = g_strndup((const gchar *)e->data, e->len);
> + break;
> + case FW_CFG_UUID:
> + info = qemu_uuid_unparse_strdup((const QemuUUID *)e->data);
> + break;
It seems odd to encode the type of each entry in this switch; I guess
it's OK if no one else needs it, else perhaps there should be a type
array.
Other than that, it's fine from the HMP side, but I agree it should
either have a QMP equivalent (in which case the structure is a bit
different) or a good justification of if it's really debug only.
Dave
> + case FW_CFG_ID:
> + case FW_CFG_NOGRAPHIC:
> + case FW_CFG_NB_CPUS:
> + case FW_CFG_BOOT_MENU:
> + case FW_CFG_MAX_CPUS:
> + case FW_CFG_RAM_SIZE:
> + case FW_CFG_KERNEL_ADDR:
> + case FW_CFG_KERNEL_SIZE:
> + case FW_CFG_KERNEL_CMDLINE:
> + case FW_CFG_KERNEL_ENTRY:
> + case FW_CFG_KERNEL_DATA:
> + case FW_CFG_INITRD_ADDR:
> + case FW_CFG_INITRD_SIZE:
> + case FW_CFG_INITRD_DATA:
> + case FW_CFG_CMDLINE_ADDR:
> + case FW_CFG_CMDLINE_SIZE:
> + case FW_CFG_CMDLINE_DATA:
> + case FW_CFG_SETUP_ADDR:
> + case FW_CFG_SETUP_SIZE:
> + case FW_CFG_SETUP_DATA:
> + switch (e->len) {
> + case 2:
> + info = g_strdup_printf("0x%04x", lduw_le_p(e->data));
> + break;
> + case 4:
> + info = g_strdup_printf("0x%08x", ldl_le_p(e->data));
> + break;
> + case 8:
> + info = g_strdup_printf("0x%016" PRIx64, ldq_le_p(e->data));
> + break;
> + default:
> + break;
> + }
> + break;
> + default:
> + break;
> + }
> + monitor_printf(mon, "%12s %5s %7d %10s %5s %-24s\n",
> + type, perm, e->len, arch_spec, "", info ? info : "");
> + g_free(type);
> + g_free(info);
> + }
> + }
> +}
> diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
> index f5a6895a74..28630b2f26 100644
> --- a/include/hw/nvram/fw_cfg.h
> +++ b/include/hw/nvram/fw_cfg.h
> @@ -226,4 +226,6 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,
> FWCfgState *fw_cfg_find(void);
> bool fw_cfg_dma_enabled(void *opaque);
>
> +void hmp_info_fw_cfg(Monitor *mon, const QDict *qdict);
> +
> #endif
> --
> 2.17.2
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2018-12-10 11:43 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-07 17:03 [Qemu-arm] [PATCH 0/6] fw_cfg: add HMP 'info fw_cfg' and add_file_from_host() Philippe Mathieu-Daudé
2018-12-07 17:03 ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-12-07 17:03 ` [Qemu-arm] [PATCH 1/6] hw/arm/virt: Remove null-check in virt_build_smbios() Philippe Mathieu-Daudé
2018-12-07 17:03 ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-12-10 16:02 ` [Qemu-arm] " Laszlo Ersek
2018-12-10 16:02 ` [Qemu-devel] " Laszlo Ersek
2019-03-05 21:01 ` Philippe Mathieu-Daudé
2019-03-05 21:01 ` Philippe Mathieu-Daudé
2018-12-07 17:03 ` [Qemu-arm] [PATCH 2/6] hw/arm: Remove unused include Philippe Mathieu-Daudé
2018-12-07 17:03 ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-12-07 17:57 ` Michael S. Tsirkin
2018-12-07 17:57 ` Michael S. Tsirkin
2018-12-10 9:14 ` Philippe Mathieu-Daudé
2018-12-10 9:14 ` Philippe Mathieu-Daudé
2018-12-07 17:03 ` [Qemu-devel] [PATCH 3/6] hw/i386: " Philippe Mathieu-Daudé
2018-12-07 17:43 ` Michael S. Tsirkin
2018-12-07 17:03 ` [Qemu-devel] [PATCH 4/6] hw/nvram/fw_cfg: Add trace events Philippe Mathieu-Daudé
2018-12-07 17:44 ` Michael S. Tsirkin
2018-12-10 16:10 ` Laszlo Ersek
2018-12-10 16:33 ` Philippe Mathieu-Daudé
2018-12-07 17:03 ` [Qemu-devel] [PATCH 5/6] hw/nvram/fw_cfg: Add HMP 'info fw_cfg' command Philippe Mathieu-Daudé
2018-12-07 17:26 ` Eric Blake
2018-12-07 17:54 ` Michael S. Tsirkin
2018-12-10 9:18 ` Philippe Mathieu-Daudé
2018-12-18 15:14 ` Philippe Mathieu-Daudé
2018-12-10 11:42 ` Dr. David Alan Gilbert [this message]
2018-12-10 16:49 ` Laszlo Ersek
2018-12-07 17:04 ` [Qemu-devel] [PATCH 6/6] hw/nvram/fw_cfg: Add fw_cfg_add_file_from_host() Philippe Mathieu-Daudé
2018-12-07 17:56 ` Michael S. Tsirkin
2018-12-07 19:17 ` Philippe Mathieu-Daudé
2018-12-10 17:11 ` Laszlo Ersek
2018-12-07 22:48 ` [Qemu-devel] [PATCH 0/6] fw_cfg: add HMP 'info fw_cfg' and add_file_from_host() no-reply
2018-12-10 9:22 ` [Qemu-arm] " Philippe Mathieu-Daudé
2018-12-10 9:22 ` Philippe Mathieu-Daudé
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=20181210114254.GB2372@work-vm \
--to=dgilbert@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=kraxel@redhat.com \
--cc=lersek@redhat.com \
--cc=mst@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.