Re: [PATCH] virtio_console: remove vq buf while unpluging port
From: Amit Shah
Date: Tue May 28 2019 - 09:03:18 EST
On Fri, 2019-05-24 at 20:51 +0200, Greg KH wrote:
> On Sun, Apr 28, 2019 at 09:50:04AM +0800, zhenwei pi wrote:
> > A bug can be easily reproduced:
> > Host# cat guest-agent.xml
> > <channel type="unix">
> > <source mode="bind" path="/var/lib/libvirt/qemu/stretch.agent"/>
> > <target type="virtio" name="org.qemu.guest_agent.0"
> > state="connected"/>
> > </channel>
> > Host# virsh attach-device instance guest-agent.xml
> > Host# virsh detach-device instance guest-agent.xml
> > Host# virsh attach-device instance guest-agent.xml
> >
> > and guest report: virtio-ports vport0p1: Error allocating inbufs
> >
> > The reason is that the port is unplugged and the vq buf still
> > remained.
> > So, fix two cases in this patch:
> > 1, fix memory leak with attach-device/detach-device.
> > 2, fix logic bug with attach-device/detach-device/attach-device.
The "leak" happens because the host-side of the connection is still
connected. This is by design -- if a guest has written data before
being unplugged, the port isn't released till the host connection goes
down to ensure a host process reads all the data out of the port.
Can you try similar, but also disconnecting the host side and see if
that fixes things?
> Amit, any ideas if this is valid or not and if this should be
> applied?
This had indeed been missed, thanks!
Amit