From patchwork Thu Jul 1 09:28:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 57495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 49420B707F for ; Thu, 1 Jul 2010 19:31:18 +1000 (EST) Received: from localhost ([127.0.0.1]:49965 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUG70-0007xu-VA for incoming@patchwork.ozlabs.org; Thu, 01 Jul 2010 05:31:15 -0400 Received: from [140.186.70.92] (port=52851 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OUG4M-00075Z-ES for qemu-devel@nongnu.org; Thu, 01 Jul 2010 05:28:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OUG4L-00071i-9Q for qemu-devel@nongnu.org; Thu, 01 Jul 2010 05:28:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3660) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OUG4L-00071M-2t for qemu-devel@nongnu.org; Thu, 01 Jul 2010 05:28:29 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o619SR3j012765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Jul 2010 05:28:27 -0400 Received: from localhost (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o619SNQ2009757; Thu, 1 Jul 2010 05:28:25 -0400 From: Amit Shah To: qemu list Date: Thu, 1 Jul 2010 14:58:16 +0530 Message-Id: <1c5b20f693ebc3882d01d8f2f9e807878251cd42.1277976486.git.amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Amit Shah Subject: [Qemu-devel] [PATCH 1/2] virtio-serial: Check if virtio queue is ready before consuming data X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If a virtio-serial port is removed before the guest comes up and initialises the virtqueues, qemu exits with the message Guest moved used index from 0 to 61440 This happens because we try to clear any pending buffers from the virtqueue. Ensure the virtqueue is initialised before calling any virtqueue operations. Signed-off-by: Amit Shah --- hw/virtio-serial-bus.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c index 7f9d28f..b89daa6 100644 --- a/hw/virtio-serial-bus.c +++ b/hw/virtio-serial-bus.c @@ -139,6 +139,9 @@ static void flush_queued_data(VirtIOSerialPort *port, bool discard) { assert(port); + if (!virtio_queue_ready(port->ovq)) { + return; + } do_flush_queued_data(port, port->ovq, &port->vser->vdev, discard); }