yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From e49b0dccdd8687fb269610c86381bdcc8ec42222 Mon Sep 17 00:00:00 2001
9ae3a8
From: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Date: Tue, 22 Jul 2014 18:31:23 +0200
9ae3a8
Subject: [PATCH 03/11] char: report frontend open/closed state in 'query-chardev'
9ae3a8
9ae3a8
Message-id: <1406053883-21237-3-git-send-email-lersek@redhat.com>
9ae3a8
Patchwork-id: 60230
9ae3a8
O-Subject: [RHEL-7.1 qemu-kvm PATCH 2/2] char: report frontend open/closed state in 'query-chardev'
9ae3a8
Bugzilla: 1122151
9ae3a8
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
9ae3a8
RH-Acked-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
RH-Acked-by: Eric Blake <eblake@redhat.com>
9ae3a8
9ae3a8
In addition to the on-line reporting added in the previous patch, allow
9ae3a8
libvirt to query frontend state independently of events.
9ae3a8
9ae3a8
Libvirt's path to identify the guest agent channel it cares about differs
9ae3a8
between the event added in the previous patch and the QMP response field
9ae3a8
added here. The event identifies the frontend device, by "id". The
9ae3a8
'query-chardev' QMP command identifies the backend device (again by "id").
9ae3a8
The association is under libvirt's control.
9ae3a8
9ae3a8
RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376
9ae3a8
9ae3a8
Reviewed-by: Amit Shah <amit.shah@redhat.com>
9ae3a8
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
9ae3a8
(cherry picked from commit 32a97ea1711f43388e178b7c43e02143a61e47ee)
9ae3a8
---
9ae3a8
 qapi-schema.json |  8 +++++++-
9ae3a8
 qemu-char.c      |  1 +
9ae3a8
 qmp-commands.hx  | 19 ++++++++++++++-----
9ae3a8
 3 files changed, 22 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 qapi-schema.json |    8 +++++++-
9ae3a8
 qemu-char.c      |    1 +
9ae3a8
 qmp-commands.hx  |   19 ++++++++++++++-----
9ae3a8
 3 files changed, 22 insertions(+), 6 deletions(-)
9ae3a8
9ae3a8
diff --git a/qapi-schema.json b/qapi-schema.json
9ae3a8
index aaa86f5..604ec69 100644
9ae3a8
--- a/qapi-schema.json
9ae3a8
+++ b/qapi-schema.json
9ae3a8
@@ -418,12 +418,18 @@
9ae3a8
 #
9ae3a8
 # @filename: the filename of the character device
9ae3a8
 #
9ae3a8
+# @frontend-open: shows whether the frontend device attached to this backend
9ae3a8
+#                 (eg. with the chardev=... option) is in open or closed state
9ae3a8
+#                 (since 2.1)
9ae3a8
+#
9ae3a8
 # Notes: @filename is encoded using the QEMU command line character device
9ae3a8
 #        encoding.  See the QEMU man page for details.
9ae3a8
 #
9ae3a8
 # Since: 0.14.0
9ae3a8
 ##
9ae3a8
-{ 'type': 'ChardevInfo', 'data': {'label': 'str', 'filename': 'str'} }
9ae3a8
+{ 'type': 'ChardevInfo', 'data': {'label': 'str',
9ae3a8
+                                  'filename': 'str',
9ae3a8
+                                  'frontend-open': 'bool'} }
9ae3a8
 
9ae3a8
 ##
9ae3a8
 # @query-chardev:
9ae3a8
diff --git a/qemu-char.c b/qemu-char.c
9ae3a8
index 930f3d4..47ac55a 100644
9ae3a8
--- a/qemu-char.c
9ae3a8
+++ b/qemu-char.c
9ae3a8
@@ -3435,6 +3435,7 @@ ChardevInfoList *qmp_query_chardev(Error **errp)
9ae3a8
         info->value = g_malloc0(sizeof(*info->value));
9ae3a8
         info->value->label = g_strdup(chr->label);
9ae3a8
         info->value->filename = g_strdup(chr->filename);
9ae3a8
+        info->value->frontend_open = chr->fe_open;
9ae3a8
 
9ae3a8
         info->next = chr_list;
9ae3a8
         chr_list = info;
9ae3a8
diff --git a/qmp-commands.hx b/qmp-commands.hx
9ae3a8
index 1d4be84..405275c 100644
9ae3a8
--- a/qmp-commands.hx
9ae3a8
+++ b/qmp-commands.hx
9ae3a8
@@ -1782,19 +1782,28 @@ Each json-object contain the following:
9ae3a8
 
9ae3a8
 - "label": device's label (json-string)
9ae3a8
 - "filename": device's file (json-string)
9ae3a8
+- "frontend-open": open/closed state of the frontend device attached to this
9ae3a8
+                   backend (json-bool)
9ae3a8
 
9ae3a8
 Example:
9ae3a8
 
9ae3a8
 -> { "execute": "query-chardev" }
9ae3a8
 <- {
9ae3a8
-      "return":[
9ae3a8
+      "return": [
9ae3a8
+         {
9ae3a8
+            "label": "charchannel0",
9ae3a8
+            "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.agent,server",
9ae3a8
+            "frontend-open": false
9ae3a8
+         },
9ae3a8
          {
9ae3a8
-            "label":"monitor",
9ae3a8
-            "filename":"stdio"
9ae3a8
+            "label": "charmonitor",
9ae3a8
+            "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.monitor,server",
9ae3a8
+            "frontend-open": true
9ae3a8
          },
9ae3a8
          {
9ae3a8
-            "label":"serial0",
9ae3a8
-            "filename":"vc"
9ae3a8
+            "label": "charserial0",
9ae3a8
+            "filename": "pty:/dev/pts/2",
9ae3a8
+            "frontend-open": true
9ae3a8
          }
9ae3a8
       ]
9ae3a8
    }
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8