qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Corey Bryant <coreyb@linux.vnet.ibm.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
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
Subject: Re: [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNVRAM details
Date: Wed, 29 May 2013 13:34:32 -0400	[thread overview]
Message-ID: <51A63C28.6040307@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130529131529.5dc5653e@redhat.com>



On 05/29/2013 01:15 PM, Luiz Capitulino wrote:
> On Thu, 23 May 2013 13:44:47 -0400
> Corey Bryant <coreyb@linux.vnet.ibm.com> wrote:
>
>> Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
>
> 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*/
>>   /*********************************************************************/
>
>
>
>

  reply	other threads:[~2013-05-29 17:35 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-23 17:44 [Qemu-devel] [PATCH 0/7] VNVRAM persistent storage Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 1/7] vnvram: VNVRAM bdrv support Corey Bryant
2013-05-24 13:06   ` Kevin Wolf
2013-05-24 15:33     ` Corey Bryant
2013-05-24 15:37       ` Kevin Wolf
2013-05-24 15:47         ` Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 2/7] vnvram: VNVRAM in-memory support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 3/7] vnvram: VNVRAM bottom-half r/w scheduling support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 4/7] vnvram: VNVRAM internal APIs Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 5/7] vnvram: VNVRAM additional debug support Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 6/7] main: Initialize VNVRAM Corey Bryant
2013-05-23 17:44 ` [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNVRAM details Corey Bryant
2013-05-23 17:59   ` Eric Blake
2013-05-23 18:43     ` Corey Bryant
2013-05-29 17:15   ` Luiz Capitulino
2013-05-29 17:34     ` Corey Bryant [this message]
2013-05-23 18:03 ` [Qemu-devel] [PATCH 0/7] VNVRAM persistent storage Anthony Liguori
2013-05-23 18:41   ` Corey Bryant
2013-05-23 19:15     ` Anthony Liguori
2013-05-24 15:27       ` Corey Bryant
2013-05-29 13:34         ` Anthony Liguori
2013-05-24  9:59 ` Stefan Hajnoczi
2013-05-24 12:13   ` Stefan Berger
2013-05-24 12:36     ` Stefan Hajnoczi
2013-05-24 15:39       ` Corey Bryant
2013-05-27  8:40         ` Stefan Hajnoczi

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=51A63C28.6040307@linux.vnet.ibm.com \
    --to=coreyb@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=jschopp@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.vnet.ibm.com \
    --cc=stefanha@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).