diff mbox

[libvirt,v2,1/2] libxl: include a XLU_Config in _libxlDriverConfig

Message ID 1460538959-23584-2-git-send-email-olaf@aepfle.de (mailing list archive)
State New, archived
Headers show

Commit Message

Olaf Hering April 13, 2016, 9:15 a.m. UTC
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 <olaf@aepfle.de>
Cc: Jim Fehlig <jfehlig@suse.com>
---
 src/libxl/libxl_conf.c | 7 +++++++
 src/libxl/libxl_conf.h | 7 +++++++
 2 files changed, 14 insertions(+)

Comments

Jim Fehlig April 15, 2016, 9:23 p.m. UTC | #1
On 04/13/2016 03:15 AM, Olaf Hering wrote:
> 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 <olaf@aepfle.de>
> Cc: Jim Fehlig <jfehlig@suse.com>
> ---
>  src/libxl/libxl_conf.c | 7 +++++++
>  src/libxl/libxl_conf.h | 7 +++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
> index d16280d..f5ef50f 100644
> --- a/src/libxl/libxl_conf.c
> +++ b/src/libxl/libxl_conf.c
> @@ -93,6 +93,7 @@ libxlDriverConfigDispose(void *obj)
>      virObjectUnref(cfg->caps);
>      libxl_ctx_free(cfg->ctx);
>      xtl_logger_destroy(cfg->logger);
> +    xlu_cfg_destroy(cfg->xlu);

This fails to compile if HAVE_LIBXLUTIL_H is not defined.

>      if (cfg->logger_file)
>          VIR_FORCE_FCLOSE(cfg->logger_file);
>  
> @@ -1738,6 +1739,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"));
> diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
> index 3c0eafb..b069e45 100644
> --- a/src/libxl/libxl_conf.h
> +++ b/src/libxl/libxl_conf.h
> @@ -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);

You'll need to add xlu_cfg_destroy here.

Regards,
Jim

> +# endif
>  
>  # include "internal.h"
>  # include "libvirt_internal.h"
> @@ -96,6 +102,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;
>  
>
>
>
diff mbox

Patch

diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index d16280d..f5ef50f 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -93,6 +93,7 @@  libxlDriverConfigDispose(void *obj)
     virObjectUnref(cfg->caps);
     libxl_ctx_free(cfg->ctx);
     xtl_logger_destroy(cfg->logger);
+    xlu_cfg_destroy(cfg->xlu);
     if (cfg->logger_file)
         VIR_FORCE_FCLOSE(cfg->logger_file);
 
@@ -1738,6 +1739,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"));
diff --git a/src/libxl/libxl_conf.h b/src/libxl/libxl_conf.h
index 3c0eafb..b069e45 100644
--- a/src/libxl/libxl_conf.h
+++ b/src/libxl/libxl_conf.h
@@ -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"
@@ -96,6 +102,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;