qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga
@ 2014-06-26 15:50 Laszlo Ersek
  2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor Laszlo Ersek
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Laszlo Ersek @ 2014-06-26 15:50 UTC (permalink / raw)
  To: qemu-devel, mprivozn, kraxel, amit.shah, eblake, lcapitulino,
	lersek

Changes in v3: patch 1 creates the event with a "bool" field called
"open" in the data portion, instead of introducing a two-valued enum.
Patch 2 is left intact. Retested.

Laszlo Ersek (2):
  virtio-serial: report frontend connection state via monitor
  char: report frontend open/closed state in 'query-chardev'

 qapi-event.json          | 14 ++++++++++++++
 qapi-schema.json         |  8 +++++++-
 hw/char/virtio-console.c | 12 +++++++++---
 monitor.c                |  1 +
 qemu-char.c              |  1 +
 qmp-commands.hx          | 19 ++++++++++++++-----
 6 files changed, 46 insertions(+), 9 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor
  2014-06-26 15:50 [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Laszlo Ersek
@ 2014-06-26 15:50 ` Laszlo Ersek
  2014-06-27  4:45   ` Amit Shah
  2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 2/2] char: report frontend open/closed state in 'query-chardev' Laszlo Ersek
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Laszlo Ersek @ 2014-06-26 15:50 UTC (permalink / raw)
  To: qemu-devel, mprivozn, kraxel, amit.shah, eblake, lcapitulino,
	lersek

Libvirt wants to know about the guest-side connection state of some
virtio-serial ports (in particular the one(s) assigned to guest agent(s)).
Report such states with a new monitor event.

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---

Notes:
    v3:
    - replace status:VirtioSerialPortStatus with open:bool in the event
      body; drop now-useless VirtioSerialPortStatus type
    
    v2:
    - emit event unconditionally; drop per-port "report_connstate" property
      [Eric]
    - rate-limit the new event [Eric] -- unify it with other
      guest-triggerable events in monitor_qapi_event_init()
    - rebased to Wenchao's qapi-event series
    - introduce one event only, VSERPORT_CHANGE, and make the port status a
      parameter [Eric]

 qapi-event.json          | 14 ++++++++++++++
 hw/char/virtio-console.c | 12 +++++++++---
 monitor.c                |  1 +
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/qapi-event.json b/qapi-event.json
index e7a47f9..5bc8589 100644
--- a/qapi-event.json
+++ b/qapi-event.json
@@ -315,4 +315,18 @@
 ##
 { 'event': 'QUORUM_REPORT_BAD',
   'data': { '*error': 'str', 'node-name': 'str',
             'sector-num': 'int', 'sector-count': 'int' } }
+
+##
+# @VSERPORT_CHANGE
+#
+# Emitted when the guest opens or closes a virtio-serial port.
+#
+# @id: device identifier of the virtio-serial port
+#
+# @open: true if the guest has opened the virtio-serial port
+#
+# Since: 2.1
+##
+{ 'event': 'VSERPORT_CHANGE',
+  'data': { 'id': 'str', 'open': 'bool' } }
diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c
index 6c8be0f..54eb15f 100644
--- a/hw/char/virtio-console.c
+++ b/hw/char/virtio-console.c
@@ -13,8 +13,9 @@
 #include "sysemu/char.h"
 #include "qemu/error-report.h"
 #include "trace.h"
 #include "hw/virtio/virtio-serial.h"
+#include "qapi-event.h"
 
 #define TYPE_VIRTIO_CONSOLE_SERIAL_PORT "virtserialport"
 #define VIRTIO_CONSOLE(obj) \
     OBJECT_CHECK(VirtConsole, (obj), TYPE_VIRTIO_CONSOLE_SERIAL_PORT)
@@ -80,13 +81,18 @@ static ssize_t flush_buf(VirtIOSerialPort *port,
 /* Callback function that's called when the guest opens/closes the port */
 static void set_guest_connected(VirtIOSerialPort *port, int guest_connected)
 {
     VirtConsole *vcon = VIRTIO_CONSOLE(port);
+    DeviceState *dev = DEVICE(port);
 
-    if (!vcon->chr) {
-        return;
+    if (vcon->chr) {
+        qemu_chr_fe_set_open(vcon->chr, guest_connected);
+    }
+
+    if (dev->id) {
+        qapi_event_send_vserport_change(dev->id, guest_connected,
+                                        &error_abort);
     }
-    qemu_chr_fe_set_open(vcon->chr, guest_connected);
 }
 
 /* Readiness of the guest to accept data on a port */
 static int chr_can_read(void *opaque)
diff --git a/monitor.c b/monitor.c
index a8ab600..5fbf987 100644
--- a/monitor.c
+++ b/monitor.c
@@ -584,8 +584,9 @@ static void monitor_qapi_event_init(void)
     /* Limit guest-triggerable events to 1 per second */
     monitor_qapi_event_throttle(QAPI_EVENT_RTC_CHANGE, 1000);
     monitor_qapi_event_throttle(QAPI_EVENT_WATCHDOG, 1000);
     monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000);
+    monitor_qapi_event_throttle(QAPI_EVENT_VSERPORT_CHANGE, 1000);
     /* limit the rate of quorum events to avoid hammering the management */
     monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_REPORT_BAD, 1000);
     monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_FAILURE, 1000);
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH for-2.1 v3 2/2] char: report frontend open/closed state in 'query-chardev'
  2014-06-26 15:50 [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Laszlo Ersek
  2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor Laszlo Ersek
@ 2014-06-26 15:50 ` Laszlo Ersek
  2014-06-26 16:37 ` [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Eric Blake
  2014-06-27 13:36 ` Luiz Capitulino
  3 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2014-06-26 15:50 UTC (permalink / raw)
  To: qemu-devel, mprivozn, kraxel, amit.shah, eblake, lcapitulino,
	lersek

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>
---

Notes:
    v2:
    - rename "frontend_open" to "frontend-open" in the schema [Eric]
    - "frontend-open" is mandatory [Eric]
    - advertise / target qemu-2.1 with the new field

 qapi-schema.json |  8 +++++++-
 qemu-char.c      |  1 +
 qmp-commands.hx  | 19 ++++++++++++++-----
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/qapi-schema.json b/qapi-schema.json
index e7727a1..6842851 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -210,14 +210,20 @@
 # @label: the label 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
 #        encoding.  See the QEMU man page for details.
 #
 # Since: 0.14.0
 ##
-{ 'type': 'ChardevInfo', 'data': {'label': 'str', 'filename': 'str'} }
+{ 'type': 'ChardevInfo', 'data': {'label': 'str',
+                                  'filename': 'str',
+                                  'frontend-open': 'bool'} }
 
 ##
 # @query-chardev:
 #
diff --git a/qemu-char.c b/qemu-char.c
index 2e50a10..98fb0ab 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -3703,8 +3703,9 @@ ChardevInfoList *qmp_query_chardev(Error **errp)
         ChardevInfoList *info = g_malloc0(sizeof(*info));
         info->value = g_malloc0(sizeof(*info->value));
         info->value->label = g_strdup(chr->label);
         info->value->filename = g_strdup(chr->filename);
+        info->value->frontend_open = chr->fe_open;
 
         info->next = chr_list;
         chr_list = info;
     }
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e4a1c80..35f5146 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1920,21 +1920,30 @@ of all devices.
 Each json-object contain the following:
 
 - "label": device's label (json-string)
 - "filename": device's file (json-string)
+- "frontend-open": open/closed state of the frontend device attached to this
+                   backend (json-bool)
 
 Example:
 
 -> { "execute": "query-chardev" }
 <- {
-      "return":[
+      "return": [
          {
-            "label":"monitor",
-            "filename":"stdio"
+            "label": "charchannel0",
+            "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.agent,server",
+            "frontend-open": false
          },
          {
-            "label":"serial0",
-            "filename":"vc"
+            "label": "charmonitor",
+            "filename": "unix:/var/lib/libvirt/qemu/seabios.rhel6.monitor,server",
+            "frontend-open": true
+         },
+         {
+            "label": "charserial0",
+            "filename": "pty:/dev/pts/2",
+            "frontend-open": true
          }
       ]
    }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga
  2014-06-26 15:50 [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Laszlo Ersek
  2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor Laszlo Ersek
  2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 2/2] char: report frontend open/closed state in 'query-chardev' Laszlo Ersek
@ 2014-06-26 16:37 ` Eric Blake
  2014-06-26 20:16   ` Laszlo Ersek
  2014-06-27 13:36 ` Luiz Capitulino
  3 siblings, 1 reply; 9+ messages in thread
From: Eric Blake @ 2014-06-26 16:37 UTC (permalink / raw)
  To: Laszlo Ersek, qemu-devel, mprivozn, kraxel, amit.shah,
	lcapitulino

[-- Attachment #1: Type: text/plain, Size: 1092 bytes --]

On 06/26/2014 09:50 AM, Laszlo Ersek wrote:
> Changes in v3: patch 1 creates the event with a "bool" field called
> "open" in the data portion, instead of introducing a two-valued enum.
> Patch 2 is left intact. Retested.
> 
> Laszlo Ersek (2):
>   virtio-serial: report frontend connection state via monitor
>   char: report frontend open/closed state in 'query-chardev'

Series:
Reviewed-by: Eric Blake <eblake@redhat.com>

> 
>  qapi-event.json          | 14 ++++++++++++++
>  qapi-schema.json         |  8 +++++++-
>  hw/char/virtio-console.c | 12 +++++++++---
>  monitor.c                |  1 +
>  qemu-char.c              |  1 +
>  qmp-commands.hx          | 19 ++++++++++++++-----
>  6 files changed, 46 insertions(+), 9 deletions(-)

Luiz is probably going to revive qmp-events.txt, at which point that
file will need to be patched in a followup patch; I can help with that
process (it's documentation-only, so safe to take even after hard freeze).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga
  2014-06-26 16:37 ` [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Eric Blake
@ 2014-06-26 20:16   ` Laszlo Ersek
  2014-06-26 20:18     ` Laszlo Ersek
  0 siblings, 1 reply; 9+ messages in thread
From: Laszlo Ersek @ 2014-06-26 20:16 UTC (permalink / raw)
  To: Eric Blake, qemu-devel, mprivozn, kraxel, amit.shah, lcapitulino

On 06/26/14 18:37, Eric Blake wrote:
> On 06/26/2014 09:50 AM, Laszlo Ersek wrote:
>> Changes in v3: patch 1 creates the event with a "bool" field called
>> "open" in the data portion, instead of introducing a two-valued enum.
>> Patch 2 is left intact. Retested.
>>
>> Laszlo Ersek (2):
>>   virtio-serial: report frontend connection state via monitor
>>   char: report frontend open/closed state in 'query-chardev'
> 
> Series:
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
>>
>>  qapi-event.json          | 14 ++++++++++++++
>>  qapi-schema.json         |  8 +++++++-
>>  hw/char/virtio-console.c | 12 +++++++++---
>>  monitor.c                |  1 +
>>  qemu-char.c              |  1 +
>>  qmp-commands.hx          | 19 ++++++++++++++-----
>>  6 files changed, 46 insertions(+), 9 deletions(-)
> 
> Luiz is probably going to revive qmp-events.txt, at which point that
> file will need to be patched in a followup patch; I can help with that
> process (it's documentation-only, so safe to take even after hard freeze).

If it helps, here's two examples in advance (also, note to self):

2014-06-26 15:41:37.895+0000: 1637: debug :
qemuMonitorJSONIOProcessLine:172 : QEMU_MONITOR_RECV_EVENT:
mon=0x7f2e2400cfd0 event={"timestamp": {"seconds": 1403797297,
"microseconds": 895242}, "event": "VSERPORT_CHANGE", "data": {"open":
true, "id": "channel0"}}

2014-06-26 15:41:40.878+0000: 1637: debug :
qemuMonitorJSONIOProcessLine:172 : QEMU_MONITOR_RECV_EVENT:
mon=0x7f2e2400cfd0 event={"timestamp": {"seconds": 1403797300,
"microseconds": 878169}, "event": "VSERPORT_CHANGE", "data": {"open":
false, "id": "channel0"}}

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga
  2014-06-26 20:16   ` Laszlo Ersek
@ 2014-06-26 20:18     ` Laszlo Ersek
  0 siblings, 0 replies; 9+ messages in thread
From: Laszlo Ersek @ 2014-06-26 20:18 UTC (permalink / raw)
  To: Eric Blake, qemu-devel, mprivozn, kraxel, amit.shah, lcapitulino

On 06/26/14 22:16, Laszlo Ersek wrote:

> 2014-06-26 15:41:37.895+0000: 1637: debug :
> qemuMonitorJSONIOProcessLine:172 : QEMU_MONITOR_RECV_EVENT:
> mon=0x7f2e2400cfd0 event={"timestamp": {"seconds": 1403797297,
> "microseconds": 895242}, "event": "VSERPORT_CHANGE", "data": {"open":
> true, "id": "channel0"}}
> 
> 2014-06-26 15:41:40.878+0000: 1637: debug :
> qemuMonitorJSONIOProcessLine:172 : QEMU_MONITOR_RECV_EVENT:
> mon=0x7f2e2400cfd0 event={"timestamp": {"seconds": 1403797300,
> "microseconds": 878169}, "event": "VSERPORT_CHANGE", "data": {"open":
> false, "id": "channel0"}}

(BTW I did not ignore your suggestion about "qemu-monitor-event" --
RHEL-7's libvirt doesn't support it yet.)

Thanks
Laszlo

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor
  2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor Laszlo Ersek
@ 2014-06-27  4:45   ` Amit Shah
  2014-06-27 12:32     ` Luiz Capitulino
  0 siblings, 1 reply; 9+ messages in thread
From: Amit Shah @ 2014-06-27  4:45 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: mprivozn, lcapitulino, qemu-devel, kraxel

On (Thu) 26 Jun 2014 [17:50:02], Laszlo Ersek wrote:
> Libvirt wants to know about the guest-side connection state of some
> virtio-serial ports (in particular the one(s) assigned to guest agent(s)).
> Report such states with a new monitor event.
> 
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376
> Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Amit Shah <amit.shah@redhat.com>

Luiz, will you pick this up via your tree?

Thanks,

		Amit

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor
  2014-06-27  4:45   ` Amit Shah
@ 2014-06-27 12:32     ` Luiz Capitulino
  0 siblings, 0 replies; 9+ messages in thread
From: Luiz Capitulino @ 2014-06-27 12:32 UTC (permalink / raw)
  To: Amit Shah; +Cc: mprivozn, Laszlo Ersek, qemu-devel, kraxel

On Fri, 27 Jun 2014 10:15:21 +0530
Amit Shah <amit.shah@redhat.com> wrote:

> On (Thu) 26 Jun 2014 [17:50:02], Laszlo Ersek wrote:
> > Libvirt wants to know about the guest-side connection state of some
> > virtio-serial ports (in particular the one(s) assigned to guest agent(s)).
> > Report such states with a new monitor event.
> > 
> > RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1080376
> > Signed-off-by: Laszlo Ersek <lersek@redhat.com>
> 
> Reviewed-by: Amit Shah <amit.shah@redhat.com>
> 
> Luiz, will you pick this up via your tree?

Yes, will do it shortly.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga
  2014-06-26 15:50 [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Laszlo Ersek
                   ` (2 preceding siblings ...)
  2014-06-26 16:37 ` [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Eric Blake
@ 2014-06-27 13:36 ` Luiz Capitulino
  3 siblings, 0 replies; 9+ messages in thread
From: Luiz Capitulino @ 2014-06-27 13:36 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: amit.shah, mprivozn, qemu-devel, kraxel

On Thu, 26 Jun 2014 17:50:01 +0200
Laszlo Ersek <lersek@redhat.com> wrote:

> Changes in v3: patch 1 creates the event with a "bool" field called
> "open" in the data portion, instead of introducing a two-valued enum.
> Patch 2 is left intact. Retested.

Applied to the qmp branch, thanks for the effort for doing it on time!

> 
> Laszlo Ersek (2):
>   virtio-serial: report frontend connection state via monitor
>   char: report frontend open/closed state in 'query-chardev'
> 
>  qapi-event.json          | 14 ++++++++++++++
>  qapi-schema.json         |  8 +++++++-
>  hw/char/virtio-console.c | 12 +++++++++---
>  monitor.c                |  1 +
>  qemu-char.c              |  1 +
>  qmp-commands.hx          | 19 ++++++++++++++-----
>  6 files changed, 46 insertions(+), 9 deletions(-)
> 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-06-27 13:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-26 15:50 [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Laszlo Ersek
2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 1/2] virtio-serial: report frontend connection state via monitor Laszlo Ersek
2014-06-27  4:45   ` Amit Shah
2014-06-27 12:32     ` Luiz Capitulino
2014-06-26 15:50 ` [Qemu-devel] [PATCH for-2.1 v3 2/2] char: report frontend open/closed state in 'query-chardev' Laszlo Ersek
2014-06-26 16:37 ` [Qemu-devel] [PATCH for-2.1 v3 0/2] help libvirt know what's up with qga Eric Blake
2014-06-26 20:16   ` Laszlo Ersek
2014-06-26 20:18     ` Laszlo Ersek
2014-06-27 13:36 ` Luiz Capitulino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).