From patchwork Mon Nov 12 11:57:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 1727941 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B4A16DFF38 for ; Mon, 12 Nov 2012 11:58:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752985Ab2KLL5y (ORCPT ); Mon, 12 Nov 2012 06:57:54 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:55177 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752900Ab2KLL5l (ORCPT ); Mon, 12 Nov 2012 06:57:41 -0500 Received: from mudshark.cambridge.arm.com (mudshark.cambridge.arm.com [10.1.79.58]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id qACBvZE7025864; Mon, 12 Nov 2012 11:57:36 GMT Received: by mudshark.cambridge.arm.com (Postfix, from userid 1000) id 32D46C2A96; Mon, 12 Nov 2012 11:57:34 +0000 (GMT) From: Will Deacon To: kvm@vger.kernel.org Cc: penberg@kernel.org, marc.zyngier@arm.com, c.dall@virtualopensystems.com, matt.evans@arm.com, peter.maydell@linaro.org, Will Deacon Subject: [RFC PATCH 12/16] kvm tools: allow arch to specify default virtio transport Date: Mon, 12 Nov 2012 11:57:26 +0000 Message-Id: <1352721450-11340-13-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1352721450-11340-1-git-send-email-will.deacon@arm.com> References: <1352721450-11340-1-git-send-email-will.deacon@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Some architectures may provide only a restricted PCI implementation and therefore prefer MMIO as the transport for virtio devices. This patch allows the arch backend to specify the default virtio transport. Some devices (e.g. net) allow the transport to be overriden by the user and are left alone by this change. Signed-off-by: Will Deacon --- tools/kvm/powerpc/include/kvm/kvm-arch.h | 2 ++ tools/kvm/virtio/9p.c | 3 ++- tools/kvm/virtio/balloon.c | 3 ++- tools/kvm/virtio/blk.c | 3 ++- tools/kvm/virtio/console.c | 3 ++- tools/kvm/virtio/rng.c | 3 ++- tools/kvm/virtio/scsi.c | 3 ++- tools/kvm/x86/include/kvm/kvm-arch.h | 2 ++ 8 files changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/kvm/powerpc/include/kvm/kvm-arch.h b/tools/kvm/powerpc/include/kvm/kvm-arch.h index dd8a307..d93e142 100644 --- a/tools/kvm/powerpc/include/kvm/kvm-arch.h +++ b/tools/kvm/powerpc/include/kvm/kvm-arch.h @@ -40,6 +40,8 @@ #define KVM_PCI_MMIO_AREA 0x1000000 #define KVM_VIRTIO_MMIO_AREA 0x2000000 +#define VIRTIO_DEFAULT_TRANS VIRTIO_PCI + struct spapr_phb; struct kvm_arch { diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c index a372c22..4665876 100644 --- a/tools/kvm/virtio/9p.c +++ b/tools/kvm/virtio/9p.c @@ -1390,7 +1390,8 @@ int virtio_9p__init(struct kvm *kvm) list_for_each_entry(p9dev, &devs, list) { virtio_init(kvm, p9dev, &p9dev->vdev, &p9_dev_virtio_ops, - VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_9P, VIRTIO_ID_9P, PCI_CLASS_9P); + VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_9P, + VIRTIO_ID_9P, PCI_CLASS_9P); } return 0; diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c index e08f628..3965b24 100644 --- a/tools/kvm/virtio/balloon.c +++ b/tools/kvm/virtio/balloon.c @@ -254,7 +254,8 @@ int virtio_bln__init(struct kvm *kvm) memset(&bdev.config, 0, sizeof(struct virtio_balloon_config)); virtio_init(kvm, &bdev, &bdev.vdev, &bln_dev_virtio_ops, - VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_BLN, VIRTIO_ID_BALLOON, PCI_CLASS_BLN); + VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_BLN, + VIRTIO_ID_BALLOON, PCI_CLASS_BLN); if (compat_id == -1) compat_id = virtio_compat_add_message("virtio-balloon", "CONFIG_VIRTIO_BALLOON"); diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c index 356a240..ec57e96 100644 --- a/tools/kvm/virtio/blk.c +++ b/tools/kvm/virtio/blk.c @@ -259,7 +259,8 @@ static int virtio_blk__init_one(struct kvm *kvm, struct disk_image *disk) }; virtio_init(kvm, bdev, &bdev->vdev, &blk_dev_virtio_ops, - VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_BLK, VIRTIO_ID_BLOCK, PCI_CLASS_BLK); + VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_BLK, + VIRTIO_ID_BLOCK, PCI_CLASS_BLK); list_add_tail(&bdev->list, &bdevs); diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c index ea5d974..74b6ffd 100644 --- a/tools/kvm/virtio/console.c +++ b/tools/kvm/virtio/console.c @@ -195,7 +195,8 @@ int virtio_console__init(struct kvm *kvm) return 0; virtio_init(kvm, &cdev, &cdev.vdev, &con_dev_virtio_ops, - VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_CONSOLE, VIRTIO_ID_CONSOLE, PCI_CLASS_CONSOLE); + VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_CONSOLE, + VIRTIO_ID_CONSOLE, PCI_CLASS_CONSOLE); if (compat_id == -1) compat_id = virtio_compat_add_message("virtio-console", "CONFIG_VIRTIO_CONSOLE"); diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c index e1e4fc0..1a09fdf 100644 --- a/tools/kvm/virtio/rng.c +++ b/tools/kvm/virtio/rng.c @@ -168,7 +168,8 @@ int virtio_rng__init(struct kvm *kvm) } r = virtio_init(kvm, rdev, &rdev->vdev, &rng_dev_virtio_ops, - VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_RNG, VIRTIO_ID_RNG, PCI_CLASS_RNG); + VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_RNG, + VIRTIO_ID_RNG, PCI_CLASS_RNG); if (r < 0) goto cleanup; diff --git a/tools/kvm/virtio/scsi.c b/tools/kvm/virtio/scsi.c index 881898b..7ba76d0 100644 --- a/tools/kvm/virtio/scsi.c +++ b/tools/kvm/virtio/scsi.c @@ -251,7 +251,8 @@ static int virtio_scsi_init_one(struct kvm *kvm, struct disk_image *disk) sdev->target.vhost_tpgt = strtol(disk->tpgt, NULL, 0); virtio_init(kvm, sdev, &sdev->vdev, &scsi_dev_virtio_ops, - VIRTIO_PCI, PCI_DEVICE_ID_VIRTIO_SCSI, VIRTIO_ID_SCSI, PCI_CLASS_BLK); + VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_SCSI, + VIRTIO_ID_SCSI, PCI_CLASS_BLK); list_add_tail(&sdev->list, &sdevs); diff --git a/tools/kvm/x86/include/kvm/kvm-arch.h b/tools/kvm/x86/include/kvm/kvm-arch.h index 30086f4..2aaedcc 100644 --- a/tools/kvm/x86/include/kvm/kvm-arch.h +++ b/tools/kvm/x86/include/kvm/kvm-arch.h @@ -23,6 +23,8 @@ #define KVM_PCI_MMIO_AREA (KVM_MMIO_START + 0x1000000) #define KVM_VIRTIO_MMIO_AREA (KVM_MMIO_START + 0x2000000) +#define VIRTIO_DEFAULT_TRANS VIRTIO_PCI + struct kvm_arch { u16 boot_selector; u16 boot_ip;