diff mbox

[RFC,11/16] kvm tools: virtio: add dummy set_size_vq implementations

Message ID 1352721450-11340-12-git-send-email-will.deacon@arm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Will Deacon Nov. 12, 2012, 11:57 a.m. UTC
When a guest kernel initialises a virtio device using an MMIO transport,
it attempts to set the size of the virtual queue. For devices that expect
a PCI transport, this is not the case and, as such, our console, 9p and
rng virtio devices do not set a pointer for this function and subsequently
SEGV.

This patch adds a dummy implementation of the function to avoid the fatal
signal.

Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 tools/kvm/virtio/9p.c      |    7 +++++++
 tools/kvm/virtio/console.c |    7 +++++++
 tools/kvm/virtio/rng.c     |    7 +++++++
 3 files changed, 21 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/tools/kvm/virtio/9p.c b/tools/kvm/virtio/9p.c
index 835a8c4..a372c22 100644
--- a/tools/kvm/virtio/9p.c
+++ b/tools/kvm/virtio/9p.c
@@ -1300,6 +1300,12 @@  static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
 	return VIRTQUEUE_NUM;
 }
 
+static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
+{
+	/* FIXME: dynamic */
+	return size;
+}
+
 struct virtio_ops p9_dev_virtio_ops = (struct virtio_ops) {
 	.get_config		= get_config,
 	.get_host_features	= get_host_features,
@@ -1308,6 +1314,7 @@  struct virtio_ops p9_dev_virtio_ops = (struct virtio_ops) {
 	.notify_vq		= notify_vq,
 	.get_pfn_vq		= get_pfn_vq,
 	.get_size_vq		= get_size_vq,
+	.set_size_vq		= set_size_vq,
 };
 
 int virtio_9p_rootdir_parser(const struct option *opt, const char *arg, int unset)
diff --git a/tools/kvm/virtio/console.c b/tools/kvm/virtio/console.c
index 1df6cb0..ea5d974 100644
--- a/tools/kvm/virtio/console.c
+++ b/tools/kvm/virtio/console.c
@@ -172,6 +172,12 @@  static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
 	return VIRTIO_CONSOLE_QUEUE_SIZE;
 }
 
+static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
+{
+	/* FIXME: dynamic */
+	return size;
+}
+
 static struct virtio_ops con_dev_virtio_ops = (struct virtio_ops) {
 	.get_config		= get_config,
 	.get_host_features	= get_host_features,
@@ -180,6 +186,7 @@  static struct virtio_ops con_dev_virtio_ops = (struct virtio_ops) {
 	.notify_vq		= notify_vq,
 	.get_pfn_vq		= get_pfn_vq,
 	.get_size_vq		= get_size_vq,
+	.set_size_vq		= set_size_vq,
 };
 
 int virtio_console__init(struct kvm *kvm)
diff --git a/tools/kvm/virtio/rng.c b/tools/kvm/virtio/rng.c
index b2616d8..e1e4fc0 100644
--- a/tools/kvm/virtio/rng.c
+++ b/tools/kvm/virtio/rng.c
@@ -132,6 +132,12 @@  static int get_size_vq(struct kvm *kvm, void *dev, u32 vq)
 	return VIRTIO_RNG_QUEUE_SIZE;
 }
 
+static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size)
+{
+	/* FIXME: dynamic */
+	return size;
+}
+
 static struct virtio_ops rng_dev_virtio_ops = (struct virtio_ops) {
 	.get_config		= get_config,
 	.get_host_features	= get_host_features,
@@ -140,6 +146,7 @@  static struct virtio_ops rng_dev_virtio_ops = (struct virtio_ops) {
 	.notify_vq		= notify_vq,
 	.get_pfn_vq		= get_pfn_vq,
 	.get_size_vq		= get_size_vq,
+	.set_size_vq		= set_size_vq,
 };
 
 int virtio_rng__init(struct kvm *kvm)