libxl: remove console 0 backend directory from xenstore on devices destroy
PATCH 1/1 libxl: remove console 0 backend directory from xenstore on devices destroy
# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1286198484 -3600
# Node ID d59be7a8e1e3bc439bb01a0f89d43411210fedcb
# Parent 1cae52330eebbe448586c0a173945bc2bf8d631f
libxl: remove console 0 backend directory from xenstore on devices destroy
The is (deliberately) no frontend directory for console 0 in xenstore. Therefore to avoid leaking /local/domain/0/backend/console/$domid/0 check explicitly for this backend directory and remove.
tools/libxl/libxl_device.c +12 -1
@@ -294,7 +294,7 @@ int libxl__devices_destroy(libxl_ctx *ctint libxl__devices_destroy (libxl_ctx *ctx,uint32_t domid,int force) {libxl__gc gc =LIBXL_INIT_GC (ctx); -char *path, *be_path, *fe_path; +char *path, *be_path, *fe_path, *tmp;unsigned int num1, num2;char **l1 =NULL , **l2 =NULL ;int i, j, n =0 , n_watches =0 ;
@@ -326,6 +326,17 @@ int libxl__devices_destroy(libxl_ctx *ct } } } + +/* console 0 has no frontend directory, check for a backend */ + be_path =libxl__sprintf (&gc,"/local/domain/0/backend/console/%d/0" , domid); + tmp =xs_read (ctx->xsh,XBT_NULL , be_path,NULL ); +if (tmp) { +if (libxl__device_destroy (ctx, be_path, force) >0 ) + n_watches++; +flexarray_set (toremove, n++,libxl__dirname (&gc, be_path)); +free (tmp); + } +if (!force) {/* Linux-ism. Most implementations leave the timeout * untouched after select. Linux, however, will chip
Quoted 11 lines · Ian Campbell
# HG changeset patch
# User Ian Campbell <[email protected]>
# Date 1286198484 -3600
# Node IDd59be7a8e1e3bc439bb01a0f89d43411210fedcb
# Parent1cae52330eebbe448586c0a173945bc2bf8d631f
libxl: remove console 0 backend directory from xenstore on devices destroyThe is (deliberately) no frontend directory for console 0 in xenstore. Therefore to avoid leaking /local/domain/0/backend/console/$domid/0 check explicitly for this backend directory and remove.
Thinking about this some more it might be preferable to write /local/domain/domid/console/{backend,backend-id} giving us a concrete pointer to the backend we wish to destroy, this would cope better with console backends in dom!=0 too.
I'm assuming its not a mistake that the backend exists in the first place?
Ian.