mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
virtio: add vhost support for virtio devices
This patch adds a get_vhost() callback function for VirtIODevices that returns the device's corresponding vhost_dev structure, if the vhost device is running. This patch also adds a vhost_started flag for VirtIODevices. Previously, a VirtIODevice wouldn't be able to tell if its corresponding vhost device was active or not. Signed-off-by: Jonah Palmer <jonah.palmer@oracle.com> Message-Id: <1648819405-25696-3-git-send-email-jonah.palmer@oracle.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
3857cd5c7f
commit
c255488d67
12 changed files with 76 additions and 1 deletions
|
@ -3620,6 +3620,14 @@ static bool dev_unplug_pending(void *opaque)
|
|||
return vdc->primary_unplug_pending(dev);
|
||||
}
|
||||
|
||||
static struct vhost_dev *virtio_net_get_vhost(VirtIODevice *vdev)
|
||||
{
|
||||
VirtIONet *n = VIRTIO_NET(vdev);
|
||||
NetClientState *nc = qemu_get_queue(n->nic);
|
||||
struct vhost_net *net = get_vhost_net(nc->peer);
|
||||
return &net->dev;
|
||||
}
|
||||
|
||||
static const VMStateDescription vmstate_virtio_net = {
|
||||
.name = "virtio-net",
|
||||
.minimum_version_id = VIRTIO_NET_VM_VERSION,
|
||||
|
@ -3722,6 +3730,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
|
|||
vdc->post_load = virtio_net_post_load_virtio;
|
||||
vdc->vmsd = &vmstate_virtio_net_device;
|
||||
vdc->primary_unplug_pending = primary_unplug_pending;
|
||||
vdc->get_vhost = virtio_net_get_vhost;
|
||||
}
|
||||
|
||||
static const TypeInfo virtio_net_info = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue