thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-char-report-frontend-open-closed-state-in-query-char.patch

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