dm: virtio: remove hv_caps from virtio_ops

currently, each virtio device has their own virtio_ops implementation.
Take virtio-blk for example:

static struct virtio_ops virtio_blk_ops = {
        "virtio_blk",
        1,
        sizeof(struct virtio_blk_config),
        virtio_blk_reset,
        virtio_blk_notify,
        virtio_blk_cfgread,
        virtio_blk_cfgwrite,
        NULL,
        NULL,
        VIRTIO_BLK_S_HOSTCAPS,
};

If start DM with two virtio-blk, this global variable will be
assigined to two virtio-blk instances. Changing hv_caps for one
instance will affect others. But different instances may need
different capabilities.

To support this requirement, we suggest to move hv_caps to
virtio_base structure, and each instance can return their own
capabilities.

Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Conghui Chen
2018-07-27 09:50:55 +00:00
committed by lijinxia
parent a2b299179d
commit f4fcf5d6eb
11 changed files with 12 additions and 18 deletions

View File

@@ -507,6 +507,7 @@ struct virtio_base {
pthread_mutex_t *mtx; /**< POSIX mutex, if any */
struct pci_vdev *dev; /**< PCI device instance */
uint64_t negotiated_caps; /**< negotiated capabilities */
uint64_t device_caps; /**< device capabilities */
struct virtio_vq_info *queues; /**< one per nvq */
int curq; /**< current queue */
uint8_t status; /**< value from last status write */
@@ -552,7 +553,6 @@ struct virtio_ops {
/**< to apply negotiated features */
void (*set_status)(void *, uint64_t);
/**< called to set device status */
uint64_t hv_caps; /**< hypervisor-provided capabilities */
};
#define VQ_ALLOC 0x01 /* set once we have a pfn */