Skip to content

Commit

Permalink
virtio: add API to detect legacy devices
Browse files Browse the repository at this point in the history
transports need to be able to detect legacy-only
devices (ATM balloon only) to use legacy path
to drive them.

Add a core API to do just that.
The implementation just blacklists balloon:
not too pretty, but let's not over-engineer.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
  • Loading branch information
Michael S. Tsirkin committed Dec 9, 2014
1 parent 48b3606 commit b6098c3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/virtio_config.h>
#include <linux/module.h>
#include <linux/idr.h>
#include <uapi/linux/virtio_ids.h>

/* Unique numbering for virtio devices. */
static DEFINE_IDA(virtio_index_ida);
Expand Down Expand Up @@ -267,6 +268,12 @@ static struct bus_type virtio_bus = {
.remove = virtio_dev_remove,
};

bool virtio_device_is_legacy_only(struct virtio_device_id id)
{
return id.device == VIRTIO_ID_BALLOON;
}
EXPORT_SYMBOL_GPL(virtio_device_is_legacy_only);

int register_virtio_driver(struct virtio_driver *driver)
{
/* Catch this early. */
Expand Down
2 changes: 2 additions & 0 deletions include/linux/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ struct virtio_device {
void *priv;
};

bool virtio_device_is_legacy_only(struct virtio_device_id id);

static inline struct virtio_device *dev_to_virtio(struct device *_dev)
{
return container_of(_dev, struct virtio_device, dev);
Expand Down

0 comments on commit b6098c3

Please sign in to comment.