libxl: include a XLU_Config in _libxlDriverConfig
PATCH 1/1 libxl: include a XLU_Config in _libxlDriverConfig
Upcoming changes for vscsi will use libxlutil.so to prepare the configuration for libxl. The helpers needs a xlu struct for logging. Provide one and reuse the existing output as log target.
--- src/libxl/libxl_conf.c | 6 ++++++ src/libxl/libxl_conf.h | 7 +++++++ 2 files changed, 13 insertions(+)
src/libxl/libxl_conf.c +6 -0
@@ -1454,6 +1454,12 @@ libxlDriverConfigNew(void) goto error; } + cfg->xlu =xlu_cfg_init (cfg->logger_file,"libvirt" ); +if (!cfg->xlu) { +VIR_ERROR (_ ("cannot create xlu for libxenlight, disabling driver" )); + goto error; + } +if (libxl_ctx_alloc (&cfg->ctx,LIBXL_VERSION ,0 , cfg->logger)) {VIR_ERROR (_ ("cannot initialize libxenlight context, probably not " "running in a Xen Dom0, disabling driver" ));
src/libxl/libxl_conf.h +7 -0
@@ -27,6 +27,12 @@# define LIBXL_CONF_H # include <libxl.h> +#ifdef HAVE_LIBXLUTIL_H +# include <libxlutil.h> +#else +typedef struct XLU_Config XLU_Config ; +XLU_Config *xlu_cfg_init (FILE *report,const char *report_filename); +#endif # include "internal.h" # include "libvirt_internal.h"
@@ -91,6 +97,7 @@ struct _libxlDriverConfig {/* log stream for driver-wide libxl ctx */ FILE *logger_file;xentoollog_logger *logger; +XLU_Config *xlu;/* libxl ctx for driver wide ops; getVersion, getNodeInfo, ... */ libxl_ctx *ctx;
Quoted 4 lines · Olaf Hering
Upcoming changes for vscsi will use libxlutil.so to prepare the configuration for libxl. The helpers needs a xlu struct for logging. Provide one and reuse the existing output as log target.
Do you not need to call xlu_cfg_destroy at some point?
Wei.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Wei Liu
Quoted 4 lines · Olaf Hering
Upcoming changes for vscsi will use libxlutil.so to prepare the configuration for libxl. The helpers needs a xlu struct for logging. Provide one and reuse the existing output as log target.
Do you not need to call
xlu_cfg_destroyat some point?
Since libvirtd runs forever there is very little code to undo most things. But I will see if there is any unload function, did not actively look for such thing.
Olaf
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Olaf Hering
Since libvirtd runs forever there is very little code to undo most things. But I will see if there is any unload function, did not actively look for such thing.
Looking through libxlStateDriver it seems that libxl and libxlu remains as is. Not sure if thats supposed that way or if perhaps libxl should be fully reinitialized during ->stateReload, and if logfiles should be closed in ->stateCleanup.
Olaf
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Olaf Hering
Quoted 3 lines · Olaf Hering
Since libvirtd runs forever there is very little code to undo most things. But I will see if there is any unload function, did not actively look for such thing.
Looking through libxlStateDriver it seems that libxl and libxlu remains as is. Not sure if thats supposed that way or if perhaps libxl should be fully reinitialized during ->stateReload, and if logfiles should be closed in ->stateCleanup.
FWIW libxl ctx is destroy in libxlDriverConfigDispose. You can probably just call xlu_cfg_destroy there.
Anyway, I'm not a libvirt expert. I just don't like leaking memory. :-)
Wei.
Quoted 1 line
Olaf
Quoted 8 lines · Olaf Hering
Quoted 4 lines · Olaf Hering
Since libvirtd runs forever there is very little code to undo most things. But I will see if there is any unload function, did not actively look for such thing.
Quoted 5 lines
Looking through libxlStateDriver it seems that libxl and libxlu remains as is. Not sure if thats supposed that way or if perhaps libxl should be fully reinitialized during ->stateReload, and if logfiles should be closed in ->stateCleanup.
Closing log files, freeing libxl_ctx, etc. is done (indirectly) in stateCleanup. The libxlDriverConfig object is unrefed, which should result in calling libxlDriverConfigDispose().
Jim
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 16 lines · Wei Liu
Quoted 13 lines · Olaf Hering
Quoted 4 lines · Olaf Hering
Since libvirtd runs forever there is very little code to undo most things. But I will see if there is any unload function, did not actively look for such thing.
Looking through libxlStateDriver it seems that libxl and libxlu remains as is. Not sure if thats supposed that way or if perhaps libxl should be fully reinitialized during ->stateReload, and if logfiles should be closed in ->stateCleanup.
Quoted 3 lines
FWIW libxl ctx is destroy in libxlDriverConfigDispose. You can probably just call
xlu_cfg_destroythere.
Right. Any additions to the libxlDriverConfig object that needs to be cleaned up should be done in libxlDriverConfigDispose.
Regards,
Jim
Quoted 7 lines · Wei Liu
Quoted 6 lines · Olaf Hering
Quoted 3 lines · Olaf Hering
Since libvirtd runs forever there is very little code to undo most things. But I will see if there is any unload function, did not actively look for such thing.
Quoted 8 lines
Quoted 5 lines
Looking through libxlStateDriver it seems that libxl and libxlu remains as is. Not sure if thats supposed that way or if perhaps libxl should be fully reinitialized during ->stateReload, and if logfiles should be closed in ->stateCleanup.
FWIW libxl ctx is destroy in libxlDriverConfigDispose. You can probably just call
xlu_cfg_destroythere.
In libvirt libxlDriverConfigDispose calls both libxl_ctx_free and xtl_logger_destroy. Both functions check if the input is valid, just xlu_cfg_destroy dereferences the input unconditionally. Should xlu_cfg_destroy be changed to do nothing if it gets passed a NULL pointer?
Olaf
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 15 lines · Olaf Hering
Quoted 13 lines · Wei Liu
Quoted 11 lines · Olaf Hering
Quoted 3 lines · Olaf Hering
Since libvirtd runs forever there is very little code to undo most things. But I will see if there is any unload function, did not actively look for such thing.
Looking through libxlStateDriver it seems that libxl and libxlu remains as is. Not sure if thats supposed that way or if perhaps libxl should be fully reinitialized during ->stateReload, and if logfiles should be closed in ->stateCleanup.
Quoted 9 lines
Quoted 2 lines
FWIW libxl ctx is destroy in libxlDriverConfigDispose. You can probably just call
xlu_cfg_destroythere.In libvirt libxlDriverConfigDispose calls both
libxl_ctx_freeandxtl_logger_destroy. Both functions check if the input is valid, justxlu_cfg_destroydereferences the input unconditionally. Shouldxlu_cfg_destroybe changed to do nothing if it gets passed a NULL pointer?
That is orthogonal to this patch. I don't particularly care if it's NULL-tolerant or not. In any case, You will need to check validity for older libxl's xlu_cfg_destroy.
Wei.
Quoted 1 line
Olaf
Quoted 33 lines · Olaf Hering
Upcoming changes for vscsi will use libxlutil.so to prepare the configuration for libxl. The helpers needs a xlu struct for logging. Provide one and reuse the existing output as log target.
Signed-off-by Olaf Hering <[email protected]>Cc Jim Fehlig <[email protected]>--- src/libxl/libxl_conf.c | 6 ++++++ src/libxl/libxl_conf.h | 7 +++++++ 2 files changed, 13 insertions(+)src/libxl/libxl_conf.c +6
-0@@ -1454,6 +1454,12 @@ libxlDriverConfigNew(void) goto error; } + cfg->xlu =xlu_cfg_init (cfg->logger_file,"libvirt" ); +if (!cfg->xlu) { +VIR_ERROR (_ ("cannot create xlu for libxenlight, disabling driver" )); + goto error; + } +if (libxl_ctx_alloc (&cfg->ctx,LIBXL_VERSION ,0 , cfg->logger)) {VIR_ERROR (_ ("cannot initialize libxenlight context, probably not " "running in a Xen Dom0, disabling driver" ));src/libxl/libxl_conf.h +0
-0
src/libxl/libxl_conf.h line 36
Quoted 10 lines
src/libxl/libxl_conf.h +6
-0@@ -27,6 +27,12 @@# define LIBXL_CONF_H # include <libxl.h> +#ifdef HAVE_LIBXLUTIL_H +# include <libxlutil.h> +#else +typedef struct XLU_Config XLU_Config ; +XLU_Config *xlu_cfg_init (FILE *report,const char *report_filename); +#endif
In addition to the cleanup mentioned by Wei, you'll need to fix the indentation of these preprocessor directives. 'make syntax-check' would have caught that if you had cppi installed.
Regards,
Jim