From: Sanidhya Kashyap <sanidhya.iiith@gmail.com>
To: qemu list <qemu-devel@nongnu.org>
Cc: Sanidhya Kashyap <sanidhya.iiith@gmail.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Juan Quintela <quintela@redhat.com>
Subject: [Qemu-devel] [RFC PATCH v3 2/6] VMState test: get information about the registered devices
Date: Sat, 9 Aug 2014 02:26:31 -0400 [thread overview]
Message-ID: <1407565595-18861-3-git-send-email-sanidhya.iiith@gmail.com> (raw)
In-Reply-To: <1407565595-18861-1-git-send-email-sanidhya.iiith@gmail.com>
Added both qmp and hmp interface to get the information about the devices that
have been qdevified and are registered with the SaveVMHandlers. I have not used
any format to print the device information for the hmp interface. It would be
great if anyone can give me some pointers about this about the printing format
if there is something.
The qmp command to extract the information about the devices is
qmp_query_devices which provides the list of device names and their respective
version. The hmp command name is 'info devices' which lists the same information
as provided by the qmp interface.
Signed-off-by: Sanidhya Kashyap <sanidhya.iiith@gmail.com>
---
hmp-commands.hx | 2 ++
hmp.c | 23 +++++++++++++++++++++++
hmp.h | 1 +
monitor.c | 7 +++++++
qapi-schema.json | 26 ++++++++++++++++++++++++++
qmp-commands.hx | 43 +++++++++++++++++++++++++++++++++++++++++++
savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
7 files changed, 147 insertions(+)
diff --git a/hmp-commands.hx b/hmp-commands.hx
index d0943b1..a221459 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1780,6 +1780,8 @@ show qdev device model list
show roms
@item info tpm
show the TPM device
+@item info devices
+show the devices registered with migration capability
@end table
ETEXI
diff --git a/hmp.c b/hmp.c
index 4d1838e..6e1802a 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1714,3 +1714,26 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
monitor_printf(mon, "\n");
}
+
+void hmp_info_devices(Monitor *mon, const QDict *qdict)
+{
+ Error *err = NULL;
+ QemuDeviceList *device_list = qmp_query_devices(&err);
+
+ if (device_list) {
+ monitor_printf(mon, "devices:\n");
+ while (device_list) {
+ monitor_printf(mon, "device-name: %s, ",
+ device_list->value->device_name);
+ monitor_printf(mon, "version: %ld\n",
+ device_list->value->version);
+ device_list = device_list->next;
+ }
+ }
+
+ if (err) {
+ hmp_handle_error(mon, &err);
+ }
+
+ qapi_free_QemuDeviceList(device_list);
+}
diff --git a/hmp.h b/hmp.h
index 4fd3c4a..9d6b577 100644
--- a/hmp.h
+++ b/hmp.h
@@ -38,6 +38,7 @@ void hmp_info_balloon(Monitor *mon, const QDict *qdict);
void hmp_info_pci(Monitor *mon, const QDict *qdict);
void hmp_info_block_jobs(Monitor *mon, const QDict *qdict);
void hmp_info_tpm(Monitor *mon, const QDict *qdict);
+void hmp_info_devices(Monitor *mon, const QDict *qdict);
void hmp_quit(Monitor *mon, const QDict *qdict);
void hmp_stop(Monitor *mon, const QDict *qdict);
void hmp_system_reset(Monitor *mon, const QDict *qdict);
diff --git a/monitor.c b/monitor.c
index 5bc70a6..2431686 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2918,6 +2918,13 @@ static mon_cmd_t info_cmds[] = {
.mhandler.cmd = hmp_info_memdev,
},
{
+ .name = "devices",
+ .args_type = "",
+ .params = "",
+ .help = "show registered devices",
+ .mhandler.cmd = hmp_info_devices,
+ },
+ {
.name = NULL,
},
};
diff --git a/qapi-schema.json b/qapi-schema.json
index b11aad2..74d26fe 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3480,3 +3480,29 @@
# Since: 2.1
##
{ 'command': 'rtc-reset-reinjection' }
+
+##
+# @QemuDevice
+#
+# device that is registered with SaveVMHandlers
+#
+# @device-name: name of the device that is registered with
+# SaveVMHandlers (in vmsd structure).
+#
+# @version: version of the device.
+#
+# Since 2.2
+##
+{ 'type': 'QemuDevice',
+ 'data': { 'device-name': 'str',
+ '*version': 'int' } }
+
+##
+# @query-devices
+#
+# returns the list of QemuDevice
+#
+# Since 2.2
+##
+{ 'command': 'query-devices',
+ 'returns': [ 'QemuDevice' ] }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 4be4765..e489197 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -3755,3 +3755,46 @@ Example:
<- { "return": {} }
EQMP
+
+ {
+ .name = "query-devices",
+ .args_type = "",
+ .mhandler.cmd_new = qmp_marshal_input_query_devices,
+ },
+
+SQMP
+query-devices
+-------------
+
+Shows registered devices along with the version
+
+Example (1):
+
+-> { "execute": "query-devices" }
+<- { "return": [
+ {
+ [ { 'device-name': 'kvm-tpr-opt', 'version': 1 },
+ { 'device-name': 'apic', 'version': 3 },
+ { 'device-name': 'kvmclock', 'version': 1 },
+ { 'device-name': 'fw_cfg', 'version': 2 },
+ { 'device-name': 'I440FX', 'version': 3 },
+ { 'device-name': 'PIIX3', 'version': 3 },
+ { 'device-name': 'i8259', 'version': 1 },
+ { 'device-name': 'i8259', 'version': 1 },
+ { 'device-name': 'ioapic', 'version': 3 },
+ { 'device-name': 'cirrus_vga', 'version': 2 },
+ { 'device-name': 'hpet', 'version': 2 },
+ { 'device-name': 'mc146818rtc', 'version': 3 },
+ { 'device-name': 'i8254', 'version': 3 },
+ { 'device-name': 'serial', 'version': 3 },
+ { 'device-name': 'pckbd', 'version': 3 },
+ { 'device-name': 'vmmouse', 'version': 0 },
+ { 'device-name': 'port92', 'version': 1 },
+ { 'device-name': 'fdc', 'version': 2 },
+ { 'device-name': 'e1000', 'version': 2 },
+ { 'device-name': 'ide', 'version': 3 },
+ { 'device-name': 'piix4_pm', 'version': 3 } ]
+ }
+ ]
+ }
+EQMP
diff --git a/savevm.c b/savevm.c
index e19ae0a..764ca71 100644
--- a/savevm.c
+++ b/savevm.c
@@ -233,6 +233,7 @@ typedef struct SaveStateEntry {
void *opaque;
CompatEntry *compat;
int is_ram;
+ DeviceState *dev;
} SaveStateEntry;
@@ -429,6 +430,7 @@ int register_savevm_live(DeviceState *dev,
se->ops = ops;
se->opaque = opaque;
se->vmsd = NULL;
+ se->dev = dev;
/* if this is a live_savem then set is_ram */
if (ops->save_live_setup != NULL) {
se->is_ram = 1;
@@ -519,6 +521,7 @@ int vmstate_register_with_alias_id(DeviceState *dev, int instance_id,
se->opaque = opaque;
se->vmsd = vmsd;
se->alias_id = alias_id;
+ se->dev = dev;
if (dev) {
char *id = qdev_get_dev_path(dev);
@@ -1137,6 +1140,48 @@ void do_savevm(Monitor *mon, const QDict *qdict)
}
}
+static QemuDeviceList *create_device_list(const char *name, int version,
+ QemuDeviceList *list)
+{
+ QemuDeviceList *temp_list;
+ QemuDeviceList *parent_list = list;
+ int len;
+
+ temp_list = g_malloc0(sizeof(QemuDeviceList));
+ len = strlen(name);
+ temp_list->value = g_malloc0(sizeof(QemuDevice));
+ temp_list->value->device_name = g_malloc0(sizeof(char)*(len+1));
+ strcpy(temp_list->value->device_name, name);
+ temp_list->value->version = version;
+ temp_list->next = NULL;
+
+ if (!list) {
+ return temp_list;
+ }
+
+ while (list->next) {
+ list = list->next;
+ }
+ list->next = temp_list;
+
+ return parent_list;
+}
+
+QemuDeviceList *qmp_query_devices(Error **errp)
+{
+ QemuDeviceList *device_list = NULL;
+ SaveStateEntry *se;
+
+ QTAILQ_FOREACH(se, &savevm_handlers, entry) {
+ if (se->dev) {
+ device_list = create_device_list(se->vmsd->name, se->version_id,
+ device_list);
+ }
+ }
+
+ return device_list;
+}
+
void qmp_xen_save_devices_state(const char *filename, Error **errp)
{
QEMUFile *f;
--
1.9.3
next prev parent reply other threads:[~2014-08-09 6:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-09 6:26 [Qemu-devel] [RFC PATCH v3 0/6] VMState testing Sanidhya Kashyap
2014-08-09 6:26 ` [Qemu-devel] [RFC PATCH v3 1/6] QEMUSizedBuffer/QEMUFile Sanidhya Kashyap
2014-08-11 2:49 ` Gonglei (Arei)
2014-08-11 18:47 ` Dr. David Alan Gilbert
2014-08-11 19:16 ` Stefan Berger
2014-08-11 16:38 ` Eric Blake
2014-08-09 6:26 ` Sanidhya Kashyap [this message]
2014-08-11 16:24 ` [Qemu-devel] [RFC PATCH v3 2/6] VMState test: get information about the registered devices Eric Blake
2014-08-09 6:26 ` [Qemu-devel] [RFC PATCH v3 3/6] VMstate test: basic VMState testing mechanism Sanidhya Kashyap
2014-08-11 16:32 ` Eric Blake
2014-08-09 6:26 ` [Qemu-devel] [RFC PATCH v3 4/6] VMState test: querying the vmstate testing process Sanidhya Kashyap
2014-08-11 16:35 ` Eric Blake
2014-08-09 6:26 ` [Qemu-devel] [RFC PATCH v3 5/6] VMState test: update period of " Sanidhya Kashyap
2014-08-09 6:26 ` [Qemu-devel] [RFC PATCH v3 6/6] VMState test: cancel mechanism for an already running " Sanidhya Kashyap
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=1407565595-18861-3-git-send-email-sanidhya.iiith@gmail.com \
--to=sanidhya.iiith@gmail.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).