From patchwork Mon Nov 14 14:55:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 5104 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 45E6F23FEE for ; Mon, 14 Nov 2011 14:55:37 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 09E98A18118 for ; Mon, 14 Nov 2011 14:55:37 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id a26so583418faa.11 for ; Mon, 14 Nov 2011 06:55:37 -0800 (PST) Received: by 10.152.105.226 with SMTP id gp2mr14150234lab.28.1321282536832; Mon, 14 Nov 2011 06:55:36 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.40.7 with SMTP id t7cs42487lak; Mon, 14 Nov 2011 06:55:36 -0800 (PST) Received: by 10.216.178.140 with SMTP id f12mr452427wem.82.1321282532514; Mon, 14 Nov 2011 06:55:32 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id o76si10662412weq.10.2011.11.14.06.55.31 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 Nov 2011 06:55:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1RPxwW-0004y3-Fx; Mon, 14 Nov 2011 14:55:28 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Pawel Moll , Anthony Liguori Subject: [RFC 1/4] virtio: Add support for guest setting of queue size Date: Mon, 14 Nov 2011 14:55:25 +0000 Message-Id: <1321282528-19070-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1321282528-19070-1-git-send-email-peter.maydell@linaro.org> References: <1321282528-19070-1-git-send-email-peter.maydell@linaro.org> The MMIO virtio transport spec allows the guest to tell the host how large the queue size is. Add virtio_queue_set_num() function which implements this in the QEMU common virtio support code. Signed-off-by: Peter Maydell --- hw/virtio.c | 6 ++++++ hw/virtio.h | 1 + 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/hw/virtio.c b/hw/virtio.c index 7011b5b..5bd43a1 100644 --- a/hw/virtio.c +++ b/hw/virtio.c @@ -619,6 +619,12 @@ target_phys_addr_t virtio_queue_get_addr(VirtIODevice *vdev, int n) return vdev->vq[n].pa; } +void virtio_queue_set_num(VirtIODevice *vdev, int n, int num) +{ + vdev->vq[n].vring.num = num; + virtqueue_init(&vdev->vq[n]); +} + int virtio_queue_get_num(VirtIODevice *vdev, int n) { return vdev->vq[n].vring.num; diff --git a/hw/virtio.h b/hw/virtio.h index 2d18209..352aba6 100644 --- a/hw/virtio.h +++ b/hw/virtio.h @@ -178,6 +178,7 @@ void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data); void virtio_queue_set_addr(VirtIODevice *vdev, int n, target_phys_addr_t addr); target_phys_addr_t virtio_queue_get_addr(VirtIODevice *vdev, int n); +void virtio_queue_set_num(VirtIODevice *vdev, int n, int num); int virtio_queue_get_num(VirtIODevice *vdev, int n); void virtio_queue_notify(VirtIODevice *vdev, int n); uint16_t virtio_queue_vector(VirtIODevice *vdev, int n);