From patchwork Mon Apr 23 11:26:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 154391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 3E7FDB6EEC for ; Mon, 23 Apr 2012 21:26:53 +1000 (EST) Received: from localhost ([::1]:47290 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMHPv-0008Mt-26 for incoming@patchwork.ozlabs.org; Mon, 23 Apr 2012 07:26:51 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMHPf-0008Bw-CL for qemu-devel@nongnu.org; Mon, 23 Apr 2012 07:26:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMHPZ-00040F-2i for qemu-devel@nongnu.org; Mon, 23 Apr 2012 07:26:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMHPY-0003zv-Ql for qemu-devel@nongnu.org; Mon, 23 Apr 2012 07:26:28 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3NBQRiS012260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Apr 2012 07:26:27 -0400 Received: from garlic.tlv.redhat.com (spice-ovirt.tlv.redhat.com [10.35.4.71]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3NBQOkt017023; Mon, 23 Apr 2012 07:26:26 -0400 From: Alon Levy To: qemu-devel@nongnu.org Date: Mon, 23 Apr 2012 14:26:24 +0300 Message-Id: <1335180384-4804-2-git-send-email-alevy@redhat.com> In-Reply-To: <1335180384-4804-1-git-send-email-alevy@redhat.com> References: <1335180384-4804-1-git-send-email-alevy@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com Subject: [Qemu-devel] [PATCH 2/2] virtio-serial-bus: query guest features after guest sets them 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: Amit Shah Currently we query the virtio features w/o even waiting for the guest to boot up and ack features. Do the querying after set_features has succeeded. The check to enable guest_connected for the host to be able to write to the guest was flawed in this way, causing all ports to be initialised with the 'guest_connected' status to on. Signed-off-by: Amit Shah --- hw/virtio-serial-bus.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index e22940e..90b3674 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -512,6 +512,23 @@ static uint32_t get_features(VirtIODevice *vdev, uint32_t features) return features; } +static void set_features(VirtIODevice *vdev, uint32_t features) +{ + VirtIOSerial *vser; + VirtIOSerialPort *port; + + vser = DO_UPCAST(VirtIOSerial, vdev, vdev); + port = find_port_by_id(vser, 0); + + if (port && !use_multiport(vser)) { + /* + * Allow writes to guest in this case; we have no way of + * knowing if a guest port is connected. + */ + port->guest_connected = true; + } +} + /* Guest requested config info */ static void get_config(VirtIODevice *vdev, uint8_t *config_data) { @@ -798,14 +815,6 @@ static int virtser_port_qdev_init(DeviceState *qdev) return ret; } - if (!use_multiport(port->vser)) { - /* - * Allow writes to guest in this case; we have no way of - * knowing if a guest port is connected. - */ - port->guest_connected = true; - } - port->elem.out_num = 0; QTAILQ_INSERT_TAIL(&port->vser->ports, port, next); @@ -903,6 +912,7 @@ VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *conf) mark_port_added(vser, 0); vser->vdev.get_features = get_features; + vser->vdev.set_features = set_features; vser->vdev.get_config = get_config; vser->vdev.set_config = set_config;