qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNV


From: Corey Bryant
Subject: Re: [Qemu-devel] [PATCH 7/7] monitor: QMP/HMP support for retrieving VNVRAM details
Date: Wed, 29 May 2013 13:34:32 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6



On 05/29/2013 01:15 PM, Luiz Capitulino wrote:
On Thu, 23 May 2013 13:44:47 -0400
Corey Bryant <address@hidden> wrote:

Signed-off-by: Corey Bryant <address@hidden>

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 via email to

[Prev in Thread] Current Thread [Next in Thread]