Solve problem of hot removal of virtio-net-pci
cover Solve problem of hot removal of virtio-net-pci
There is regression of hotplug removal of virtio-net-pci on q35 introduced long time ago in 3.0.0 with commit:
48564041a73adbbff52834f9edbe3806fceefab7
exec: reintroduce MemoryRegion caching
virtio-net does not destroy some of caching resources upon hot unplug and on further hot plug the device with the same name can not be added.
These 2 patches solve the problem.
Yuri Benditovich (2):
virtio: reset region cache when on queue deletion
virtio-net: delete also control queue when TX/RX deleted
hw/net/virtio-net.c | 3 ++- hw/virtio/virtio.c | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
PATCH 1/2 virtio: reset region cache when on queue deletion
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.
--- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/virtio/virtio.c +5 -0
@@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice *vdev, int n) vdev->vq[n].vring.num_default =0 ; vdev->vq[n].handle_output =NULL ; vdev->vq[n].handle_aio_output =NULL ; +/* +* with vring.num = 0 the queue will be ignored +* in later loops of region cache reset +*/ +virtio_virtqueue_reset_region_cache (&vdev->vq[n]);g_free (vdev->vq[n].used_elems); }
Signature · 1 line
2.17.1
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 3 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.
More information is needed here, the bug said only q35 can meet this issue. What makes q35 different here?
Quoted 11 lines
Signed-off-by Yuri Benditovich <[email protected]>--- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+)hw/virtio/virtio.c +0
-0
hw/virtio/virtio.c void virtio_del_queue(VirtIODevice *vdev, int n) · line 2346
Quoted 7 lines
hw/virtio/virtio.c +4
-0@@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice *vdev, int n) vdev->vq[n].vring.num_default =0 ; vdev->vq[n].handle_output =NULL ; vdev->vq[n].handle_aio_output =NULL ; +/* +* with vring.num = 0 the queue will be ignored +* in later loops of region cache reset +*/
I can't get the meaning of this comment.
Thanks
Quoted 4 lines
hw/virtio/virtio.c +1
-0+virtio_virtqueue_reset_region_cache (&vdev->vq[n]);g_free (vdev->vq[n].used_elems); }
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 11 lines · Jason Wang
Quoted 3 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.More information is needed here, the bug said only q35 can meet this issue. What makes q35 different here?
I do not have any ready answer, I did not dig into it too much. Probably Michael Tsirkin or Paolo Bonzini can answer without digging.
Quoted 31 lines
Quoted 12 lines
Signed-off-by Yuri Benditovich <[email protected]>--- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+)hw/virtio/virtio.c +0
-0hw/virtio/virtio.c void virtio_del_queue(VirtIODevice *vdev, int n) · line 2346
Quoted 7 lines
hw/virtio/virtio.c +4
-0@@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice *vdev, int n) vdev->vq[n].vring.num_default =0 ; vdev->vq[n].handle_output =NULL ; vdev->vq[n].handle_aio_output =NULL ; +/* +* with vring.num = 0 the queue will be ignored +* in later loops of region cache reset +*/ I can't get the meaning of this comment.
Thanks
Quoted 4 lines
hw/virtio/virtio.c +1
-0+virtio_virtqueue_reset_region_cache (&vdev->vq[n]);g_free (vdev->vq[n].used_elems); }
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 9 lines · Yuri Benditovich
Quoted 8 lines · Jason Wang
Quoted 3 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.
Quoted 36 lines
Quoted 3 lines
More information is needed here, the bug said only q35 can meet this issue. What makes q35 different here?
I do not have any ready answer, I did not dig into it too much. Probably Michael Tsirkin or Paolo Bonzini can answer without digging.
Quoted 27 lines
Quoted 12 lines
Signed-off-by Yuri Benditovich <[email protected]>--- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+)hw/virtio/virtio.c +0
-0hw/virtio/virtio.c void virtio_del_queue(VirtIODevice *vdev, int n) · line 2346
Quoted 7 lines
hw/virtio/virtio.c +4
-0@@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice *vdev, int n) vdev->vq[n].vring.num_default =0 ; vdev->vq[n].handle_output =NULL ; vdev->vq[n].handle_aio_output =NULL ; +/* +* with vring.num = 0 the queue will be ignored +* in later loops of region cache reset +*/ I can't get the meaning of this comment.
Thanks
Quoted 1 line
hw/virtio/virtio.c +1
-0+virtio_virtqueue_reset_region_cache (&vdev->vq[n]);
Do we need to drop this from virtio_device_free_virtqueues then?
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
hw/virtio/virtio.c +0
-0g_free (vdev->vq[n].used_elems); }
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 43 lines · Michael S. Tsirkin
Quoted 25 lines · Yuri Benditovich
Quoted 11 lines · Jason Wang
Quoted 3 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.More information is needed here, the bug said only q35 can meet this issue. What makes q35 different here?
I do not have any ready answer, I did not dig into it too much. Probably Michael Tsirkin or Paolo Bonzini can answer without digging.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Yuri Benditovich <[email protected]>--- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+)Quoted 5 lines
Quoted 5 lines
hw/virtio/virtio.c void virtio_del_queue(VirtIODevice *vdev, int
Quoted 5 lines
hw/virtio/virtio.c +0
-0@@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice *vdev, intn)
Quoted 11 lines
Quoted 11 lines
hw/virtio/virtio.c void virtio_del_queue(VirtIODevice *vdev, int n) · line 2346
Quoted 7 lines
hw/virtio/virtio.c +4
-0vdev->vq[n].vring.num_default =0 ; vdev->vq[n].handle_output =NULL ; vdev->vq[n].handle_aio_output =NULL ; +/* +* with vring.num = 0 the queue will be ignored +* in later loops of region cache reset +*/ I can't get the meaning of this comment.
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Thanks
Quoted 1 line
hw/virtio/virtio.c +1
-0+virtio_virtqueue_reset_region_cache (&vdev->vq[n]);Do we need to drop this from
virtio_device_free_virtqueuesthen?
Not mandatory. Repetitive virtio_virtqueue_reset_region_cache does not do anything bad.
Some of virtio devices do not do 'virtio_del_queue' at all. Currently virtio_device_free_virtqueues resets region cache for them. IMO, not calling 'virtio_del_queue' is a bug, but not in the scope of current series, I'll take care of that later.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
hw/virtio/virtio.c +0
-0g_free (vdev->vq[n].used_elems); }
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 57 lines · Yuri Benditovich
On Thu, Jan 2, 2020 at 1:50 AM Michael S. Tsirkin <[email protected]> wrote:
On Thu, Dec 26, 2019 at 11:29:50AM +0200, Yuri Benditovich wrote: > On Thu, Dec 26, 2019 at 10:58 AM Jason Wang <[email protected]> wrote: > > > > > > On 2019/12/26 下午12:36, Yuri Benditovich wrote: > > > https://bugzilla.redhat.com/show_bug.cgi?id=1708480 > > > Fix leak of region reference that prevents complete > > > device deletion on hot unplug. > > > > > > More information is needed here, the bug said only q35 can meet this > > issue. What makes q35 different here? > > > > I do not have any ready answer, I did not dig into it too much. > Probably Michael Tsirkin or Paolo Bonzini can answer without digging. > > > > > > > > Signed-off-by: Yuri Benditovich <[email protected]> > > > --- > > > hw/virtio/virtio.c | 5 +++++ > > > 1 file changed, 5 insertions(+) > > > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > > index 04716b5f6c..baadec8abc 100644 > > > --- a/hw/virtio/virtio.c > > > +++ b/hw/virtio/virtio.c > > > @@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice *vdev, int n) > > > vdev->vq[n].vring.num_default = 0; > > > vdev->vq[n].handle_output = NULL; > > > vdev->vq[n].handle_aio_output = NULL; > > > + /* > > > + * with vring.num = 0 the queue will be ignored > > > + * in later loops of region cache reset > > > + */ > > > > > > I can't get the meaning of this comment. > > > > Thanks > > > > > > > + virtio_virtqueue_reset_region_cache(&vdev->vq[n]); Do we need to drop this from virtio_device_free_virtqueues then?
Quoted 6 lines
Not mandatory. Repetitive virtio_virtqueue_reset_region_cache does not do anything bad.
Some of virtio devices do not do 'virtio_del_queue' at all. Currentlyvirtio_device_free_virtqueuesresets region cache for them.
IMO, not calling 'virtio_del_queue' is a bug, but not in the scope of current series, I'll take care of that later.
Maybe we should just del all queues in virtio_device_unrealize? Will allow us to drop some logic tracking which vqs were created.
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
g_free(vdev->vq[n].used_elems);
}
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 69 lines · Michael S. Tsirkin
Quoted 3 lines · Yuri Benditovich
On Thu, Jan 2, 2020 at 1:50 AM Michael S. Tsirkin <[email protected]>
Quoted 3 lines · wrote:
On Thu, Dec 26, 2019 at 11:29:50AM +0200, Yuri Benditovich wrote: > On Thu, Dec 26, 2019 at 10:58 AM Jason Wang <[email protected]>Quoted 9 lines · wrote:
Quoted 9 lines
Quoted 9 lines · Yuri Benditovich
Quoted 3 lines
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.More information is needed here, the bug said only q35 can meet
this
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
issue. What makes q35 different here?
I do not have any ready answer, I did not dig into it too much. Probably Michael Tsirkin or Paolo Bonzini can answer without
digging.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Signed-off-by Yuri Benditovich <[email protected]>--- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
hw/virtio/virtio.c void virtio_del_queue(VirtIODevice
Quoted 5 lines
hw/virtio/virtio.c +0
-0@@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice*vdev, int
Quoted 22 lines
n) > > > vdev->vq[n].vring.num_default = 0; > > > vdev->vq[n].handle_output = NULL; > > > vdev->vq[n].handle_aio_output = NULL; > > > + /* > > > + * with vring.num = 0 the queue will be ignored > > > + * in later loops of region cache reset > > > + */ > > > > > > I can't get the meaning of this comment. > > > > Thanks > > > > > > > + virtio_virtqueue_reset_region_cache(&vdev->vq[n]); Do we need to drop this from virtio_device_free_virtqueues then?Quoted 1 line
Not mandatory. Repetitive
virtio_virtqueue_reset_region_cachedoes notdo
Quoted 4 lines
anything bad.
Some of virtio devices do not do 'virtio_del_queue' at all. Currentlyvirtio_device_free_virtqueuesresets region cache for them. IMO, not calling 'virtio_del_queue' is a bug, but not in the scope of
Quoted 7 lines
current
Quoted 1 line
series, I'll take care of that later.
Maybe we should just del all queues in
virtio_device_unrealize? Will allow us to drop some logic tracking which vqs were created.
Yes, this is also possible with some rework of virtio_device_free_virtqueues.
virtio-net has some additional operations around queue deletion, it deletes queues when switches from single queue to multiple.
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
hw/virtio/virtio.c +0
-0g_free (vdev->vq[n].used_elems); }
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Michael,
Can you please comment on Jason's question: why we have a problem only with q35 and not with legacy pc?
If you have a simple answer, it will help us in further work with other hot plug/unplug problems.
Thanks,
Yuri Benditovich
Quoted 96 lines · Yuri Benditovich
Quoted 69 lines · Michael S. Tsirkin
Quoted 3 lines · Yuri Benditovich
On Thu, Jan 2, 2020 at 1:50 AM Michael S. Tsirkin <[email protected]>
Quoted 3 lines · wrote:
On Thu, Dec 26, 2019 at 11:29:50AM +0200, Yuri Benditovich wrote: > On Thu, Dec 26, 2019 at 10:58 AM Jason Wang <[email protected]>Quoted 9 lines · wrote:
Quoted 9 lines
Quoted 9 lines · Yuri Benditovich
Quoted 3 lines
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.More information is needed here, the bug said only q35 can meet
this
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
issue. What makes q35 different here?
I do not have any ready answer, I did not dig into it too much. Probably Michael Tsirkin or Paolo Bonzini can answer without
digging.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Signed-off-by Yuri Benditovich <[email protected]>--- hw/virtio/virtio.c | 5 +++++ 1 file changed, 5 insertions(+)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
hw/virtio/virtio.c void virtio_del_queue(VirtIODevice
Quoted 5 lines
hw/virtio/virtio.c +0
-0@@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice*vdev, int
Quoted 22 lines
n) > > > vdev->vq[n].vring.num_default = 0; > > > vdev->vq[n].handle_output = NULL; > > > vdev->vq[n].handle_aio_output = NULL; > > > + /* > > > + * with vring.num = 0 the queue will be ignored > > > + * in later loops of region cache reset > > > + */ > > > > > > I can't get the meaning of this comment. > > > > Thanks > > > > > > > + virtio_virtqueue_reset_region_cache(&vdev->vq[n]); Do we need to drop this from virtio_device_free_virtqueues then?Quoted 1 line
Not mandatory. Repetitive
virtio_virtqueue_reset_region_cachedoes notdo
Quoted 4 lines
anything bad.
Some of virtio devices do not do 'virtio_del_queue' at all. Currentlyvirtio_device_free_virtqueuesresets region cache for them. IMO, not calling 'virtio_del_queue' is a bug, but not in the scope ofQuoted 7 lines
current
Quoted 1 line
series, I'll take care of that later.
Maybe we should just del all queues in
virtio_device_unrealize? Will allow us to drop some logic tracking which vqs were created.Yes, this is also possible with some rework of
virtio_device_free_virtqueues.
virtio-net has some additional operations around queue deletion, it deletes queues when switches from single queue to multiple.Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
hw/virtio/virtio.c +0
-0g_free (vdev->vq[n].used_elems); }
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
I guess it somehow has to do with the following:
if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) {
proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF;
}so by default device on an express port does not have a legacy interface.
Somehow having a legacy interface fixes things?
Does enabling legacy on q35 without this patch fix things? And does disabling legacy on PIIX without this patch break thing?
How can having a legacy interface fix things if it's not even active? I don't know. Is there a chance windows drivers use the legacy interface on a transitional device by mistake?
Quoted 111 lines · Yuri Benditovich
Michael,
Can you please comment on Jason's question: why we have a problem only with q35 and not with legacy pc?
If you have a simple answer, it will help us in further work with other hot plug/unplug problems.Thanks,
Yuri BenditovichOn Sun, Jan 5, 2020 at 6:21 PM Yuri Benditovich <[email protected]> wrote:
On Sun, Jan 5, 2020 at 1:39 PM Michael S. Tsirkin <[email protected]> wrote:
On Thu, Jan 02, 2020 at 09:09:04AM +0200, Yuri Benditovich wrote:
>
>
> On Thu, Jan 2, 2020 at 1:50 AM Michael S. Tsirkin <[email protected]> wrote:
>
> On Thu, Dec 26, 2019 at 11:29:50AM +0200, Yuri Benditovich wrote:
> > On Thu, Dec 26, 2019 at 10:58 AM Jason Wang < [email protected]> wrote:
> > >
> > >
> > > On 2019/12/26 下午12:36, Yuri Benditovich wrote:
> > > > https://bugzilla.redhat.com/show_bug.cgi?id=1708480
> > > > Fix leak of region reference that prevents complete > > > > device deletion on hot unplug.
> > >
> > >
> > > More information is needed here, the bug said only q35 can meet this
> > > issue. What makes q35 different here?
> > >
> >
> > I do not have any ready answer, I did not dig into it too much. > > Probably Michael Tsirkin or Paolo Bonzini can answer without digging.
>
>
>
> > >
> > > >
> > > > Signed-off-by: Yuri Benditovich < [email protected]>
> > > > ---
> > > > hw/virtio/virtio.c | 5 +++++
> > > > 1 file changed, 5 insertions(+)
> > > >
> > > > diff --gita/hw/virtio/virtio.cb/hw/virtio/virtio.c> > > > index04716b5f6c..baadec8abc100644
> > > > ---a/hw/virtio/virtio.c
> > > > +++b/hw/virtio/virtio.c
> > > > @@ -2340,6 +2340,11 @@ void virtio_del_queue(VirtIODevice *vdev, int
> n)
> > > > vdev->vq[n].vring.num_default = 0;
> > > > vdev->vq[n].handle_output = NULL;
> > > > vdev->vq[n].handle_aio_output = NULL;
> > > > + /*
> > > > + * with vring.num = 0 the queue will be ignored > > > > + * in later loops of region cache reset
> > > > + */
> > >
> > >
> > > I can't get the meaning of this comment.
> > >
> > > Thanks
> > >
> > >
> > > > +virtio_virtqueue_reset_region_cache(&vdev->vq[n]); >
>
> Do we need to drop this fromvirtio_device_free_virtqueuesthen? >
>
>
> Not mandatory. Repetitive virtio_virtqueue_reset_region_cache does not do
> anything bad.
> Some of virtio devices do not do 'virtio_del_queue' at all. Currently
>virtio_device_free_virtqueuesresets region cache for them. > IMO, not calling 'virtio_del_queue' is a bug, but not in the scope of current
> series, I'll take care of that later.Maybe we should just del all queues in
virtio_device_unrealize? Will allow us to drop some logic tracking which vqs were created.Yes, this is also possible with some rework of
virtio_device_free_virtqueues.
virtio-net has some additional operations around queue deletion, it deletes queues when switches from single queue to multiple.>
> > > > g_free(vdev->vq[n].used_elems); > > > > }
> > > >
> > >
>
>
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 11 lines · Michael S. Tsirkin
I guess it somehow has to do with the following:
if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) { proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; }so by default device on an express port does not have a legacy interface.
Somehow having a legacy interface fixes things?
I'll check it.
Quoted 2 lines
Does enabling legacy on q35 without this patch fix things?
I'll check it also.
Quoted 2 lines
And does disabling legacy on PIIX without this patch break thing?
I'll check it also.
Quoted 6 lines
How can having a legacy interface fix things if it's not even active? I don't know. Is there a chance windows drivers use the legacy interface on a transitional device by mistake?
I'll recheck it. I do not think we use legacy interface on modern device even if it has one.
Quoted 130 lines · Yuri Benditovich
Quoted 2 lines
Michael,
Can you please comment on Jason's question: why we have a problem onlywith q35
Quoted 2 lines
and not with legacy pc?
If you have a simple answer, it will help us in further work with otherhot
Quoted 6 lines
plug/unplug problems.
Thanks,
Yuri BenditovichOn Sun, Jan 5, 2020 at 6:21 PM Yuri Benditovich <
Quoted 5 lines
wrote:
On Sun, Jan 5, 2020 at 1:39 PM Michael S. Tsirkin <[email protected]>
Quoted 5 lines · wrote:
On Thu, Jan 02, 2020 at 09:09:04AM +0200, Yuri Benditovich wrote: > > > On Thu, Jan 2, 2020 at 1:50 AM Michael S. Tsirkin <Quoted 3 lines
wrote: > > On Thu, Dec 26, 2019 at 11:29:50AM +0200, Yuri BenditovichQuoted 11 lines · wrote:
> > On Thu, Dec 26, 2019 at 10:58 AM Jason Wang < [email protected]> wrote: > > > > > > > > > On 2019/12/26 下午12:36, Yuri Benditovich wrote: > > > > https://bugzilla.redhat.com/show_bug.cgi?id=1708480 > > > > Fix leak of region reference that prevents complete > > > > device deletion on hot unplug. > > > > > > > > > More information is needed here, the bug said only q35can
Quoted 5 lines
meet this
> > > issue. What makes q35 different here?
> > >
> >
> > I do not have any ready answer, I did not dig into ittoo much.
Quoted 1 line
> > Probably Michael Tsirkin or Paolo Bonzini can answer
without
Quoted 9 lines
digging. > > > > > > > > > > > > > > Signed-off-by: Yuri Benditovich < [email protected]> > > > > ---Quoted 8 lines
> > > > hw/virtio/virtio.c | 5 +++++ > > > > 1 file changed, 5 insertions(+) > > > > > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > > > index 04716b5f6c..baadec8abc 100644 > > > > --- a/hw/virtio/virtio.c > > > > +++ b/hw/virtio/virtio.c > > > > @@ -2340,6 +2340,11 @@ voidvirtio_del_queue(VirtIODevice
Quoted 9 lines
*vdev, int > n) > > > > vdev->vq[n].vring.num_default = 0; > > > > vdev->vq[n].handle_output = NULL; > > > > vdev->vq[n].handle_aio_output = NULL; > > > > + /* > > > > + * with vring.num = 0 the queue will be ignored > > > > + * in later loops of region cache reset > > > > + */Quoted 8 lines
> > > > > > > > > I can't get the meaning of this comment. > > > > > > Thanks > > > > > > > > > > +
virtio_virtqueue_reset_region_cache(&vdev->vq[n]);Quoted 3 lines
> > > Do we need to drop this from virtio_device_free_virtqueuesthen?
Quoted 4 lines
> > > > Not mandatory. Repetitive
virtio_virtqueue_reset_region_cachedoesQuoted 6 lines
not do
> anything bad.
> Some of virtio devices do not do 'virtio_del_queue' at all. Currently
>virtio_device_free_virtqueuesresets region cache for them. > IMO, not calling 'virtio_del_queue' is a bug, but not in thescope of
Quoted 11 lines
current
> series, I'll take care of that later.Maybe we should just del all queues in
virtio_device_unrealize? Will allow us to drop some logic tracking which vqs were created.Yes, this is also possible with some rework of
virtio_device_free_virtqueues.
virtio-net has some additional operations around queue deletion, itdeletes
Quoted 13 lines
queues when switches from single queue to multiple. > > > > > g_free(vdev->vq[n].used_elems); > > > > } > > > > > > > > >
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 10 lines · Yuri Benditovich
Quoted 7 lines · Michael S. Tsirkin
I guess it somehow has to do with the following:
if (proxy->disable_legacy == ON_OFF_AUTO_AUTO) { proxy->disable_legacy = pcie_port ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; }
Quoted 6 lines
Quoted 4 lines
so by default device on an express port does not have a legacy interface.
Somehow having a legacy interface fixes things?
No, transitional virtio-net on q35 behaves exactly as the modern one.
Quoted 6 lines
Quoted 4 lines
Does enabling legacy on q35 without this patch fix things?
No, legacy virtio-net on q35 has the same problem.
There is also an additional problem with legacy device unplug on q35, but I think it is not in the scope of this discussion.
Quoted 6 lines
Quoted 4 lines
And does disabling legacy on PIIX without this patch break thing?
No, modern device on PIIX does hot unplug without problems.
Quoted 8 lines
Quoted 7 lines
How can having a legacy interface fix things if it's not even active? I don't know. Is there a chance windows drivers use the legacy interface on a transitional device by mistake?
As far as I can see - no. The driver works with the device depending on VERSION_1
Quoted 136 lines
I'll recheck it. I do not think we use legacy interface on modern device even if it has one.
Quoted 132 lines · Yuri Benditovich
Quoted 2 lines
Michael,
Can you please comment on Jason's question: why we have a problem onlywith q35
Quoted 2 lines
and not with legacy pc?
If you have a simple answer, it will help us in further work with otherhot
Quoted 6 lines
plug/unplug problems.
Thanks,
Yuri BenditovichOn Sun, Jan 5, 2020 at 6:21 PM Yuri Benditovich <
Quoted 5 lines
wrote:
On Sun, Jan 5, 2020 at 1:39 PM Michael S. Tsirkin <[email protected]>
Quoted 2 lines · wrote:
On Thu, Jan 02, 2020 at 09:09:04AM +0200, Yuri BenditovichQuoted 3 lines · wrote:
> > > On Thu, Jan 2, 2020 at 1:50 AM Michael S. Tsirkin <Quoted 3 lines
wrote: > > On Thu, Dec 26, 2019 at 11:29:50AM +0200, YuriQuoted 11 lines · Benditovich
> > On Thu, Dec 26, 2019 at 10:58 AM Jason Wang < [email protected]> wrote: > > > > > > > > > On 2019/12/26 下午12:36, Yuri Benditovich wrote: > > > > https://bugzilla.redhat.com/show_bug.cgi?id=1708480 > > > > Fix leak of region reference that prevents complete > > > > device deletion on hot unplug. > > > > > > > > > More information is needed here, the bug said onlyq35 can
Quoted 5 lines
meet this
> > > issue. What makes q35 different here?
> > >
> >
> > I do not have any ready answer, I did not dig into ittoo much.
Quoted 1 line
> > Probably Michael Tsirkin or Paolo Bonzini can answer
without
Quoted 9 lines
digging. > > > > > > > > > > > > > > Signed-off-by: Yuri Benditovich < [email protected]> > > > > ---Quoted 8 lines
> > > > hw/virtio/virtio.c | 5 +++++ > > > > 1 file changed, 5 insertions(+) > > > > > > > > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c > > > > index 04716b5f6c..baadec8abc 100644 > > > > --- a/hw/virtio/virtio.c > > > > +++ b/hw/virtio/virtio.c > > > > @@ -2340,6 +2340,11 @@ voidvirtio_del_queue(VirtIODevice
Quoted 9 lines
*vdev, int > n) > > > > vdev->vq[n].vring.num_default = 0; > > > > vdev->vq[n].handle_output = NULL; > > > > vdev->vq[n].handle_aio_output = NULL; > > > > + /* > > > > + * with vring.num = 0 the queue will be ignored > > > > + * in later loops of region cache reset > > > > + */Quoted 8 lines
> > > > > > > > > I can't get the meaning of this comment. > > > > > > Thanks > > > > > > > > > > +
virtio_virtqueue_reset_region_cache(&vdev->vq[n]);Quoted 3 lines
> > > Do we need to drop this from
virtio_device_free_virtqueuesthen?Quoted 4 lines
> > > > Not mandatory. Repetitive
virtio_virtqueue_reset_region_cachedoesQuoted 6 lines
not do
> anything bad.
> Some of virtio devices do not do 'virtio_del_queue' at all. Currently
>virtio_device_free_virtqueuesresets region cache for them. > IMO, not calling 'virtio_del_queue' is a bug, but not in thescope of
Quoted 5 lines
current
> series, I'll take care of that later.Maybe we should just del all queues in
virtio_device_unrealize? Will allow us to drop some logic tracking which vqs werecreated.
Quoted 6 lines
Yes, this is also possible with some rework of
virtio_device_free_virtqueues.
virtio-net has some additional operations around queue deletion, itdeletes
Quoted 13 lines
queues when switches from single queue to multiple. > > > > > g_free(vdev->vq[n].used_elems); > > > > } > > > > > > > > >
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
In reply to Yuri BenditovichQuoted 5 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.Signed-off-by Yuri Benditovich <[email protected]>
I rebased this on top of my tree.
Got this:
commit f3dee6a062c1f4445768296ee39070bab9863372
Author: Yuri Benditovich <[email protected]> Date: Thu Dec 26 06:36:48 2019 +0200
virtio: reset region cache when on queue deletion
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.
Message-Id: <[email protected]>
hw/virtio/virtio.c +1 -0
@@ -2344,6 +2344,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_aio_output =NULL ;g_free (vq->used_elems); vq->used_elems =NULL ; +virtio_virtqueue_reset_region_cache (vq); }void virtio_del_queue (VirtIODevice *vdev,int n)
Can you confirm pls?
Re: [PATCH 1/2] virtio: reset region cache when on queue deletion
Quoted 38 lines · Michael S. Tsirkin
Quoted 5 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.Signed-off-by Yuri Benditovich <[email protected]>I rebased this on top of my tree.
Got this:
commit
f3dee6a062c1f4445768296ee39070bab9863372Author: Yuri Benditovich <[email protected]> Date: Thu Dec 26 06:36:48 2019 +0200virtio: reset region cache when on queue deletion
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
Fix leak of region reference that prevents complete device deletion on hot unplug.Signed-off-by Yuri Benditovich <[email protected]>Message-Id: <[email protected]>
hw/virtio/virtio.c +1
-0@@ -2344,6 +2344,7 @@ void virtio_delete_queue(VirtQueue *vq) vq->handle_aio_output =NULL ;g_free (vq->used_elems); vq->used_elems =NULL ; +virtio_virtqueue_reset_region_cache (vq); }void virtio_del_queue (VirtIODevice *vdev,int n)
Quoted 2 lines
Can you confirm pls?
Yes, it is
PATCH 2/2 virtio-net: delete also control queue when TX/RX deleted
In reply to Yuri Benditovichhttps://bugzilla.redhat.com/show_bug.cgi?id=1708480
If the control queue is not deleted together with TX/RX, it later will be ignored in freeing cache resources and hot unplug will not be completed.
--- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/net/virtio-net.c +2 -1
@@ -3101,7 +3101,8 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)for (i =0 ; i < max_queues; i++) {virtio_net_del_queue (n, i); } - +/* delete also control vq */ +virtio_del_queue (vdev, max_queues *2 );qemu_announce_timer_del (&n->announce_timer, false);g_free (n->vqs);qemu_del_nic (n->nic);
Signature · 1 line
2.17.1
Re: [PATCH 2/2] virtio-net: delete also control queue when TX/RX deleted
Quoted 15 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
If the control queue is not deleted together with TX/RX, it later will be ignored in freeing cache resources and hot unplug will not be completed.Signed-off-by Yuri Benditovich <[email protected]>--- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/net/virtio-net.c +0
-0
hw/net/virtio-net.c static void virtio_net_device_unrealize(DeviceState *dev, Error **errp) · line 3108
Quoted 9 lines
hw/net/virtio-net.c +2
-1@@ -3101,7 +3101,8 @@ static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)for (i =0 ; i < max_queues; i++) {virtio_net_del_queue (n, i); } - +/* delete also control vq */ +virtio_del_queue (vdev, max_queues *2 );qemu_announce_timer_del (&n->announce_timer, false);g_free (n->vqs);qemu_del_nic (n->nic);
Do we need to limit this to when ctrl vq exists?
Quoted 2 lines
Signature · 1 line
2.17.1
Re: [PATCH 2/2] virtio-net: delete also control queue when TX/RX deleted
Quoted 27 lines · Michael S. Tsirkin
hw/net/virtio-net.c static void
Quoted 15 lines · Yuri Benditovich
https://bugzilla.redhat.com/show_bug.cgi?id=1708480
If the control queue is not deleted together with TX/RX, it later will be ignored in freeing cache resources and hot unplug will not be completed.Signed-off-by Yuri Benditovich <[email protected]>--- hw/net/virtio-net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)hw/net/virtio-net.c +0
-0@@ -3101,7 +3101,8 @@ static void
virtio_net_device_unrealize(DeviceState *dev, Error **errp)hw/net/virtio-net.c static void virtio_net_device_unrealize(DeviceState *dev, Error **errp) · line 3108
Quoted 9 lines
hw/net/virtio-net.c +2
-1for (i =0 ; i < max_queues; i++) {virtio_net_del_queue (n, i); } - +/* delete also control vq */ +virtio_del_queue (vdev, max_queues *2 );qemu_announce_timer_del (&n->announce_timer, false);g_free (n->vqs);qemu_del_nic (n->nic);
Quoted 2 lines
Do we need to limit this to when ctrl vq exists?
ctrl vq always exists (we _add_ it unconditionally).
we may suggest respective feature or not, but the initialized queue structure present.
Quoted 5 lines
Quoted 3 lines
--
2.17.1