[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/4] monitor: add device info infrastructure
From: |
Blue Swirl |
Subject: |
[Qemu-devel] [PATCH 1/4] monitor: add device info infrastructure |
Date: |
Wed, 12 May 2010 23:56:46 +0300 |
Signed-off-by: Blue Swirl <address@hidden>
---
monitor.c | 41 +++++++++++++++++++++++++++++++++++++++++
monitor.h | 10 ++++++++++
qemu-monitor.hx | 13 +++++++++++++
3 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/monitor.c b/monitor.c
index a1ebc5d..9bb1a30 100644
--- a/monitor.c
+++ b/monitor.c
@@ -129,6 +129,13 @@ typedef struct MonitorControl {
int command_mode;
} MonitorControl;
+/* Callback for device info command */
+struct MonDevInfoEntry {
+ const struct MonDevInfo *dev_info;
+ void *dev_opaque;
+ QLIST_ENTRY(MonDevInfoEntry) next;
+};
+
struct Monitor {
CharDriverState *chr;
int mux_out;
@@ -147,6 +154,7 @@ struct Monitor {
#endif
QError *error;
QLIST_HEAD(,mon_fd_t) fds;
+ QLIST_HEAD(,MonDevInfoEntry) dev_infos;
QLIST_ENTRY(Monitor) entry;
};
@@ -2494,6 +2502,21 @@ int monitor_get_fd(Monitor *mon, const char *fdname)
return -1;
}
+static void do_info_device(Monitor *mon, const QDict *qdict)
+{
+ struct MonDevInfoEntry *entry;
+ const char *name;
+
+ name = qdict_get_str(qdict, "devname");
+
+ QLIST_FOREACH(entry, &mon->dev_infos, next) {
+ if (strcmp(entry->dev_info->dev_name, name) != 0) {
+ continue;
+ }
+ entry->dev_info->dev_info_cb(mon, entry->dev_opaque);
+ }
+}
+
static const mon_cmd_t mon_cmds[] = {
#include "qemu-monitor.h"
{ NULL, NULL, },
@@ -4166,6 +4189,13 @@ static void monitor_find_completion(const char *cmdline)
for (cmd = mon_cmds; cmd->name != NULL; cmd++) {
cmd_completion(str, cmd->name);
}
+ } else if (!strcmp(cmd->name, "dev_info")) {
+ struct MonDevInfoEntry *entry;
+
+ readline_set_completion_index(cur_mon->rs, strlen(str));
+ QLIST_FOREACH(entry, &cur_mon->dev_infos, next) {
+ cmd_completion(str, entry->dev_info->dev_name);
+ }
}
break;
default:
@@ -4680,3 +4710,14 @@ int monitor_read_bdrv_key_start(Monitor *mon,
BlockDriverState *bs,
return err;
}
+
+void monitor_register_device_info(const struct MonDevInfo *dev_info,
+ void *dev_opaque)
+{
+ struct MonDevInfoEntry *entry;
+
+ entry = qemu_malloc(sizeof(*entry));
+ entry->dev_info = dev_info;
+ entry->dev_opaque = dev_opaque;
+ QLIST_INSERT_HEAD(&cur_mon->dev_infos, entry, next);
+}
diff --git a/monitor.h b/monitor.h
index ea15469..472f367 100644
--- a/monitor.h
+++ b/monitor.h
@@ -43,6 +43,16 @@ int monitor_read_bdrv_key_start(Monitor *mon,
BlockDriverState *bs,
BlockDriverCompletionFunc *completion_cb,
void *opaque);
+typedef void DeviceInfoFunc(Monitor *mon, void *opaque);
+
+struct MonDevInfo {
+ const char *dev_name;
+ DeviceInfoFunc *dev_info_cb;
+};
+
+void monitor_register_device_info(const struct MonDevInfo *dev_info,
+ void *dev_opaque);
+
int monitor_get_fd(Monitor *mon, const char *fdname);
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap);
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index a8f194c..596025f 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -1182,6 +1182,19 @@ STEXI
Enable the specified QMP capabilities
ETEXI
+ {
+ .name = "dev_info",
+ .args_type = "devname:s",
+ .params = "device name",
+ .user_print = monitor_user_noop,
+ .mhandler.cmd = do_info_device,
+ .help = "show device information",
+ },
+STEXI
address@hidden device @var{devicename}
+Show information about a device.
+ETEXI
+
STEXI
@end table
ETEXI
--
1.6.2.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH 1/4] monitor: add device info infrastructure,
Blue Swirl <=