From patchwork Fri Jun 27 19:42:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 365154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2051714008B for ; Sat, 28 Jun 2014 05:47:51 +1000 (EST) Received: from localhost ([::1]:52274 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0c7h-0000Lj-Jm for incoming@patchwork.ozlabs.org; Fri, 27 Jun 2014 15:47:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0c2V-0002vn-8P for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:42:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X0c2L-0001ak-1P for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:42:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X0c2K-0001aS-Nv for qemu-devel@nongnu.org; Fri, 27 Jun 2014 15:42:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5RJgATT013966 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Jun 2014 15:42:11 -0400 Received: from localhost (ovpn-113-142.phx2.redhat.com [10.3.113.142]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5RJgAj8025016; Fri, 27 Jun 2014 15:42:10 -0400 From: Luiz Capitulino To: peter.maydell@linaro.org Date: Fri, 27 Jun 2014 15:42:01 -0400 Message-Id: <1403898123-22963-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1403898123-22963-1-git-send-email-lcapitulino@redhat.com> References: <1403898123-22963-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws Subject: [Qemu-devel] [PULL 6/8] virtio-serial: report frontend connection state via monitor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Laszlo Ersek 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 Reviewed-by: Eric Blake Reviewed-by: Amit Shah Signed-off-by: Luiz Capitulino --- hw/char/virtio-console.c | 12 +++++++++--- monitor.c | 1 + qapi/event.json | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) 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 @@ -14,6 +14,7 @@ #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) \ @@ -81,11 +82,16 @@ static ssize_t flush_buf(VirtIOSerialPort *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 */ diff --git a/monitor.c b/monitor.c index fd34ab7..5718d0b 100644 --- a/monitor.c +++ b/monitor.c @@ -588,6 +588,7 @@ static void monitor_qapi_event_init(void) monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000); monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_REPORT_BAD, 1000); monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_FAILURE, 1000); + monitor_qapi_event_throttle(QAPI_EVENT_VSERPORT_CHANGE, 1000); qmp_event_set_func_emit(monitor_qapi_event_queue); } diff --git a/qapi/event.json b/qapi/event.json index 8f817b1..ff97aeb 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -316,3 +316,17 @@ { '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' } }