From: "Michael S. Tsirkin" <mst@redhat.com> To: qemu-devel@nongnu.org Cc: "Peter Maydell" <peter.maydell@linaro.org>, "Jonah Palmer" <jonah.palmer@oracle.com>, "Raphael Norwitz" <raphael.norwitz@nutanix.com>, "Kevin Wolf" <kwolf@redhat.com>, "Hanna Reitz" <hreitz@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Gerd Hoffmann" <kraxel@redhat.com>, "Jason Wang" <jasowang@redhat.com>, "Paolo Bonzini" <pbonzini@redhat.com>, "Fam Zheng" <fam@euphon.net>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Stefan Hajnoczi" <stefanha@redhat.com>, "Mathieu Poirier" <mathieu.poirier@linaro.org>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, qemu-block@nongnu.org, virtio-fs@redhat.com Subject: [PULL v2 71/86] virtio: add vhost support for virtio devices Date: Mon, 16 May 2022 16:55:04 -0400 [thread overview] Message-ID: <20220516204913.542894-72-mst@redhat.com> (raw) In-Reply-To: <20220516204913.542894-1-mst@redhat.com> From: Jonah Palmer <jonah.palmer@oracle.com> 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> --- include/hw/virtio/virtio.h | 3 +++ hw/block/vhost-user-blk.c | 7 +++++++ hw/display/vhost-user-gpu.c | 7 +++++++ hw/input/vhost-user-input.c | 7 +++++++ hw/net/virtio-net.c | 9 +++++++++ hw/scsi/vhost-scsi.c | 8 ++++++++ hw/virtio/vhost-user-fs.c | 7 +++++++ hw/virtio/vhost-user-rng.c | 7 +++++++ hw/virtio/vhost-vsock-common.c | 7 +++++++ hw/virtio/vhost.c | 4 +++- hw/virtio/virtio-crypto.c | 10 ++++++++++ hw/virtio/virtio.c | 1 + 12 files changed, 76 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b6890ffa70..db1c0ddf6b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -22,6 +22,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" +#include "hw/virtio/vhost.h" /* A guest should never accept this. It implies negotiation is broken. */ #define VIRTIO_F_BAD_FEATURE 30 @@ -102,6 +103,7 @@ struct VirtIODevice bool started; bool start_on_kick; /* when virtio 1.0 feature has not been negotiated */ bool disable_legacy_check; + bool vhost_started; VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; @@ -160,6 +162,7 @@ struct VirtioDeviceClass { int (*post_load)(VirtIODevice *vdev); const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); + struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); }; void virtio_instance_init_common(Object *proxy_obj, void *data, diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index e8cb170032..5dca4eab09 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -569,6 +569,12 @@ static void vhost_user_blk_instance_init(Object *obj) "/disk@0,0", DEVICE(obj)); } +static struct vhost_dev *vhost_user_blk_get_vhost(VirtIODevice *vdev) +{ + VHostUserBlk *s = VHOST_USER_BLK(vdev); + return &s->dev; +} + static const VMStateDescription vmstate_vhost_user_blk = { .name = "vhost-user-blk", .minimum_version_id = 1, @@ -603,6 +609,7 @@ static void vhost_user_blk_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_user_blk_get_features; vdc->set_status = vhost_user_blk_set_status; vdc->reset = vhost_user_blk_reset; + vdc->get_vhost = vhost_user_blk_get_vhost; } static const TypeInfo vhost_user_blk_info = { diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 09818231bd..96e56c4467 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -565,6 +565,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp) g->vhost_gpu_fd = -1; } +static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) +{ + VhostUserGPU *g = VHOST_USER_GPU(vdev); + return &g->vhost->dev; +} + static Property vhost_user_gpu_properties[] = { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), DEFINE_PROP_END_OF_LIST(), @@ -586,6 +592,7 @@ vhost_user_gpu_class_init(ObjectClass *klass, void *data) vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending; vdc->get_config = vhost_user_gpu_get_config; vdc->set_config = vhost_user_gpu_set_config; + vdc->get_vhost = vhost_user_gpu_get_vhost; device_class_set_props(dc, vhost_user_gpu_properties); } diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c index aeb0624fe5..1352e372ff 100644 --- a/hw/input/vhost-user-input.c +++ b/hw/input/vhost-user-input.c @@ -78,6 +78,12 @@ static void vhost_input_set_config(VirtIODevice *vdev, virtio_notify_config(vdev); } +static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) +{ + VHostUserInput *vhi = VHOST_USER_INPUT(vdev); + return &vhi->vhost->dev; +} + static const VMStateDescription vmstate_vhost_input = { .name = "vhost-user-input", .unmigratable = 1, @@ -92,6 +98,7 @@ static void vhost_input_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_vhost_input; vdc->get_config = vhost_input_get_config; vdc->set_config = vhost_input_set_config; + vdc->get_vhost = vhost_input_get_vhost; vic->realize = vhost_input_realize; vic->change_active = vhost_input_change_active; } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index bd0224caaf..a788f1c5c7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -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 = { diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 778f43e4c1..3059068175 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -273,6 +273,13 @@ static void vhost_scsi_unrealize(DeviceState *dev) virtio_scsi_common_unrealize(dev); } +static struct vhost_dev *vhost_scsi_get_vhost(VirtIODevice *vdev) +{ + VHostSCSI *s = VHOST_SCSI(vdev); + VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); + return &vsc->dev; +} + static Property vhost_scsi_properties[] = { DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd), DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn), @@ -307,6 +314,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_scsi_common_get_features; vdc->set_config = vhost_scsi_common_set_config; vdc->set_status = vhost_scsi_set_status; + vdc->get_vhost = vhost_scsi_get_vhost; fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index b875640147..e513e4fdda 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -276,6 +276,12 @@ static void vuf_device_unrealize(DeviceState *dev) fs->vhost_dev.vqs = NULL; } +static struct vhost_dev *vuf_get_vhost(VirtIODevice *vdev) +{ + VHostUserFS *fs = VHOST_USER_FS(vdev); + return &fs->vhost_dev; +} + static const VMStateDescription vuf_vmstate = { .name = "vhost-user-fs", .unmigratable = 1, @@ -313,6 +319,7 @@ static void vuf_class_init(ObjectClass *klass, void *data) vdc->set_status = vuf_set_status; vdc->guest_notifier_mask = vuf_guest_notifier_mask; vdc->guest_notifier_pending = vuf_guest_notifier_pending; + vdc->get_vhost = vuf_get_vhost; } static const TypeInfo vuf_info = { diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 08bccba9dc..3a7bf8e32d 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -247,6 +247,12 @@ static void vu_rng_device_unrealize(DeviceState *dev) vhost_user_cleanup(&rng->vhost_user); } +static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) +{ + VHostUserRNG *rng = VHOST_USER_RNG(vdev); + return &rng->vhost_dev; +} + static const VMStateDescription vu_rng_vmstate = { .name = "vhost-user-rng", .unmigratable = 1, @@ -272,6 +278,7 @@ static void vu_rng_class_init(ObjectClass *klass, void *data) vdc->set_status = vu_rng_set_status; vdc->guest_notifier_mask = vu_rng_guest_notifier_mask; vdc->guest_notifier_pending = vu_rng_guest_notifier_pending; + vdc->get_vhost = vu_rng_get_vhost; } static const TypeInfo vu_rng_info = { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index ad5c8ff5d5..7394818e00 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -258,6 +258,12 @@ void vhost_vsock_common_unrealize(VirtIODevice *vdev) virtio_cleanup(vdev); } +static struct vhost_dev *vhost_vsock_common_get_vhost(VirtIODevice *vdev) +{ + VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); + return &vvc->vhost_dev; +} + static Property vhost_vsock_common_properties[] = { DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSockCommon, seqpacket, ON_OFF_AUTO_AUTO), @@ -273,6 +279,7 @@ static void vhost_vsock_common_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); vdc->guest_notifier_mask = vhost_vsock_common_guest_notifier_mask; vdc->guest_notifier_pending = vhost_vsock_common_guest_notifier_pending; + vdc->get_vhost = vhost_vsock_common_get_vhost; } static const TypeInfo vhost_vsock_common_info = { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2bc72c27c5..dd3263df56 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1738,6 +1738,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + vdev->vhost_started = true; hdev->started = true; hdev->vdev = vdev; @@ -1810,7 +1811,7 @@ fail_vq: fail_mem: fail_features: - + vdev->vhost_started = false; hdev->started = false; return r; } @@ -1841,6 +1842,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) } vhost_log_put(hdev, true); hdev->started = false; + vdev->vhost_started = false; hdev->vdev = NULL; } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index df9adb2c07..c3829e7498 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -961,6 +961,15 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } +static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev) +{ + VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev); + CryptoDevBackend *b = vcrypto->cryptodev; + CryptoDevBackendClient *cc = b->conf.peers.ccs[0]; + CryptoDevBackendVhost *vhost_crypto = cryptodev_get_vhost(cc, b, 0); + return &vhost_crypto->dev; +} + static void virtio_crypto_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -977,6 +986,7 @@ static void virtio_crypto_class_init(ObjectClass *klass, void *data) vdc->set_status = virtio_crypto_set_status; vdc->guest_notifier_mask = virtio_crypto_guest_notifier_mask; vdc->guest_notifier_pending = virtio_crypto_guest_notifier_pending; + vdc->get_vhost = virtio_crypto_get_vhost; } static void virtio_crypto_instance_init(Object *obj) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7f9fcfd06d..5d607aeaa0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3271,6 +3271,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size) vdev->start_on_kick = false; vdev->started = false; + vdev->vhost_started = false; vdev->device_id = device_id; vdev->status = 0; qatomic_set(&vdev->isr, 0); -- MST
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com> To: qemu-devel@nongnu.org Cc: "Peter Maydell" <peter.maydell@linaro.org>, "Jonah Palmer" <jonah.palmer@oracle.com>, "Raphael Norwitz" <raphael.norwitz@nutanix.com>, "Kevin Wolf" <kwolf@redhat.com>, "Hanna Reitz" <hreitz@redhat.com>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, "Gerd Hoffmann" <kraxel@redhat.com>, "Jason Wang" <jasowang@redhat.com>, "Paolo Bonzini" <pbonzini@redhat.com>, "Fam Zheng" <fam@euphon.net>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, "Stefan Hajnoczi" <stefanha@redhat.com>, "Mathieu Poirier" <mathieu.poirier@linaro.org>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, qemu-block@nongnu.org, virtio-fs@redhat.com Subject: [Virtio-fs] [PULL v2 71/86] virtio: add vhost support for virtio devices Date: Mon, 16 May 2022 16:55:04 -0400 [thread overview] Message-ID: <20220516204913.542894-72-mst@redhat.com> (raw) In-Reply-To: <20220516204913.542894-1-mst@redhat.com> From: Jonah Palmer <jonah.palmer@oracle.com> 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> --- include/hw/virtio/virtio.h | 3 +++ hw/block/vhost-user-blk.c | 7 +++++++ hw/display/vhost-user-gpu.c | 7 +++++++ hw/input/vhost-user-input.c | 7 +++++++ hw/net/virtio-net.c | 9 +++++++++ hw/scsi/vhost-scsi.c | 8 ++++++++ hw/virtio/vhost-user-fs.c | 7 +++++++ hw/virtio/vhost-user-rng.c | 7 +++++++ hw/virtio/vhost-vsock-common.c | 7 +++++++ hw/virtio/vhost.c | 4 +++- hw/virtio/virtio-crypto.c | 10 ++++++++++ hw/virtio/virtio.c | 1 + 12 files changed, 76 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b6890ffa70..db1c0ddf6b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -22,6 +22,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" +#include "hw/virtio/vhost.h" /* A guest should never accept this. It implies negotiation is broken. */ #define VIRTIO_F_BAD_FEATURE 30 @@ -102,6 +103,7 @@ struct VirtIODevice bool started; bool start_on_kick; /* when virtio 1.0 feature has not been negotiated */ bool disable_legacy_check; + bool vhost_started; VMChangeStateEntry *vmstate; char *bus_name; uint8_t device_endian; @@ -160,6 +162,7 @@ struct VirtioDeviceClass { int (*post_load)(VirtIODevice *vdev); const VMStateDescription *vmsd; bool (*primary_unplug_pending)(void *opaque); + struct vhost_dev *(*get_vhost)(VirtIODevice *vdev); }; void virtio_instance_init_common(Object *proxy_obj, void *data, diff --git a/hw/block/vhost-user-blk.c b/hw/block/vhost-user-blk.c index e8cb170032..5dca4eab09 100644 --- a/hw/block/vhost-user-blk.c +++ b/hw/block/vhost-user-blk.c @@ -569,6 +569,12 @@ static void vhost_user_blk_instance_init(Object *obj) "/disk@0,0", DEVICE(obj)); } +static struct vhost_dev *vhost_user_blk_get_vhost(VirtIODevice *vdev) +{ + VHostUserBlk *s = VHOST_USER_BLK(vdev); + return &s->dev; +} + static const VMStateDescription vmstate_vhost_user_blk = { .name = "vhost-user-blk", .minimum_version_id = 1, @@ -603,6 +609,7 @@ static void vhost_user_blk_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_user_blk_get_features; vdc->set_status = vhost_user_blk_set_status; vdc->reset = vhost_user_blk_reset; + vdc->get_vhost = vhost_user_blk_get_vhost; } static const TypeInfo vhost_user_blk_info = { diff --git a/hw/display/vhost-user-gpu.c b/hw/display/vhost-user-gpu.c index 09818231bd..96e56c4467 100644 --- a/hw/display/vhost-user-gpu.c +++ b/hw/display/vhost-user-gpu.c @@ -565,6 +565,12 @@ vhost_user_gpu_device_realize(DeviceState *qdev, Error **errp) g->vhost_gpu_fd = -1; } +static struct vhost_dev *vhost_user_gpu_get_vhost(VirtIODevice *vdev) +{ + VhostUserGPU *g = VHOST_USER_GPU(vdev); + return &g->vhost->dev; +} + static Property vhost_user_gpu_properties[] = { VIRTIO_GPU_BASE_PROPERTIES(VhostUserGPU, parent_obj.conf), DEFINE_PROP_END_OF_LIST(), @@ -586,6 +592,7 @@ vhost_user_gpu_class_init(ObjectClass *klass, void *data) vdc->guest_notifier_pending = vhost_user_gpu_guest_notifier_pending; vdc->get_config = vhost_user_gpu_get_config; vdc->set_config = vhost_user_gpu_set_config; + vdc->get_vhost = vhost_user_gpu_get_vhost; device_class_set_props(dc, vhost_user_gpu_properties); } diff --git a/hw/input/vhost-user-input.c b/hw/input/vhost-user-input.c index aeb0624fe5..1352e372ff 100644 --- a/hw/input/vhost-user-input.c +++ b/hw/input/vhost-user-input.c @@ -78,6 +78,12 @@ static void vhost_input_set_config(VirtIODevice *vdev, virtio_notify_config(vdev); } +static struct vhost_dev *vhost_input_get_vhost(VirtIODevice *vdev) +{ + VHostUserInput *vhi = VHOST_USER_INPUT(vdev); + return &vhi->vhost->dev; +} + static const VMStateDescription vmstate_vhost_input = { .name = "vhost-user-input", .unmigratable = 1, @@ -92,6 +98,7 @@ static void vhost_input_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_vhost_input; vdc->get_config = vhost_input_get_config; vdc->set_config = vhost_input_set_config; + vdc->get_vhost = vhost_input_get_vhost; vic->realize = vhost_input_realize; vic->change_active = vhost_input_change_active; } diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index bd0224caaf..a788f1c5c7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -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 = { diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c index 778f43e4c1..3059068175 100644 --- a/hw/scsi/vhost-scsi.c +++ b/hw/scsi/vhost-scsi.c @@ -273,6 +273,13 @@ static void vhost_scsi_unrealize(DeviceState *dev) virtio_scsi_common_unrealize(dev); } +static struct vhost_dev *vhost_scsi_get_vhost(VirtIODevice *vdev) +{ + VHostSCSI *s = VHOST_SCSI(vdev); + VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s); + return &vsc->dev; +} + static Property vhost_scsi_properties[] = { DEFINE_PROP_STRING("vhostfd", VirtIOSCSICommon, conf.vhostfd), DEFINE_PROP_STRING("wwpn", VirtIOSCSICommon, conf.wwpn), @@ -307,6 +314,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data) vdc->get_features = vhost_scsi_common_get_features; vdc->set_config = vhost_scsi_common_set_config; vdc->set_status = vhost_scsi_set_status; + vdc->get_vhost = vhost_scsi_get_vhost; fwc->get_dev_path = vhost_scsi_common_get_fw_dev_path; } diff --git a/hw/virtio/vhost-user-fs.c b/hw/virtio/vhost-user-fs.c index b875640147..e513e4fdda 100644 --- a/hw/virtio/vhost-user-fs.c +++ b/hw/virtio/vhost-user-fs.c @@ -276,6 +276,12 @@ static void vuf_device_unrealize(DeviceState *dev) fs->vhost_dev.vqs = NULL; } +static struct vhost_dev *vuf_get_vhost(VirtIODevice *vdev) +{ + VHostUserFS *fs = VHOST_USER_FS(vdev); + return &fs->vhost_dev; +} + static const VMStateDescription vuf_vmstate = { .name = "vhost-user-fs", .unmigratable = 1, @@ -313,6 +319,7 @@ static void vuf_class_init(ObjectClass *klass, void *data) vdc->set_status = vuf_set_status; vdc->guest_notifier_mask = vuf_guest_notifier_mask; vdc->guest_notifier_pending = vuf_guest_notifier_pending; + vdc->get_vhost = vuf_get_vhost; } static const TypeInfo vuf_info = { diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c index 08bccba9dc..3a7bf8e32d 100644 --- a/hw/virtio/vhost-user-rng.c +++ b/hw/virtio/vhost-user-rng.c @@ -247,6 +247,12 @@ static void vu_rng_device_unrealize(DeviceState *dev) vhost_user_cleanup(&rng->vhost_user); } +static struct vhost_dev *vu_rng_get_vhost(VirtIODevice *vdev) +{ + VHostUserRNG *rng = VHOST_USER_RNG(vdev); + return &rng->vhost_dev; +} + static const VMStateDescription vu_rng_vmstate = { .name = "vhost-user-rng", .unmigratable = 1, @@ -272,6 +278,7 @@ static void vu_rng_class_init(ObjectClass *klass, void *data) vdc->set_status = vu_rng_set_status; vdc->guest_notifier_mask = vu_rng_guest_notifier_mask; vdc->guest_notifier_pending = vu_rng_guest_notifier_pending; + vdc->get_vhost = vu_rng_get_vhost; } static const TypeInfo vu_rng_info = { diff --git a/hw/virtio/vhost-vsock-common.c b/hw/virtio/vhost-vsock-common.c index ad5c8ff5d5..7394818e00 100644 --- a/hw/virtio/vhost-vsock-common.c +++ b/hw/virtio/vhost-vsock-common.c @@ -258,6 +258,12 @@ void vhost_vsock_common_unrealize(VirtIODevice *vdev) virtio_cleanup(vdev); } +static struct vhost_dev *vhost_vsock_common_get_vhost(VirtIODevice *vdev) +{ + VHostVSockCommon *vvc = VHOST_VSOCK_COMMON(vdev); + return &vvc->vhost_dev; +} + static Property vhost_vsock_common_properties[] = { DEFINE_PROP_ON_OFF_AUTO("seqpacket", VHostVSockCommon, seqpacket, ON_OFF_AUTO_AUTO), @@ -273,6 +279,7 @@ static void vhost_vsock_common_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); vdc->guest_notifier_mask = vhost_vsock_common_guest_notifier_mask; vdc->guest_notifier_pending = vhost_vsock_common_guest_notifier_pending; + vdc->get_vhost = vhost_vsock_common_get_vhost; } static const TypeInfo vhost_vsock_common_info = { diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 2bc72c27c5..dd3263df56 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1738,6 +1738,7 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) /* should only be called after backend is connected */ assert(hdev->vhost_ops); + vdev->vhost_started = true; hdev->started = true; hdev->vdev = vdev; @@ -1810,7 +1811,7 @@ fail_vq: fail_mem: fail_features: - + vdev->vhost_started = false; hdev->started = false; return r; } @@ -1841,6 +1842,7 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) } vhost_log_put(hdev, true); hdev->started = false; + vdev->vhost_started = false; hdev->vdev = NULL; } diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index df9adb2c07..c3829e7498 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -961,6 +961,15 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx) return cryptodev_vhost_virtqueue_pending(vdev, queue, idx); } +static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev) +{ + VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev); + CryptoDevBackend *b = vcrypto->cryptodev; + CryptoDevBackendClient *cc = b->conf.peers.ccs[0]; + CryptoDevBackendVhost *vhost_crypto = cryptodev_get_vhost(cc, b, 0); + return &vhost_crypto->dev; +} + static void virtio_crypto_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -977,6 +986,7 @@ static void virtio_crypto_class_init(ObjectClass *klass, void *data) vdc->set_status = virtio_crypto_set_status; vdc->guest_notifier_mask = virtio_crypto_guest_notifier_mask; vdc->guest_notifier_pending = virtio_crypto_guest_notifier_pending; + vdc->get_vhost = virtio_crypto_get_vhost; } static void virtio_crypto_instance_init(Object *obj) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 7f9fcfd06d..5d607aeaa0 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3271,6 +3271,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size) vdev->start_on_kick = false; vdev->started = false; + vdev->vhost_started = false; vdev->device_id = device_id; vdev->status = 0; qatomic_set(&vdev->isr, 0); -- MST
next prev parent reply other threads:[~2022-05-16 21:56 UTC|newest] Thread overview: 109+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-05-16 20:49 [PULL v2 00/86] virtio,pc,pci: fixes,cleanups,features Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 01/86] virtio: fix feature negotiation for ACCESS_PLATFORM Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 02/86] intel-iommu: correct the value used for error_setg_errno() Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 03/86] hw/pci/cxl: Add a CXL component type (interface) Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 04/86] hw/cxl/component: Introduce CXL components (8.1.x, 8.2.5) Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 05/86] MAINTAINERS: Add entry for Compute Express Link Emulation Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 06/86] hw/cxl/device: Introduce a CXL device (8.2.8) Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 07/86] hw/cxl/device: Implement the CAP array (8.2.8.1-2) Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 08/86] hw/cxl/device: Implement basic mailbox (8.2.8.4) Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 09/86] hw/cxl/device: Add memory device utilities Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 10/86] hw/cxl/device: Add cheap EVENTS implementation (8.2.9.1) Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 11/86] hw/cxl/device: Timestamp implementation (8.2.9.3) Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 12/86] hw/cxl/device: Add log commands (8.2.9.4) + CEL Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 13/86] hw/pxb: Use a type for realizing expanders Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 14/86] hw/pci/cxl: Create a CXL bus type Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 15/86] cxl: Machine level control on whether CXL support is enabled Michael S. Tsirkin 2022-05-16 20:50 ` [PULL v2 16/86] hw/pxb: Allow creation of a CXL PXB (host bridge) Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 17/86] qtest/cxl: Introduce initial test for pxb-cxl only Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 18/86] hw/cxl/rp: Add a root port Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 19/86] hw/cxl/device: Add a memory device (8.2.8.5) Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 20/86] hw/cxl/device: Implement MMIO HDM decoding (8.2.5.12) Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 21/86] hw/cxl/device: Add some trivial commands Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 22/86] hw/cxl/device: Plumb real Label Storage Area (LSA) sizing Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 23/86] hw/cxl/device: Implement get/set Label Storage Area (LSA) Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 24/86] qtests/cxl: Add initial root port and CXL type3 tests Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 25/86] hw/cxl/component: Implement host bridge MMIO (8.2.5, table 142) Michael S. Tsirkin 2022-06-16 14:45 ` Igor Mammedov 2022-06-17 10:51 ` Jonathan Cameron via 2022-06-17 11:56 ` Igor Mammedov 2022-05-16 20:51 ` [PULL v2 26/86] acpi/cxl: Add _OSC implementation (9.14.2) Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 27/86] acpi/cxl: Create the CEDT (9.14.1) Michael S. Tsirkin 2022-05-16 20:51 ` [PULL v2 28/86] hw/cxl/component: Add utils for interleave parameter encoding/decoding Michael S. Tsirkin 2022-06-27 13:29 ` Peter Maydell 2022-06-27 14:59 ` Jonathan Cameron via 2022-05-16 20:51 ` [PULL v2 29/86] hw/cxl/host: Add support for CXL Fixed Memory Windows Michael S. Tsirkin 2022-07-19 13:57 ` Peter Maydell 2022-05-16 20:51 ` [PULL v2 30/86] acpi/cxl: Introduce CFMWS structures in CEDT Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 31/86] hw/pci-host/gpex-acpi: Add support for dsdt construction for pxb-cxl Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 32/86] pci/pcie_port: Add pci_find_port_by_pn() Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 33/86] CXL/cxl_component: Add cxl_get_hb_cstate() Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 34/86] mem/cxl_type3: Add read and write functions for associated hostmem Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 35/86] cxl/cxl-host: Add memops for CFMWS region Michael S. Tsirkin 2022-07-20 12:23 ` Peter Maydell 2022-07-21 14:37 ` Jonathan Cameron via 2022-05-16 20:52 ` [PULL v2 36/86] hw/cxl/component Add a dumb HDM decoder handler Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 37/86] i386/pc: Enable CXL fixed memory windows Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 38/86] tests/acpi: q35: Allow addition of a CXL test Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 39/86] qtests/bios-tables-test: Add a test for CXL emulation Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 40/86] tests/acpi: Add tables " Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 41/86] qtest/cxl: Add more complex test cases with CFMWs Michael S. Tsirkin 2022-05-16 20:52 ` [PULL v2 42/86] docs/cxl: Add initial Compute eXpress Link (CXL) documentation Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 43/86] vhost: Track descriptor chain in private at SVQ Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 44/86] vhost: Fix device's used descriptor dequeue Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 45/86] vdpa: Fix bad index calculus at vhost_vdpa_get_vring_base Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 46/86] vdpa: Fix index calculus at vhost_vdpa_svqs_start Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 47/86] hw/virtio: Replace g_memdup() by g_memdup2() Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 48/86] vhost: Fix element in vhost_svq_add failure Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 49/86] target/i386: Fix sanity check on max APIC ID / X2APIC enablement Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 50/86] intel_iommu: Support IR-only mode without DMA translation Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 51/86] intel_iommu: Only allow interrupt remapping to be enabled if it's supported Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 52/86] intel_iommu: Fix irqchip / X2APIC configuration checks Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 53/86] intel-iommu: remove VTD_FR_RESERVED_ERR Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 54/86] intel-iommu: block output address in interrupt address range Michael S. Tsirkin 2022-05-16 20:53 ` [PULL v2 55/86] intel-iommu: update root_scalable before switching as during post_load Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 56/86] intel-iommu: update iq_dw during post load Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 57/86] vhost_net: Print feature masks in hex Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 58/86] hw/virtio: move virtio-pci.h into shared include space Michael S. Tsirkin 2022-05-16 20:54 ` [Virtio-fs] " Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 59/86] virtio-pci: add notification trace points Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 60/86] hw/virtio: add vhost_user_[read|write] " Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 61/86] docs: vhost-user: clean up request/reply description Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 62/86] docs: vhost-user: rewrite section on ring state machine Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 63/86] docs: vhost-user: replace master/slave with front-end/back-end Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 64/86] vhost-user.rst: add clarifying language about protocol negotiation Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 65/86] libvhost-user: expose vu_request_to_string Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 66/86] docs/devel: start documenting writing VirtIO devices Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 67/86] include/hw: start documenting the vhost API Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 68/86] hw/virtio/vhost-user: don't suppress F_CONFIG when supported Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 69/86] virtio/vhost-user: dynamically assign VhostUserHostNotifiers Michael S. Tsirkin 2022-05-16 20:54 ` [PULL v2 70/86] virtio: drop name parameter for virtio_init() Michael S. Tsirkin 2022-05-16 20:54 ` [Virtio-fs] " Michael S. Tsirkin 2022-05-16 20:55 ` Michael S. Tsirkin [this message] 2022-05-16 20:55 ` [Virtio-fs] [PULL v2 71/86] virtio: add vhost support for virtio devices Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 72/86] vhost-user: more master/slave things Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 73/86] docs/vhost-user: Clarifications for VHOST_USER_ADD/REM_MEM_REG Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 74/86] include/hw/pci/pcie_host: Correct PCIE_MMCFG_BUS_MASK Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 75/86] include/hw/pci/pcie_host: Correct PCIE_MMCFG_SIZE_MAX Michael S. Tsirkin 2022-05-26 13:27 ` Daniel Henrique Barboza 2022-05-26 15:54 ` BALATON Zoltan 2022-05-26 16:43 ` BALATON Zoltan 2022-05-26 19:13 ` Michael S. Tsirkin 2022-05-26 19:34 ` BALATON Zoltan 2022-05-26 19:55 ` Michael S. Tsirkin 2022-05-26 20:51 ` BALATON Zoltan 2022-05-30 9:42 ` Thomas Huth 2022-05-30 10:09 ` Cédric Le Goater 2022-05-30 16:00 ` Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 76/86] hw/i386: Make pit a property of common x86 base machine type Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 77/86] hw/i386: Make pic " Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 78/86] hw/i386/amd_iommu: Fix IOMMU event log encoding errors Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 79/86] virtio-net: setup vhost_dev and notifiers for cvq only when feature is negotiated Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 80/86] virtio-net: align ctrl_vq index for non-mq guest for vhost_vdpa Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 81/86] vhost-vdpa: fix improper cleanup in net_init_vhost_vdpa Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 82/86] vhost-net: fix improper cleanup in vhost_net_start Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 83/86] vhost-vdpa: backend feature should set only once Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 84/86] vhost-vdpa: change name and polarity for vhost_vdpa_one_time_request() Michael S. Tsirkin 2022-05-16 20:55 ` [PULL v2 85/86] virtio-net: don't handle mq request in userspace handler for vhost-vdpa Michael S. Tsirkin 2022-05-16 20:56 ` [PULL v2 86/86] vhost-user-scsi: avoid unlink(NULL) with fd passing Michael S. Tsirkin 2022-05-17 3:01 ` [PULL v2 00/86] virtio,pc,pci: fixes,cleanups,features Richard Henderson
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220516204913.542894-72-mst@redhat.com \ --to=mst@redhat.com \ --cc=arei.gonglei@huawei.com \ --cc=dgilbert@redhat.com \ --cc=fam@euphon.net \ --cc=hreitz@redhat.com \ --cc=jasowang@redhat.com \ --cc=jonah.palmer@oracle.com \ --cc=kraxel@redhat.com \ --cc=kwolf@redhat.com \ --cc=marcandre.lureau@redhat.com \ --cc=mathieu.poirier@linaro.org \ --cc=pbonzini@redhat.com \ --cc=peter.maydell@linaro.org \ --cc=qemu-block@nongnu.org \ --cc=qemu-devel@nongnu.org \ --cc=raphael.norwitz@nutanix.com \ --cc=stefanha@redhat.com \ --cc=virtio-fs@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.