From patchwork Thu May 23 17:44:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Bryant X-Patchwork-Id: 245997 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 63A612C0090 for ; Fri, 24 May 2013 03:49:28 +1000 (EST) Received: from localhost ([::1]:59570 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZdm-0001Cm-LS for incoming@patchwork.ozlabs.org; Thu, 23 May 2013 13:49:26 -0400 Received: from eggs.gnu.org ([208.118.235.92]:39113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZZd-0003fo-1f for qemu-devel@nongnu.org; Thu, 23 May 2013 13:45:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfZZb-0006jN-43 for qemu-devel@nongnu.org; Thu, 23 May 2013 13:45:08 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:49963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZZa-0006ix-Vk for qemu-devel@nongnu.org; Thu, 23 May 2013 13:45:07 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 23 May 2013 13:45:06 -0400 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 23 May 2013 13:45:03 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 80AC938C804D for ; Thu, 23 May 2013 13:45:02 -0400 (EDT) Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4NHj20S242442 for ; Thu, 23 May 2013 13:45:02 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4NHj1CM016779 for ; Thu, 23 May 2013 14:45:01 -0300 Received: from localhost ([9.80.101.134]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r4NHj03E016634; Thu, 23 May 2013 14:45:01 -0300 From: Corey Bryant To: qemu-devel@nongnu.org Date: Thu, 23 May 2013 13:44:47 -0400 Message-Id: <1369331087-22345-8-git-send-email-coreyb@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1369331087-22345-1-git-send-email-coreyb@linux.vnet.ibm.com> References: <1369331087-22345-1-git-send-email-coreyb@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13052317-7182-0000-0000-000006E2FF00 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 32.97.182.139 Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanb@linux.vnet.ibm.com, Corey Bryant , mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com, jschopp@linux.vnet.ibm.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNVRAM details X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Corey Bryant --- hmp.c | 32 ++++++++++++++++++++++++ hmp.h | 1 + monitor.c | 7 +++++ qapi-schema.json | 47 +++++++++++++++++++++++++++++++++++ qmp-commands.hx | 41 +++++++++++++++++++++++++++++++ vnvram.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 199 insertions(+), 0 deletions(-) diff --git a/hmp.c b/hmp.c index 4fb76ec..a144f73 100644 --- a/hmp.c +++ b/hmp.c @@ -653,6 +653,38 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) qapi_free_TPMInfoList(info_list); } +void hmp_info_vnvram(Monitor *mon, const QDict *dict) +{ + VNVRAMInfoList *info_list, *info; + Error *err = NULL; + unsigned int c = 0; + + info_list = qmp_query_vnvram(&err); + if (err) { + monitor_printf(mon, "VNVRAM not found\n"); + error_free(err); + return; + } + + for (info = info_list; info; info = info->next) { + VNVRAMInfo *ni = info->value; + VNVRAMEntryInfoList *einfo_list = ni->entries, *einfo; + unsigned int d = 0; + monitor_printf(mon, "vnvram%u: drive-id=%s " + "virtual-disk-size=%"PRId64" vnvram-size=%"PRIu64"\n", + c++, ni->drive_id, ni->virtual_disk_size, + ni->vnvram_size); + + for (einfo = einfo_list; einfo; einfo = einfo->next) { + VNVRAMEntryInfo *nei = einfo->value; + monitor_printf(mon, " entry%u: name=%s cur-size=%"PRIu64" " + "max-size=%"PRIu64"\n", + d++, nei->name, nei->cur_size, nei->max_size); + } + } + qapi_free_VNVRAMInfoList(info_list); +} + void hmp_quit(Monitor *mon, const QDict *qdict) { monitor_suspend(mon); diff --git a/hmp.h b/hmp.h index 95fe76e..e26daf2 100644 --- a/hmp.h +++ b/hmp.h @@ -37,6 +37,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_vnvram(Monitor *mon, const QDict *dict); 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 62aaebe..c10fe15 100644 --- a/monitor.c +++ b/monitor.c @@ -2764,6 +2764,13 @@ static mon_cmd_t info_cmds[] = { .mhandler.cmd = hmp_info_tpm, }, { + .name = "vnvram", + .args_type = "", + .params = "", + .help = "show VNVRAM information", + .mhandler.cmd = hmp_info_vnvram, + }, + { .name = NULL, }, }; diff --git a/qapi-schema.json b/qapi-schema.json index 9302e7d..73d42d6 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3619,3 +3619,50 @@ '*cpuid-input-ecx': 'int', 'cpuid-register': 'X86CPURegister32', 'features': 'int' } } + +# @VNVRAMEntryInfo: +# +# Information about an entry in the VNVRAM. +# +# @name: name of the entry +# +# @cur-size: current size of the entry's blob in bytes +# +# @max-size: max size of the entry's blob in bytes +# +# Since: 1.6 +# +## +{ 'type': 'VNVRAMEntryInfo', + 'data': {'name': 'str', 'cur-size': 'int', 'max-size': 'int', } } + +## +# @VNVRAMInfo: +# +# Information about the VNVRAM device. +# +# @drive-id: ID of the VNVRAM (and associated drive) +# +# @virtual-disk-size: Virtual size of the associated disk drive in bytes +# +# @vnvram-size: Size of the VNVRAM in bytes +# +# @entries: Array of @VNVRAMEntryInfo +# +# Since: 1.6 +# +## +{ 'type': 'VNVRAMInfo', + 'data': {'drive-id': 'str', 'virtual-disk-size': 'int', + 'vnvram-size': 'int', 'entries' : ['VNVRAMEntryInfo']} } + +## +# @query-vnvram: +# +# Return information about the VNVRAM devices. +# +# Returns: @VNVRAMInfo on success +# +# Since: 1.6 +## +{ 'command': 'query-vnvram', 'returns': ['VNVRAMInfo'] } diff --git a/qmp-commands.hx b/qmp-commands.hx index ffd130e..56a57b7 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -2932,3 +2932,44 @@ Example: <- { "return": {} } EQMP + + { + .name = "query-vnvram", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_vnvram, + }, + +SQMP +query-vnvram +------------ + +Show VNVRAM info. + +Return a json-array of json-objects representing VNVRAMs. Each VNVRAM +is described by a json-object with the following: + +- "drive-id": ID of the VNVRAM (json-string) +- "vitual-disk-size": Virtual size of associated disk drive in bytes (json-int) +- "vnvram-size": Size of the VNVRAM in bytes (json-int) +- "entries": json-array of json-objects representing entries + +Each entry is described by a json-object with the following: + +- "name": Name of the entry (json-string) +- "cur-size": Current size of the entry's blob in bytes (json-int) +- "max-size": Max size of the entry's blob in bytes (json-int) + +Example: + +-> { "execute": "query-vnvram" } +<- {"return": [ + { "vnvram-size": 2050, "virtual-disk-size": 2000896, + "drive-id": "drive-ide0-0-0", + "entries": [ + { "name": "this-entry", "cur-size": 2048, "max-size": 21504 }, + { "name": "that-entry", "cur-size": 1024, "max-size": 21504 }, + { "name": "other-entry", "cur-size": 4096, "max-size": 41472 } ] + } ] + } + +EQMP diff --git a/vnvram.c b/vnvram.c index 9c4f64f..a5fe101 100644 --- a/vnvram.c +++ b/vnvram.c @@ -16,6 +16,7 @@ #include "monitor/monitor.h" #include "qemu/thread.h" #include "sysemu/sysemu.h" +#include "qmp-commands.h" /* #define VNVRAM_DEBUG @@ -897,6 +898,76 @@ static int vnvram_rwrequest_schedule(VNVRAMRWRequest *rwr) return rc; } +/************************ VNVRAM monitor *****************************/ +/* VNVRAM functions that support QMP and HMP commands */ +/*********************************************************************/ + +/* + * Get VNVRAM entry details for an in-memory entry + */ +static VNVRAMEntryInfo *vnvram_get_vnvram_entry_info(VNVRAMEntry *entry) +{ + VNVRAMEntryInfo *res = g_new0(VNVRAMEntryInfo, 1); + + res->name = g_strndup(entry->name, sizeof(entry->name)); + res->cur_size = entry->cur_size; + res->max_size = entry->max_size; + + return res; +} + +/* + * Get VNVRAM details based on the VNVRAM struct + */ +static VNVRAMInfo *vnvram_get_vnvram_info(VNVRAM *vnvram) +{ + VNVRAMEntry *entry; + VNVRAMEntryInfoList *info, *head = NULL, *cur = NULL; + VNVRAMInfo *res = g_new0(VNVRAMInfo, 1); + + res->drive_id = g_strdup(vnvram->drv_id); + res->virtual_disk_size = bdrv_getlength(vnvram->bds); + res->vnvram_size = vnvram_get_size(vnvram); + + QLIST_FOREACH(entry, &vnvram->entries_head, next) { + info = g_new0(VNVRAMEntryInfoList, 1); + info->value = vnvram_get_vnvram_entry_info(entry); + + if (!cur) { + head = cur = info; + } else { + cur->next = info; + cur = info; + } + } + res->entries = head; + + return res; +} + +/* + * Get VNVRAM data from the in-memory VNVRAM struct and entries + */ +VNVRAMInfoList *qmp_query_vnvram(Error **errp) +{ + VNVRAM *vnvram; + VNVRAMInfoList *info, *head = NULL, *cur = NULL; + + QLIST_FOREACH(vnvram, &vnvrams, list) { + info = g_new0(VNVRAMInfoList, 1); + info->value = vnvram_get_vnvram_info(vnvram); + + if (!cur) { + head = cur = info; + } else { + cur->next = info; + cur = info; + } + } + + return head; +} + /************************* VNVRAM APIs *******************************/ /* VNVRAM APIs that can be used by QEMU to provide persistent storage*/ /*********************************************************************/