virtio-balloon: correct used length
PATCH 1/1 virtio-balloon: correct used length
Spec said:
"and len the total of bytes written into the buffer."
For inflateq, deflateq and statsq, we don't process in_sg so the used length should be zero. For free_page_vq, though the free pages are supplied via in_sgs, zero used length should still be fine since anyway driver is expected to use the length in this case and it simplifies the error handling path.
--- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/virtio/virtio-balloon.c +3 -3
@@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque)return ; } -virtqueue_push (s->svq, s->stats_vq_elem, s->stats_vq_offset); +virtqueue_push (s->svq, s->stats_vq_elem,0 );virtio_notify (vdev, s->svq);g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ;
@@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)memory_region_unref (section.mr); } -virtqueue_push (vq, elem, offset); +virtqueue_push (vq, elem,0 );virtio_notify (vdev, vq);g_free (elem);virtio_balloon_pbp_free (&pbp);
@@ -549,7 +549,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } out: -virtqueue_push (vq, elem,1 ); +virtqueue_push (vq, elem,0 );g_free (elem);return ret; }
Signature · 1 line
2.25.1
Quoted 11 lines · Jason Wang
Spec said:
"and len the total of bytes written into the buffer."
For inflateq, deflateq and statsq, we don't process
in_sgso the used length should be zero. Forfree_page_vq, though the free pages are supplied viain_sgs, zero used length should still be fine since anyway driver is expected to use the length in this case and it simplifies the error handling path.Signed-off-by Jason Wang <[email protected]>
I think for free page vq the point is that the pages are zeroed by hypervisor, so we must set used len accordingly. No?
Quoted 37 lines
--- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/virtio/virtio-balloon.c +3
-3@@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque)return ; } -virtqueue_push (s->svq, s->stats_vq_elem, s->stats_vq_offset); +virtqueue_push (s->svq, s->stats_vq_elem,0 );virtio_notify (vdev, s->svq);g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ;@@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)memory_region_unref (section.mr); } -virtqueue_push (vq, elem, offset); +virtqueue_push (vq, elem,0 );virtio_notify (vdev, vq);g_free (elem);virtio_balloon_pbp_free (&pbp);@@ -549,7 +549,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } out: -virtqueue_push (vq, elem,1 ); +virtqueue_push (vq, elem,0 );g_free (elem);return ret; }Signature · 1 line
2.25.1
Quoted 12 lines · Michael S. Tsirkin
Quoted 10 lines · Jason Wang
Spec said:
"and len the total of bytes written into the buffer."
For inflateq, deflateq and statsq, we don't process
in_sgso the used length should be zero. Forfree_page_vq, though the free pages are supplied viain_sgs, zero used length should still be fine since anyway driver is expected to use the length in this case and it simplifies the error handling path.
Quoted 4 lines
Quoted 1 line
Signed-off-by Jason Wang <[email protected]>I think for free page vq the point is that the pages are zeroed by hypervisor, so we must set used len accordingly. No?
I may miss something, I think it is used for clearing the dirty bitmaps to avoid migrating unused pages, the zeroing is not needed.
Thanks
Quoted 39 lines
Quoted 38 lines
--- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/virtio/virtio-balloon.c +3
-4@@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque)return ; } -virtqueue_push (s->svq, s->stats_vq_elem, s->stats_vq_offset); +virtqueue_push (s->svq, s->stats_vq_elem,0 );virtio_notify (vdev, s->svq);g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ;@@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)memory_region_unref (section.mr); } -virtqueue_push (vq, elem, offset); +virtqueue_push (vq, elem,0 );virtio_notify (vdev, vq);g_free (elem);virtio_balloon_pbp_free (&pbp);@@ -549,7 +549,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } out: -virtqueue_push (vq, elem,1 ); +virtqueue_push (vq, elem,0 );g_free (elem);return ret; } --2.25.1
Quoted 15 lines · Jason Wang
Quoted 14 lines · Michael S. Tsirkin
Quoted 11 lines · Jason Wang
Spec said:
"and len the total of bytes written into the buffer."
For inflateq, deflateq and statsq, we don't process
in_sgso the used length should be zero. Forfree_page_vq, though the free pages are supplied viain_sgs, zero used length should still be fine since anyway driver is expected to use the length in this case and it simplifies the error handling path.Signed-off-by Jason Wang <[email protected]>
Quoted 7 lines
Quoted 2 lines
I think for free page vq the point is that the pages are zeroed by hypervisor, so we must set used len accordingly. No?
I may miss something, I think it is used for clearing the dirty bitmaps to avoid migrating unused pages, the zeroing is not needed.
Thanks
And, once the page is migrated, it's value on destination may differ from one on source.
Quoted 39 lines
Quoted 39 lines
Quoted 38 lines
--- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/virtio/virtio-balloon.c +3
-4@@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque)return ; } -virtqueue_push (s->svq, s->stats_vq_elem, s->stats_vq_offset); +virtqueue_push (s->svq, s->stats_vq_elem,0 );virtio_notify (vdev, s->svq);g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ;@@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)memory_region_unref (section.mr); } -virtqueue_push (vq, elem, offset); +virtqueue_push (vq, elem,0 );virtio_notify (vdev, vq);g_free (elem);virtio_balloon_pbp_free (&pbp);@@ -549,7 +549,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } out: -virtqueue_push (vq, elem,1 ); +virtqueue_push (vq, elem,0 );g_free (elem);return ret; } --2.25.1
Quoted 20 lines · Michael S. Tsirkin
Quoted 18 lines · Jason Wang
Quoted 16 lines · Michael S. Tsirkin
Quoted 11 lines · Jason Wang
Spec said:
"and len the total of bytes written into the buffer."
For inflateq, deflateq and statsq, we don't process
in_sgso the used length should be zero. Forfree_page_vq, though the free pages are supplied viain_sgs, zero used length should still be fine since anyway driver is expected to use the length in this case and it simplifies the error handling path.Signed-off-by Jason Wang <[email protected]>I think for free page vq the point is that the pages are zeroed by hypervisor, so we must set used len accordingly. No?
Quoted 7 lines
Quoted 4 lines
I may miss something, I think it is used for clearing the dirty bitmaps to avoid migrating unused pages, the zeroing is not needed.
Thanks
And, once the page is migrated, it's value on destination may differ from one on source.
Right, I will fix this in the next version.
Thanks
Quoted 41 lines
Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
--- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/virtio/virtio-balloon.c +3
-4@@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque)return ; } -virtqueue_push (s->svq, s->stats_vq_elem, s->stats_vq_offset); +virtqueue_push (s->svq, s->stats_vq_elem,0 );virtio_notify (vdev, s->svq);g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ;@@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)memory_region_unref (section.mr); } -virtqueue_push (vq, elem, offset); +virtqueue_push (vq, elem,0 );virtio_notify (vdev, vq);g_free (elem);virtio_balloon_pbp_free (&pbp);@@ -549,7 +549,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } out: -virtqueue_push (vq, elem,1 ); +virtqueue_push (vq, elem,0 );g_free (elem);return ret; } --2.25.1
Quoted 25 lines · Jason Wang
Quoted 23 lines · Michael S. Tsirkin
Quoted 21 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 10 lines · Jason Wang
Spec said:
"and len the total of bytes written into the buffer."
For inflateq, deflateq and statsq, we don't process
in_sgso the used length should be zero. Forfree_page_vq, though the free pages are supplied viain_sgs, zero used length should still be fine since anyway driver is expected to use the length in this case and it simplifies the error handling path.Quoted 4 lines
Quoted 1 line
Signed-off-by Jason Wang <[email protected]>I think for free page vq the point is that the pages are zeroed by hypervisor, so we must set used len accordingly. No?
I may miss something, I think it is used for clearing the dirty bitmaps to avoid migrating unused pages, the zeroing is not needed.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Thanks
And, once the page is migrated, it's value on destination may differ from one on source.
Right, I will fix this in the next version.
Thanks
Btw in the get_free_page_hints() I see this:
if (elem->in_num && dev->free_page_hint_status == FREE_PAGE_HINT_S_START) {
qemu_guest_free_page_hint(elem->in_sg[0].iov_base,
elem->in_sg[0].iov_len);
}It looks like only the first in sg is used, it looks like a bug?
Thanks
Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines
--- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/virtio/virtio-balloon.c +3
-4@@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque)return ; } -virtqueue_push (s->svq, s->stats_vq_elem, s->stats_vq_offset); +virtqueue_push (s->svq, s->stats_vq_elem,0 );virtio_notify (vdev, s->svq);g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ;@@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)memory_region_unref (section.mr); } -virtqueue_push (vq, elem, offset); +virtqueue_push (vq, elem,0 );virtio_notify (vdev, vq);g_free (elem);virtio_balloon_pbp_free (&pbp);@@ -549,7 +549,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } out: -virtqueue_push (vq, elem,1 ); +virtqueue_push (vq, elem,0 );g_free (elem);return ret; } --2.25.1
Quoted 37 lines · Jason Wang
Quoted 25 lines · Jason Wang
Quoted 23 lines · Michael S. Tsirkin
Quoted 21 lines · Jason Wang
Quoted 12 lines · Michael S. Tsirkin
Quoted 10 lines · Jason Wang
Spec said:
"and len the total of bytes written into the buffer."
For inflateq, deflateq and statsq, we don't process
in_sgso the used length should be zero. Forfree_page_vq, though the free pages are supplied viain_sgs, zero used length should still be fine since anyway driver is expected to use the length in this case and it simplifies the error handling path.Quoted 4 lines
Quoted 1 line
Signed-off-by Jason Wang <[email protected]>I think for free page vq the point is that the pages are zeroed by hypervisor, so we must set used len accordingly. No?
I may miss something, I think it is used for clearing the dirty bitmaps to avoid migrating unused pages, the zeroing is not needed.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Thanks
And, once the page is migrated, it's value on destination may differ from one on source.
Right, I will fix this in the next version.
Thanks
Btw in the
get_free_page_hints()I see this:
Quoted 8 lines
if (elem->in_num && dev->free_page_hint_status == FREE_PAGE_HINT_S_START) { qemu_guest_free_page_hint(elem->in_sg[0].iov_base, elem->in_sg[0].iov_len); }It looks like only the first in sg is used, it looks like a bug?
Thanks
It sure does.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
Quoted 42 lines
Quoted 42 lines
Quoted 41 lines
--- hw/virtio/virtio-balloon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)hw/virtio/virtio-balloon.c +3
-4@@ -231,7 +231,7 @@ static void balloon_stats_poll_cb(void *opaque)return ; } -virtqueue_push (s->svq, s->stats_vq_elem, s->stats_vq_offset); +virtqueue_push (s->svq, s->stats_vq_elem,0 );virtio_notify (vdev, s->svq);g_free (s->stats_vq_elem); s->stats_vq_elem =NULL ;@@ -438,7 +438,7 @@ static void virtio_balloon_handle_output(VirtIODevice *vdev, VirtQueue *vq)memory_region_unref (section.mr); } -virtqueue_push (vq, elem, offset); +virtqueue_push (vq, elem,0 );virtio_notify (vdev, vq);g_free (elem);virtio_balloon_pbp_free (&pbp);@@ -549,7 +549,7 @@ static bool get_free_page_hints(VirtIOBalloon *dev) } out: -virtqueue_push (vq, elem,1 ); +virtqueue_push (vq, elem,0 );g_free (elem);return ret; } --2.25.1