[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 7/9] plugins: add API to return a name for a IO device
From: |
Alex Bennée |
Subject: |
[PATCH v1 7/9] plugins: add API to return a name for a IO device |
Date: |
Tue, 2 Jun 2020 16:46:22 +0100 |
This may well end up being anonymous but it should always be unique.
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
include/qemu/qemu-plugin.h | 5 +++++
plugins/api.c | 18 ++++++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h
index bab8b0d4b3a..43c6a9e857f 100644
--- a/include/qemu/qemu-plugin.h
+++ b/include/qemu/qemu-plugin.h
@@ -335,6 +335,11 @@ struct qemu_plugin_hwaddr
*qemu_plugin_get_hwaddr(qemu_plugin_meminfo_t info,
bool qemu_plugin_hwaddr_is_io(const struct qemu_plugin_hwaddr *haddr);
uint64_t qemu_plugin_hwaddr_device_offset(const struct qemu_plugin_hwaddr
*haddr);
+/*
+ * Returns a string representing the device. Plugin must free() it
+ */
+char * qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *haddr);
+
typedef void
(*qemu_plugin_vcpu_mem_cb_t)(unsigned int vcpu_index,
qemu_plugin_meminfo_t info, uint64_t vaddr,
diff --git a/plugins/api.c b/plugins/api.c
index bbdc5a4eb46..3c73de8c1c2 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -303,6 +303,24 @@ uint64_t qemu_plugin_hwaddr_device_offset(const struct
qemu_plugin_hwaddr *haddr
return 0;
}
+char * qemu_plugin_hwaddr_device_name(const struct qemu_plugin_hwaddr *haddr)
+{
+#ifdef CONFIG_SOFTMMU
+ if (haddr && haddr->is_io) {
+ MemoryRegionSection *mrs = haddr->v.io.section;
+ if (!mrs->mr->name) {
+ return g_strdup_printf("anon%08lx", 0xffffffff & (uintptr_t)
mrs->mr);
+ } else {
+ return g_strdup(mrs->mr->name);
+ }
+ } else {
+ return g_strdup("RAM");
+ }
+#else
+ return g_strdup("Invalid");
+#endif
+}
+
/*
* Queries to the number and potential maximum number of vCPUs there
* will be. This helps the plugin dimension per-vcpu arrays.
--
2.20.1
- [PATCH v1 3/9] scripts/clean-includes: Mark 'qemu/qemu-plugin.h' as special header, (continued)
- [PATCH v1 3/9] scripts/clean-includes: Mark 'qemu/qemu-plugin.h' as special header, Alex Bennée, 2020/06/02
- [PATCH v1 1/9] plugins: new lockstep plugin for debugging TCG changes, Alex Bennée, 2020/06/02
- [PATCH v1 4/9] tests/plugin: correctly honour io_count, Alex Bennée, 2020/06/02
- [PATCH v1 5/9] cputlb: ensure we re-fill the TLB if it has reset, Alex Bennée, 2020/06/02
- [PATCH v1 6/9] hw/virtio/pci: include vdev name in registered PCI sections, Alex Bennée, 2020/06/02
- [PATCH v1 7/9] plugins: add API to return a name for a IO device,
Alex Bennée <=
- Re: [PATCH v1 7/9] plugins: add API to return a name for a IO device, Clement Deschamps, 2020/06/02
- Re: [PATCH v1 7/9] plugins: add API to return a name for a IO device, Emilio G. Cota, 2020/06/07
- Re: [PATCH v1 7/9] plugins: add API to return a name for a IO device, Philippe Mathieu-Daudé, 2020/06/08
- Re: [PATCH v1 7/9] plugins: add API to return a name for a IO device, Alex Bennée, 2020/06/08
- Re: [PATCH v1 7/9] plugins: add API to return a name for a IO device, Emilio G. Cota, 2020/06/09
- Re: [PATCH v1 7/9] plugins: add API to return a name for a IO device, Alex Bennée, 2020/06/09
- Re: [PATCH v1 7/9] plugins: add API to return a name for a IO device, Emilio G. Cota, 2020/06/09
[PATCH v1 9/9] .travis.yml: allow failure for unreliable hosts, Alex Bennée, 2020/06/02