diff options
author | Jean-Philippe Brucker <jean-philippe.brucker@arm.com> | 2019-01-10 14:12:40 +0000 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2019-01-22 06:55:26 +0000 |
commit | b98ac59172405034be3886f7a37f9f2df5989b1f (patch) | |
tree | 94cdae002e5596e8fc3c106cb1b930150c415a39 | |
parent | 95242e44535bfb37b4ac4c90c353d5b73824a08e (diff) | |
download | kvmtool-b98ac59172405034be3886f7a37f9f2df5989b1f.tar.gz |
virtio: Add get_vq_count() callback
Modern virtio requires devices to report how many queues they support. Add
an operation to query all devices about their capacities.
Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r-- | include/kvm/virtio.h | 1 | ||||
-rw-r--r-- | virtio/9p.c | 6 | ||||
-rw-r--r-- | virtio/balloon.c | 6 | ||||
-rw-r--r-- | virtio/blk.c | 6 | ||||
-rw-r--r-- | virtio/console.c | 6 | ||||
-rw-r--r-- | virtio/net.c | 8 | ||||
-rw-r--r-- | virtio/rng.c | 6 | ||||
-rw-r--r-- | virtio/scsi.c | 6 |
8 files changed, 45 insertions, 0 deletions
diff --git a/include/kvm/virtio.h b/include/kvm/virtio.h index f1433210..cc49c9d3 100644 --- a/include/kvm/virtio.h +++ b/include/kvm/virtio.h @@ -184,6 +184,7 @@ struct virtio_ops { u8 *(*get_config)(struct kvm *kvm, void *dev); u32 (*get_host_features)(struct kvm *kvm, void *dev); void (*set_guest_features)(struct kvm *kvm, void *dev, u32 features); + int (*get_vq_count)(struct kvm *kvm, void *dev); int (*init_vq)(struct kvm *kvm, void *dev, u32 vq, u32 page_size, u32 align, u32 pfn); int (*notify_vq)(struct kvm *kvm, void *dev, u32 vq); diff --git a/virtio/9p.c b/virtio/9p.c index 4b93b4c7..94f7a8fd 100644 --- a/virtio/9p.c +++ b/virtio/9p.c @@ -1440,6 +1440,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) return size; } +static int get_vq_count(struct kvm *kvm, void *dev) +{ + return NUM_VIRT_QUEUES; +} + struct virtio_ops p9_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, @@ -1450,6 +1455,7 @@ struct virtio_ops p9_dev_virtio_ops = { .get_pfn_vq = get_pfn_vq, .get_size_vq = get_size_vq, .set_size_vq = set_size_vq, + .get_vq_count = get_vq_count, }; int virtio_9p_rootdir_parser(const struct option *opt, const char *arg, int unset) diff --git a/virtio/balloon.c b/virtio/balloon.c index 871d6e07..2c2e24ac 100644 --- a/virtio/balloon.c +++ b/virtio/balloon.c @@ -243,6 +243,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) return size; } +static int get_vq_count(struct kvm *kvm, void *dev) +{ + return NUM_VIRT_QUEUES; +} + struct virtio_ops bln_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, @@ -253,6 +258,7 @@ struct virtio_ops bln_dev_virtio_ops = { .get_pfn_vq = get_pfn_vq, .get_size_vq = get_size_vq, .set_size_vq = set_size_vq, + .get_vq_count = get_vq_count, }; int virtio_bln__init(struct kvm *kvm) diff --git a/virtio/blk.c b/virtio/blk.c index db9f4cc9..6502b8ce 100644 --- a/virtio/blk.c +++ b/virtio/blk.c @@ -248,10 +248,16 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) return size; } +static int get_vq_count(struct kvm *kvm, void *dev) +{ + return NUM_VIRT_QUEUES; +} + static struct virtio_ops blk_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features, + .get_vq_count = get_vq_count, .init_vq = init_vq, .notify_status = notify_status, .notify_vq = notify_vq, diff --git a/virtio/console.c b/virtio/console.c index b9df5c99..c96bc11f 100644 --- a/virtio/console.c +++ b/virtio/console.c @@ -202,10 +202,16 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) return size; } +static int get_vq_count(struct kvm *kvm, void *dev) +{ + return VIRTIO_CONSOLE_NUM_QUEUES; +} + static struct virtio_ops con_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features, + .get_vq_count = get_vq_count, .init_vq = init_vq, .notify_status = notify_status, .notify_vq = notify_vq, diff --git a/virtio/net.c b/virtio/net.c index 619b5458..3b08aead 100644 --- a/virtio/net.c +++ b/virtio/net.c @@ -681,10 +681,18 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) return size; } +static int get_vq_count(struct kvm *kvm, void *dev) +{ + struct net_dev *ndev = dev; + + return ndev->queue_pairs * 2 + 1; +} + static struct virtio_ops net_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, .set_guest_features = set_guest_features, + .get_vq_count = get_vq_count, .init_vq = init_vq, .get_pfn_vq = get_pfn_vq, .get_size_vq = get_size_vq, diff --git a/virtio/rng.c b/virtio/rng.c index 9b9e1283..fc0e3207 100644 --- a/virtio/rng.c +++ b/virtio/rng.c @@ -141,6 +141,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) return size; } +static int get_vq_count(struct kvm *kvm, void *dev) +{ + return NUM_VIRT_QUEUES; +} + static struct virtio_ops rng_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, @@ -150,6 +155,7 @@ static struct virtio_ops rng_dev_virtio_ops = { .get_pfn_vq = get_pfn_vq, .get_size_vq = get_size_vq, .set_size_vq = set_size_vq, + .get_vq_count = get_vq_count, }; int virtio_rng__init(struct kvm *kvm) diff --git a/virtio/scsi.c b/virtio/scsi.c index 788bfa2d..e21263c6 100644 --- a/virtio/scsi.c +++ b/virtio/scsi.c @@ -167,6 +167,11 @@ static int set_size_vq(struct kvm *kvm, void *dev, u32 vq, int size) return size; } +static int get_vq_count(struct kvm *kvm, void *dev) +{ + return NUM_VIRT_QUEUES; +} + static struct virtio_ops scsi_dev_virtio_ops = { .get_config = get_config, .get_host_features = get_host_features, @@ -179,6 +184,7 @@ static struct virtio_ops scsi_dev_virtio_ops = { .notify_vq = notify_vq, .notify_vq_gsi = notify_vq_gsi, .notify_vq_eventfd = notify_vq_eventfd, + .get_vq_count = get_vq_count, }; static void virtio_scsi_vhost_init(struct kvm *kvm, struct scsi_dev *sdev) |