[PATCH] libxl: cleanup remaining backend xs dirs after driver domain

Marek Marczykowski-Górecki posted 1 patch 3 years, 5 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20201108145942.3089012-1-marmarek@invisiblethingslab.com
tools/libs/light/libxl_device.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] libxl: cleanup remaining backend xs dirs after driver domain
Posted by Marek Marczykowski-Górecki 3 years, 5 months ago
When device is removed, backend domain (which may be a driver domain) is
responsible for removing backend entries from xenstore. But in case of
driver domain, it has no access to remove all of them - specifically the
directory named after frontend-id remains. This may accumulate enough to
exceed xenstore quote of the driver domain, breaking further devices.

Fix this by calling libxl__xs_path_cleanup() on the backend path from
libxl__device_destroy() in the toolstack domain too. Note
libxl__device_destroy() is called when the driver domain already removed
what it can (see device_destroy_be_watch_cb()->device_hotplug_done()).

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/libs/light/libxl_device.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/libs/light/libxl_device.c b/tools/libs/light/libxl_device.c
index e081faf9a94e..f131a6c822c6 100644
--- a/tools/libs/light/libxl_device.c
+++ b/tools/libs/light/libxl_device.c
@@ -763,6 +763,12 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
              * from the backend path.
              */
             libxl__xs_path_cleanup(gc, t, be_path);
+        } else if (domid == LIBXL_TOOLSTACK_DOMID && !libxl_only) {
+            /*
+             * Then, toolstack domain is in charge of removing the parent
+             * directory if empty already.
+             */
+            libxl__xs_path_cleanup(gc, t, be_path);
         }
 
         rc = libxl__xs_transaction_commit(gc, &t);
-- 
2.25.4


Re: [PATCH] libxl: cleanup remaining backend xs dirs after driver domain
Posted by Marek Marczykowski-Górecki 3 years, 4 months ago
On Sun, Nov 08, 2020 at 03:59:42PM +0100, Marek Marczykowski-Górecki wrote:
> When device is removed, backend domain (which may be a driver domain) is
> responsible for removing backend entries from xenstore. But in case of
> driver domain, it has no access to remove all of them - specifically the
> directory named after frontend-id remains. This may accumulate enough to
> exceed xenstore quote of the driver domain, breaking further devices.
> 
> Fix this by calling libxl__xs_path_cleanup() on the backend path from
> libxl__device_destroy() in the toolstack domain too. Note
> libxl__device_destroy() is called when the driver domain already removed
> what it can (see device_destroy_be_watch_cb()->device_hotplug_done()).
> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>

Ping?

> ---
>  tools/libs/light/libxl_device.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/tools/libs/light/libxl_device.c b/tools/libs/light/libxl_device.c
> index e081faf9a94e..f131a6c822c6 100644
> --- a/tools/libs/light/libxl_device.c
> +++ b/tools/libs/light/libxl_device.c
> @@ -763,6 +763,12 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
>               * from the backend path.
>               */
>              libxl__xs_path_cleanup(gc, t, be_path);
> +        } else if (domid == LIBXL_TOOLSTACK_DOMID && !libxl_only) {
> +            /*
> +             * Then, toolstack domain is in charge of removing the parent
> +             * directory if empty already.
> +             */
> +            libxl__xs_path_cleanup(gc, t, be_path);
>          }
>  
>          rc = libxl__xs_transaction_commit(gc, &t);

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
Re: [PATCH] libxl: cleanup remaining backend xs dirs after driver domain
Posted by Wei Liu 3 years, 3 months ago
On Wed, Dec 09, 2020 at 04:01:21PM +0100, Marek Marczykowski-Górecki wrote:
> On Sun, Nov 08, 2020 at 03:59:42PM +0100, Marek Marczykowski-Górecki wrote:
> > When device is removed, backend domain (which may be a driver domain) is
> > responsible for removing backend entries from xenstore. But in case of
> > driver domain, it has no access to remove all of them - specifically the
> > directory named after frontend-id remains. This may accumulate enough to
> > exceed xenstore quote of the driver domain, breaking further devices.
> > 
> > Fix this by calling libxl__xs_path_cleanup() on the backend path from
> > libxl__device_destroy() in the toolstack domain too. Note
> > libxl__device_destroy() is called when the driver domain already removed
> > what it can (see device_destroy_be_watch_cb()->device_hotplug_done()).
> > 
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> 
> Ping?

Acked-by: Wei Liu <wl@xen.org>