소스 검색

char: report frontend open/closed state in 'query-chardev'

In addition to the on-line reporting added in the previous patch, allow
libvirt to query frontend state independently of events.

Libvirt's path to identify the guest agent channel it cares about differs
between the event added in the previous patch and the QMP response field
added here. The event identifies the frontend device, by "id". The
'query-chardev' QMP command identifies the backend device (again by "id").
The association is under libvirt's control.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376

Reviewed-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Laszlo Ersek 11 년 전
부모
커밋
32a97ea171
3개의 변경된 파일22개의 추가작업 그리고 6개의 파일을 삭제
  1. 7 1
      qapi-schema.json
  2. 1 0
      qemu-char.c
  3. 14 5
      qmp-commands.hx

+ 7 - 1
qapi-schema.json

@@ -214,12 +214,18 @@
 #
 #
 # @filename: the filename of the character device
 # @filename: the filename of the character device
 #
 #
+# @frontend-open: shows whether the frontend device attached to this backend
+#                 (eg. with the chardev=... option) is in open or closed state
+#                 (since 2.1)
+#
 # Notes: @filename is encoded using the QEMU command line character device
 # Notes: @filename is encoded using the QEMU command line character device
 #        encoding.  See the QEMU man page for details.
 #        encoding.  See the QEMU man page for details.
 #
 #
 # Since: 0.14.0
 # Since: 0.14.0
 ##
 ##
-{ 'type': 'ChardevInfo', 'data': {'label': 'str', 'filename': 'str'} }
+{ 'type': 'ChardevInfo', 'data': {'label': 'str',
+                                  'filename': 'str',
+                                  'frontend-open': 'bool'} }
 
 
 ##
 ##
 # @query-chardev:
 # @query-chardev:

+ 1 - 0
qemu-char.c

@@ -3705,6 +3705,7 @@ ChardevInfoList *qmp_query_chardev(Error **errp)
         info->value = g_malloc0(sizeof(*info->value));
         info->value = g_malloc0(sizeof(*info->value));
         info->value->label = g_strdup(chr->label);
         info->value->label = g_strdup(chr->label);
         info->value->filename = g_strdup(chr->filename);
         info->value->filename = g_strdup(chr->filename);
+        info->value->frontend_open = chr->fe_open;
 
 
         info->next = chr_list;
         info->next = chr_list;
         chr_list = info;
         chr_list = info;

+ 14 - 5
qmp-commands.hx

@@ -1921,19 +1921,28 @@ Each json-object contain the following:
 
 
 - "label": device's label (json-string)
 - "label": device's label (json-string)
 - "filename": device's file (json-string)
 - "filename": device's file (json-string)
+- "frontend-open": open/closed state of the frontend device attached to this
+                   backend (json-bool)
 
 
 Example:
 Example:
 
 
 -> { "execute": "query-chardev" }
 -> { "execute": "query-chardev" }
 <- {
 <- {
-      "return":[
+      "return": [
+         {
+            "label": "charchannel0",
+            "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.agent,server",
+            "frontend-open": false
+         },
          {
          {
-            "label":"monitor",
-            "filename":"stdio"
+            "label": "charmonitor",
+            "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.monitor,server",
+            "frontend-open": true
          },
          },
          {
          {
-            "label":"serial0",
-            "filename":"vc"
+            "label": "charserial0",
+            "filename": "pty:/dev/pts/2",
+            "frontend-open": true
          }
          }
       ]
       ]
    }
    }