From patchwork Tue Feb 4 16:54:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 3578061 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8EC309F382 for ; Tue, 4 Feb 2014 16:55:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E247F2017D for ; Tue, 4 Feb 2014 16:55:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D1F5E2018B for ; Tue, 4 Feb 2014 16:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932296AbaBDQyq (ORCPT ); Tue, 4 Feb 2014 11:54:46 -0500 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:49671 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932261AbaBDQyc (ORCPT ); Tue, 4 Feb 2014 11:54:32 -0500 Received: from mudshark.cambridge.arm.com (mudshark.cambridge.arm.com [10.1.203.36]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s14GsAkm003413; Tue, 4 Feb 2014 16:54:10 GMT Received: by mudshark.cambridge.arm.com (Postfix, from userid 1000) id D7DD4C2B17; Tue, 4 Feb 2014 16:54:09 +0000 (GMT) From: Will Deacon To: kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, penberg@kernel.org, marc.zyngier@arm.com, arnd@arndb.de, Will Deacon Subject: [PATCH 17/17] kvm tools: ARM: allow default virtio transport to be passed on cmdline Date: Tue, 4 Feb 2014 16:54:05 +0000 Message-Id: <1391532845-2177-18-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1391532845-2177-1-git-send-email-will.deacon@arm.com> References: <1391532845-2177-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 X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch changes VIRTIO_DEFAULT_TRANS to take a struct kvm parameter, allowing architectures to choose the default transport dynamically. For ARM, this is driven by an arch-specific cmdline option. Signed-off-by: Will Deacon --- tools/kvm/arm/include/arm-common/kvm-arch.h | 3 ++- tools/kvm/arm/include/arm-common/kvm-config-arch.h | 12 ++++++++---- tools/kvm/powerpc/include/kvm/kvm-arch.h | 2 +- tools/kvm/virtio/9p.c | 2 +- tools/kvm/virtio/balloon.c | 2 +- tools/kvm/virtio/blk.c | 2 +- tools/kvm/virtio/console.c | 2 +- tools/kvm/virtio/rng.c | 2 +- tools/kvm/virtio/scsi.c | 2 +- tools/kvm/x86/include/kvm/kvm-arch.h | 2 +- 10 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tools/kvm/arm/include/arm-common/kvm-arch.h b/tools/kvm/arm/include/arm-common/kvm-arch.h index 8adfcd495c03..b6c4bf8de364 100644 --- a/tools/kvm/arm/include/arm-common/kvm-arch.h +++ b/tools/kvm/arm/include/arm-common/kvm-arch.h @@ -32,7 +32,8 @@ #define KVM_IRQ_OFFSET GIC_SPI_IRQ_BASE -#define VIRTIO_DEFAULT_TRANS VIRTIO_MMIO +#define VIRTIO_DEFAULT_TRANS(kvm) \ + ((kvm)->cfg.arch.virtio_trans_pci ? VIRTIO_PCI : VIRTIO_MMIO) static inline bool arm_addr_in_ioport_region(u64 phys_addr) { diff --git a/tools/kvm/arm/include/arm-common/kvm-config-arch.h b/tools/kvm/arm/include/arm-common/kvm-config-arch.h index f3baf392704d..a8ebd94a78f1 100644 --- a/tools/kvm/arm/include/arm-common/kvm-config-arch.h +++ b/tools/kvm/arm/include/arm-common/kvm-config-arch.h @@ -4,9 +4,10 @@ #include "kvm/parse-options.h" struct kvm_config_arch { - const char *dump_dtb_filename; - unsigned int force_cntfrq; - bool aarch32_guest; + const char *dump_dtb_filename; + unsigned int force_cntfrq; + bool virtio_trans_pci; + bool aarch32_guest; }; #define OPT_ARCH_RUN(pfx, cfg) \ @@ -17,6 +18,9 @@ struct kvm_config_arch { OPT_UINTEGER('\0', "override-bad-firmware-cntfrq", &(cfg)->force_cntfrq,\ "Specify Generic Timer frequency in guest DT to " \ "work around buggy secure firmware *Firmware should be " \ - "updated to program CNTFRQ correctly*"), + "updated to program CNTFRQ correctly*"), \ + OPT_BOOLEAN('\0', "force-pci", &(cfg)->virtio_trans_pci, \ + "Force virtio devices to use PCI as their default " \ + "transport"), #endif /* ARM_COMMON__KVM_CONFIG_ARCH_H */ diff --git a/tools/kvm/powerpc/include/kvm/kvm-arch.h b/tools/kvm/powerpc/include/kvm/kvm-arch.h index d2b52bf0f617..f8627a2a2dd3 100644 --- a/tools/kvm/powerpc/include/kvm/kvm-arch.h +++ b/tools/kvm/powerpc/include/kvm/kvm-arch.h @@ -44,7 +44,7 @@ #define KVM_IRQ_OFFSET 16 -#define VIRTIO_DEFAULT_TRANS VIRTIO_PCI +#define VIRTIO_DEFAULT_TRANS(kvm) VIRTIO_PCI struct spapr_phb; diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c index 127b13afdf0b..25cdd8c2e70b 100644 --- a/tools/kvm/virtio/9p.c +++ b/tools/kvm/virtio/9p.c @@ -1392,7 +1392,7 @@ 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_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_9P, + VIRTIO_DEFAULT_TRANS(kvm), PCI_DEVICE_ID_VIRTIO_9P, VIRTIO_ID_9P, PCI_CLASS_9P); } diff --git a/tools/kvm/virtio/balloon.c b/tools/kvm/virtio/balloon.c index 486353584904..f7dfb0be2875 100644 --- a/tools/kvm/virtio/balloon.c +++ b/tools/kvm/virtio/balloon.c @@ -262,7 +262,7 @@ 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_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_BLN, + VIRTIO_DEFAULT_TRANS(kvm), PCI_DEVICE_ID_VIRTIO_BLN, VIRTIO_ID_BALLOON, PCI_CLASS_BLN); if (compat_id == -1) diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c index ab1871673d46..4bed3a975d1d 100644 --- a/tools/kvm/virtio/blk.c +++ b/tools/kvm/virtio/blk.c @@ -260,7 +260,7 @@ static int virtio_blk__init_one(struct kvm *kvm, struct disk_image *disk) }; virtio_init(kvm, bdev, &bdev->vdev, &blk_dev_virtio_ops, - VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_BLK, + VIRTIO_DEFAULT_TRANS(kvm), 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 f982dab702e3..0474e2b0e668 100644 --- a/tools/kvm/virtio/console.c +++ b/tools/kvm/virtio/console.c @@ -210,7 +210,7 @@ int virtio_console__init(struct kvm *kvm) pthread_cond_init(&cdev.poll_cond, NULL); virtio_init(kvm, &cdev, &cdev.vdev, &con_dev_virtio_ops, - VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_CONSOLE, + VIRTIO_DEFAULT_TRANS(kvm), 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 394de710838d..8031368a7e73 100644 --- a/tools/kvm/virtio/rng.c +++ b/tools/kvm/virtio/rng.c @@ -171,7 +171,7 @@ int virtio_rng__init(struct kvm *kvm) } r = virtio_init(kvm, rdev, &rdev->vdev, &rng_dev_virtio_ops, - VIRTIO_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_RNG, + VIRTIO_DEFAULT_TRANS(kvm), 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 8da24209eb90..be254f30e61c 100644 --- a/tools/kvm/virtio/scsi.c +++ b/tools/kvm/virtio/scsi.c @@ -252,7 +252,7 @@ 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_DEFAULT_TRANS, PCI_DEVICE_ID_VIRTIO_SCSI, + VIRTIO_DEFAULT_TRANS(kvm), 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 29953a761aa4..a9f23b81f87e 100644 --- a/tools/kvm/x86/include/kvm/kvm-arch.h +++ b/tools/kvm/x86/include/kvm/kvm-arch.h @@ -27,7 +27,7 @@ #define KVM_IRQ_OFFSET 5 -#define VIRTIO_DEFAULT_TRANS VIRTIO_PCI +#define VIRTIO_DEFAULT_TRANS(kvm) VIRTIO_PCI struct kvm_arch { u16 boot_selector;