From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhkHD-0008Mu-Gf for qemu-devel@nongnu.org; Wed, 29 May 2013 13:35:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhkH6-0004gK-By for qemu-devel@nongnu.org; Wed, 29 May 2013 13:35:07 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:48831) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhkH6-0004eD-7U for qemu-devel@nongnu.org; Wed, 29 May 2013 13:35:00 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 29 May 2013 13:34:48 -0400 Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id BE40F6E8047 for ; Wed, 29 May 2013 13:34:41 -0400 (EDT) Received: from d03av03.boulder.ibm.com (d03av03.boulder.ibm.com [9.17.195.169]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r4THYfjC58458132 for ; Wed, 29 May 2013 13:34:42 -0400 Received: from d03av03.boulder.ibm.com (loopback [127.0.0.1]) by d03av03.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r4THYX8I021693 for ; Wed, 29 May 2013 11:34:34 -0600 Message-ID: <51A63C28.6040307@linux.vnet.ibm.com> Date: Wed, 29 May 2013 13:34:32 -0400 From: Corey Bryant MIME-Version: 1.0 References: <1369331087-22345-1-git-send-email-coreyb@linux.vnet.ibm.com> <1369331087-22345-8-git-send-email-coreyb@linux.vnet.ibm.com> <20130529131529.5dc5653e@redhat.com> In-Reply-To: <20130529131529.5dc5653e@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNVRAM details List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanb@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, jschopp@linux.vnet.ibm.com, stefanha@redhat.com On 05/29/2013 01:15 PM, Luiz Capitulino wrote: > On Thu, 23 May 2013 13:44:47 -0400 > Corey Bryant wrote: > >> Signed-off-by: Corey Bryant > > Looks good to me, only one small nit below. > It looks like this series is going to get dropped, but thanks for the review! -- Regards, 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 > > It's preferable not to abbreviate, you can have current-size. > >> +# >> +# @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*/ >> /*********************************************************************/ > > > >