vhost-blk: set features before setting inflight feature
PATCH 1/1 vhost-blk: set features before setting inflight feature
Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.
--- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 18 ++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 25 insertions(+)
hw/block/vhost-user-blk.c +6 -0
@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret =vhost_dev_prepare_inflight (&s->dev); +if (ret <0 ) { +error_report ("Error set inflight format: %d" , -ret); + goto err_guest_notifiers; + } +if (!s->inflight->addr) { ret =vhost_dev_get_inflight (&s->dev, s->queue_size, s->inflight);if (ret <0 ) {
hw/virtio/vhost.c +18 -0
@@ -1616,6 +1616,24 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f)return 0 ; } +int vhost_dev_prepare_inflight (struct vhost_dev *hdev) +{ +int r; + +if (hdev->vhost_ops->vhost_get_inflight_fd ==NULL || + hdev->vhost_ops->vhost_set_inflight_fd ==NULL ) { +return 0 ; + } + + r =vhost_dev_set_features (hdev, hdev->log_enabled); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_dev_prepare_inflight failed" ); +return r; + } + +return 0 ; +} +int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight) {
include/hw/virtio/vhost.h +1 -0
@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *inflight);void vhost_dev_free_inflight (struct vhost_inflight *inflight);void vhost_dev_save_inflight (struct vhost_inflight *inflight,QEMUFile *f);int vhost_dev_load_inflight (struct vhost_inflight *inflight,QEMUFile *f); +int vhost_dev_prepare_inflight (struct vhost_dev *hdev);int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size,
Signature · 1 line
2.17.2
Backends already receive the format in vhost_dev_start before the memory tables are set or any of the virtqueues are started. Can you elaborate on why you need to know the virtqueue format before setting the inflight FD?
Quoted 73 lines · Jin Yu
Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.
Signed-off-by Jin Yu <[email protected]>--- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 18 ++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 25 insertions(+)hw/block/vhost-user-blk.c +6
-0@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret =vhost_dev_prepare_inflight (&s->dev); +if (ret <0 ) { +error_report ("Error set inflight format: %d" , -ret); + goto err_guest_notifiers; + } +if (!s->inflight->addr) { ret =vhost_dev_get_inflight (&s->dev, s->queue_size, s->inflight);if (ret <0 ) {hw/virtio/vhost.c +18
-0@@ -1616,6 +1616,24 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f)return 0 ; } +int vhost_dev_prepare_inflight (struct vhost_dev *hdev) +{ +int r; + +if (hdev->vhost_ops->vhost_get_inflight_fd ==NULL || + hdev->vhost_ops->vhost_set_inflight_fd ==NULL ) { +return 0 ; + } + + r =vhost_dev_set_features (hdev, hdev->log_enabled); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_dev_prepare_inflight failed" ); +return r; + } + +return 0 ; +} +int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight) {include/hw/virtio/vhost.h +1
-1@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *inflight);void vhost_dev_free_inflight (struct vhost_inflight *inflight);void vhost_dev_save_inflight (struct vhost_inflight *inflight,QEMUFile *f);int vhost_dev_load_inflight (struct vhost_inflight *inflight,QEMUFile *f); +int vhost_dev_prepare_inflight (struct vhost_dev *hdev);int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size, --2.17.2
Quoted 9 lines
-----Original Message-----
From: Raphael Norwitz <[email protected]>
Sent: Tuesday, September 15, 2020 9:25 AM
To: Yu, Jin <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Raphael Norwitz <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; QEMU <[email protected]>
Subject: Re: [PATCH] vhost-blk: set features before setting inflight feature
Quoted 4 lines
Backends already receive the format in
vhost_dev_startbefore the memory tables are set or any of the virtqueues are started. Can you elaborate on why you need to know the virtqueue format before setting the inflight FD?
First, when the backend receives the get_inflight_fd sent by QEMU, it needs to allocate vq's inflight memory, and it needs to know the format of vq.
Second, when the backend reconnects to QEMU, QEMU sends set_inflight_fd, and the backend restores the inflight memory of vq. It also needs to know the format of vq.
Thanks.
Quoted 75 lines · Jin Yu
hw/virtio/vhost.c int vhost_dev_load_inflight(struct vhost_inflight
Quoted 34 lines
Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.
Signed-off-by Jin Yu <[email protected]>--- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 18 ++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 25 insertions(+)hw/block/vhost-user-blk.c +6
-0@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret =vhost_dev_prepare_inflight (&s->dev); +if (ret <0 ) { +error_report ("Error set inflight format: %d" , -ret); + goto err_guest_notifiers; + } +if (!s->inflight->addr) { ret =vhost_dev_get_inflight (&s->dev, s->queue_size, s->inflight);if (ret < 0) {hw/virtio/vhost.c index renamed from hw/virtio/vhost.c +0
-0
1a1384e7a6..4027c11886100644hw/virtio/vhost.c +0
-0@@ -1616,6 +1616,24 @@ int vhost_dev_load_inflight(struct vhost_inflight*inflight, QEMUFile *f)
Quoted 39 lines
hw/virtio/vhost.c +17
-1return 0 ; } +int vhost_dev_prepare_inflight (struct vhost_dev *hdev) { +int r; + +if (hdev->vhost_ops->vhost_get_inflight_fd ==NULL || + hdev->vhost_ops->vhost_set_inflight_fd ==NULL ) { +return 0 ; + } + + r =vhost_dev_set_features (hdev, hdev->log_enabled); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_dev_prepare_inflight failed" ); +return r; + } + +return 0 ; +} +int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index
767a95ec0b..4e2fc75528100644include/hw/virtio/vhost.h +0
-0@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct
vhost_inflight*inflight); voidvhost_dev_free_inflight(struct vhost_inflight *inflight); voidvhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f); intvhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f); +intvhost_dev_prepare_inflight(struct vhost_dev *hdev);
int vhost_dev_set_inflight(structvhost_dev*dev,
structvhost_inflight*inflight); int
vhost_dev_get_inflight(structvhost_dev*dev,uint16_tqueue_size, --
2.17.2
I see your point - all the open source backends I could find which support VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD rely on knowing the vq type to allocate the fd.
That said, it looks like dpdk supports both VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD and packed vqs without needing
such an API https://github.com/DPDK/dpdk/blob/main/lib/librte_vhost/vhost_user.c#L1509.
I'm not sure exactly how the VQ state is sent to DPDK before the
inflight fd negotiation, but ideally vhost-user-blk could be made to
work the same way. Maybe someone with more vhost-net and dpdk
knowledge could chime in on how vhost-net backends do it?
Quoted 94 lines · Jin
Quoted 10 lines
-----Original Message-----
From: Raphael Norwitz <[email protected]>
Sent: Tuesday, September 15, 2020 9:25 AM
To: Yu, Jin <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Raphael Norwitz <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; QEMU <[email protected]>
Subject: Re: [PATCH] vhost-blk: set features before setting inflight featureQuoted 4 lines
Backends already receive the format in
vhost_dev_startbefore the memory tables are set or any of the virtqueues are started. Can you elaborate on why you need to know the virtqueue format before setting the inflight FD?First, when the backend receives the
get_inflight_fdsent by QEMU, it needs to allocate vq's inflight memory, and it needs to know the format of vq.
Second, when the backend reconnects to QEMU, QEMU sendsset_inflight_fd, and the backend restores the inflight memory of vq. It also needs to know the format of vq.
Thanks.Quoted 75 lines · Jin Yu
hw/virtio/vhost.c int vhost_dev_load_inflight(struct vhost_inflight
Quoted 34 lines
Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.
Signed-off-by Jin Yu <[email protected]>--- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 18 ++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 25 insertions(+)hw/block/vhost-user-blk.c +6
-0@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret =vhost_dev_prepare_inflight (&s->dev); +if (ret <0 ) { +error_report ("Error set inflight format: %d" , -ret); + goto err_guest_notifiers; + } +if (!s->inflight->addr) { ret =vhost_dev_get_inflight (&s->dev, s->queue_size, s->inflight);if (ret < 0) {hw/virtio/vhost.c index renamed from hw/virtio/vhost.c +0
-0
1a1384e7a6..4027c11886100644hw/virtio/vhost.c +0
-0@@ -1616,6 +1616,24 @@ int vhost_dev_load_inflight(struct vhost_inflight*inflight, QEMUFile *f)
Quoted 39 lines
hw/virtio/vhost.c +17
-1return 0 ; } +int vhost_dev_prepare_inflight (struct vhost_dev *hdev) { +int r; + +if (hdev->vhost_ops->vhost_get_inflight_fd ==NULL || + hdev->vhost_ops->vhost_set_inflight_fd ==NULL ) { +return 0 ; + } + + r =vhost_dev_set_features (hdev, hdev->log_enabled); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_dev_prepare_inflight failed" ); +return r; + } + +return 0 ; +} +int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index
767a95ec0b..4e2fc75528100644include/hw/virtio/vhost.h +0
-0@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct
vhost_inflight*inflight); voidvhost_dev_free_inflight(struct vhost_inflight *inflight); voidvhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f); intvhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f); +intvhost_dev_prepare_inflight(struct vhost_dev *hdev);
int vhost_dev_set_inflight(structvhost_dev*dev,
structvhost_inflight*inflight); int
vhost_dev_get_inflight(structvhost_dev*dev,uint16_tqueue_size, --
2.17.2
Quoted 13 lines
-----Original Message-----
From: Raphael Norwitz <[email protected]>
Sent: Tuesday, September 22, 2020 7:03 AM
To: Yu, Jin <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Raphael Norwitz <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; QEMU <[email protected]>
Subject: Re: [PATCH] vhost-blk: set features before setting inflight featureI see your point - all the open source backends I could find which support
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFDrely on knowing the vq type to allocate the fd.
Quoted 10 lines
That said, it looks like dpdk supports both
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFDand packed vqs without needing such an API
https://github.com/DPDK/dpdk/blob/main/lib/librte_vhost/vhost_user.c#L1
509.
I'm not sure exactly how the VQ state is sent to DPDK before the inflight fd negotiation, but ideally vhost-user-blk could be made to work the same way. Maybe someone with more vhost-net and dpdk knowledge could chime in on how vhost-net backends do it?
I checked the code of vhost-net in QEMU, it did not use the inflight feature, which should be different from storage, after all, the network can lose packets and retransmit.
Of course, as you said, we need an expert familiar with vhost-net and dpdk.
Thanks
Quoted 102 lines · Jin
Quoted 11 lines
Quoted 11 lines
-----Original Message-----
From: Raphael Norwitz <[email protected]>
Sent: Tuesday, September 15, 2020 9:25 AM
To: Yu, Jin <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Raphael Norwitz <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; QEMU <[email protected]>
Subject: Re: [PATCH] vhost-blk: set features before setting inflight featureQuoted 3 lines
Quoted 3 lines
Backends already receive the format in
vhost_dev_startbefore the memory tables are set or any of the virtqueues are started. Can you elaborate on why you need to know the virtqueue format before settingthe inflight FD?
Quoted 3 lines
Quoted 1 line
First, when the backend receives the
get_inflight_fdsent by QEMU, it needs to allocate vq's inflight memory, and it needs to know the format ofvq.
Quoted 1 line
Second, when the backend reconnects to QEMU, QEMU sends
set_inflight_fd, and the backend restores the inflight memory of vq.Quoted 80 lines
It also needs to know the format of vq.
Thanks.Quoted 78 lines · Jin Yu
Quoted 34 lines
Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.
Signed-off-by Jin Yu <[email protected]>--- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 18 ++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 25 insertions(+)hw/block/vhost-user-blk.c +6
-0@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret =vhost_dev_prepare_inflight (&s->dev); +if (ret <0 ) { +error_report ("Error set inflight format: %d" , -ret); + goto err_guest_notifiers; + } +if (!s->inflight->addr) { ret =vhost_dev_get_inflight (&s->dev, s->queue_size, s->inflight);if (ret < 0) {hw/virtio/vhost.c index renamed from hw/virtio/vhost.c +0
-0
1a1384e7a6..4027c11886100644hw/virtio/vhost.c +0
-0@@ -1616,6 +1616,24 @@ int vhost_dev_load_inflight(structQuoted 1 line
vhost_inflight*inflight, QEMUFile *f)
Quoted 41 lines
return 0;}
hw/virtio/vhost.c +17
-0+int vhost_dev_prepare_inflight (struct vhost_dev *hdev) { +int r; + +if (hdev->vhost_ops->vhost_get_inflight_fd ==NULL || + hdev->vhost_ops->vhost_set_inflight_fd ==NULL ) { +return 0 ; + } + + r =vhost_dev_set_features (hdev, hdev->log_enabled); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_dev_prepare_inflight failed" ); +return r; + } + +return 0 ; +} +int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight) {include/hw/virtio/vhost.h +0
-0index
767a95ec0b..4e2fc75528100644include/hw/virtio/vhost.h +0
-0@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct
vhost_inflight*inflight); voidvhost_dev_free_inflight(struct vhost_inflight *inflight); voidvhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f); intvhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f);
+intvhost_dev_prepare_inflight(struct vhost_dev *hdev);
int vhost_dev_set_inflight(structvhost_dev*dev,
structvhost_inflight*inflight); int
vhost_dev_get_inflight(structvhost_dev*dev,uint16_tqueue_size, --
2.17.2
Raphael Norwitz
Acked-byI see you're right - or rather even if a vhost-net backend negotiates the inflight feature, QEMU never sets/gets an inflight fd. That clears up all my concerns - I support the change.
I don't like sending an additional VHOST_USER_SET_FEATURES message in vhost_dev_start() right after we've sent one in vhost_dev_prepare_inflight(), but I don't see a clean way around it. We could add a flag in vhost_dev, set it in vhost_dev_prepare_inflight() and then check and set it back in vhost_dev_set_features(), but that seems quite ugly. Unless anyone can think of a better option, I say we go with the patch as is.
Quoted 133 lines · Jin
Quoted 14 lines
-----Original Message-----
From: Raphael Norwitz <[email protected]>
Sent: Tuesday, September 22, 2020 7:03 AM
To: Yu, Jin <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Raphael Norwitz <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; QEMU <[email protected]>
Subject: Re: [PATCH] vhost-blk: set features before setting inflight featureI see your point - all the open source backends I could find which support
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFDrely on knowing the vq type to allocate the fd.Quoted 10 lines
That said, it looks like dpdk supports both
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFDand packed vqs without needing such an API
https://github.com/DPDK/dpdk/blob/main/lib/librte_vhost/vhost_user.c#L1
509.
I'm not sure exactly how the VQ state is sent to DPDK before the inflight fd negotiation, but ideally vhost-user-blk could be made to work the same way. Maybe someone with more vhost-net and dpdk knowledge could chime in on how vhost-net backends do it?I checked the code of vhost-net in QEMU, it did not use the inflight feature, which should be different from storage, after all, the network can lose packets and retransmit.
Of course, as you said, we need an expert familiar with vhost-net and dpdk.
Thanks
Quoted 102 lines · Jin
Quoted 11 lines
Quoted 11 lines
-----Original Message-----
From: Raphael Norwitz <[email protected]>
Sent: Tuesday, September 15, 2020 9:25 AM
To: Yu, Jin <[email protected]>
Cc: Michael S. Tsirkin <[email protected]>; Raphael Norwitz <[email protected]>; Kevin Wolf <[email protected]>; Max Reitz <[email protected]>; QEMU <[email protected]>
Subject: Re: [PATCH] vhost-blk: set features before setting inflight featureQuoted 3 lines
Quoted 3 lines
Backends already receive the format in
vhost_dev_startbefore the memory tables are set or any of the virtqueues are started. Can you elaborate on why you need to know the virtqueue format before settingthe inflight FD?
Quoted 3 lines
Quoted 1 line
First, when the backend receives the
get_inflight_fdsent by QEMU, it needs to allocate vq's inflight memory, and it needs to know the format ofvq.
Quoted 1 line
Second, when the backend reconnects to QEMU, QEMU sends
set_inflight_fd, and the backend restores the inflight memory of vq.Quoted 80 lines
It also needs to know the format of vq.
Thanks.Quoted 78 lines · Jin Yu
Quoted 34 lines
Virtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.
Signed-off-by Jin Yu <[email protected]>--- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 18 ++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 25 insertions(+)hw/block/vhost-user-blk.c +6
-0@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret =vhost_dev_prepare_inflight (&s->dev); +if (ret <0 ) { +error_report ("Error set inflight format: %d" , -ret); + goto err_guest_notifiers; + } +if (!s->inflight->addr) { ret =vhost_dev_get_inflight (&s->dev, s->queue_size, s->inflight);if (ret < 0) {hw/virtio/vhost.c index renamed from hw/virtio/vhost.c +0
-0
1a1384e7a6..4027c11886100644hw/virtio/vhost.c +0
-0@@ -1616,6 +1616,24 @@ int vhost_dev_load_inflight(structQuoted 1 line
vhost_inflight*inflight, QEMUFile *f)
Quoted 41 lines
return 0;}
hw/virtio/vhost.c +17
-0+int vhost_dev_prepare_inflight (struct vhost_dev *hdev) { +int r; + +if (hdev->vhost_ops->vhost_get_inflight_fd ==NULL || + hdev->vhost_ops->vhost_set_inflight_fd ==NULL ) { +return 0 ; + } + + r =vhost_dev_set_features (hdev, hdev->log_enabled); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_dev_prepare_inflight failed" ); +return r; + } + +return 0 ; +} +int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight) {include/hw/virtio/vhost.h +0
-0index
767a95ec0b..4e2fc75528100644include/hw/virtio/vhost.h +0
-0@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct
vhost_inflight*inflight); voidvhost_dev_free_inflight(struct vhost_inflight *inflight); voidvhost_dev_save_inflight(struct vhost_inflight *inflight, QEMUFile *f); intvhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f);
+intvhost_dev_prepare_inflight(struct vhost_dev *hdev);
int vhost_dev_set_inflight(structvhost_dev*dev,
structvhost_inflight*inflight); int
vhost_dev_get_inflight(structvhost_dev*dev,uint16_tqueue_size, --
2.17.2
PATCH v2 1/1 vhost-blk: set features before setting inflight feature
In reply to Jin YuVirtqueue has split and packed, so before setting inflight, you need to inform the back-end virtqueue format.
---
v2:
* Fixed the segfault.
--- hw/block/vhost-user-blk.c | 6 ++++++ hw/virtio/vhost.c | 20 ++++++++++++++++++++ include/hw/virtio/vhost.h | 1 + 3 files changed, 27 insertions(+)
hw/block/vhost-user-blk.c +6 -0
@@ -131,6 +131,12 @@ static int vhost_user_blk_start(VirtIODevice *vdev) s->dev.acked_features = vdev->guest_features; + ret =vhost_dev_prepare_inflight (&s->dev, vdev); +if (ret <0 ) { +error_report ("Error set inflight format: %d" , -ret); + goto err_guest_notifiers; + } +if (!s->inflight->addr) { ret =vhost_dev_get_inflight (&s->dev, s->queue_size, s->inflight);if (ret <0 ) {
hw/virtio/vhost.c +20 -0
@@ -1616,6 +1616,26 @@ int vhost_dev_load_inflight(struct vhost_inflight *inflight, QEMUFile *f)return 0 ; } +int vhost_dev_prepare_inflight (struct vhost_dev *hdev,VirtIODevice *vdev) +{ +int r; + +if (hdev->vhost_ops->vhost_get_inflight_fd ==NULL || + hdev->vhost_ops->vhost_set_inflight_fd ==NULL ) { +return 0 ; + } + + hdev->vdev = vdev; + + r =vhost_dev_set_features (hdev, hdev->log_enabled); +if (r <0 ) { +VHOST_OPS_DEBUG ("vhost_dev_prepare_inflight failed" ); +return r; + } + +return 0 ; +} +int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight) {
include/hw/virtio/vhost.h +1 -0
@@ -140,6 +140,7 @@ void vhost_dev_reset_inflight(struct vhost_inflight *inflight);void vhost_dev_free_inflight (struct vhost_inflight *inflight);void vhost_dev_save_inflight (struct vhost_inflight *inflight,QEMUFile *f);int vhost_dev_load_inflight (struct vhost_inflight *inflight,QEMUFile *f); +int vhost_dev_prepare_inflight (struct vhost_dev *hdev,VirtIODevice *vdev);int vhost_dev_set_inflight (struct vhost_dev *dev,struct vhost_inflight *inflight); int vhost_dev_get_inflight(struct vhost_dev *dev, uint16_t queue_size,
Signature · 1 line
2.17.2