All of lore.kernel.org
 help / color / mirror / Atom feed
From: <arei.gonglei@huawei.com>
To: qemu-devel@nongnu.org
Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com,
	aik@ozlabs.ru, hutao@cn.fujitsu.com, armbru@redhat.com,
	kraxel@redhat.com, akong@redhat.com, agraf@suse.de,
	Gonglei <arei.gonglei@huawei.com>,
	aliguori@amazon.com, gaowanlong@cn.fujitsu.com,
	ehabkost@redhat.com, luonengjun@huawei.com,
	peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com,
	pbonzini@redhat.com, lcapitulino@redhat.com, kwolf@redhat.com,
	peter.crosthwaite@xilinx.com, imammedo@redhat.com,
	afaerber@suse.de
Subject: [Qemu-devel] [PATCH v5 7/8] qmp: add query-bootindex command
Date: Mon, 4 Aug 2014 20:46:21 +0800	[thread overview]
Message-ID: <1407156382-2836-8-git-send-email-arei.gonglei@huawei.com> (raw)
In-Reply-To: <1407156382-2836-1-git-send-email-arei.gonglei@huawei.com>

From: Gonglei <arei.gonglei@huawei.com>

Adds "query-bootindex" QMP command.

Example QMP command:

-> { "execute": "query-bootindex"}
<- {
      "return":[
         {
            "id":"ide0-0-0",
            "bootindex":1,
            "suffix":"/disk@0"
         },
         {
            "id":"nic1",
            "bootindex":2,
            "suffix":"/ethernet-phy@0"
         }
      ]
   }

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Chenliang <chenliang88@huawei.com>
---
 qapi-schema.json | 29 +++++++++++++++++++++++++++++
 qmp-commands.hx  | 41 +++++++++++++++++++++++++++++++++++++++++
 vl.c             | 31 +++++++++++++++++++++++++++++++
 3 files changed, 101 insertions(+)

diff --git a/qapi-schema.json b/qapi-schema.json
index 30bd6ad..680cbc5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1704,6 +1704,33 @@
 { 'command': 'device_del', 'data': {'id': 'str'} }
 
 ##
+# @BootindexInfo:
+#
+# Information about devcie's bootindex.
+#
+# @id: the name of a device owning the bootindex
+#
+# @bootindex: the bootindex number
+#
+# @suffix: the suffix a device's bootindex
+#
+# Since: 2.2
+##
+{ 'type': 'BootindexInfo',
+  'data': {'id': 'str', 'bootindex': 'int', 'suffix': 'str'} }
+
+##
+# @query-bootindex:
+#
+# Returns information about bootindex
+#
+# Returns: a list of @BootindexInfo for existing device
+#
+# Since: 2.2
+##
+{ 'command': 'query-bootindex', 'returns': ['BootindexInfo'] }
+
+##
 # @set-bootindex:
 #
 # set bootindex of a device
@@ -1715,6 +1742,8 @@
 # Returns: Nothing on success
 #          If @id is not a valid device, DeviceNotFound
 #
+# Note: suffix can be gotten by query-bootindex command
+#
 # Since: 2.2
 ##
 { 'command': 'set-bootindex',
diff --git a/qmp-commands.hx b/qmp-commands.hx
index 19cc3b8..6ab9325 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -337,6 +337,47 @@ EQMP
     },
 
 SQMP
+query-bootindex
+---------------
+
+Show VM bootindex information.
+
+The returned value is a json-array of all device configured
+bootindex property. Each bootindex is represented by a json-object.
+
+The bootindex json-object contains the following:
+
+- "id": the name of a device owning the bootindex (json-string)
+- "bootindex": the bootindex number (json-int)
+- "suffix": the suffix a device's bootindex (json-string)
+
+Example:
+
+-> { "execute": "query-bootindex" }
+<- {
+      "return":[
+         {
+            "id":"ide0-0-0",
+            "bootindex":1,
+            "suffix":"/disk@0"
+         },
+         {
+            "id":"nic1",
+            "bootindex":2,
+            "suffix":"/ethernet-phy@0"
+         }
+      ]
+   }
+
+EQMP
+
+    {
+        .name       = "query-bootindex",
+        .args_type  = "",
+        .mhandler.cmd_new = qmp_marshal_input_query_bootindex,
+    },
+
+SQMP
 set-bootindex
 -------------
 
diff --git a/vl.c b/vl.c
index 2424135..b1d8896 100644
--- a/vl.c
+++ b/vl.c
@@ -1219,6 +1219,37 @@ static void restore_boot_order(void *opaque)
     g_free(normal_boot_order);
 }
 
+BootindexInfoList *qmp_query_bootindex(Error **errp)
+{
+    BootindexInfoList *booindex_list = NULL;
+    BootindexInfoList *info;
+    FWBootEntry *i;
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        info = g_new0(BootindexInfoList, 1);
+        info->value = g_new0(BootindexInfo, 1);
+
+        if (i->dev->id) {
+            info->value->id = g_strdup(i->dev->id);
+        } else {
+            /* For virtio devices, we should get id from they parent */
+            if (i->dev->parent_bus) {
+                DeviceState *dev = i->dev->parent_bus->parent;
+                info->value->id = g_strdup(dev->id);
+            } else {
+                info->value->id = g_strdup("");
+            }
+        }
+        info->value->bootindex = i->bootindex;
+        info->value->suffix = g_strdup(i->suffix);
+
+        info->next = booindex_list;
+        booindex_list = info;
+    }
+
+    return booindex_list;
+}
+
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix)
 {
-- 
1.7.12.4

  parent reply	other threads:[~2014-08-04 12:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04 12:46 [Qemu-devel] [PATCH v5 0/8] modify boot order of guest, and take effect after rebooting arei.gonglei
2014-08-04 12:46 ` [Qemu-devel] [PATCH v5 1/8] bootindex: add modify_boot_device_path function arei.gonglei
2014-08-04 12:46 ` [Qemu-devel] [PATCH v5 2/8] bootindex: add del_boot_device_path function arei.gonglei
2014-08-04 12:46 ` [Qemu-devel] [PATCH v5 3/8] fw_cfg: add fw_cfg_machine_reset function arei.gonglei
2014-08-04 12:46 ` [Qemu-devel] [PATCH v5 4/8] bootindex: delete bootindex when device is removed arei.gonglei
2014-08-04 12:46 ` [Qemu-devel] [PATCH v5 5/8] qmp: add set-bootindex command arei.gonglei
2014-08-04 12:46 ` [Qemu-devel] [PATCH v5 6/8] qemu-monitor: HMP set-bootindex wrapper arei.gonglei
2014-08-04 12:46 ` arei.gonglei [this message]
2014-08-04 12:46 ` [Qemu-devel] [PATCH v5 8/8] qemu-monitor: add HMP "info-bootindex" command arei.gonglei
2014-08-04 12:53 ` [Qemu-devel] [PATCH v5 0/8] modify boot order of guest, and take effect after rebooting Gonglei (Arei)
2014-08-07 11:50 ` Gonglei (Arei)
2014-08-07 12:57   ` Paolo Bonzini
2014-08-07 13:01     ` Gonglei (Arei)
2014-08-26  6:36 ` Gerd Hoffmann
2014-08-26  9:07   ` Gonglei (Arei)
2014-08-26 10:00     ` Gerd Hoffmann
2014-08-26 11:24       ` Markus Armbruster
2014-08-27  2:11         ` Gonglei (Arei)
2014-08-27 14:23           ` Gerd Hoffmann
2014-08-28  4:50             ` Gonglei (Arei)

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=1407156382-2836-8-git-send-email-arei.gonglei@huawei.com \
    --to=arei.gonglei@huawei.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=akong@redhat.com \
    --cc=aliguori@amazon.com \
    --cc=armbru@redhat.com \
    --cc=chenliang88@huawei.com \
    --cc=ehabkost@redhat.com \
    --cc=gaowanlong@cn.fujitsu.com \
    --cc=hani@linux.com \
    --cc=hutao@cn.fujitsu.com \
    --cc=imammedo@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=luonengjun@huawei.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.crosthwaite@xilinx.com \
    --cc=peter.huangpeng@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=weidong.huang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.