[PATCH 17/17] kvm tools: ARM: allow default virtio transport to be passed on cmdline

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <will.deacon@xxxxxxx>
---
 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;
-- 
1.8.2.2

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux