From patchwork Wed May 25 12:21:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 97370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5F9C8B6F8A for ; Thu, 26 May 2011 01:27:13 +1000 (EST) Received: from localhost ([::1]:47536 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPFzK-00063g-Hq for incoming@patchwork.ozlabs.org; Wed, 25 May 2011 11:27:10 -0400 Received: from eggs.gnu.org ([140.186.70.92]:52469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPFyF-0004Ci-Sq for qemu-devel@nongnu.org; Wed, 25 May 2011 11:26:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QPFyC-0006v1-Gr for qemu-devel@nongnu.org; Wed, 25 May 2011 11:26:03 -0400 Received: from oxygen-new.pond.sub.org ([78.46.104.156]:36442 helo=oxygen.pond.sub.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QPFyC-0006rQ-7g for qemu-devel@nongnu.org; Wed, 25 May 2011 11:26:00 -0400 Received: from oxygen-old.pond.sub.org (oxygen.pond.sub.org [IPv6:2a01:4f8:130:9021::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "oxygen.pond.sub.org", Issuer "CAcert Class 3 Root" (verified OK)) by oxygen.pond.sub.org (Postfix) with ESMTPS id ACFD6A2468 for ; Wed, 25 May 2011 14:21:15 +0200 (CEST) Received: from blackfin.pond.sub.org (p5B32BEFC.dip.t-dialin.net [91.50.190.252]) by oxygen-old.pond.sub.org (Postfix) with ESMTPA id 4EFE1277186 for ; Wed, 25 May 2011 14:21:15 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id CC1E0A4; Wed, 25 May 2011 14:21:14 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 25 May 2011 14:21:11 +0200 Message-Id: <1306326074-22737-3-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1306326074-22737-1-git-send-email-armbru@redhat.com> References: <1306326074-22737-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.46.104.156 Cc: amit.shah@redhat.com Subject: [Qemu-devel] [PATCH 2/5] virtio-serial: Clean up virtconsole detection 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 virtio-serial-bus needs to treat "virtconsole" devices specially. It uses VirtIOSerialPort member is_console to recognize them. It gets its value via property initialization. Cute hack, except it lets users mess with it: "-device virtconsole,is_console=0" isn't plugged into port 0 as it should. Move the flag to VirtIOSerialPortInfo. Keep the property for backward compatibility; its value has no effect. Signed-off-by: Markus Armbruster --- hw/virtio-console.c | 5 +++-- hw/virtio-serial-bus.c | 4 ++-- hw/virtio-serial.h | 8 ++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/virtio-console.c b/hw/virtio-console.c index de539c4..50b85f8 100644 --- a/hw/virtio-console.c +++ b/hw/virtio-console.c @@ -91,7 +91,7 @@ static int virtconsole_initfn(VirtIOSerialPort *port) { VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port); - port->is_console = true; + port->is_console_dummy = true; return generic_port_init(vcon, port); } @@ -113,10 +113,11 @@ static int virtconsole_exitfn(VirtIOSerialPort *port) static VirtIOSerialPortInfo virtconsole_info = { .qdev.name = "virtconsole", .qdev.size = sizeof(VirtConsole), + .is_console = true, .init = virtconsole_initfn, .exit = virtconsole_exitfn, .qdev.props = (Property[]) { - DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1), + DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console_dummy, 1), DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID), DEFINE_PROP_CHR("chardev", VirtConsole, chr), DEFINE_PROP_STRING("name", VirtConsole, port.name), diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index adbcf6a..d0a4ade 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -350,7 +350,7 @@ static void handle_control_message(VirtIOSerial *vser, void *buf, size_t len) * this port is a console port so that the guest can hook it * up to hvc. */ - if (port->is_console) { + if (port->info->is_console) { send_control_event(port, VIRTIO_CONSOLE_CONSOLE_PORT, 1); } @@ -722,7 +722,7 @@ static int virtser_port_qdev_init(DeviceState *qdev, DeviceInfo *base) * location 0. This is done for backward compatibility (old * kernel, new qemu). */ - plugging_port0 = port->is_console && !find_port_by_id(port->vser, 0); + plugging_port0 = info->is_console && !find_port_by_id(port->vser, 0); if (find_port_by_id(port->vser, port->id)) { error_report("virtio-serial-bus: A port already exists at id %u\n", diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h index 5eb948e..c0d1717 100644 --- a/hw/virtio-serial.h +++ b/hw/virtio-serial.h @@ -119,8 +119,8 @@ struct VirtIOSerialPort { uint32_t iov_idx; uint64_t iov_offset; - /* Identify if this is a port that binds with hvc in the guest */ - uint8_t is_console; + /* For property backward compatibility, not used otherwise */ + uint8_t is_console_dummy; /* Is the corresponding guest device open? */ bool guest_connected; @@ -132,6 +132,10 @@ struct VirtIOSerialPort { struct VirtIOSerialPortInfo { DeviceInfo qdev; + + /* Is this a device that binds with hvc in the guest? */ + bool is_console; + /* * The per-port (or per-app) init function that's called when a * new device is found on the bus.