All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/35] libxl LOG*D functions
@ 2016-11-15 10:18 Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families Cédric Bosdonnat
                   ` (34 more replies)
  0 siblings, 35 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel; +Cc: Cédric Bosdonnat

Hi all,

This patch series adds a LOG*D family matching the existing
LOG* one, but with one more parameter for the domain ID.
Using this new family will allow the libxl-based applications
to sort log entries by domain ID. For example a typical use
case of this is  the libvirt libxl driver: it should output
one log file per domain as done by other libvirt drivers.

The first patch of the series adds the the LOG*D functions,
the other ones are to convert the existing LOG* calls to LOG*D
when possible.

I'm new to the xen code base, and I may have used the wrong
value for the publicly know domain ID in some places.

I also have changed some log messages that where already
including the domain ID... I'm not sure whether this is
a good idea or not.

Note that I have made one commit per changed file as it
would ease maintenance, and the values used for the domain ID
are generally consistent within each file. However, I have
split the libxl.c file into several commits to ease reviewing
that giant change.

As these changes where all manually done, there is no
script to document here.

Cédric Bosdonnat (35):
  libxl: add LIBXL_LOGD_* and LOG*D function families.
  libxl.c: switch to LOG*D use
  libxl.c: switch to LOG*D use (refactored messages)
  libxl.c: switch to LOG*D use (refactored messages)
  libxl/libxl_bootloader.c: used LOG*D functions
  libxl/libxl_checkpoint_device.c: used LOG*D functions
  libxl/libxl_colo.h: used LOG*D functions
  libxl/libxl_colo_nic.c: used LOG*D functions
  libxl/libxl_colo_proxy.c: used LOG*D functions
  libxl/libxl_colo_qdisk.c: used LOG*D functions
  libxl/libxl_colo_restore.c: used LOG*D functions
  libxl/libxl_colo_save.c: used LOG*D functions
  libxl/libxl_create.c: used LOG*D functions
  libxl/libxl_device.c: used LOG*D functions
  libxl/libxl_dm.c: used LOG*D functions
  libxl/libxl_dom_save.c: used LOG*D functions
  libxl/libxl_dom_suspend.c: used LOG*D functions
  libxl/libxl_freebsd.c: used LOG*D functions
  libxl/libxl_internal.c: used LOG*D functions
  libxl/libxl_linux.c: used LOG*D functions
  libxl/libxl_netbsd.c: used LOG*D functions
  libxl/libxl_netbuffer.c: used LOG*D functions
  libxl/libxl_nic.c: used LOG*D functions
  libxl/libxl_no_colo.c: used LOG*D functions
  libxl/libxl_pci.c: used LOG*D functions
  libxl/libxl_psr.c: used LOG*D functions
  libxl/libxl_pvusb.c: used LOG*D functions
  libxl/libxl_qmp.c: used LOG*D functions
  libxl/libxl_remus.c: used LOG*D functions
  libxl/libxl_save_callout.c: used LOG*D functions
  libxl/libxl_stream_write.c: used LOG*D functions
  libxl/libxl_vnuma.c: used LOG*D functions
  libxl/libxl_vtpm.c: used LOG*D functions
  libxl/libxl_x86.c: used LOG*D functions
  libxl/libxl_xshelp.c: used LOG*D functions

 tools/libxl/libxl.c                   | 499 +++++++++++++++++-----------------
 tools/libxl/libxl_bootloader.c        |  84 +++---
 tools/libxl/libxl_checkpoint_device.c |  14 +-
 tools/libxl/libxl_colo.h              |   2 +-
 tools/libxl/libxl_colo_nic.c          |   2 +-
 tools/libxl/libxl_colo_proxy.c        |  24 +-
 tools/libxl/libxl_colo_qdisk.c        |   2 +-
 tools/libxl/libxl_colo_restore.c      |  57 ++--
 tools/libxl/libxl_colo_save.c         |  49 ++--
 tools/libxl/libxl_create.c            | 119 ++++----
 tools/libxl/libxl_device.c            |  70 ++---
 tools/libxl/libxl_dm.c                | 111 ++++----
 tools/libxl/libxl_dom_save.c          |  29 +-
 tools/libxl/libxl_dom_suspend.c       |  45 ++-
 tools/libxl/libxl_event.c             |   6 +-
 tools/libxl/libxl_freebsd.c           |   8 +-
 tools/libxl/libxl_internal.c          |  45 +--
 tools/libxl/libxl_internal.h          |  38 ++-
 tools/libxl/libxl_linux.c             |  23 +-
 tools/libxl/libxl_netbsd.c            |   9 +-
 tools/libxl/libxl_netbuffer.c         |  43 +--
 tools/libxl/libxl_nic.c               |   9 +-
 tools/libxl/libxl_no_colo.c           |   4 +-
 tools/libxl/libxl_pci.c               | 153 ++++++-----
 tools/libxl/libxl_psr.c               |  12 +-
 tools/libxl/libxl_qmp.c               |  56 ++--
 tools/libxl/libxl_remus.c             |  27 +-
 tools/libxl/libxl_save_callout.c      |   8 +-
 tools/libxl/libxl_stream_write.c      |  10 +-
 tools/libxl/libxl_usb.c               |  57 ++--
 tools/libxl/libxl_vnuma.c             |   2 +-
 tools/libxl/libxl_vtpm.c              |   8 +-
 tools/libxl/libxl_x86.c               |   6 +-
 tools/libxl/libxl_xshelp.c            |   4 +-
 34 files changed, 856 insertions(+), 779 deletions(-)

-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-17 14:41   ` Wei Liu
  2016-11-15 10:18 ` [PATCH 02/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
                   ` (33 subsequent siblings)
  34 siblings, 1 reply; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

These functions should be used to log messages when the domain
id is known. libxl__log will now prepend the log message by
"Domain %PRIu32:" if the domain id is a valid one.

This aims at helping consumers filter logs on domain IDs.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_event.c    |  6 +++---
 tools/libxl/libxl_internal.c | 16 ++++++++++------
 tools/libxl/libxl_internal.h | 38 +++++++++++++++++++++++++++++++-------
 3 files changed, 44 insertions(+), 16 deletions(-)

diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
index 02b39e6..fc9bdc9 100644
--- a/tools/libxl/libxl_event.c
+++ b/tools/libxl/libxl_event.c
@@ -1362,7 +1362,7 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,
 {
     EGC_GC;
 
-    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func,
+    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMID,
                "DISASTER in event loop: %s%s%s%s",
                msg,
                type ? " (relates to event type " : "",
@@ -1943,7 +1943,7 @@ libxl__ao *libxl__ao_create(libxl_ctx *ctx, uint32_t domid,
         ao->poller = libxl__poller_get(&ao->gc);
         if (!ao->poller) goto out;
     }
-    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,
+    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,domid,
                "ao %p: create: how=%p callback=%p poller=%p",
                ao, how, ao->how.callback, ao->poller);
 
@@ -1968,7 +1968,7 @@ int libxl__ao_inprogress(libxl__ao *ao,
     assert(ao->in_initiator);
     ao->constructing = 0;
 
-    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,
+    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,INVALID_DOMID,
                "ao %p: inprogress: poller=%p, flags=%s%s%s%s",
                ao, ao->poller,
                ao->constructing ? "o" : "",
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index 448dd61..78ed2f6 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -22,7 +22,7 @@ void libxl__alloc_failed(libxl_ctx *ctx, const char *func,
 #define M "libxl: FATAL ERROR: memory allocation failure"
 #define L (size ? M " (%s, %lu x %lu)\n" : M " (%s)\n"), \
           func, (unsigned long)nmemb, (unsigned long)size
-    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, L);
+    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, INVALID_DOMID, L);
     fprintf(stderr, L);
     fflush(stderr);
     _exit(-1);
@@ -202,7 +202,7 @@ char *libxl__dirname(libxl__gc *gc, const char *s)
 
 void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
              const char *file, int line, const char *func,
-             const char *fmt, va_list ap)
+             uint32_t domid, const char *fmt, va_list ap)
 {
     /* WARNING this function may not call any libxl-provided
      * memory allocation function, as those may
@@ -211,6 +211,7 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
     char *base = NULL;
     int rc, esave;
     char fileline[256];
+    char domain[256];
 
     esave = errno;
 
@@ -221,22 +222,25 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
     if (file) snprintf(fileline, sizeof(fileline), "%s:%d",file,line);
     fileline[sizeof(fileline)-1] = 0;
 
+    domain[0] = 0;
+    if (domid != INVALID_DOMID) snprintf(domain, sizeof(domain), "Domain %"PRIu32":", domid);
+    domain[sizeof(domain)-1] = 0;
  x:
     xtl_log(ctx->lg, msglevel, errnoval, "libxl",
-            "%s%s%s%s" "%s",
+            "%s%s%s%s%s" "%s",
             fileline, func&&file?":":"", func?func:"", func||file?": ":"",
-            base);
+            domain, base);
     if (base != enomem) free(base);
     errno = esave;
 }
 
 void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
             const char *file, int line, const char *func,
-            const char *fmt, ...)
+            uint32_t domid, const char *fmt, ...)
 {
     va_list ap;
     va_start(ap, fmt);
-    libxl__logv(ctx, msglevel, errnoval, file, line, func, fmt, ap);
+    libxl__logv(ctx, msglevel, errnoval, file, line, func, domid, fmt, ap);
     va_end(ap);
 }
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 8366fee..5f46578 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -152,13 +152,22 @@
 #define LIBXL__LOGGING_ENABLED
 
 #ifdef LIBXL__LOGGING_ENABLED
-#define LIBXL__LOG(ctx, loglevel, _f, _a...)   libxl__log(ctx, loglevel, -1, __FILE__, __LINE__, __func__, _f, ##_a)
-#define LIBXL__LOG_ERRNO(ctx, loglevel, _f, _a...)   libxl__log(ctx, loglevel, errno, __FILE__, __LINE__, __func__, _f, ##_a)
-#define LIBXL__LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)   libxl__log(ctx, loglevel, errnoval, __FILE__, __LINE__, __func__, _f, ##_a)
+#define LIBXL__LOG(ctx, loglevel, _f, _a...)   libxl__log(ctx, loglevel, -1, __FILE__, __LINE__, __func__, INVALID_DOMID, _f, ##_a)
+#define LIBXL__LOG_ERRNO(ctx, loglevel, _f, _a...)   libxl__log(ctx, loglevel, errno, __FILE__, __LINE__, __func__, INVALID_DOMID, _f, ##_a)
+#define LIBXL__LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)   libxl__log(ctx, loglevel, errnoval, __FILE__, __LINE__, __func__, INVALID_DOMID, _f, ##_a)
+
+/* Same log functions as above, but with _d being a domain id. */
+#define LIBXL__LOGD(ctx, loglevel, _d, _f, _a...)   libxl__log(ctx, loglevel, -1, __FILE__, __LINE__, __func__, _d, _f, ##_a)
+#define LIBXL__LOGD_ERRNO(ctx, loglevel, _d, _f, _a...)   libxl__log(ctx, loglevel, errno, __FILE__, __LINE__, __func__, _d, _f, ##_a)
+#define LIBXL__LOGD_ERRNOVAL(ctx, loglevel, errnoval, _d, _f, _a...)   libxl__log(ctx, loglevel, errnoval, __FILE__, __LINE__, __func__, _d, _f, ##_a)
 #else
 #define LIBXL__LOG(ctx, loglevel, _f, _a...)
 #define LIBXL__LOG_ERRNO(ctx, loglevel, _f, _a...)
 #define LIBXL__LOG_ERRNOVAL(ctx, loglevel, errnoval, _f, _a...)
+
+#define LIBXLD__LOG(ctx, loglevel, _d, _f, _a...)
+#define LIBXLD__LOG_ERRNO(ctx, loglevel, _d, _f, _a...)
+#define LIBXLD__LOG_ERRNOVAL(ctx, loglevel, errnoval, _d, _f, _a...)
 #endif
   /* all of these macros preserve errno (saving and restoring) */
 
@@ -169,14 +178,16 @@
 _hidden void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
              const char *file /* may be 0 */, int line /* ignored if !file */,
              const char *func /* may be 0 */,
+             uint32_t domid /* may be INVALID_DOMID */,
              const char *fmt, va_list al)
-     __attribute__((format(printf,7,0)));
+     __attribute__((format(printf,8,0)));
 
 _hidden void libxl__log(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
             const char *file /* may be 0 */, int line /* ignored if !file */,
             const char *func /* may be 0 */,
+            uint32_t domid /* may be INVALID_DOMID */,
             const char *fmt, ...)
-     __attribute__((format(printf,7,8)));
+     __attribute__((format(printf,8,9)));
 
      /* these functions preserve errno (saving and restoring) */
 
@@ -3875,22 +3886,35 @@ _hidden void libxl__remus_restore_setup(libxl__egc *egc,
  *    void LOG(<xtl_level_suffix>, const char *fmt, ...);
  *    void LOGE(<xtl_level_suffix>, const char *fmt, ...);
  *    void LOGEV(<xtl_level_suffix>, int errnoval, const char *fmt, ...);
+ *
+ *    void LOGD(<xtl_level_suffix>, uint32_t domid, const char *fmt, ...);
+ *    void LOGED(<xtl_level_suffix>, uint32_t domid, const char *fmt, ...);
+ *    void LOGEVD(<xtl_level_suffix>, int errnoval, uint32_t domid, const char *fmt, ...);
  * Use
  *    libxl__gc *gc;
  *
- * Trivial convenience wrappers for LIBXL__LOG, LIBXL__LOG_ERRNO and
- * LIBXL__LOG_ERRNOVAL, respectively (and thus for libxl__log).
+ * Trivial convenience wrappers for LIBXL__LOG, LIBXL__LOG_ERRNO,
+ * LIBXL__LOG_ERRNOVAL, LIBXL__LOGD, LIBXL__LOGD_ERRNO and
+ * LIBXL__LOGD_ERRNOVAL respectively (and thus for libxl__log).
  *
  * XTL_<xtl_level_suffix> should exist and be an xentoollog.h log level
  * So <xtl_level_suffix> should be one of
  *   DEBUG VERBOSE DETAIL PROGRESS INFO NOTICE WARN ERROR ERROR CRITICAL
  * Of these, most of libxl uses
  *   DEBUG INFO WARN ERROR
+ *
+ * The LOG*D family will preprend the log message with a string formatted
+ * as follows: 'Domain %PRIu32:'. This should help better automatic sorting
+ * of log messages per domain.
  */
 #define LOG(l,f, ...)     LIBXL__LOG(CTX,XTL_##l,(f),##__VA_ARGS__)
 #define LOGE(l,f, ...)    LIBXL__LOG_ERRNO(CTX,XTL_##l,(f),##__VA_ARGS__)
 #define LOGEV(l,e,f, ...) LIBXL__LOG_ERRNOVAL(CTX,XTL_##l,(e),(f),##__VA_ARGS__)
 
+#define LOGD(l,d,f, ...)     LIBXL__LOGD(CTX,XTL_##l,(d),(f),##__VA_ARGS__)
+#define LOGED(l,d,f, ...)    LIBXL__LOGD_ERRNO(CTX,XTL_##l,(d),(f),##__VA_ARGS__)
+#define LOGEVD(l,e,d,f, ...) LIBXL__LOGD_ERRNOVAL(CTX,XTL_##l,(e),(d),(f),##__VA_ARGS__)
+
 
 /* Locking functions.  See comment for "lock" member of libxl__ctx. */
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 02/35] libxl.c: switch to LOG*D use
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 03/35] libxl.c: switch to LOG*D use (refactored messages) Cédric Bosdonnat
                   ` (32 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson, Cédric Bosdonnat

Use LOG*D functions to output the domain ID in logs as much as
possible. This will help consumer code sorting the logs by
domain.

This commit, only changes LOG*() into LOG*D() and adds a domid
parameter.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl.c | 302 ++++++++++++++++++++++++++--------------------------
 1 file changed, 153 insertions(+), 149 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 33c5e4c..b5ff309 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -394,13 +394,13 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
     if (!trans) {
         trans = our_trans = xs_transaction_start(ctx->xsh);
         if (!our_trans) {
-            LOGEV(ERROR, errno, "create xs transaction for domain (re)name");
+            LOGEVD(ERROR, errno, domid, "Create xs transaction for domain (re)name");
             goto x_fail;
         }
     }
 
     if (!new_name) {
-        LOG(ERROR, "new domain name not specified");
+        LOGD(ERROR, domid, "New domain name not specified");
         rc = ERROR_INVAL;
         goto x_rc;
     }
@@ -412,14 +412,14 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
         if (rc == ERROR_INVAL) {
             /* no such domain, good */
         } else if (rc != 0) {
-            LOG(ERROR, "unexpected error checking for existing domain");
+            LOGD(ERROR, domid, "Unexpected error checking for existing domain");
             goto x_rc;
         } else if (domid_e == domid) {
             /* domain already has this name, ok (but we do still
              * need the rest of the code as we may need to check
              * old_name, for example). */
         } else {
-            LOG(ERROR, "domain with name \"%s\" already exists.", new_name);
+            LOGD(ERROR, domid, "Domain with name \"%s\" already exists.", new_name);
             rc = ERROR_INVAL;
             goto x_rc;
         }
@@ -473,7 +473,7 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
                                   stub_dm_new_name,
                                   trans);
         if (rc) {
-            LOGE(ERROR, "unable to rename stub-domain");
+            LOGED(ERROR, domid, "Unable to rename stub-domain");
             goto x_rc;
         }
     }
@@ -678,7 +678,7 @@ int libxl_domain_info(libxl_ctx *ctx, libxl_dominfo *info_r,
 
     ret = xc_domain_getinfolist(ctx->xch, domid, 1, &xcinfo);
     if (ret<0) {
-        LOGE(ERROR, "getting domain info list");
+        LOGED(ERROR, domid, "Getting domain info list");
         GC_FREE;
         return ERROR_FAIL;
     }
@@ -842,7 +842,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
 
     /* The caller must set this defbool */
     if (libxl_defbool_is_default(info->colo)) {
-        LOG(ERROR, "colo mode must be enabled/disabled");
+        LOGD(ERROR, domid, "Colo mode must be enabled/disabled");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -856,7 +856,8 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
 
     if (libxl_defbool_val(info->colo) &&
         libxl_defbool_val(info->compression)) {
-            LOG(ERROR, "cannot use memory checkpoint compression in COLO mode");
+            LOGD(ERROR, domid, "Cannot use memory checkpoint "
+                        "compression in COLO mode");
             rc = ERROR_FAIL;
             goto out;
     }
@@ -865,8 +866,8 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
         (libxl_defbool_val(info->blackhole) ||
          !libxl_defbool_val(info->netbuf) ||
          !libxl_defbool_val(info->diskbuf))) {
-        LOG(ERROR, "Unsafe mode must be enabled to replicate to /dev/null,"
-                   "disable network buffering and disk replication");
+        LOGD(ERROR, domid, "Unsafe mode must be enabled to replicate to /dev/null,"
+                    "disable network buffering and disk replication");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -969,7 +970,7 @@ int libxl_domain_pause(libxl_ctx *ctx, uint32_t domid)
     GC_INIT(ctx);
     ret = xc_domain_pause(ctx->xch, domid);
     if (ret<0) {
-        LOGE(ERROR, "pausing domain %d", domid);
+        LOGED(ERROR, domid, "Pausing domain");
         GC_FREE;
         return ERROR_FAIL;
     }
@@ -1047,7 +1048,7 @@ int libxl__domain_pvcontrol_available(libxl__gc *gc, uint32_t domid)
 
     ret = xc_hvm_param_get(ctx->xch, domid, HVM_PARAM_CALLBACK_IRQ, &pvdriver);
     if (ret<0) {
-        LOGE(ERROR, "getting HVM callback IRQ");
+        LOGED(ERROR, domid, "Getting HVM callback IRQ");
         return ERROR_FAIL;
     }
     return !!pvdriver;
@@ -1649,10 +1650,10 @@ static void devices_destroy_cb(libxl__egc *egc,
     vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/vm", dom_path));
     if (vm_path)
         if (!xs_rm(ctx->xsh, XBT_NULL, vm_path))
-            LOGE(ERROR, "xs_rm failed for %s", vm_path);
+            LOGED(ERROR, domid, "xs_rm failed for %s", vm_path);
 
     if (!xs_rm(ctx->xsh, XBT_NULL, dom_path))
-        LOGE(ERROR, "xs_rm failed for %s", dom_path);
+        LOGED(ERROR, domid, "xs_rm failed for %s", dom_path);
 
     xs_rm(ctx->xsh, XBT_NULL, libxl__xs_libxl_path(gc, domid));
     xs_rm(ctx->xsh, XBT_NULL, GCSPRINTF( "/local/domain/%d/hvmloader", domid));
@@ -1828,7 +1829,8 @@ int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num,
 
     tty = libxl__xs_read(gc, XBT_NULL, tty_path);
     if (!tty || tty[0] == '\0') {
-       LOGE(ERROR,"unable to read console tty path `%s'",tty_path);
+       LOGED(ERROR, domid, "Unable to read console tty path `%s'",
+             tty_path);
        rc = ERROR_FAIL;
        goto out;
     }
@@ -1946,13 +1948,13 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass)
         char tmpname[] = "/tmp/vncautopass.XXXXXX";
         autopass_fd = mkstemp(tmpname);
         if ( autopass_fd < 0 ) {
-            LOGE(ERROR, "mkstemp %s failed", tmpname);
+            LOGED(ERROR, domid, "mkstemp %s failed", tmpname);
             goto x_fail;
         }
 
         if ( unlink(tmpname) ) {
             /* should never happen */
-            LOGE(ERROR, "unlink %s failed", tmpname);
+            LOGED(ERROR, domid, "unlink %s failed", tmpname);
             goto x_fail;
         }
 
@@ -1961,7 +1963,7 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass)
             goto x_fail;
 
         if ( lseek(autopass_fd, SEEK_SET, 0) ) {
-            LOGE(ERROR, "rewind %s (autopass) failed", tmpname);
+            LOGED(ERROR, domid, "rewind %s (autopass) failed", tmpname);
             goto x_fail;
         }
 
@@ -2068,7 +2070,7 @@ int libxl__device_disk_setdefault(libxl__gc *gc, libxl_device_disk *disk,
         LIBXL_DEVICE_MODEL_VERSION_NONE) {
         if (!(disk->backend == LIBXL_DISK_BACKEND_QDISK ||
               disk->backend == LIBXL_DISK_BACKEND_UNKNOWN)) {
-            LOG(ERROR, "Backend for CD devices on HVM guests must be Qdisk");
+            LOGD(ERROR, domid, "Backend for CD devices on HVM guests must be Qdisk");
             return ERROR_FAIL;
         }
         disk->backend = LIBXL_DISK_BACKEND_QDISK;
@@ -2086,8 +2088,8 @@ int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
 
     devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
     if (devid==-1) {
-        LOG(ERROR, "Invalid or unsupported"" virtual disk identifier %s",
-            disk->vdev);
+        LOGD(ERROR, domid, "Invalid or unsupported"" virtual disk identifier %s",
+             disk->vdev);
         return ERROR_INVAL;
     }
 
@@ -2105,7 +2107,8 @@ int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
             device->backend_kind = LIBXL__DEVICE_KIND_QDISK;
             break;
         default:
-            LOG(ERROR, "unrecognized disk backend type: %d", disk->backend);
+            LOGD(ERROR, domid, "Unrecognized disk backend type: %d",
+                 disk->backend);
             return ERROR_INVAL;
     }
 
@@ -2201,15 +2204,15 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
         GCNEW(device);
         rc = libxl__device_from_disk(gc, domid, disk, device);
         if (rc != 0) {
-            LOG(ERROR, "Invalid or unsupported"" virtual disk identifier %s",
-                disk->vdev);
+            LOGD(ERROR, domid, "Invalid or unsupported"" virtual disk identifier %s",
+                 disk->vdev);
             goto out;
         }
 
         rc = libxl__device_exists(gc, t, device);
         if (rc < 0) goto out;
         if (rc == 1) {              /* already exists in xenstore */
-            LOG(ERROR, "device already exists in xenstore");
+            LOGD(ERROR, domid, "device already exists in xenstore");
             aodev->action = LIBXL__DEVICE_ACTION_ADD; /* for error message */
             rc = ERROR_DEVICE_EXISTS;
             goto out;
@@ -2235,8 +2238,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
                     dev = libxl__blktap_devpath(gc, disk->pdev_path,
                                                 disk->format);
                     if (!dev) {
-                        LOG(ERROR, "failed to get blktap devpath for %p",
-                            disk->pdev_path);
+                        LOGD(ERROR, domid, "Failed to get blktap devpath for %p",
+                             disk->pdev_path);
                         rc = ERROR_FAIL;
                         goto out;
                     }
@@ -2271,8 +2274,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
                 assert(device->backend_kind == LIBXL__DEVICE_KIND_QDISK);
                 break;
             default:
-                LOG(ERROR, "unrecognized disk backend type: %d",
-                    disk->backend);
+                LOGD(ERROR, domid, "Unrecognized disk backend type: %d",
+                     disk->backend);
                 rc = ERROR_INVAL;
                 goto out;
         }
@@ -2655,26 +2658,26 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
         goto out;
     }
     if (type != LIBXL_DOMAIN_TYPE_HVM) {
-        LOG(ERROR, "cdrom-insert requires an HVM domain");
+        LOGD(ERROR, domid, "cdrom-insert requires an HVM domain");
         rc = ERROR_INVAL;
         goto out;
     }
 
     if (libxl_get_stubdom_id(ctx, domid) != 0) {
-        LOG(ERROR, "cdrom-insert doesn't work for stub domains");
+        LOGD(ERROR, domid, "cdrom-insert doesn't work for stub domains");
         rc = ERROR_INVAL;
         goto out;
     }
 
     dm_ver = libxl__device_model_version_running(gc, domid);
     if (dm_ver == -1) {
-        LOG(ERROR, "cannot determine device model version");
+        LOGD(ERROR, domid, "Cannot determine device model version");
         rc = ERROR_FAIL;
         goto out;
     }
 
     if (dm_ver == LIBXL_DEVICE_MODEL_VERSION_NONE) {
-        LOG(ERROR, "Guests without a device model cannot use cd-insert");
+        LOGD(ERROR, domid, "Guests without a device model cannot use cd-insert");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -2689,7 +2692,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
         }
     }
     if (i == num) {
-        LOG(ERROR, "Virtual device not found");
+        LOGD(ERROR, domid, "Virtual device not found");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -2749,8 +2752,8 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
         tmp = libxl__xs_read(gc, t, GCSPRINTF("%s/frontend", libxl_path));
         if (!tmp)
         {
-            LOG(ERROR, "Internal error: %s does not exist",
-                GCSPRINTF("%s/frontend", libxl_path));
+            LOGD(ERROR, domid, "Internal error: %s does not exist",
+                 GCSPRINTF("%s/frontend", libxl_path));
             rc = ERROR_FAIL;
             goto out;
         }
@@ -2788,8 +2791,8 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
         tmp = libxl__xs_read(gc, t, GCSPRINTF("%s/frontend", libxl_path));
         if (!tmp)
         {
-            LOG(ERROR, "Internal error: %s does not exist",
-                GCSPRINTF("%s/frontend", libxl_path));
+            LOGD(ERROR, domid, "Internal error: %s does not exist",
+                 GCSPRINTF("%s/frontend", libxl_path));
             rc = ERROR_FAIL;
             goto out;
         }
@@ -3100,7 +3103,7 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
         goto out;
     }
     if (!console->devid && (console->name || console->path)) {
-        LOG(ERROR, "Primary console has invalid configuration");
+        LOGD(ERROR, domid, "Primary console has invalid configuration");
         rc = ERROR_INVAL;
         goto out;
     }
@@ -3338,7 +3341,7 @@ libxl_device_channel *libxl_device_channel_list(libxl_ctx *ctx,
     return channels;
 
 out_err:
-    LOG(ERROR, "Unable to list channels");
+    LOGD(ERROR, domid, "Unable to list channels");
     while (*num) {
         (*num)--;
         libxl_device_channel_dispose(&channels[*num]);
@@ -3450,7 +3453,7 @@ int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
 
     rc = libxl__device_vkb_add(gc, domid, vkb);
     if (rc) {
-        LOG(ERROR, "unable to add vkb device");
+        LOGD(ERROR, domid, "Unable to add vkb device");
         goto out;
     }
 
@@ -3550,7 +3553,7 @@ int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
 
     rc = libxl__device_vfb_add(gc, domid, vfb);
     if (rc) {
-        LOG(ERROR, "unable to add vfb device");
+        LOGD(ERROR, domid, "Unable to add vfb device");
         goto out;
     }
 
@@ -4041,18 +4044,20 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
 
     mem = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/memory/target", dompath));
     if (!mem) {
-        LOGE(ERROR, "cannot get memory info from %s/memory/target", dompath);
+        LOGED(ERROR, domid, "Cannot get memory info from %s/memory/target",
+              dompath);
         goto out;
     }
     memorykb = strtoull(mem, &endptr, 10);
     if (*endptr != '\0') {
-        LOGE(ERROR, "invalid memory %s from %s/memory/target\n", mem, dompath);
+        LOGED(ERROR, domid, "Invalid memory %s from %s/memory/target\n",
+              mem, dompath);
         goto out;
     }
 
     if (max_memkb < memorykb) {
-        LOGE(ERROR,
-             "memory_static_max must be greater than or or equal to memory_dynamic_max");
+        LOGED(ERROR, domid,
+              "memory_static_max must be greater than or or equal to memory_dynamic_max");
         goto out;
     }
 
@@ -4070,9 +4075,9 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
 
     rc = xc_domain_setmaxmem(ctx->xch, domid, max_memkb + size);
     if (rc != 0) {
-        LOGE(ERROR,
-             "xc_domain_setmaxmem domid=%d memkb=%"PRIu64" failed ""rc=%d\n",
-             domid, max_memkb + size, rc);
+        LOGED(ERROR, domid,
+              "xc_domain_setmaxmem domid=%d memkb=%"PRIu64" failed ""rc=%d\n",
+              domid, max_memkb + size, rc);
         goto out;
     }
 
@@ -4216,16 +4221,16 @@ retry_transaction:
         if (lrc < 0) { rc = ERROR_FAIL; goto out_no_transaction; }
         goto retry_transaction;
     } else if (!target) {
-        LOGE(ERROR, "cannot get target memory info from %s/memory/target",
-             dompath);
+        LOGED(ERROR, domid, "Cannot get target memory info from %s/memory/target",
+              dompath);
         abort_transaction = 1;
         rc = ERROR_FAIL;
         goto out;
     } else {
         current_target_memkb = strtoull(target, &endptr, 10);
         if (*endptr != '\0') {
-            LOGE(ERROR, "invalid memory target %s from %s/memory/target\n",
-                 target, dompath);
+            LOGED(ERROR, domid, "Invalid memory target %s from %s/memory/target\n",
+                  target, dompath);
             abort_transaction = 1;
             rc = ERROR_FAIL;
             goto out;
@@ -4233,15 +4238,15 @@ retry_transaction:
     }
     memmax = libxl__xs_read(gc, t, GCSPRINTF("%s/memory/static-max", dompath));
     if (!memmax) {
-        LOGE(ERROR, "cannot get memory info from %s/memory/static-max",
-             dompath);
+        LOGED(ERROR, domid, "Cannot get memory info from %s/memory/static-max",
+              dompath);
         abort_transaction = 1;
         rc = ERROR_FAIL;
         goto out;
     }
     memorykb = strtoull(memmax, &endptr, 10);
     if (*endptr != '\0') {
-        LOGE(ERROR, "invalid max memory %s from %s/memory/static-max\n",
+        LOGED(ERROR, domid, "Invalid max memory %s from %s/memory/static-max\n",
              memmax, dompath);
         abort_transaction = 1;
         rc = ERROR_FAIL;
@@ -4260,18 +4265,18 @@ retry_transaction:
     } else
         new_target_memkb = target_memkb - videoram;
     if (new_target_memkb > memorykb) {
-        LOG(ERROR,
-            "memory_dynamic_max must be less than or equal to"
-            " memory_static_max\n");
+        LOGD(ERROR, domid,
+             "memory_dynamic_max must be less than or equal to"
+             " memory_static_max\n");
         abort_transaction = 1;
         rc = ERROR_INVAL;
         goto out;
     }
 
     if (!domid && new_target_memkb < LIBXL_MIN_DOM0_MEM) {
-        LOG(ERROR,
-            "new target %"PRIu64" for dom0 is below the minimum threshold",
-            new_target_memkb);
+        LOGD(ERROR, domid,
+             "New target %"PRIu64" for dom0 is below the minimum threshold",
+             new_target_memkb);
         abort_transaction = 1;
         rc = ERROR_INVAL;
         goto out;
@@ -4352,27 +4357,27 @@ static int libxl__get_memory_target(libxl__gc *gc, uint32_t domid,
         if (rc < 0)
             goto out;
     } else if (!target) {
-        LOGE(ERROR, "cannot get target memory info from %s/memory/target",
-             dompath);
+        LOGED(ERROR, domid, "Cannot get target memory info from %s/memory/target",
+              dompath);
         goto out;
     } else if (!static_max) {
-        LOGE(ERROR,
-             "cannot get target memory info from %s/memory/static-max",
-             dompath);
+        LOGED(ERROR, domid,
+              "Cannot get target memory info from %s/memory/static-max",
+               dompath);
         goto out;
     } else {
         target_memkb = strtoull(target, &endptr, 10);
         if (*endptr != '\0') {
-            LOGE(ERROR, "invalid memory target %s from %s/memory/target\n",
-                 target, dompath);
+            LOGED(ERROR, domid, "Invalid memory target %s from %s/memory/target\n",
+                  target, dompath);
             goto out;
         }
         max_memkb = strtoull(static_max, &endptr, 10);
         if (*endptr != '\0') {
-            LOGE(ERROR,
-                 "invalid memory target %s from %s/memory/static-max\n",
-                 static_max,
-                 dompath);
+            LOGED(ERROR, domid,
+                  "Invalid memory target %s from %s/memory/static-max\n",
+                  static_max,
+                  dompath);
             goto out;
         }
 
@@ -4864,7 +4869,7 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
     xc_vcpuinfo_t vcpuinfo;
 
     if (xc_domain_getinfolist(ctx->xch, domid, 1, &domaininfo) != 1) {
-        LOGE(ERROR, "getting infolist");
+        LOGED(ERROR, domid, "Getting infolist");
         GC_FREE;
         return NULL;
     }
@@ -4888,14 +4893,14 @@ libxl_vcpuinfo *libxl_list_vcpu(libxl_ctx *ctx, uint32_t domid,
         if (libxl_cpu_bitmap_alloc(ctx, &ptr->cpumap_soft, 0))
             goto err;
         if (xc_vcpu_getinfo(ctx->xch, domid, *nr_vcpus_out, &vcpuinfo) == -1) {
-            LOGE(ERROR, "getting vcpu info");
+            LOGED(ERROR, domid, "Getting vcpu info");
             goto err;
         }
 
         if (xc_vcpu_getaffinity(ctx->xch, domid, *nr_vcpus_out,
                                 ptr->cpumap.map, ptr->cpumap_soft.map,
                                 XEN_VCPUAFFINITY_SOFT|XEN_VCPUAFFINITY_HARD) == -1) {
-            LOGE(ERROR, "getting vcpu affinity");
+            LOGED(ERROR, domid, "Getting vcpu affinity");
             goto err;
         }
         ptr->vcpuid = *nr_vcpus_out;
@@ -4959,7 +4964,7 @@ static int libxl__set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid,
                             cpumap_hard ? hard.map : NULL,
                             cpumap_soft ? soft.map : NULL,
                             flags)) {
-        LOGE(ERROR, "setting vcpu affinity");
+        LOGED(ERROR, domid, "Setting vcpu affinity");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -4971,20 +4976,19 @@ static int libxl__set_vcpuaffinity(libxl_ctx *ctx, uint32_t domid,
      */
     if (cpumap_hard &&
         !libxl_bitmap_equal(cpumap_hard, &hard, 0))
-        LOG(DEBUG, "New hard affinity for vcpu %d has unreachable cpus",
-        vcpuid);
+        LOGD(DEBUG, domid, "New hard affinity for vcpu %d has unreachable cpus", vcpuid);
     /*
      * Soft affinity can both be different from what asked and empty. Check
      * for (and report) both.
      */
     if (cpumap_soft) {
         if (!libxl_bitmap_equal(cpumap_soft, &soft, 0))
-            LOG(DEBUG, "New soft affinity for vcpu %d has unreachable cpus",
-                vcpuid);
+            LOGD(DEBUG, domid, "New soft affinity for vcpu %d has unreachable cpus",
+                 vcpuid);
         if (libxl_bitmap_is_empty(&soft))
-            LOG(WARN, "all cpus in soft affinity of vcpu %d are unreachable."
-                " Only hard affinity will be considered for scheduling",
-                vcpuid);
+            LOGD(WARN, domid, "All cpus in soft affinity of vcpu %d are unreachable."
+                 " Only hard affinity will be considered for scheduling",
+                 vcpuid);
     }
 
     rc = 0;
@@ -5022,7 +5026,7 @@ int libxl_set_vcpuaffinity_all(libxl_ctx *ctx, uint32_t domid,
 
     for (i = 0; i < max_vcpus; i++) {
         if (libxl_set_vcpuaffinity(ctx, domid, i, cpumap_hard, cpumap_soft)) {
-            LOG(WARN, "failed to set affinity for %d", i);
+            LOGD(WARN, domid, "Failed to set affinity for %d", i);
             rc = ERROR_FAIL;
         }
     }
@@ -5036,7 +5040,7 @@ int libxl_domain_set_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
 {
     GC_INIT(ctx);
     if (xc_domain_node_setaffinity(ctx->xch, domid, nodemap->map)) {
-        LOGE(ERROR, "setting node affinity");
+        LOGED(ERROR, domid, "Setting node affinity");
         GC_FREE;
         return ERROR_FAIL;
     }
@@ -5049,7 +5053,7 @@ int libxl_domain_get_nodeaffinity(libxl_ctx *ctx, uint32_t domid,
 {
     GC_INIT(ctx);
     if (xc_domain_node_getaffinity(ctx->xch, domid, nodemap->map)) {
-        LOGE(ERROR, "getting node affinity");
+        LOGED(ERROR, domid, "Getting node affinity");
         GC_FREE;
         return ERROR_FAIL;
     }
@@ -5097,7 +5101,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
     libxl_bitmap_set_none(&current_map);
     rc = libxl__qmp_query_cpus(gc, domid, &current_map);
     if (rc) {
-        LOG(ERROR, "failed to query cpus for domain %d", domid);
+        LOGD(ERROR, domid, "Failed to query cpus");
         goto out;
     }
 
@@ -5131,15 +5135,15 @@ int libxl_set_vcpuonline(libxl_ctx *ctx, uint32_t domid, libxl_bitmap *cpumap)
 
     rc = libxl_domain_info(CTX, &info, domid);
     if (rc < 0) {
-        LOGE(ERROR, "getting domain info list");
+        LOGED(ERROR, domid, "Getting domain info list");
         goto out;
     }
 
     maxcpus = libxl_bitmap_count_set(cpumap);
     if (maxcpus > info.vcpu_max_id + 1)
     {
-        LOGE(ERROR, "Requested %d VCPUs, however maxcpus is %d!",
-             maxcpus, info.vcpu_max_id + 1);
+        LOGED(ERROR, domid, "Requested %d VCPUs, however maxcpus is %d!",
+              maxcpus, info.vcpu_max_id + 1);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5200,7 +5204,7 @@ static int sched_credit_domain_get(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_credit_domain_get(CTX->xch, domid, &sdom);
     if (rc != 0) {
-        LOGE(ERROR, "getting domain sched credit");
+        LOGED(ERROR, domid, "Getting domain sched credit");
         return ERROR_FAIL;
     }
 
@@ -5221,7 +5225,7 @@ static int sched_credit_domain_set(libxl__gc *gc, uint32_t domid,
 
     rc = xc_domain_getinfolist(CTX->xch, domid, 1, &domaininfo);
     if (rc < 0) {
-        LOGE(ERROR, "getting domain info list");
+        LOGED(ERROR, domid, "Getting domain info list");
         return ERROR_FAIL;
     }
     if (rc != 1 || domaininfo.domain != domid)
@@ -5229,14 +5233,14 @@ static int sched_credit_domain_set(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_credit_domain_get(CTX->xch, domid, &sdom);
     if (rc != 0) {
-        LOGE(ERROR, "getting domain sched credit");
+        LOGED(ERROR, domid, "Getting domain sched credit");
         return ERROR_FAIL;
     }
 
     if (scinfo->weight != LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT) {
         if (scinfo->weight < 1 || scinfo->weight > 65535) {
-            LOG(ERROR, "Cpu weight out of range, "
-                "valid values are within range from 1 to 65535");
+            LOGD(ERROR, domid, "Cpu weight out of range, "
+                 "valid values are within range from 1 to 65535");
             return ERROR_INVAL;
         }
         sdom.weight = scinfo->weight;
@@ -5245,9 +5249,9 @@ static int sched_credit_domain_set(libxl__gc *gc, uint32_t domid,
     if (scinfo->cap != LIBXL_DOMAIN_SCHED_PARAM_CAP_DEFAULT) {
         if (scinfo->cap < 0
             || scinfo->cap > (domaininfo.max_vcpu_id + 1) * 100) {
-            LOG(ERROR, "Cpu cap out of range, "
-                "valid range is from 0 to %d for specified number of vcpus",
-                ((domaininfo.max_vcpu_id + 1) * 100));
+            LOGD(ERROR, domid, "Cpu cap out of range, "
+                 "valid range is from 0 to %d for specified number of vcpus",
+                 ((domaininfo.max_vcpu_id + 1) * 100));
             return ERROR_INVAL;
         }
         sdom.cap = scinfo->cap;
@@ -5255,7 +5259,7 @@ static int sched_credit_domain_set(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_credit_domain_set(CTX->xch, domid, &sdom);
     if ( rc < 0 ) {
-        LOGE(ERROR, "setting domain sched credit");
+        LOGED(ERROR, domid, "Setting domain sched credit");
         return ERROR_FAIL;
     }
 
@@ -5399,7 +5403,7 @@ static int sched_credit2_domain_get(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_credit2_domain_get(CTX->xch, domid, &sdom);
     if (rc != 0) {
-        LOGE(ERROR, "getting domain sched credit2");
+        LOGED(ERROR, domid, "Getting domain sched credit2");
         return ERROR_FAIL;
     }
 
@@ -5418,14 +5422,14 @@ static int sched_credit2_domain_set(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_credit2_domain_get(CTX->xch, domid, &sdom);
     if (rc != 0) {
-        LOGE(ERROR, "getting domain sched credit2");
+        LOGED(ERROR, domid, "Getting domain sched credit2");
         return ERROR_FAIL;
     }
 
     if (scinfo->weight != LIBXL_DOMAIN_SCHED_PARAM_WEIGHT_DEFAULT) {
         if (scinfo->weight < 1 || scinfo->weight > 65535) {
-            LOG(ERROR, "Cpu weight out of range, "
-                       "valid values are within range from 1 to 65535");
+            LOGD(ERROR, domid, "Cpu weight out of range, "
+                        "valid values are within range from 1 to 65535");
             return ERROR_INVAL;
         }
         sdom.weight = scinfo->weight;
@@ -5433,7 +5437,7 @@ static int sched_credit2_domain_set(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_credit2_domain_set(CTX->xch, domid, &sdom);
     if ( rc < 0 ) {
-        LOGE(ERROR, "setting domain sched credit2");
+        LOGED(ERROR, domid, "Setting domain sched credit2");
         return ERROR_FAIL;
     }
 
@@ -5478,7 +5482,7 @@ static int sched_rtds_vcpu_get(libxl__gc *gc, uint32_t domid,
 
     r = xc_domain_getinfo(CTX->xch, domid, 1, &info);
     if (r < 0) {
-        LOGE(ERROR, "getting domain info");
+        LOGED(ERROR, domid, "Getting domain info");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5492,9 +5496,9 @@ static int sched_rtds_vcpu_get(libxl__gc *gc, uint32_t domid,
         for (i = 0; i < num_vcpus; i++) {
             if (scinfo->vcpus[i].vcpuid < 0 ||
                 scinfo->vcpus[i].vcpuid > info.max_vcpu_id) {
-                LOG(ERROR, "VCPU index is out of range, "
-                           "valid values are within range from 0 to %d",
-                           info.max_vcpu_id);
+                LOGD(ERROR, domid, "VCPU index is out of range, "
+                            "valid values are within range from 0 to %d",
+                            info.max_vcpu_id);
                 rc = ERROR_INVAL;
                 goto out;
             }
@@ -5504,7 +5508,7 @@ static int sched_rtds_vcpu_get(libxl__gc *gc, uint32_t domid,
 
     r = xc_sched_rtds_vcpu_get(CTX->xch, domid, vcpus, num_vcpus);
     if (r != 0) {
-        LOGE(ERROR, "getting vcpu sched rtds");
+        LOGED(ERROR, domid, "Getting vcpu sched rtds");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5530,7 +5534,7 @@ static int sched_rtds_vcpu_get_all(libxl__gc *gc, uint32_t domid,
 
     r = xc_domain_getinfo(CTX->xch, domid, 1, &info);
     if (r < 0) {
-        LOGE(ERROR, "getting domain info");
+        LOGED(ERROR, domid, "Getting domain info");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5547,7 +5551,7 @@ static int sched_rtds_vcpu_get_all(libxl__gc *gc, uint32_t domid,
 
     r = xc_sched_rtds_vcpu_get(CTX->xch, domid, vcpus, num_vcpus);
     if (r != 0) {
-        LOGE(ERROR, "getting vcpu sched rtds");
+        LOGED(ERROR, domid, "Getting vcpu sched rtds");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5578,7 +5582,7 @@ static int sched_rtds_vcpu_set(libxl__gc *gc, uint32_t domid,
 
     r = xc_domain_getinfo(CTX->xch, domid, 1, &info);
     if (r < 0) {
-        LOGE(ERROR, "getting domain info");
+        LOGED(ERROR, domid, "Getting domain info");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5591,8 +5595,8 @@ static int sched_rtds_vcpu_set(libxl__gc *gc, uint32_t domid,
     for (i = 0; i < scinfo->num_vcpus; i++) {
         if (scinfo->vcpus[i].vcpuid < 0 ||
             scinfo->vcpus[i].vcpuid > max_vcpuid) {
-            LOG(ERROR, "Invalid VCPU %d: valid range is [0, %d]",
-                       scinfo->vcpus[i].vcpuid, max_vcpuid);
+            LOGD(ERROR, domid, "Invalid VCPU %d: valid range is [0, %d]",
+                        scinfo->vcpus[i].vcpuid, max_vcpuid);
             rc = ERROR_INVAL;
             goto out;
         }
@@ -5613,7 +5617,7 @@ static int sched_rtds_vcpu_set(libxl__gc *gc, uint32_t domid,
     r = xc_sched_rtds_vcpu_set(CTX->xch, domid,
                                vcpus, scinfo->num_vcpus);
     if (r != 0) {
-        LOGE(ERROR, "setting vcpu sched rtds");
+        LOGED(ERROR, domid, "Setting vcpu sched rtds");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5635,7 +5639,7 @@ static int sched_rtds_vcpu_set_all(libxl__gc *gc, uint32_t domid,
 
     r = xc_domain_getinfo(CTX->xch, domid, 1, &info);
     if (r < 0) {
-        LOGE(ERROR, "getting domain info");
+        LOGED(ERROR, domid, "Getting domain info");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5661,7 +5665,7 @@ static int sched_rtds_vcpu_set_all(libxl__gc *gc, uint32_t domid,
     r = xc_sched_rtds_vcpu_set(CTX->xch, domid,
                                vcpus, num_vcpus);
     if (r != 0) {
-        LOGE(ERROR, "setting vcpu sched rtds");
+        LOGED(ERROR, domid, "Setting vcpu sched rtds");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -5678,7 +5682,7 @@ static int sched_rtds_domain_get(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_rtds_domain_get(CTX->xch, domid, &sdom);
     if (rc != 0) {
-        LOGE(ERROR, "getting domain sched rtds");
+        LOGED(ERROR, domid, "Getting domain sched rtds");
         return ERROR_FAIL;
     }
 
@@ -5699,7 +5703,7 @@ static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_rtds_domain_get(CTX->xch, domid, &sdom);
     if (rc != 0) {
-        LOGE(ERROR, "getting domain sched rtds");
+        LOGED(ERROR, domid, "Getting domain sched rtds");
         return ERROR_FAIL;
     }
     if (scinfo->period != LIBXL_DOMAIN_SCHED_PARAM_PERIOD_DEFAULT)
@@ -5711,7 +5715,7 @@ static int sched_rtds_domain_set(libxl__gc *gc, uint32_t domid,
 
     rc = xc_sched_rtds_domain_set(CTX->xch, domid, &sdom);
     if (rc < 0) {
-        LOGE(ERROR, "setting domain sched rtds");
+        LOGED(ERROR, domid, "Setting domain sched rtds");
         return ERROR_FAIL;
     }
 
@@ -5730,7 +5734,7 @@ int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,
 
     switch (sched) {
     case LIBXL_SCHEDULER_SEDF:
-        LOG(ERROR, "SEDF scheduler no longer available");
+        LOGD(ERROR, domid, "SEDF scheduler no longer available");
         ret=ERROR_FEATURE_REMOVED;
         break;
     case LIBXL_SCHEDULER_CREDIT:
@@ -5746,7 +5750,7 @@ int libxl_domain_sched_params_set(libxl_ctx *ctx, uint32_t domid,
         ret=sched_rtds_domain_set(gc, domid, scinfo);
         break;
     default:
-        LOG(ERROR, "Unknown scheduler");
+        LOGD(ERROR, domid, "Unknown scheduler");
         ret=ERROR_INVAL;
         break;
     }
@@ -5767,20 +5771,20 @@ int libxl_vcpu_sched_params_set(libxl_ctx *ctx, uint32_t domid,
 
     switch (sched) {
     case LIBXL_SCHEDULER_SEDF:
-        LOG(ERROR, "SEDF scheduler no longer available");
+        LOGD(ERROR, domid, "SEDF scheduler no longer available");
         rc = ERROR_FEATURE_REMOVED;
         break;
     case LIBXL_SCHEDULER_CREDIT:
     case LIBXL_SCHEDULER_CREDIT2:
     case LIBXL_SCHEDULER_ARINC653:
-        LOG(ERROR, "per-VCPU parameter setting not supported for this scheduler");
+        LOGD(ERROR, domid, "per-VCPU parameter setting not supported for this scheduler");
         rc = ERROR_INVAL;
         break;
     case LIBXL_SCHEDULER_RTDS:
         rc = sched_rtds_vcpu_set(gc, domid, scinfo);
         break;
     default:
-        LOG(ERROR, "Unknown scheduler");
+        LOGD(ERROR, domid, "Unknown scheduler");
         rc = ERROR_INVAL;
         break;
     }
@@ -5801,20 +5805,20 @@ int libxl_vcpu_sched_params_set_all(libxl_ctx *ctx, uint32_t domid,
 
     switch (sched) {
     case LIBXL_SCHEDULER_SEDF:
-        LOG(ERROR, "SEDF scheduler no longer available");
+        LOGD(ERROR, domid, "SEDF scheduler no longer available");
         rc = ERROR_FEATURE_REMOVED;
         break;
     case LIBXL_SCHEDULER_CREDIT:
     case LIBXL_SCHEDULER_CREDIT2:
     case LIBXL_SCHEDULER_ARINC653:
-        LOG(ERROR, "per-VCPU parameter setting not supported for this scheduler");
+        LOGD(ERROR, domid, "per-VCPU parameter setting not supported for this scheduler");
         rc = ERROR_INVAL;
         break;
     case LIBXL_SCHEDULER_RTDS:
         rc = sched_rtds_vcpu_set_all(gc, domid, scinfo);
         break;
     default:
-        LOG(ERROR, "Unknown scheduler");
+        LOGD(ERROR, domid, "Unknown scheduler");
         rc = ERROR_INVAL;
         break;
     }
@@ -5835,7 +5839,7 @@ int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
 
     switch (scinfo->sched) {
     case LIBXL_SCHEDULER_SEDF:
-        LOG(ERROR, "SEDF scheduler no longer available");
+        LOGD(ERROR, domid, "SEDF scheduler no longer available");
         ret=ERROR_FEATURE_REMOVED;
         break;
     case LIBXL_SCHEDULER_CREDIT:
@@ -5848,7 +5852,7 @@ int libxl_domain_sched_params_get(libxl_ctx *ctx, uint32_t domid,
         ret=sched_rtds_domain_get(gc, domid, scinfo);
         break;
     default:
-        LOG(ERROR, "Unknown scheduler");
+        LOGD(ERROR, domid, "Unknown scheduler");
         ret=ERROR_INVAL;
         break;
     }
@@ -5867,20 +5871,20 @@ int libxl_vcpu_sched_params_get(libxl_ctx *ctx, uint32_t domid,
 
     switch (scinfo->sched) {
     case LIBXL_SCHEDULER_SEDF:
-        LOG(ERROR, "SEDF scheduler is no longer available");
+        LOGD(ERROR, domid, "SEDF scheduler is no longer available");
         rc = ERROR_FEATURE_REMOVED;
         break;
     case LIBXL_SCHEDULER_CREDIT:
     case LIBXL_SCHEDULER_CREDIT2:
     case LIBXL_SCHEDULER_ARINC653:
-        LOG(ERROR, "per-VCPU parameter getting not supported for this scheduler");
+        LOGD(ERROR, domid, "per-VCPU parameter getting not supported for this scheduler");
         rc = ERROR_INVAL;
         break;
     case LIBXL_SCHEDULER_RTDS:
         rc = sched_rtds_vcpu_get(gc, domid, scinfo);
         break;
     default:
-        LOG(ERROR, "Unknown scheduler");
+        LOGD(ERROR, domid, "Unknown scheduler");
         rc = ERROR_INVAL;
         break;
     }
@@ -5899,20 +5903,20 @@ int libxl_vcpu_sched_params_get_all(libxl_ctx *ctx, uint32_t domid,
 
     switch (scinfo->sched) {
     case LIBXL_SCHEDULER_SEDF:
-        LOG(ERROR, "SEDF scheduler is no longer available");
+        LOGD(ERROR, domid, "SEDF scheduler is no longer available");
         rc = ERROR_FEATURE_REMOVED;
         break;
     case LIBXL_SCHEDULER_CREDIT:
     case LIBXL_SCHEDULER_CREDIT2:
     case LIBXL_SCHEDULER_ARINC653:
-        LOG(ERROR, "per-VCPU parameter getting not supported for this scheduler");
+        LOGD(ERROR, domid, "per-VCPU parameter getting not supported for this scheduler");
         rc = ERROR_INVAL;
         break;
     case LIBXL_SCHEDULER_RTDS:
         rc = sched_rtds_vcpu_get_all(gc, domid, scinfo);
         break;
     default:
-        LOG(ERROR, "Unknown scheduler");
+        LOGD(ERROR, domid, "Unknown scheduler");
         rc = ERROR_INVAL;
         break;
     }
@@ -5984,8 +5988,8 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
     }
 
     if (rc != 0) {
-        LOGE(ERROR, "Send trigger '%s' failed",
-             libxl_trigger_to_string(trigger));
+        LOGED(ERROR, domid, "Send trigger '%s' failed",
+              libxl_trigger_to_string(trigger));
         rc = ERROR_FAIL;
     }
 
@@ -6111,7 +6115,7 @@ char *libxl_tmem_list(libxl_ctx *ctx, uint32_t domid, int use_long)
     r = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_LIST, domid, 32768,
                         use_long, _buf);
     if (r < 0) {
-        LOGE(ERROR, "Can not get tmem list");
+        LOGED(ERROR, domid, "Can not get tmem list");
         GC_FREE;
         return NULL;
     }
@@ -6128,7 +6132,7 @@ int libxl_tmem_freeze(libxl_ctx *ctx, uint32_t domid)
     r = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_FREEZE, domid, 0, 0,
                         NULL);
     if (r < 0) {
-        LOGE(ERROR, "Can not freeze tmem pools");
+        LOGED(ERROR, domid, "Can not freeze tmem pools");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -6147,7 +6151,7 @@ int libxl_tmem_thaw(libxl_ctx *ctx, uint32_t domid)
     r = xc_tmem_control(ctx->xch, -1, XEN_SYSCTL_TMEM_OP_THAW, domid, 0, 0,
                         NULL);
     if (r < 0) {
-        LOGE(ERROR, "Can not thaw tmem pools");
+        LOGED(ERROR, domid, "Can not thaw tmem pools");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -6181,13 +6185,13 @@ int libxl_tmem_set(libxl_ctx *ctx, uint32_t domid, char* name, uint32_t set)
                         XEN_SYSCTL_TMEM_OP_GET_CLIENT_INFO,
                         domid, sizeof(info), 0 /* arg */, &info);
     if (r < 0) {
-        LOGE(ERROR, "Can not get tmem data!");
+        LOGED(ERROR, domid, "Can not get tmem data!");
         rc = ERROR_FAIL;
         goto out;
     }
     rc = tmem_setop_from_string(name, set, &info);
     if (rc == -1) {
-        LOGEV(ERROR, -1, "Invalid set, valid sets are <weight|compress>");
+        LOGEVD(ERROR, -1, domid, "Invalid set, valid sets are <weight|compress>");
         rc = ERROR_INVAL;
         goto out;
     }
@@ -6195,7 +6199,7 @@ int libxl_tmem_set(libxl_ctx *ctx, uint32_t domid, char* name, uint32_t set)
                         XEN_SYSCTL_TMEM_OP_SET_CLIENT_INFO,
                         domid, sizeof(info), 0 /* arg */, &info);
     if (r < 0) {
-        LOGE(ERROR, "Can not set tmem %s", name);
+        LOGED(ERROR, domid, "Can not set tmem %s", name);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -6214,7 +6218,7 @@ int libxl_tmem_shared_auth(libxl_ctx *ctx, uint32_t domid,
 
     r = xc_tmem_auth(ctx->xch, domid, uuid, auth);
     if (r < 0) {
-        LOGE(ERROR, "Can not set tmem shared auth");
+        LOGED(ERROR, domid, "Can not set tmem shared auth");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -6559,7 +6563,7 @@ int libxl_cpupool_movedomain(libxl_ctx *ctx, uint32_t poolid, uint32_t domid)
 
     rc = xc_cpupool_movedomain(ctx->xch, poolid, domid);
     if (rc) {
-        LOGEV(ERROR, rc, "Error moving domain to cpupool");
+        LOGEVD(ERROR, rc, domid, "Error moving domain to cpupool");
         GC_FREE;
         return ERROR_FAIL;
     }
@@ -6901,8 +6905,8 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
                     if (dt->merge)
                         dt->merge(ctx, p + dt->dev_elem_size * j, q);
                 } else {                /* not found in xenstore */
-                    LOG(WARN,
-                        "Device present in JSON but not in xenstore, ignored");
+                    LOGD(WARN, domid,
+                         "Device present in JSON but not in xenstore, ignored");
 
                     dt->dispose(q);
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 03/35] libxl.c: switch to LOG*D use (refactored messages)
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 02/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 04/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
                   ` (31 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson, Cédric Bosdonnat

Use LOG*D functions to output the domain ID in logs as much as
possible. This will help consumer code sorting the logs by
domain.

This commit changes LOG*() into LOG*D(), adds a domid
parameter and messages has been altered to remove the domain
id from it since it is already contained in the output log string.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl.c | 118 ++++++++++++++++++++++++----------------------------
 1 file changed, 55 insertions(+), 63 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index b5ff309..0ee7d9f 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -428,19 +428,16 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
     if (old_name) {
         got_old_name = xs_read(ctx->xsh, trans, name_path, &got_old_len);
         if (!got_old_name) {
-            LOGEV(ERROR, errno,
-                  "check old name for domain %"PRIu32" allegedly named `%s'",
-                  domid,
-                  old_name);
+            LOGEVD(ERROR, errno, domid,
+                   "Check old name for domain allegedly named `%s'",
+                   old_name);
             goto x_fail;
         }
         if (strcmp(old_name, got_old_name)) {
-            LOG(ERROR,
-                "domain %"PRIu32" allegedly named "
-                "`%s' is actually named `%s' - racing ?",
-                domid,
-                old_name,
-                got_old_name);
+            LOGD(ERROR, domid,
+                 "Allegedly named `%s' is actually named `%s' - racing ?",
+                 old_name,
+                 got_old_name);
             free(got_old_name);
             goto x_fail;
         }
@@ -448,12 +445,11 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
     }
     if (!xs_write(ctx->xsh, trans, name_path,
                   new_name, strlen(new_name))) {
-        LOG(ERROR,
-            "failed to write new name `%s'"
-            " for domain %"PRIu32" previously named `%s'",
-            new_name,
-            domid,
-            old_name);
+        LOGD(ERROR, domid,
+             "Failed to write new name `%s'"
+             " for domain previously named `%s'",
+             new_name,
+             old_name);
         goto x_fail;
     }
 
@@ -482,20 +478,18 @@ int libxl__domain_rename(libxl__gc *gc, uint32_t domid,
         if (!xs_transaction_end(ctx->xsh, our_trans, 0)) {
             trans = our_trans = 0;
             if (errno != EAGAIN) {
-                LOG(ERROR,
-                    "failed to commit new name `%s'"
-                    " for domain %"PRIu32" previously named `%s'",
-                    new_name,
-                    domid,
-                    old_name);
+                LOGD(ERROR, domid,
+                     "Failed to commit new name `%s'"
+                     " for domain previously named `%s'",
+                     new_name,
+                     old_name);
                 goto x_fail;
             }
-            LOG(DEBUG,
-                "need to retry rename transaction"
-                " for domain %"PRIu32" (name_path=\"%s\", new_name=\"%s\")",
-                domid,
-                name_path,
-                new_name);
+            LOGD(DEBUG, domid,
+                 "Need to retry rename transaction"
+                 " for domain (name_path=\"%s\", new_name=\"%s\")",
+                 name_path,
+                 new_name);
             goto retry_transaction;
         }
         our_trans = 0;
@@ -987,7 +981,7 @@ int libxl_domain_core_dump(libxl_ctx *ctx, uint32_t domid,
 
     ret = xc_domain_dumpcore(ctx->xch, domid, filename);
     if (ret<0) {
-        LOGE(ERROR, "core dumping domain %d to %s", domid, filename);
+        LOGED(ERROR, domid, "Core dumping domain to %s", filename);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1016,15 +1010,15 @@ int libxl_domain_unpause(libxl_ctx *ctx, uint32_t domid)
             LIBXL_DEVICE_MODEL_VERSION_NONE) {
             rc = libxl__domain_resume_device_model(gc, domid);
             if (rc < 0) {
-                LOG(ERROR, "failed to unpause device model for domain %u:%d",
-                    domid, rc);
+                LOGD(ERROR, domid, "Failed to unpause device model for domain:%d",
+                     rc);
                 goto out;
             }
         }
     }
     ret = xc_domain_unpause(ctx->xch, domid);
     if (ret<0) {
-        LOGE(ERROR, "unpausing domain %d", domid);
+        LOGED(ERROR, domid, "Unpausing domain");
         rc = ERROR_FAIL;
     }
  out:
@@ -1573,7 +1567,7 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis)
     case 0:
         break;
     case ERROR_DOMAIN_NOTFOUND:
-        LOG(ERROR, "non-existant domain %d", domid);
+        LOGD(ERROR, domid, "Non-existant domain");
     default:
         goto out;
     }
@@ -1602,14 +1596,14 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis)
     }
 
     if (libxl__device_pci_destroy_all(gc, domid) < 0)
-        LOG(ERROR, "pci shutdown failed for domid %d", domid);
+        LOGD(ERROR, domid, "Pci shutdown failed");
     rc = xc_domain_pause(ctx->xch, domid);
     if (rc < 0) {
-        LOGEV(ERROR, rc, "xc_domain_pause failed for %d", domid);
+        LOGEVD(ERROR, rc, domid, "xc_domain_pause failed");
     }
     if (dm_present) {
         if (libxl__destroy_device_model(gc, domid) < 0)
-            LOG(ERROR, "libxl__destroy_device_model failed for %d", domid);
+            LOGD(ERROR, domid, "libxl__destroy_device_model failed");
 
         libxl__qmp_cleanup(gc, domid);
     }
@@ -1645,7 +1639,7 @@ static void devices_destroy_cb(libxl__egc *egc,
     }
 
     if (rc < 0)
-        LOG(ERROR, "libxl__devices_destroy failed for %d", domid);
+        LOGD(ERROR, domid, "libxl__devices_destroy failed");
 
     vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/vm", dom_path));
     if (vm_path)
@@ -1704,13 +1698,13 @@ static void devices_destroy_cb(libxl__egc *egc,
         if (errno > 0  && errno < 126) {
             _exit(errno);
         } else {
-            LOGE(ERROR,
- "xc_domain_destroy failed for %d (with difficult errno value %d)",
-                 domid, errno);
+            LOGED(ERROR, domid,
+ "xc_domain_destroy failed (with difficult errno value %d)",
+                  errno);
             _exit(-1);
         }
     }
-    LOG(DEBUG, "forked pid %ld for destroy of domain %d", (long)rc, domid);
+    LOGD(DEBUG, domid, "Forked pid %ld for destroy of domain", (long)rc);
 
     return;
 
@@ -1823,7 +1817,7 @@ int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num,
 
     rc = libxl__console_tty_path(gc, domid, cons_num, type, &tty_path);
     if (rc) {
-        LOG(ERROR, "Failed to get tty path for domain %d\n", domid);
+        LOGD(ERROR, domid, "Failed to get tty path\n");
         goto out;
     }
 
@@ -1921,7 +1915,7 @@ int libxl_vncviewer_exec(libxl_ctx *ctx, uint32_t domid, int autopass)
                             GCSPRINTF(
                             "/local/domain/%d/console/vnc-port", domid));
     if (!vnc_port) {
-        LOG(ERROR, "Cannot get vnc-port of domain %d", domid);
+        LOGD(ERROR, domid, "Cannot get vnc-port");
         goto x_fail;
     }
 
@@ -4286,11 +4280,10 @@ retry_transaction:
         memorykb = new_target_memkb + videoram;
         r = xc_domain_setmaxmem(ctx->xch, domid, memorykb + size);
         if (r != 0) {
-            LOGE(ERROR,
-                 "xc_domain_setmaxmem domid=%u memkb=%"PRIu64" failed ""rc=%d\n",
-                 domid,
-                 memorykb + size,
-                 r);
+            LOGED(ERROR, domid,
+                  "xc_domain_setmaxmem memkb=%"PRIu64" failed ""rc=%d\n",
+                  memorykb + size,
+                  r);
             abort_transaction = 1;
             rc = ERROR_FAIL;
             goto out;
@@ -4300,11 +4293,10 @@ retry_transaction:
     r = xc_domain_set_pod_target(ctx->xch, domid,
             (new_target_memkb + size) / 4, NULL, NULL, NULL);
     if (r != 0) {
-        LOGE(ERROR,
-             "xc_domain_set_pod_target domid=%d, memkb=%"PRIu64" failed rc=%d\n",
-             domid,
-             (new_target_memkb + size) / 4,
-             r);
+        LOGED(ERROR, domid,
+              "xc_domain_set_pod_target memkb=%"PRIu64" failed rc=%d\n",
+              (new_target_memkb + size) / 4,
+              r);
         abort_transaction = 1;
         rc = ERROR_FAIL;
         goto out;
@@ -5113,7 +5105,7 @@ static int libxl__set_vcpuonline_qmp(libxl__gc *gc, uint32_t domid,
     libxl_for_each_set_bit(i, final_map) {
         rc = libxl__qmp_cpu_add(gc, domid, i);
         if (rc) {
-            LOG(ERROR, "failed to add cpu %d to domain %d", i, domid);
+            LOGD(ERROR, domid, "Failed to add cpu %d", i);
             goto out;
         }
     }
@@ -6097,7 +6089,7 @@ uint32_t libxl_vm_get_start_time(libxl_ctx *ctx, uint32_t domid)
     start_time = libxl__xs_read(
         gc, XBT_NULL, GCSPRINTF("%s/start_time", vm_path));
     if (start_time == NULL) {
-        LOGEV(ERROR, -1, "Can't get start time of domain '%d'", domid);
+        LOGEVD(ERROR, -1, domid, "Can't get start time of domain");
         ret = -1;
     }else{
         ret = strtoul(start_time, NULL, 10);
@@ -6691,7 +6683,7 @@ static int libxl__update_avail_vcpus_qmp(libxl__gc *gc, uint32_t domid,
 
     rc = libxl__qmp_query_cpus(gc, domid, map);
     if (rc) {
-        LOG(ERROR, "fail to get number of cpus for domain %d", domid);
+        LOGD(ERROR, domid, "Fail to get number of cpus");
         goto out;
     }
 
@@ -6745,7 +6737,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
 
     rc = libxl__get_domain_configuration(gc, domid, d_config);
     if (rc) {
-        LOG(ERROR, "fail to get domain configuration for domain %d", domid);
+        LOGD(ERROR, domid, "Fail to get domain configuration");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -6755,7 +6747,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
         char *domname;
         domname = libxl_domid_to_name(ctx, domid);
         if (!domname) {
-            LOG(ERROR, "fail to get domain name for domain %d", domid);
+            LOGD(ERROR, domid, "Fail to get domain name");
             goto out;
         }
         free(d_config->c_info.name);
@@ -6768,7 +6760,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
         libxl_dominfo_init(&info);
         rc = libxl_domain_info(ctx, &info, domid);
         if (rc) {
-            LOG(ERROR, "fail to get domain info for domain %d", domid);
+            LOGD(ERROR, domid, "Fail to get domain info");
             libxl_dominfo_dispose(&info);
             goto out;
         }
@@ -6814,7 +6806,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
         }
 
         if (rc) {
-            LOG(ERROR, "fail to update available cpu map for domain %d", domid);
+            LOGD(ERROR, domid, "Fail to update available cpu map");
             goto out;
         }
     }
@@ -6836,7 +6828,7 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
         /* "target" */
         rc = libxl__get_memory_target(gc, domid, &target_memkb, &max_memkb);
         if (rc) {
-            LOG(ERROR, "fail to get memory target for domain %d", domid);
+            LOGD(ERROR, domid, "Fail to get memory target");
             goto out;
         }
 
@@ -6887,8 +6879,8 @@ int libxl_retrieve_domain_configuration(libxl_ctx *ctx, uint32_t domid,
             num_dev = libxl__device_type_get_num(dt, d_config);
             p = dt->list(CTX, domid, &num);
             if (p == NULL) {
-                LOG(DEBUG, "no %s from xenstore for domain %d",
-                    dt->type, domid);
+                LOGD(DEBUG, domid, "No %s from xenstore",
+                     dt->type);
             }
             devs = libxl__device_type_get_ptr(dt, d_config);
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 04/35] libxl.c: switch to LOG*D use
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (2 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 03/35] libxl.c: switch to LOG*D use (refactored messages) Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-17 14:50   ` Wei Liu
  2016-11-15 10:18 ` [PATCH 05/35] libxl/libxl_bootloader.c: used LOG*D functions Cédric Bosdonnat
                   ` (30 subsequent siblings)
  34 siblings, 1 reply; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Ian Jackson, Cédric Bosdonnat

Use LOG*D functions to output the domain ID in logs as much as
possible. This will help consumer code sorting the logs by
domain.

This commit includes all LOG* to LOG*D changes where the domain
ID is not just a domid variable. We want the domain ID provided
to the LOG*D functions to be the one of the publicly known
domain, not a stubdom one.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl.c | 79 +++++++++++++++++++++++++++--------------------------
 1 file changed, 41 insertions(+), 38 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 0ee7d9f..6fd4fe1 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -1125,7 +1125,7 @@ static void domain_death_occurred(libxl__egc *egc,
     EGC_GC;
     libxl_evgen_domain_death *const evg = *evg_upd;
 
-    LOG(DEBUG, "%s", why);
+    LOGD(DEBUG, evg->domid, "%s", why);
 
     libxl_evgen_domain_death *evg_next = LIBXL_TAILQ_NEXT(evg, entry);
     *evg_upd = evg_next;
@@ -1165,10 +1165,10 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
         }
         gotend = &domaininfos[rc];
 
-        LOG(DEBUG, "[evg=%p:%"PRIu32"] nentries=%d rc=%d %ld..%ld",
-            evg, evg->domid, nentries, rc,
-            rc>0 ? (long)domaininfos[0].domain : 0,
-            rc>0 ? (long)domaininfos[rc-1].domain : 0);
+        LOGD(DEBUG, evg->domid, "[evg=%p] nentries=%d rc=%d %ld..%ld",
+             evg, nentries, rc,
+             rc>0 ? (long)domaininfos[0].domain : 0,
+             rc>0 ? (long)domaininfos[rc-1].domain : 0);
 
         for (;;) {
             if (!evg) {
@@ -1176,10 +1176,10 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
                 goto all_reported;
             }
 
-            LOG(DEBUG, "[evg=%p:%"PRIu32"]"
-                "   got=domaininfos[%d] got->domain=%ld",
-                evg, evg->domid, (int)(got - domaininfos),
-                got < gotend ? (long)got->domain : -1L);
+            LOGD(DEBUG, evg->domid, "[evg=%p]"
+                 "   got=domaininfos[%d] got->domain=%ld",
+                 evg, (int)(got - domaininfos),
+                 got < gotend ? (long)got->domain : -1L);
 
             if (!rc) {
                 domain_death_occurred(egc, &evg, "empty list");
@@ -1204,8 +1204,8 @@ static void domain_death_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
             }
 
             assert(evg->domid == got->domain);
-            LOG(DEBUG, " exists shutdown_reported=%d"" dominf.flags=%x",
-                evg->shutdown_reported, got->flags);
+            LOGD(DEBUG, evg->domid, "Exists shutdown_reported=%d"" dominf.flags=%x",
+                 evg->shutdown_reported, got->flags);
 
             if (got->flags & XEN_DOMINF_dying) {
                 domain_death_occurred(egc, &evg, "dying");
@@ -1455,7 +1455,7 @@ static void domain_destroy_cb(libxl__egc *egc, libxl__domain_destroy_state *dds,
     STATE_AO_GC(dds->ao);
 
     if (rc)
-        LOG(ERROR, "destruction of domain %u failed", dds->domid);
+        LOGD(ERROR, dds->domid, "Destruction of domain failed");
 
     libxl__ao_complete(egc, ao, rc);
 }
@@ -1504,7 +1504,8 @@ static void stubdom_destroy_callback(libxl__egc *egc,
     const char *savefile;
 
     if (rc) {
-        LOG(ERROR, "unable to destroy stubdom with domid %u", dis->domid);
+        LOGD(ERROR, dds->domain.domid, "Unable to destroy stubdom with domid %u",
+             dis->domid);
         dds->rc = rc;
     }
 
@@ -1512,7 +1513,8 @@ static void stubdom_destroy_callback(libxl__egc *egc,
     savefile = libxl__device_model_savefile(gc, dis->domid);
     rc = libxl__remove_file(gc, savefile);
     if (rc) {
-        LOG(ERROR, "failed to remove device-model savefile %s", savefile);
+        LOGD(ERROR, dds->domain.domid, "Failed to remove device-model savefile %s",
+             savefile);
     }
 
     destroy_finish_check(egc, dds);
@@ -1526,7 +1528,7 @@ static void domain_destroy_callback(libxl__egc *egc,
     libxl__domain_destroy_state *dds = CONTAINER_OF(dis, *dds, domain);
 
     if (rc) {
-        LOG(ERROR, "unable to destroy guest with domid %u", dis->domid);
+        LOGD(ERROR, dis->domid, "Unable to destroy guest");
         dds->rc = rc;
     }
 
@@ -1723,8 +1725,8 @@ static void domain_destroy_domid_cb(libxl__egc *egc,
 
     if (status) {
         if (WIFEXITED(status) && WEXITSTATUS(status)<126) {
-            LOGEV(ERROR, WEXITSTATUS(status),
-                  "xc_domain_destroy failed for %"PRIu32"", dis->domid);
+            LOGEVD(ERROR, WEXITSTATUS(status), dis->domid,
+                   "xc_domain_destroy failed");
         } else {
             libxl_report_child_exitstatus(CTX, XTL_ERROR,
                                           "async domain destroy", pid, status);
@@ -1999,7 +2001,7 @@ void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev)
 
     if (aodev->rc) {
         if (aodev->dev) {
-            LOG(ERROR, "unable to %s %s with id %u",
+            LOGD(ERROR, aodev->dev->domid, "Unable to %s %s with id %u",
                         libxl__device_action_to_string(aodev->action),
                         libxl__device_kind_to_string(aodev->dev->kind),
                         aodev->dev->devid);
@@ -2905,9 +2907,9 @@ char *libxl__device_disk_find_local_path(libxl__gc *gc,
         char *be_path, *pdpath;
         int rc;
 
-        LOG(DEBUG,
-            "Run from a script; checking for physical-device-path (vdev %s)",
-            disk->vdev);
+        LOGD(DEBUG, guest_domid,
+             "Run from a script; checking for physical-device-path (vdev %s)",
+             disk->vdev);
 
         rc = libxl__device_from_disk(gc, guest_domid, disk, &device);
         if (rc < 0)
@@ -2917,13 +2919,13 @@ char *libxl__device_disk_find_local_path(libxl__gc *gc,
 
         pdpath = libxl__sprintf(gc, "%s/physical-device-path", be_path);
 
-        LOG(DEBUG, "Attempting to read node %s", pdpath);
+        LOGD(DEBUG, guest_domid, "Attempting to read node %s", pdpath);
         path = libxl__xs_read(gc, XBT_NULL, pdpath);
 
         if (path)
-            LOG(DEBUG, "Accessing cooked block device %s", path);
+            LOGD(DEBUG, guest_domid, "Accessing cooked block device %s", path);
         else
-            LOG(DEBUG, "No physical-device-path, can't access locally.");
+            LOGD(DEBUG, guest_domid, "No physical-device-path, can't access locally.");
 
         goto out;
     }
@@ -3064,10 +3066,10 @@ static void local_device_detach_cb(libxl__egc *egc, libxl__ao_device *aodev)
     int rc;
 
     if (aodev->rc) {
-        LOGE(ERROR, "unable to %s %s with id %u",
-                    libxl__device_action_to_string(aodev->action),
-                    libxl__device_kind_to_string(aodev->dev->kind),
-                    aodev->dev->devid);
+        LOGED(ERROR, aodev->dev->domid, "Unable to %s %s with id %u",
+                     libxl__device_action_to_string(aodev->action),
+                     libxl__device_kind_to_string(aodev->dev->kind),
+                     aodev->dev->devid);
         goto out;
     }
 
@@ -3728,8 +3730,8 @@ static void qdisk_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss,
 {
     STATE_AO_GC(dmss->spawn.ao);
 
-    LOG(DEBUG, "qdisk backend spawn for domain %u %s", dmss->guest_domid,
-               rc ? "failed" : "succeed");
+    LOGD(DEBUG, dmss->guest_domid, "qdisk backend spawn %s",
+                rc ? "failed" : "succeed");
 
     libxl__nested_ao_free(dmss->spawn.ao);
 }
@@ -3882,8 +3884,7 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch,
         dguest->domid = dev->domid;
         LIBXL_SLIST_INIT(&dguest->devices);
         LIBXL_SLIST_INSERT_HEAD(&ddomain->guests, dguest, next);
-        LOG(DEBUG, "added domain %u to the list of active guests",
-                   dguest->domid);
+        LOGD(DEBUG, dguest->domid, "Added domain to the list of active guests");
     }
     ddev = search_for_device(dguest, dev);
     if (ddev == NULL && state == XenbusStateClosed) {
@@ -3900,7 +3901,8 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch,
         ddev = libxl__zalloc(NOGC, sizeof(*ddev));
         ddev->dev = dev;
         LIBXL_SLIST_INSERT_HEAD(&dguest->devices, ddev, next);
-        LOG(DEBUG, "added device %s to the list of active devices", path);
+        LOGD(DEBUG, dev->domid, "Added device %s to the list of active devices",
+             path);
         rc = add_device(egc, nested_ao, dguest, ddev);
         if (rc > 0)
             free_ao = true;
@@ -3914,7 +3916,8 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch,
          */
         LIBXL_SLIST_REMOVE(&dguest->devices, ddev, libxl__ddomain_device,
                            next);
-        LOG(DEBUG, "removed device %s from the list of active devices", path);
+        LOGD(DEBUG, dev->domid, "Removed device %s from the list of active devices",
+             path);
         rc = remove_device(egc, nested_ao, dguest, ddev);
         if (rc > 0)
             free_ao = true;
@@ -3925,8 +3928,7 @@ static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch,
         if (num_devs == 0) {
             LIBXL_SLIST_REMOVE(&ddomain->guests, dguest, libxl__ddomain_guest,
                                next);
-            LOG(DEBUG, "removed domain %u from the list of active guests",
-                       dguest->domid);
+            LOGD(DEBUG, dguest->domid, "Removed domain from the list of active guests");
             /* Clear any leftovers in libxl/<domid> */
             libxl__xs_rm_checked(gc, XBT_NULL,
                                  GCSPRINTF("libxl/%u", dguest->domid));
@@ -4111,7 +4113,7 @@ retry_transaction:
     if (target) {
         *target_memkb = strtoull(target, &endptr, 10);
         if (*endptr != '\0') {
-            LOGE(ERROR, "invalid memory target %s from %s\n", target,
+            LOGED(ERROR, 0, "Invalid memory target %s from %s\n", target,
                  target_path);
             rc = ERROR_FAIL;
             goto out;
@@ -4121,7 +4123,8 @@ retry_transaction:
     if (staticmax) {
         *max_memkb = strtoull(staticmax, &endptr, 10);
         if (*endptr != '\0') {
-            LOGE(ERROR, "invalid memory static-max %s from %s\n", staticmax,
+            LOGED(ERROR, 0, "Invalid memory static-max %s from %s\n",
+                 staticmax,
                  max_path);
             rc = ERROR_FAIL;
             goto out;
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 05/35] libxl/libxl_bootloader.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (3 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 04/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 06/35] libxl/libxl_checkpoint_device.c: " Cédric Bosdonnat
                   ` (29 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D functions to output the domain ID in logs as much as
possible. This will help consumer code sorting the logs by
domain.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_bootloader.c | 84 ++++++++++++++++++++++++------------------
 1 file changed, 49 insertions(+), 35 deletions(-)

diff --git a/tools/libxl/libxl_bootloader.c b/tools/libxl/libxl_bootloader.c
index 2cfc8cf..c7c2012 100644
--- a/tools/libxl/libxl_bootloader.c
+++ b/tools/libxl/libxl_bootloader.c
@@ -99,7 +99,7 @@ static int setup_xenconsoled_pty(libxl__egc *egc, libxl__bootloader_state *bl,
 
     r = ttyname_r(slave, slave_path, slave_path_len);
     if (r == -1) {
-        LOGE(ERROR,"ttyname_r failed");
+        LOGED(ERROR, bl->domid, "ttyname_r failed");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -125,7 +125,7 @@ static int setup_xenconsoled_pty(libxl__egc *egc, libxl__bootloader_state *bl,
 }
 
 static const char *bootloader_result_command(libxl__gc *gc, const char *buf,
-                         const char *prefix, size_t prefixlen) {
+                         const char *prefix, size_t prefixlen, uint32_t domid) {
     if (strncmp(buf, prefix, prefixlen))
         return 0;
 
@@ -136,7 +136,7 @@ static const char *bootloader_result_command(libxl__gc *gc, const char *buf,
     while (CTYPE(isspace,*rhs))
         rhs++;
 
-    LOG(DEBUG,"bootloader output contained %s %s", prefix, rhs);
+    LOGD(DEBUG, domid, "bootloader output contained %s %s", prefix, rhs);
 
     return rhs;
 }
@@ -151,7 +151,8 @@ static int parse_bootloader_result(libxl__egc *egc,
 
     f = fopen(bl->outputpath, "r");
     if (!f) {
-        LOGE(ERROR,"open bootloader output file %s", bl->outputpath);
+        LOGED(ERROR, bl->domid, "open bootloader output file %s",
+              bl->outputpath);
         goto out;
     }
 
@@ -166,21 +167,22 @@ static int parse_bootloader_result(libxl__egc *egc,
         }
         if (c == EOF) {
             if (ferror(f)) {
-                LOGE(ERROR,"read bootloader output file %s", bl->outputpath);
+                LOGED(ERROR, bl->domid, "read bootloader output file %s",
+                      bl->outputpath);
                 goto out;
             }
             if (!l)
                 break;
         }
         if (l >= sizeof(buf)) {
-            LOG(WARN,"bootloader output contained"
-                " overly long item `%.150s...'", buf);
+            LOGD(WARN, bl->domid, "bootloader output contained"
+                 " overly long item `%.150s...'", buf);
             continue;
         }
         buf[l] = 0;
 
         const char *rhs;
-#define COMMAND(s) ((rhs = bootloader_result_command(gc, buf, s, sizeof(s)-1)))
+#define COMMAND(s) ((rhs = bootloader_result_command(gc, buf, s, sizeof(s)-1, bl->domid)))
 
         if (COMMAND("kernel")) {
             bl->kernel->path = libxl__strdup(gc, rhs);
@@ -193,7 +195,8 @@ static int parse_bootloader_result(libxl__egc *egc,
         } else if (COMMAND("args")) {
             bl->cmdline = libxl__strdup(gc, rhs);
         } else if (l) {
-            LOG(WARN, "unexpected output from bootloader: `%s'", buf);
+            LOGD(WARN, bl->domid,
+                 "unexpected output from bootloader: `%s'", buf);
         }
     }
     rc = 0;
@@ -276,7 +279,8 @@ static void bootloader_local_detached_cb(libxl__egc *egc,
     libxl__bootloader_state *bl = CONTAINER_OF(dls, *bl, dls);
 
     if (rc) {
-        LOG(ERROR, "unable to detach locally attached disk");
+        LOGD(ERROR, bl->domid,
+             "unable to detach locally attached disk");
         if (!bl->rc)
             bl->rc = rc;
     }
@@ -295,8 +299,8 @@ static void bootloader_stop(libxl__egc *egc,
     libxl__datacopier_kill(&bl->display);
     if (libxl__ev_child_inuse(&bl->child)) {
         r = kill(bl->child.pid, SIGTERM);
-        if (r) LOGE(WARN, "%sfailed to kill bootloader [%lu]",
-                    rc ? "after failure, " : "", (unsigned long)bl->child.pid);
+        if (r) LOGED(WARN, bl->domid, "%sfailed to kill bootloader [%lu]",
+                     rc ? "after failure, " : "", (unsigned long)bl->child.pid);
     }
     if (!bl->rc)
         bl->rc = rc;
@@ -321,13 +325,14 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl)
     libxl__bootloader_init(bl);
 
     if (info->type != LIBXL_DOMAIN_TYPE_PV) {
-        LOG(DEBUG, "not a PV domain, skipping bootloader");
+        LOGD(DEBUG, domid, "not a PV domain, skipping bootloader");
         rc = 0;
         goto out_ok;
     }
 
     if (!info->u.pv.bootloader) {
-        LOG(DEBUG, "no bootloader configured, using user supplied kernel");
+        LOGD(DEBUG, domid,
+             "no bootloader configured, using user supplied kernel");
         bl->kernel->path = bl->info->kernel;
         bl->ramdisk->path = bl->info->ramdisk;
         bl->cmdline = bl->info->cmdline;
@@ -336,7 +341,7 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl)
     }
 
     if (!bl->disk) {
-        LOG(ERROR, "cannot run bootloader with no boot disk");
+        LOGD(ERROR, domid, "cannot run bootloader with no boot disk");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -354,7 +359,8 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl)
 
     bl->display.log = fopen(bl->logfile, "a");
     if (!bl->display.log) {
-        LOGE(ERROR, "failed to create bootloader logfile %s", bl->logfile);
+        LOGED(ERROR, domid,
+              "failed to create bootloader logfile %s", bl->logfile);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -364,7 +370,8 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl)
         if (!r) break;
         if (errno == EINTR) continue;
         if (errno == EEXIST) break;
-        LOGE(ERROR, "failed to create bootloader dir %s", bl->outputdir);
+        LOGED(ERROR, domid,
+              "failed to create bootloader dir %s", bl->outputdir);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -373,7 +380,8 @@ void libxl__bootloader_run(libxl__egc *egc, libxl__bootloader_state *bl)
         r = open(bl->outputpath, O_WRONLY|O_CREAT|O_TRUNC, 0600);
         if (r>=0) { close(r); break; }
         if (errno == EINTR) continue;
-        LOGE(ERROR, "failed to precreate bootloader output %s", bl->outputpath);
+        LOGED(ERROR, domid,
+              "failed to precreate bootloader output %s", bl->outputpath);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -405,15 +413,18 @@ static void bootloader_disk_attached_cb(libxl__egc *egc,
     const char *bootloader;
 
     if (rc) {
-        LOG(ERROR, "failed to attach local disk for bootloader execution");
+        LOGD(ERROR, bl->domid,
+             "failed to attach local disk for bootloader execution");
         goto out;
     }
 
-    LOG(DEBUG, "Config bootloader value: %s", info->u.pv.bootloader);
+    LOGD(DEBUG, bl->domid,
+         "Config bootloader value: %s", info->u.pv.bootloader);
 
     if ( !strcmp(info->u.pv.bootloader, "/usr/bin/pygrub") )
-        LOG(WARN, "bootloader='/usr/bin/pygrub' is deprecated; use " \
-            "bootloader='pygrub' instead");
+        LOGD(WARN, bl->domid,
+             "bootloader='/usr/bin/pygrub' is deprecated; use " \
+             "bootloader='pygrub' instead");
 
     bootloader = info->u.pv.bootloader;
 
@@ -425,11 +436,13 @@ static void bootloader_disk_attached_cb(libxl__egc *egc,
         bltmp = libxl__abs_path(gc, bootloader, libxl__private_bindir_path());
         /* Check to see if the file exists in this location; if not,
          * fall back to checking the path */
-        LOG(DEBUG, "Checking for bootloader in libexec path: %s", bltmp);
+        LOGD(DEBUG, bl->domid,
+             "Checking for bootloader in libexec path: %s", bltmp);
 
         if ( lstat(bltmp, &st) )
-            LOG(DEBUG, "%s doesn't exist, falling back to config path",
-                bltmp);
+            LOGD(DEBUG, bl->domid,
+                 "%s doesn't exist, falling back to config path",
+                 bltmp);
         else
             bootloader = bltmp;
     }
@@ -488,7 +501,7 @@ static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op)
     rc = libxl__xs_printf(gc, XBT_NULL, dom_console_xs_path, "%s",
                           dom_console_slave_tty_path);
     if (rc) {
-        LOGE(ERROR,"xs write console path %s := %s failed",
+        LOGED(ERROR, bl->domid, "xs write console path %s := %s failed",
              dom_console_xs_path, dom_console_slave_tty_path);
         rc = ERROR_FAIL;
         goto out;
@@ -537,11 +550,11 @@ static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op)
     rc = libxl__datacopier_start(&bl->display);
     if (rc) goto out;
 
-    LOG(DEBUG, "executing bootloader: %s", bl->args[0]);
+    LOGD(DEBUG, bl->domid, "executing bootloader: %s", bl->args[0]);
     for (const char **blarg = bl->args;
          *blarg;
          blarg++)
-        LOG(DEBUG, "  bootloader arg: %s", *blarg);
+        LOGD(DEBUG, bl->domid, "  bootloader arg: %s", *blarg);
 
     struct termios termattr;
 
@@ -554,7 +567,7 @@ static void bootloader_gotptys(libxl__egc *egc, libxl__openpty_state *op)
     if (!pid) {
         /* child */
         r = login_tty(libxl__carefd_fd(bl->ptys[0].slave));
-        if (r) { LOGE(ERROR, "login_tty failed"); exit(-1); }
+        if (r) { LOGED(ERROR, bl->domid, "login_tty failed"); exit(-1); }
         libxl__exec(gc, -1, -1, -1, bl->args[0], (char **) bl->args, env);
     }
 
@@ -589,10 +602,10 @@ static void bootloader_copyfail(libxl__egc *egc, const char *which,
             rc = 0;
             bl->got_pollhup = 1;
         } else {
-            LOG(ERROR, "unexpected POLLHUP on %s", which);
+            LOGD(ERROR, bl->domid, "unexpected POLLHUP on %s", which);
         }
     } else if (!rc) {
-        LOG(ERROR, "unexpected eof copying %s", which);
+        LOGD(ERROR, bl->domid, "unexpected eof copying %s", which);
         rc = ERROR_FAIL;
     }
 
@@ -631,14 +644,15 @@ static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child,
 
     if (status) {
         if (bl->got_pollhup && WIFSIGNALED(status) && WTERMSIG(status)==SIGTERM)
-            LOG(ERROR, "got POLLHUP, sent SIGTERM");
-        LOG(ERROR, "bootloader failed - consult logfile %s", bl->logfile);
+            LOGD(ERROR, bl->domid, "got POLLHUP, sent SIGTERM");
+        LOGD(ERROR, bl->domid,
+             "bootloader failed - consult logfile %s", bl->logfile);
         libxl_report_child_exitstatus(CTX, XTL_ERROR, "bootloader",
                                       pid, status);
         rc = ERROR_FAIL;
         goto out;
     } else {
-        LOG(DEBUG, "bootloader completed");
+        LOGD(DEBUG, bl->domid, "bootloader completed");
     }
 
     if (bl->rc) {
@@ -651,7 +665,7 @@ static void bootloader_finished(libxl__egc *egc, libxl__ev_child *child,
     if (rc) goto out;
 
     rc = 0;
-    LOG(DEBUG, "bootloader execution successful");
+    LOGD(DEBUG, bl->domid, "bootloader execution successful");
 
  out:
     bootloader_callback(egc, bl, rc);
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 06/35] libxl/libxl_checkpoint_device.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (4 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 05/35] libxl/libxl_bootloader.c: used LOG*D functions Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 07/35] libxl/libxl_colo.h: " Cédric Bosdonnat
                   ` (28 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_checkpoint_device.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/libxl_checkpoint_device.c b/tools/libxl/libxl_checkpoint_device.c
index 0a16dbb..01e74b5 100644
--- a/tools/libxl/libxl_checkpoint_device.c
+++ b/tools/libxl/libxl_checkpoint_device.c
@@ -132,7 +132,7 @@ static void device_setup_iterate(libxl__egc *egc, libxl__ao_device *aodev)
         if (!dev->ops) {
             libxl_device_nic * nic = NULL;
             libxl_device_disk * disk = NULL;
-            uint32_t domid;
+            uint32_t domid = INVALID_DOMID;
             int devid;
             if (dev->kind == LIBXL__DEVICE_KIND_VIF) {
                 nic = (libxl_device_nic *)dev->backend_dev;
@@ -143,15 +143,15 @@ static void device_setup_iterate(libxl__egc *egc, libxl__ao_device *aodev)
                 domid = disk->backend_domid;
                 devid = libxl__device_disk_dev_number(disk->vdev, NULL, NULL);
             } else {
-                LOG(ERROR,"device kind not handled by checkpoint: %s",
-                    libxl__device_kind_to_string(dev->kind));
+                LOGD(ERROR, domid, "device kind not handled by checkpoint: %s",
+                     libxl__device_kind_to_string(dev->kind));
                 aodev->rc = ERROR_FAIL;
                 goto out;
             }
-            LOG(ERROR,"device not handled by checkpoint"
-                " (device=%s:%"PRId32"/%"PRId32")",
-                libxl__device_kind_to_string(dev->kind),
-                domid, devid);
+            LOGD(ERROR, domid, "device not handled by checkpoint"
+                 " (device=%s:%"PRId32"/%"PRId32")",
+                 libxl__device_kind_to_string(dev->kind),
+                 domid, devid);
             aodev->rc = ERROR_CHECKPOINT_DEVICE_NOT_SUPPORTED;
             goto out;
         }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 07/35] libxl/libxl_colo.h: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (5 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 06/35] libxl/libxl_checkpoint_device.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 08/35] libxl/libxl_colo_nic.c: " Cédric Bosdonnat
                   ` (27 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_colo.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_colo.h b/tools/libxl/libxl_colo.h
index f0e438e..682275c 100644
--- a/tools/libxl/libxl_colo.h
+++ b/tools/libxl/libxl_colo.h
@@ -27,7 +27,7 @@
                                                                         \
     pid = libxl__ev_child_fork(gc, child, callback);                    \
     if (pid == -1) {                                                    \
-        LOG(ERROR, "unable to fork");                                   \
+        LOGD(ERROR, ao->domid, "unable to fork");                       \
         goto out;                                                       \
     }                                                                   \
                                                                         \
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 08/35] libxl/libxl_colo_nic.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (6 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 07/35] libxl/libxl_colo.h: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 09/35] libxl/libxl_colo_proxy.c: " Cédric Bosdonnat
                   ` (26 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_colo_nic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_colo_nic.c b/tools/libxl/libxl_colo_nic.c
index 5e0968c..a164e22 100644
--- a/tools/libxl/libxl_colo_nic.c
+++ b/tools/libxl/libxl_colo_nic.c
@@ -213,7 +213,7 @@ static void colo_save_setup_script_cb(libxl__egc *egc,
         goto out;
 
     if (hotplug_error) {
-        LOG(ERROR, "colo_proxy script %s setup failed for vif %s: %s",
+        LOGD(ERROR, domid, "colo_proxy script %s setup failed for vif %s: %s",
             aes->args[0], vif, hotplug_error);
         rc = ERROR_FAIL;
         goto out;
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 09/35] libxl/libxl_colo_proxy.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (7 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 08/35] libxl/libxl_colo_nic.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 10/35] libxl/libxl_colo_qdisk.c: " Cédric Bosdonnat
                   ` (25 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_colo_proxy.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libxl/libxl_colo_proxy.c
index d4b73ee..0983f42 100644
--- a/tools/libxl/libxl_colo_proxy.c
+++ b/tools/libxl/libxl_colo_proxy.c
@@ -69,7 +69,7 @@ static int colo_proxy_send(libxl__colo_proxy_state *cps, uint8_t *buff,
 
     ret = sendmsg(cps->sock_fd, &mh, 0);
     if (ret <= 0) {
-        LOG(ERROR, "can't send msg to kernel by netlink: %s",
+        LOGD(ERROR, ao->domid, "can't send msg to kernel by netlink: %s",
             strerror(errno));
     }
 
@@ -108,7 +108,7 @@ next:
     ret = recvmsg(cps->sock_fd, &mh, 0);
     if (ret <= 0) {
         if (errno != EAGAIN && errno != EWOULDBLOCK)
-            LOGE(ERROR, "can't recv msg from kernel by netlink");
+            LOGED(ERROR, ao->domid, "can't recv msg from kernel by netlink");
         goto err;
     }
 
@@ -154,7 +154,7 @@ int colo_proxy_setup(libxl__colo_proxy_state *cps)
 
     skfd = socket(PF_NETLINK, SOCK_RAW, NETLINK_COLO);
     if (skfd < 0) {
-        LOG(ERROR, "can not create a netlink socket: %s", strerror(errno));
+        LOGD(ERROR, ao->domid, "can not create a netlink socket: %s", strerror(errno));
         goto out;
     }
     cps->sock_fd = skfd;
@@ -165,16 +165,16 @@ retry:
     sa.nl_pid = i++;
 
     if (i > 10) {
-        LOG(ERROR, "netlink bind error");
+        LOGD(ERROR, ao->domid, "netlink bind error");
         goto out;
     }
 
     ret = bind(skfd, (struct sockaddr *)&sa, sizeof(sa));
     if (ret < 0 && errno == EADDRINUSE) {
-        LOG(ERROR, "colo index %d has already in used", sa.nl_pid);
+        LOGD(ERROR, ao->domid, "colo index %d has already in used", sa.nl_pid);
         goto retry;
     } else if (ret < 0) {
-        LOG(ERROR, "netlink bind error");
+        LOGD(ERROR, ao->domid, "netlink bind error");
         goto out;
     }
 
@@ -186,8 +186,8 @@ retry:
     /* receive ack */
     size = colo_proxy_recv(cps, &buff, 500000);
     if (size < 0) {
-        LOG(ERROR, "Can't recv msg from kernel by netlink: %s",
-            strerror(errno));
+        LOGD(ERROR, ao->domid, "Can't recv msg from kernel by netlink: %s",
+             strerror(errno));
         goto out;
     }
 
@@ -198,12 +198,12 @@ retry:
             struct nlmsgerr *err = (struct nlmsgerr *)NLMSG_DATA(h);
 
             if (size - sizeof(*h) < sizeof(*err)) {
-                LOG(ERROR, "NLMSG_LENGTH is too short");
+                LOGD(ERROR, ao->domid, "NLMSG_LENGTH is too short");
                 goto out;
             }
 
             if (err->error) {
-                LOG(ERROR, "NLMSG_ERROR contains error %d", err->error);
+                LOGD(ERROR, ao->domid, "NLMSG_ERROR contains error %d", err->error);
                 goto out;
             }
         }
@@ -271,12 +271,12 @@ int colo_proxy_checkpoint(libxl__colo_proxy_state *cps,
     h = (struct nlmsghdr *) buff;
 
     if (h->nlmsg_type == NLMSG_ERROR) {
-        LOG(ERROR, "receive NLMSG_ERROR");
+        LOGD(ERROR, ao->domid, "receive NLMSG_ERROR");
         goto out;
     }
 
     if (h->nlmsg_len < NLMSG_LENGTH(sizeof(*m))) {
-        LOG(ERROR, "NLMSG_LENGTH is too short");
+        LOGD(ERROR, ao->domid, "NLMSG_LENGTH is too short");
         goto out;
     }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 10/35] libxl/libxl_colo_qdisk.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (8 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 09/35] libxl/libxl_colo_proxy.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 11/35] libxl/libxl_colo_restore.c: " Cédric Bosdonnat
                   ` (24 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_colo_qdisk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_colo_qdisk.c b/tools/libxl/libxl_colo_qdisk.c
index d271d1f..303b96e 100644
--- a/tools/libxl/libxl_colo_qdisk.c
+++ b/tools/libxl/libxl_colo_qdisk.c
@@ -84,7 +84,7 @@ static void colo_qdisk_setup(libxl__egc *egc, libxl__checkpoint_device *dev,
             crs->port = port;
         } else {
             if (strcmp(crs->host, host) || strcmp(crs->port, port)) {
-                LOG(ERROR, "The host and port of all disks must be the same");
+                LOGD(ERROR, domid, "The host and port of all disks must be the same");
                 rc = ERROR_FAIL;
                 goto out;
             }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 11/35] libxl/libxl_colo_restore.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (9 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 10/35] libxl/libxl_colo_qdisk.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 12/35] libxl/libxl_colo_save.c: " Cédric Bosdonnat
                   ` (23 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_colo_restore.c | 57 ++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 29 deletions(-)

diff --git a/tools/libxl/libxl_colo_restore.c b/tools/libxl/libxl_colo_restore.c
index 3483f39..6a96328 100644
--- a/tools/libxl/libxl_colo_restore.c
+++ b/tools/libxl/libxl_colo_restore.c
@@ -63,7 +63,7 @@ static void colo_enable_logdirty(libxl__colo_restore_state *crs, libxl__egc *egc
     if (xc_shadow_control(CTX->xch, domid,
                           XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY,
                           NULL, 0, NULL, 0, NULL) < 0) {
-        LOG(ERROR, "cannot enable secondary vm's logdirty");
+        LOGD(ERROR, domid, "cannot enable secondary vm's logdirty");
         lds->callback(egc, lds, ERROR_FAIL);
         return;
     }
@@ -91,7 +91,7 @@ static void colo_disable_logdirty(libxl__colo_restore_state *crs,
     /* we need to know which pages are dirty to restore the guest */
     if (xc_shadow_control(CTX->xch, domid, XEN_DOMCTL_SHADOW_OP_OFF,
                           NULL, 0, NULL, 0, NULL) < 0)
-        LOG(WARN, "cannot disable secondary vm's logdirty");
+        LOGD(WARN, domid, "cannot disable secondary vm's logdirty");
 
     if (crs->hvm) {
         libxl__domain_common_switch_qemu_logdirty(egc, domid, 0, lds);
@@ -118,14 +118,15 @@ static void colo_resume_vm(libxl__egc *egc,
         if (restore_device_model) {
             rc = libxl__qmp_restore(gc, crs->domid, crcs->state_file);
             if (rc) {
-                LOG(ERROR, "cannot restore device model for secondary vm");
+                LOGD(ERROR, crs->domid,
+                     "cannot restore device model for secondary vm");
                 crcs->callback(egc, crcs, rc);
                 return;
             }
         }
         rc = libxl__domain_resume(gc, crs->domid, 0);
         if (rc)
-            LOG(ERROR, "cannot resume secondary vm");
+            LOGD(ERROR, crs->domid, "cannot resume secondary vm");
 
         crcs->callback(egc, crcs, rc);
         return;
@@ -317,7 +318,7 @@ void libxl__colo_restore_teardown(libxl__egc *egc, void *dcs_void,
     if (ret == 0 && retval == 0)
         rc = 0;
 
-    LOG(INFO, "%s", rc ? "colo fails" : "failover");
+    LOGD(INFO, crs->domid, "%s", rc ? "colo fails" : "failover");
 
     libxl__stream_write_abort(egc, &crcs->sws, 1);
     if (crs->saved_cb) {
@@ -351,8 +352,8 @@ static void colo_restore_teardown_devices_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc)
-        LOG(ERROR, "COLO: failed to teardown device for guest with domid %u,"
-            " rc %d", cds->domid, rc);
+        LOGD(ERROR, cds->domid, "COLO: failed to teardown device for guest,"
+            " rc %d", rc);
 
     if (crcs->teardown_devices)
         cleanup_device_subkind(cds);
@@ -387,7 +388,7 @@ static void do_failover(libxl__egc *egc, libxl__colo_restore_state *crs)
          * is not called. In this case, the migration is not finished,
          * so we cannot do failover.
          */
-        LOG(ERROR, "migration fails");
+        LOGD(ERROR, crs->domid, "migration fails");
         crcs->callback(egc, crcs, ERROR_FAIL);
         return;
     case LIBXL_COLO_SUSPENDED:
@@ -397,7 +398,7 @@ static void do_failover(libxl__egc *egc, libxl__colo_restore_state *crs)
         colo_disable_logdirty(crs, egc);
         return;
     default:
-        LOG(ERROR, "invalid status: %d", status);
+        LOGD(ERROR, crs->domid, "invalid status: %d", status);
         crcs->callback(egc, crcs, ERROR_FAIL);
     }
 }
@@ -414,7 +415,7 @@ static void do_failover_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc)
-        LOG(ERROR, "cannot do failover");
+        LOGD(ERROR, crs->domid, "cannot do failover");
 
     libxl__colo_restore_teardown_done(egc, crs, rc);
 }
@@ -428,7 +429,7 @@ static void colo_disable_logdirty_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc)
-        LOG(WARN, "cannot disable logdirty");
+        LOGD(WARN, crcs->crs->domid, "cannot disable logdirty");
 
     if (crcs->status == LIBXL_COLO_SUSPENDED) {
         /*
@@ -601,13 +602,13 @@ static void colo_restore_preresume_cb(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "preresume fails");
+        LOGD(ERROR, crs->domid, "preresume fails");
         goto out;
     }
 
     if (crs->qdisk_setuped) {
         if (libxl__qmp_do_checkpoint(gc, crs->domid)) {
-            LOG(ERROR, "doing checkpoint fails");
+            LOGD(ERROR, crs->domid, "doing checkpoint fails");
             goto out;
         }
     }
@@ -644,7 +645,7 @@ static void colo_resume_vm_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "cannot resume secondary vm");
+        LOGD(ERROR, crs->domid, "cannot resume secondary vm");
         goto out;
     }
 
@@ -719,7 +720,7 @@ static void colo_reenable_logdirty(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "cannot enable logdirty");
+        LOGD(ERROR, crs->domid, "cannot enable logdirty");
         goto out;
     }
 
@@ -745,7 +746,7 @@ static void colo_reenable_logdirty_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "cannot enable logdirty");
+        LOGD(ERROR, crcs->crs->domid, "cannot enable logdirty");
         goto out;
     }
 
@@ -782,8 +783,7 @@ static void colo_setup_checkpoint_devices(libxl__egc *egc,
 
     crs->cps.ao = ao;
     if (colo_proxy_setup(&crs->cps)) {
-        LOG(ERROR, "COLO: failed to setup colo proxy for guest with domid %u",
-            cds->domid);
+        LOGD(ERROR, cds->domid, "COLO: failed to setup colo proxy for guest");
         goto out;
     }
 
@@ -813,14 +813,13 @@ static void colo_restore_setup_cds_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "COLO: failed to setup device for guest with domid %u",
-            cds->domid);
+        LOGD(ERROR, cds->domid, "COLO: failed to setup device for guest");
         goto out;
     }
 
     if (crs->qdisk_used && !crs->qdisk_setuped) {
         if (libxl__qmp_start_replication(gc, crs->domid, false)) {
-            LOG(ERROR, "starting replication fails");
+            LOGD(ERROR, cds->domid, "starting replication fails");
             goto out;
         }
         crs->qdisk_setuped = true;
@@ -849,7 +848,7 @@ static void colo_unpause_svm(libxl__egc *egc,
     /* We have enabled secondary vm's logdirty, so we can unpause it now */
     rc = libxl_domain_unpause(CTX, domid);
     if (rc) {
-        LOG(ERROR, "cannot unpause secondary vm");
+        LOGD(ERROR, domid, "cannot unpause secondary vm");
         goto out;
     }
 
@@ -894,7 +893,7 @@ static void colo_restore_commit_cb(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "commit fails");
+        LOGD(ERROR, crs->domid, "commit fails");
         goto out;
     }
 
@@ -918,7 +917,7 @@ static void colo_stream_read_done(libxl__egc *egc,
     EGC_GC;
 
     if (id != CHECKPOINT_NEW) {
-        LOG(ERROR, "invalid section: %d", id);
+        LOGD(ERROR, crcs->crs->domid, "invalid section: %d", id);
         goto out;
     }
 
@@ -974,14 +973,14 @@ static void colo_suspend_vm_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "cannot suspend secondary vm");
+        LOGD(ERROR, crs->domid, "cannot suspend secondary vm");
         goto out;
     }
 
     crcs->status = LIBXL_COLO_SUSPENDED;
 
     if (libxl__qmp_get_replication_error(gc, crs->domid)) {
-        LOG(ERROR, "replication error occurs when secondary vm is running");
+        LOGD(ERROR, crs->domid, "replication error occurs when secondary vm is running");
         goto out;
     }
 
@@ -1006,7 +1005,7 @@ static void colo_restore_postsuspend_cb(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "postsuspend fails");
+        LOGD(ERROR, crs->domid, "postsuspend fails");
         goto out;
     }
 
@@ -1035,7 +1034,7 @@ static void colo_common_write_stream_done(libxl__egc *egc,
 
     if (rc < 0) {
         /* TODO: it may be a internal error, but we don't know */
-        LOG(ERROR, "sending data fails");
+        LOGD(ERROR, crcs->crs->domid, "sending data fails");
         ok = 2;
         goto out;
     }
@@ -1066,7 +1065,7 @@ static void colo_common_read_stream_done(libxl__egc *egc,
 
     if (rc < 0) {
         /* TODO: it may be a internal error, but we don't know */
-        LOG(ERROR, "reading data fails");
+        LOGD(ERROR, crcs->crs->domid, "reading data fails");
         ok = 2;
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 12/35] libxl/libxl_colo_save.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (10 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 11/35] libxl/libxl_colo_restore.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 13/35] libxl/libxl_create.c: " Cédric Bosdonnat
                   ` (22 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_colo_save.c | 49 ++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c
index 26b3afd..6277770 100644
--- a/tools/libxl/libxl_colo_save.c
+++ b/tools/libxl/libxl_colo_save.c
@@ -90,7 +90,7 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css)
     STATE_AO_GC(dss->ao);
 
     if (dss->type != LIBXL_DOMAIN_TYPE_HVM) {
-        LOG(ERROR, "COLO only supports hvm now");
+        LOGD(ERROR, dss->domid, "COLO only supports hvm now");
         goto out;
     }
 
@@ -122,8 +122,7 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css)
     libxl__stream_read_start(egc, &css->srs);
     css->cps.ao = ao;
     if (colo_proxy_setup(&css->cps)) {
-        LOG(ERROR, "COLO: failed to setup colo proxy for guest with domid %u",
-            cds->domid);
+        LOGD(ERROR, cds->domid, "COLO: failed to setup colo proxy for guest");
         goto out;
     }
 
@@ -156,8 +155,7 @@ static void colo_save_setup_done(libxl__egc *egc,
         return;
     }
 
-    LOG(ERROR, "COLO: failed to setup device for guest with domid %u",
-        dss->domid);
+    LOGD(ERROR, dss->domid, "COLO: failed to setup device for guest");
     cds->callback = colo_save_setup_failed;
     libxl__checkpoint_devices_teardown(egc, cds);
 }
@@ -171,8 +169,9 @@ static void colo_save_setup_failed(libxl__egc *egc,
     STATE_AO_GC(cds->ao);
 
     if (rc)
-        LOG(ERROR, "COLO: failed to teardown device after setup failed"
-            " for guest with domid %u, rc %d", cds->domid, rc);
+        LOGD(ERROR, cds->domid,
+             "COLO: failed to teardown device after setup failed"
+             " for guest, rc %d", rc);
 
     cleanup_device_subkind(cds);
     dss->callback(egc, dss, rc);
@@ -192,8 +191,9 @@ void libxl__colo_save_teardown(libxl__egc *egc,
 
     EGC_GC;
 
-    LOG(WARN, "COLO: Domain suspend terminated with rc %d,"
-        " teardown COLO devices...", rc);
+    LOGD(WARN, dss->domid,
+         "COLO: Domain suspend terminated with rc %d,"
+         " teardown COLO devices...", rc);
 
     libxl__stream_read_abort(egc, &css->srs, 1);
 
@@ -268,7 +268,7 @@ static void colo_suspend_primary_vm_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "cannot suspend primary vm");
+        LOGD(ERROR, dss->domid, "cannot suspend primary vm");
         goto out;
     }
 
@@ -294,7 +294,7 @@ static void colo_postsuspend_cb(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "postsuspend fails");
+        LOGD(ERROR, dss->domid, "postsuspend fails");
         goto out;
     }
 
@@ -326,13 +326,14 @@ static void colo_read_svm_suspended_done(libxl__egc *egc,
     EGC_GC;
 
     if (id != CHECKPOINT_SVM_SUSPENDED) {
-        LOG(ERROR, "invalid section: %d, expected: %d", id,
+        LOGD(ERROR, dss->domid, "invalid section: %d, expected: %d", id,
             CHECKPOINT_SVM_SUSPENDED);
         goto out;
     }
 
     if (!css->paused && libxl__qmp_get_replication_error(gc, dss->domid)) {
-        LOG(ERROR, "replication error occurs when primary vm is running");
+        LOGD(ERROR, dss->domid,
+             "replication error occurs when primary vm is running");
         goto out;
     }
 
@@ -405,7 +406,7 @@ static void colo_read_svm_ready_done(libxl__egc *egc,
     EGC_GC;
 
     if (id != CHECKPOINT_SVM_READY) {
-        LOG(ERROR, "invalid section: %d, expected: %d", id,
+        LOGD(ERROR, dss->domid, "invalid section: %d, expected: %d", id,
             CHECKPOINT_SVM_READY);
         goto out;
     }
@@ -432,13 +433,13 @@ static void colo_preresume_cb(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "preresume fails");
+        LOGD(ERROR, dss->domid, "preresume fails");
         goto out;
     }
 
     if (css->qdisk_used && !css->qdisk_setuped) {
         if (libxl__qmp_start_replication(gc, dss->domid, true)) {
-            LOG(ERROR, "starting replication fails");
+            LOGD(ERROR, dss->domid, "starting replication fails");
             goto out;
         }
         css->qdisk_setuped = true;
@@ -446,14 +447,14 @@ static void colo_preresume_cb(libxl__egc *egc,
 
     if (!css->paused) {
         if (libxl__qmp_do_checkpoint(gc, dss->domid)) {
-            LOG(ERROR, "doing checkpoint fails");
+            LOGD(ERROR, dss->domid, "doing checkpoint fails");
             goto out;
         }
     }
 
     /* Resumes the domain and the device model */
     if (libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1)) {
-        LOG(ERROR, "cannot resume primary vm");
+        LOGD(ERROR, dss->domid, "cannot resume primary vm");
         goto out;
     }
 
@@ -464,7 +465,7 @@ static void colo_preresume_cb(libxl__egc *egc,
     if (css->paused) {
         rc = libxl_domain_unpause(CTX, dss->domid);
         if (rc) {
-            LOG(ERROR, "cannot unpause primary vm");
+            LOGD(ERROR, dss->domid, "cannot unpause primary vm");
             goto out;
         }
         css->paused = false;
@@ -491,7 +492,7 @@ static void colo_read_svm_resumed_done(libxl__egc *egc,
     EGC_GC;
 
     if (id != CHECKPOINT_SVM_RESUMED) {
-        LOG(ERROR, "invalid section: %d, expected: %d", id,
+        LOGD(ERROR, dss->domid, "invalid section: %d, expected: %d", id,
             CHECKPOINT_SVM_RESUMED);
         goto out;
     }
@@ -553,7 +554,7 @@ static void colo_proxy_async_call_done(libxl__egc *egc,
     EGC_GC;
 
     if (status) {
-        LOG(ERROR, "failed to wait for new checkpoint");
+        LOGD(ERROR, dss->domid, "failed to wait for new checkpoint");
         colo_start_new_checkpoint(egc, &dss->cds, ERROR_FAIL);
         return;
     }
@@ -595,7 +596,7 @@ static void colo_device_commit_cb(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "commit fails");
+        LOGD(ERROR, dss->domid, "commit fails");
         goto out;
     }
 
@@ -644,7 +645,7 @@ static void colo_common_write_stream_done(libxl__egc *egc,
 
     if (rc < 0) {
         /* TODO: it may be a internal error, but we don't know */
-        LOG(ERROR, "sending data fails");
+        LOGD(ERROR, dss->domid, "sending data fails");
         ok = 0;
         goto out;
     }
@@ -675,7 +676,7 @@ static void colo_common_read_stream_done(libxl__egc *egc,
 
     if (rc < 0) {
         /* TODO: it may be a internal error, but we don't know */
-        LOG(ERROR, "reading data fails");
+        LOGD(ERROR, dss->domid, "reading data fails");
         ok = 0;
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 13/35] libxl/libxl_create.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (11 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 12/35] libxl/libxl_colo_save.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 14/35] libxl/libxl_device.c: " Cédric Bosdonnat
                   ` (21 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_create.c | 119 +++++++++++++++++++++++----------------------
 1 file changed, 60 insertions(+), 59 deletions(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 7c1695a..e3bc257 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -539,7 +539,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
     } else if (libxl_defbool_val(info->pvh)) {
         flags |= XEN_DOMCTL_CDF_pvh_guest;
         if (!libxl_defbool_val(info->hap)) {
-            LOG(ERROR, "HAP must be on for PVH");
+            LOGD(ERROR, *domid, "HAP must be on for PVH");
             rc = ERROR_INVAL;
             goto out;
         }
@@ -551,7 +551,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
 
     ret = libxl__arch_domain_prepare_config(gc, d_config, xc_config);
     if (ret < 0) {
-        LOGE(ERROR, "fail to get domain config");
+        LOGED(ERROR, *domid, "fail to get domain config");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -561,7 +561,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
         ret = xc_domain_create(ctx->xch, info->ssidref, handle, flags, domid,
                                xc_config);
         if (ret < 0) {
-            LOGE(ERROR, "domain creation fail");
+            LOGED(ERROR, *domid, "domain creation fail");
             rc = ERROR_FAIL;
             goto out;
         }
@@ -573,7 +573,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
 
     ret = xc_cpupool_movedomain(ctx->xch, info->poolid, *domid);
     if (ret < 0) {
-        LOGE(ERROR, "domain move fail");
+        LOGED(ERROR, *domid, "domain move fail");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -586,7 +586,7 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
 
     vm_path = GCSPRINTF("/vm/%s", uuid_string);
     if (!vm_path) {
-        LOG(ERROR, "cannot allocate create paths");
+        LOGD(ERROR, *domid, "cannot allocate create paths");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -697,7 +697,7 @@ retry_transaction:
 
     vm_list = libxl_list_vm(ctx, &nb_vm);
     if (!vm_list) {
-        LOG(ERROR, "cannot get number of running guests");
+        LOGD(ERROR, *domid, "cannot get number of running guests");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -716,7 +716,7 @@ retry_transaction:
             t = 0;
             goto retry_transaction;
         }
-        LOGE(ERROR, "domain creation ""xenstore transaction commit failed");
+        LOGED(ERROR, *domid, "domain creation ""xenstore transaction commit failed");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -806,10 +806,10 @@ static void initiate_domain_create(libxl__egc *egc,
                                          &d_config->c_info.ssidref);
         if (ret) {
             if (errno == ENOSYS) {
-                LOG(WARN, "XSM Disabled: init_seclabel not supported");
+                LOGD(WARN, domid, "XSM Disabled: init_seclabel not supported");
                 ret = 0;
             } else {
-                LOG(ERROR, "Invalid init_seclabel: %s", s);
+                LOGD(ERROR, domid, "Invalid init_seclabel: %s", s);
                 goto error_out;
             }
         }
@@ -821,10 +821,10 @@ static void initiate_domain_create(libxl__egc *egc,
                                          &d_config->b_info.exec_ssidref);
         if (ret) {
             if (errno == ENOSYS) {
-                LOG(WARN, "XSM Disabled: seclabel not supported");
+                LOGD(WARN, domid, "XSM Disabled: seclabel not supported");
                 ret = 0;
             } else {
-                LOG(ERROR, "Invalid seclabel: %s", s);
+                LOGD(ERROR, domid, "Invalid seclabel: %s", s);
                 goto error_out;
             }
         }
@@ -836,10 +836,11 @@ static void initiate_domain_create(libxl__egc *egc,
                                          &d_config->b_info.device_model_ssidref);
         if (ret) {
             if (errno == ENOSYS) {
-                LOG(WARN,"XSM Disabled: device_model_stubdomain_seclabel not supported");
+                LOGD(WARN, domid,
+                     "XSM Disabled: device_model_stubdomain_seclabel not supported");
                 ret = 0;
             } else {
-                LOG(ERROR, "Invalid device_model_stubdomain_seclabel: %s", s);
+                LOGD(ERROR, domid, "Invalid device_model_stubdomain_seclabel: %s", s);
                 goto error_out;
             }
         }
@@ -852,7 +853,8 @@ static void initiate_domain_create(libxl__egc *egc,
                                              NULL);
     }
     if (!libxl_cpupoolid_is_valid(ctx, d_config->c_info.poolid)) {
-        LOG(ERROR, "Illegal pool specified: %s", d_config->c_info.pool_name);
+        LOGD(ERROR, domid, "Illegal pool specified: %s",
+             d_config->c_info.pool_name);
         ret = ERROR_INVAL;
         goto error_out;
     }
@@ -872,7 +874,8 @@ static void initiate_domain_create(libxl__egc *egc,
     if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_HVM &&
         d_config->num_pcidevs && pod_enabled) {
         ret = ERROR_INVAL;
-        LOG(ERROR, "PCI device assignment for HVM guest failed due to PoD enabled");
+        LOGD(ERROR, domid,
+             "PCI device assignment for HVM guest failed due to PoD enabled");
         goto error_out;
     }
 
@@ -881,7 +884,7 @@ static void initiate_domain_create(libxl__egc *egc,
      */
     if (pod_enabled && d_config->b_info.num_vnuma_nodes) {
         ret = ERROR_INVAL;
-        LOG(ERROR, "Cannot enable PoD and vNUMA at the same time");
+        LOGD(ERROR, domid, "Cannot enable PoD and vNUMA at the same time");
         goto error_out;
     }
 
@@ -891,19 +894,19 @@ static void initiate_domain_create(libxl__egc *egc,
     if (d_config->c_info.type == LIBXL_DOMAIN_TYPE_PV &&
         d_config->b_info.num_vnuma_nodes) {
         ret = ERROR_INVAL;
-        LOG(ERROR, "PV vNUMA is not yet supported");
+        LOGD(ERROR, domid, "PV vNUMA is not yet supported");
         goto error_out;
     }
 
     ret = libxl__domain_create_info_setdefault(gc, &d_config->c_info);
     if (ret) {
-        LOG(ERROR, "Unable to set domain create info defaults");
+        LOGD(ERROR, domid, "Unable to set domain create info defaults");
         goto error_out;
     }
 
     ret = libxl__domain_build_info_setdefault(gc, &d_config->b_info);
     if (ret) {
-        LOG(ERROR, "Unable to set domain build info defaults");
+        LOGD(ERROR, domid, "Unable to set domain build info defaults");
         goto error_out;
     }
 
@@ -911,7 +914,7 @@ static void initiate_domain_create(libxl__egc *egc,
         (libxl_defbool_val(d_config->b_info.u.hvm.nested_hvm) &&
          libxl_defbool_val(d_config->b_info.u.hvm.altp2m))) {
         ret = ERROR_INVAL;
-        LOG(ERROR, "nestedhvm and altp2mhvm cannot be used together");
+        LOGD(ERROR, domid, "nestedhvm and altp2mhvm cannot be used together");
         goto error_out;
     }
 
@@ -919,13 +922,13 @@ static void initiate_domain_create(libxl__egc *egc,
         libxl_defbool_val(d_config->b_info.u.hvm.altp2m) &&
         pod_enabled) {
         ret = ERROR_INVAL;
-        LOG(ERROR, "Cannot enable PoD and ALTP2M at the same time");
+        LOGD(ERROR, domid, "Cannot enable PoD and ALTP2M at the same time");
         goto error_out;
     }
 
     ret = libxl__domain_make(gc, d_config, &domid, &state->config);
     if (ret) {
-        LOG(ERROR, "cannot make domain: %d", ret);
+        LOGD(ERROR, domid, "cannot make domain: %d", ret);
         dcs->guest_domid = domid;
         ret = ERROR_FAIL;
         goto error_out;
@@ -943,7 +946,7 @@ static void initiate_domain_create(libxl__egc *egc,
     for (i = 0; i < d_config->num_disks; i++) {
         ret = libxl__device_disk_setdefault(gc, &d_config->disks[i], domid);
         if (ret) {
-            LOG(ERROR, "Unable to set disk defaults for disk %d", i);
+            LOGD(ERROR, domid, "Unable to set disk defaults for disk %d", i);
             goto error_out;
         }
     }
@@ -964,10 +967,10 @@ static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
 
     if (restore_fd >= 0 || dcs->domid_soft_reset != INVALID_DOMID) {
-        LOG(DEBUG, "restoring, not running bootloader");
+        LOGD(DEBUG, domid, "restoring, not running bootloader");
         domcreate_bootloader_done(egc, &dcs->bl, 0);
     } else  {
-        LOG(DEBUG, "running bootloader");
+        LOGD(DEBUG, domid, "running bootloader");
         dcs->bl.callback = domcreate_bootloader_done;
         dcs->bl.console_available = domcreate_bootloader_console_available;
         dcs->bl.info = &d_config->b_info;
@@ -1011,7 +1014,7 @@ static void libxl__colo_restore_setup_done(libxl__egc *egc,
     EGC_GC;
 
     if (rc) {
-        LOG(ERROR, "colo restore setup fails: %d", rc);
+        LOGD(ERROR, dcs->guest_domid, "colo restore setup fails: %d", rc);
         domcreate_stream_done(egc, &dcs->srs, rc);
         return;
     }
@@ -1075,8 +1078,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,
      */
     if (info->type != LIBXL_DOMAIN_TYPE_HVM &&
         checkpointed_stream == LIBXL_CHECKPOINTED_STREAM_COLO) {
-        LOG(ERROR, "COLO only supports HVM, unable to restore domain %d",
-            domid);
+        LOGD(ERROR, domid, "COLO only supports HVM, unable to restore domain");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1220,7 +1222,7 @@ static void domcreate_rebuild_done(libxl__egc *egc,
     libxl_domain_config *const d_config = dcs->guest_config;
 
     if (ret) {
-        LOG(ERROR, "cannot (re-)build domain: %d", ret);
+        LOGD(ERROR, domid, "cannot (re-)build domain: %d", ret);
         ret = ERROR_FAIL;
         goto error_out;
     }
@@ -1252,22 +1254,22 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
     libxl__domain_build_state *const state = &dcs->build_state;
 
     if (ret) {
-        LOG(ERROR, "unable to add disk devices");
+        LOGD(ERROR, domid, "unable to add disk devices");
         goto error_out;
     }
 
     for (i = 0; i < d_config->b_info.num_ioports; i++) {
         libxl_ioport_range *io = &d_config->b_info.ioports[i];
 
-        LOG(DEBUG, "dom%d ioports %"PRIx32"-%"PRIx32,
-            domid, io->first, io->first + io->number - 1);
+        LOGD(DEBUG, domid, "ioports %"PRIx32"-%"PRIx32,
+             io->first, io->first + io->number - 1);
 
         ret = xc_domain_ioport_permission(CTX->xch, domid,
                                           io->first, io->number, 1);
         if (ret < 0) {
-            LOGE(ERROR,
-                 "failed give dom%d access to ioports %"PRIx32"-%"PRIx32,
-                 domid, io->first, io->first + io->number - 1);
+            LOGED(ERROR, domid,
+                  "failed give domain access to ioports %"PRIx32"-%"PRIx32,
+                  io->first, io->first + io->number - 1);
             ret = ERROR_FAIL;
             goto error_out;
         }
@@ -1276,12 +1278,12 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
     for (i = 0; i < d_config->b_info.num_irqs; i++) {
         int irq = d_config->b_info.irqs[i];
 
-        LOG(DEBUG, "dom%d irq %d", domid, irq);
+        LOGD(DEBUG, domid, "irq %d", irq);
 
         ret = irq >= 0 ? libxl__arch_domain_map_irq(gc, domid, irq)
                        : -EOVERFLOW;
         if (ret) {
-            LOGE(ERROR, "failed give dom%d access to irq %d", domid, irq);
+            LOGED(ERROR, domid, "failed give domain access to irq %d", irq);
             ret = ERROR_FAIL;
             goto error_out;
         }
@@ -1290,15 +1292,15 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
     for (i = 0; i < d_config->b_info.num_iomem; i++) {
         libxl_iomem_range *io = &d_config->b_info.iomem[i];
 
-        LOG(DEBUG, "dom%d iomem %"PRIx64"-%"PRIx64,
-            domid, io->start, io->start + io->number - 1);
+        LOGD(DEBUG, domid, "iomem %"PRIx64"-%"PRIx64,
+             io->start, io->start + io->number - 1);
 
         ret = xc_domain_iomem_permission(CTX->xch, domid,
                                           io->start, io->number, 1);
         if (ret < 0) {
-            LOGE(ERROR,
-                 "failed give dom%d access to iomem range %"PRIx64"-%"PRIx64,
-                 domid, io->start, io->start + io->number - 1);
+            LOGED(ERROR, domid,
+                  "failed give domain access to iomem range %"PRIx64"-%"PRIx64,
+                  io->start, io->start + io->number - 1);
             ret = ERROR_FAIL;
             goto error_out;
         }
@@ -1306,10 +1308,10 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
                                        io->gfn, io->start,
                                        io->number, 1);
         if (ret < 0) {
-            LOGE(ERROR,
-                 "failed to map to dom%d iomem range %"PRIx64"-%"PRIx64
-                 " to guest address %"PRIx64,
-                 domid, io->start, io->start + io->number - 1, io->gfn);
+            LOGED(ERROR, domid,
+                  "failed to map to domain iomem range %"PRIx64"-%"PRIx64
+                  " to guest address %"PRIx64,
+                  io->start, io->start + io->number - 1, io->gfn);
             ret = ERROR_FAIL;
             goto error_out;
         }
@@ -1418,10 +1420,10 @@ static void libxl__add_dtdevs(libxl__egc *egc, libxl__ao *ao, uint32_t domid,
     for (i = 0; i < d_config->num_dtdevs; i++) {
         const libxl_device_dtdev *dtdev = &d_config->dtdevs[i];
 
-        LOG(DEBUG, "Assign device \"%s\" to dom%u", dtdev->path, domid);
+        LOGD(DEBUG, domid, "Assign device \"%s\" to domain", dtdev->path);
         rc = xc_assign_dt_device(CTX->xch, domid, dtdev->path);
         if (rc < 0) {
-            LOG(ERROR, "xc_assign_dtdevice failed: %d", rc);
+            LOGD(ERROR, domid, "xc_assign_dtdevice failed: %d", rc);
             goto out;
         }
     }
@@ -1457,8 +1459,8 @@ static void domcreate_attach_devices(libxl__egc *egc,
     const struct libxl_device_type *dt;
 
     if (ret) {
-        LOG(ERROR, "unable to add %s devices",
-            device_type_tbl[dcs->device_type_idx]->type);
+        LOGD(ERROR, domid, "unable to add %s devices",
+             device_type_tbl[dcs->device_type_idx]->type);
         goto error_out;
     }
 
@@ -1501,7 +1503,7 @@ static void domcreate_devmodel_started(libxl__egc *egc,
     libxl_domain_config *const d_config = dcs->guest_config;
 
     if (ret) {
-        LOG(ERROR, "device model did not start: %d", ret);
+        LOGD(ERROR, domid, "device model did not start: %d", ret);
         goto error_out;
     }
 
@@ -1579,8 +1581,7 @@ static void domcreate_destruction_cb(libxl__egc *egc,
     libxl__domain_create_state *dcs = CONTAINER_OF(dds, *dcs, dds);
 
     if (rc)
-        LOG(ERROR, "unable to destroy domain %u following failed creation",
-                   dds->domid);
+        LOGD(ERROR, dds->domid, "unable to destroy domain following failed creation");
 
     dcs->callback(egc, dcs, ERROR_FAIL, dcs->guest_domid);
 }
@@ -1654,7 +1655,7 @@ static void domain_soft_reset_cb(libxl__egc *egc,
     char *savefile, *restorefile;
 
     if (rc) {
-        LOG(ERROR, "destruction of domain %u failed.", dds->domid);
+        LOGD(ERROR, dds->domid, "destruction of domain failed.");
         goto error;
     }
 
@@ -1662,7 +1663,7 @@ static void domain_soft_reset_cb(libxl__egc *egc,
     rc = libxl__restore_emulator_xenstore_data(&cdcs->dcs, srs->toolstack_buf,
                                                srs->toolstack_len);
     if (rc) {
-        LOG(ERROR, "failed to restore toolstack record.");
+        LOGD(ERROR, dds->domid, "failed to restore toolstack record.");
         goto error;
     }
 
@@ -1670,7 +1671,7 @@ static void domain_soft_reset_cb(libxl__egc *egc,
     restorefile = GCSPRINTF(LIBXL_DEVICE_MODEL_RESTORE_FILE".%d", dds->domid);
     rc = rename(savefile, restorefile);
     if (rc) {
-        LOG(ERROR, "failed to rename dm save file.");
+        LOGD(ERROR, dds->domid, "failed to rename dm save file.");
         goto error;
     }
 
@@ -1718,7 +1719,7 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
 
     dom_path = libxl__xs_get_dompath(gc, domid_soft_reset);
     if (!dom_path) {
-        LOG(ERROR, "failed to read domain path");
+        LOGD(ERROR, domid_soft_reset, "failed to read domain path");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1743,13 +1744,13 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
     rc = libxl__save_emulator_xenstore_data(dss, &srs->toolstack_buf,
                                             &srs->toolstack_len);
     if (rc) {
-        LOG(ERROR, "failed to save toolstack record.");
+        LOGD(ERROR, domid_soft_reset, "failed to save toolstack record.");
         goto out;
     }
 
     rc = libxl__domain_suspend_device_model(gc, &dss->dsps);
     if (rc) {
-        LOG(ERROR, "failed to suspend device model.");
+        LOGD(ERROR, domid_soft_reset, "failed to suspend device model.");
         goto out;
     }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 14/35] libxl/libxl_device.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (12 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 13/35] libxl/libxl_create.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 15/35] libxl/libxl_dm.c: " Cédric Bosdonnat
                   ` (20 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_device.c | 70 ++++++++++++++++++++++++----------------------
 1 file changed, 37 insertions(+), 33 deletions(-)

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 3e7a102..5e22866 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -94,13 +94,13 @@ int libxl__nic_type(libxl__gc *gc, libxl__device *dev, libxl_nic_type *nictype)
     snictype = libxl__xs_read(gc, XBT_NULL,
                               GCSPRINTF("%s/%s", be_path, "type"));
     if (!snictype) {
-        LOGE(ERROR, "unable to read nictype from %s", be_path);
+        LOGED(ERROR, dev->domid, "unable to read nictype from %s", be_path);
         rc = ERROR_FAIL;
         goto out;
     }
     rc = libxl_nic_type_from_string(snictype, nictype);
     if (rc) {
-        LOGE(ERROR, "unable to parse nictype from %s", be_path);
+        LOGED(ERROR, dev->domid, "unable to parse nictype from %s", be_path);
         goto out;
     }
 
@@ -231,7 +231,7 @@ retry_transaction:
         if (errno == EAGAIN)
             goto retry_transaction;
         else {
-            LOGE(ERROR, "xs transaction failed");
+            LOGED(ERROR, device->domid, "xs transaction failed");
             return ERROR_FAIL;
         }
     }
@@ -885,7 +885,7 @@ void libxl__wait_device_connection(libxl__egc *egc, libxl__ao_device *aodev)
                                  state_path, XenbusStateInitWait,
                                  LIBXL_INIT_TIMEOUT * 1000);
     if (rc) {
-        LOG(ERROR, "unable to initialize device %s", be_path);
+        LOGD(ERROR, aodev->dev->domid, "unable to initialize device %s", be_path);
         goto out;
     }
 
@@ -914,14 +914,14 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc,
 
     rc = libxl__get_domid(gc, &my_domid);
     if (rc) {
-        LOG(ERROR, "unable to get my domid");
+        LOGD(ERROR, domid, "unable to get my domid");
         goto out;
     }
 
     if (my_domid == LIBXL_TOOLSTACK_DOMID) {
         rc = libxl_domain_info(CTX, &info, domid);
         if (rc) {
-            LOG(ERROR, "unable to get info for domain %d", domid);
+            LOGD(ERROR, domid, "unable to get info for domain %d", domid);
             goto out;
         }
         if (QEMU_BACKEND(aodev->dev) &&
@@ -934,8 +934,8 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc,
                                              device_qemu_timeout,
                                              LIBXL_QEMU_BODGE_TIMEOUT * 1000);
             if (rc) {
-                LOG(ERROR, "unable to register timeout for Qemu device %s",
-                           be_path);
+                LOGD(ERROR, domid, "unable to register timeout for Qemu device %s",
+                            be_path);
                 goto out;
             }
             goto out_success;
@@ -945,7 +945,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc,
     for (;;) {
         rc = libxl__xs_transaction_start(gc, &t);
         if (rc) {
-            LOG(ERROR, "unable to start transaction");
+            LOGD(ERROR, domid, "unable to start transaction");
             goto out;
         }
 
@@ -955,7 +955,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc,
 
         rc = libxl__xs_read_checked(gc, t, state_path, &state);
         if (rc) {
-            LOG(ERROR, "unable to read device state from path %s", state_path);
+            LOGD(ERROR, domid, "unable to read device state from path %s", state_path);
             goto out;
         }
 
@@ -970,7 +970,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc,
          if (state && atoi(state) != XenbusStateClosed) {
             rc = libxl__xs_write_checked(gc, t, state_path, GCSPRINTF("%d", XenbusStateClosing));
             if (rc) {
-                LOG(ERROR, "unable to write to xenstore path %s", state_path);
+                LOGD(ERROR, domid, "unable to write to xenstore path %s", state_path);
                 goto out;
             }
         }
@@ -985,7 +985,7 @@ void libxl__initiate_device_generic_remove(libxl__egc *egc,
                                  state_path, XenbusStateClosed,
                                  LIBXL_DESTROY_TIMEOUT * 1000);
     if (rc) {
-        LOG(ERROR, "unable to remove device %s", be_path);
+        LOGD(ERROR, domid, "unable to remove device %s", be_path);
         goto out;
     }
 
@@ -1019,7 +1019,7 @@ static void device_qemu_timeout(libxl__egc *egc, libxl__ev_time *ev,
     for (;;) {
         rc = libxl__xs_transaction_start(gc, &t);
         if (rc) {
-            LOG(ERROR, "unable to start transaction");
+            LOGD(ERROR, aodev->dev->domid, "unable to start transaction");
             goto out;
         }
 
@@ -1056,22 +1056,22 @@ static void device_backend_callback(libxl__egc *egc, libxl__ev_devstate *ds,
     libxl__ao_device *aodev = CONTAINER_OF(ds, *aodev, backend_ds);
     STATE_AO_GC(aodev->ao);
 
-    LOG(DEBUG, "calling device_backend_cleanup");
+    LOGD(DEBUG, aodev->dev->domid, "calling device_backend_cleanup");
     device_backend_cleanup(gc, aodev);
 
     if (rc == ERROR_TIMEDOUT &&
         aodev->action == LIBXL__DEVICE_ACTION_REMOVE &&
         !aodev->force) {
-        LOG(DEBUG, "Timeout reached, initiating forced remove");
+        LOGD(DEBUG, aodev->dev->domid, "Timeout reached, initiating forced remove");
         aodev->force = 1;
         libxl__initiate_device_generic_remove(egc, aodev);
         return;
     }
 
     if (rc) {
-        LOG(ERROR, "unable to %s device with path %s",
-                   libxl__device_action_to_string(aodev->action),
-                   libxl__device_backend_path(gc, aodev->dev));
+        LOGD(ERROR, aodev->dev->domid, "unable to %s device with path %s",
+                    libxl__device_action_to_string(aodev->action),
+                    libxl__device_backend_path(gc, aodev->dev));
         goto out;
     }
 
@@ -1106,12 +1106,13 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
      */
     rc = libxl__get_domid(gc, &domid);
     if (rc) {
-        LOG(ERROR, "Failed to get domid");
+        LOGD(ERROR, aodev->dev->domid, "Failed to get domid");
         goto out;
     }
     if (aodev->dev->backend_domid != domid) {
-        LOG(DEBUG, "Backend domid %d, domid %d, assuming driver domains",
-            aodev->dev->backend_domid, domid);
+        LOGD(DEBUG, aodev->dev->domid,
+             "Backend domid %d, domid %d, assuming driver domains",
+             aodev->dev->backend_domid, domid);
 
         if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE) {
             LOG(DEBUG, "Not a remove, not executing hotplug scripts");
@@ -1125,7 +1126,8 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
         aodev->xswait.callback = device_destroy_be_watch_cb;
         rc = libxl__xswait_start(gc, &aodev->xswait);
         if (rc) {
-            LOG(ERROR, "Setup of backend removal watch failed (path %s)", be_path);
+            LOGD(ERROR, aodev->dev->domid,
+                 "Setup of backend removal watch failed (path %s)", be_path);
             goto out;
         }
 
@@ -1140,43 +1142,44 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
     switch (hotplug) {
     case 0:
         /* no hotplug script to execute */
-        LOG(DEBUG, "No hotplug script to execute");
+        LOGD(DEBUG, aodev->dev->domid, "No hotplug script to execute");
         goto out;
     case 1:
         /* execute hotplug script */
         break;
     default:
         /* everything else is an error */
-        LOG(ERROR, "unable to get args/env to execute hotplug script for "
-                   "device %s", libxl__device_backend_path(gc, aodev->dev));
+        LOGD(ERROR, aodev->dev->domid,
+                    "unable to get args/env to execute hotplug script for "
+                    "device %s", libxl__device_backend_path(gc, aodev->dev));
         rc = hotplug;
         goto out;
     }
 
     assert(args != NULL);
-    LOG(DEBUG, "calling hotplug script: %s %s", args[0], args[1]);
-    LOG(DEBUG, "extra args:");
+    LOGD(DEBUG, aodev->dev->domid, "calling hotplug script: %s %s", args[0], args[1]);
+    LOGD(DEBUG, aodev->dev->domid, "extra args:");
     {
         const char *arg;
         unsigned int x;
 
         for (x = 2; (arg = args[x]); x++)
-            LOG(DEBUG, "\t%s", arg);
+            LOGD(DEBUG, aodev->dev->domid, "\t%s", arg);
     }
-    LOG(DEBUG, "env:");
+    LOGD(DEBUG, aodev->dev->domid, "env:");
     if (env != NULL) {
         const char *k, *v;
         unsigned int x;
 
         for (x = 0; (k = env[x]); x += 2) {
             v = env[x+1];
-            LOG(DEBUG, "\t%s: %s", k, v);
+            LOGD(DEBUG, aodev->dev->domid, "\t%s: %s", k, v);
         }
     }
 
     nullfd = open("/dev/null", O_RDONLY);
     if (nullfd < 0) {
-        LOG(ERROR, "unable to open /dev/null for hotplug script");
+        LOGD(ERROR, aodev->dev->domid, "unable to open /dev/null for hotplug script");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1260,8 +1263,9 @@ static void device_destroy_be_watch_cb(libxl__egc *egc,
 
     if (rc) {
         if (rc == ERROR_TIMEDOUT)
-            LOG(ERROR, "timed out while waiting for %s to be removed",
-                xswait->path);
+            LOGD(ERROR, aodev->dev->domid,
+                 "timed out while waiting for %s to be removed",
+                 xswait->path);
         aodev->rc = rc;
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 15/35] libxl/libxl_dm.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (13 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 14/35] libxl/libxl_device.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 16/35] libxl/libxl_dom_save.c: " Cédric Bosdonnat
                   ` (19 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_dm.c | 111 ++++++++++++++++++++++++++-----------------------
 1 file changed, 59 insertions(+), 52 deletions(-)

diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index ad366a8..be928ad 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -455,7 +455,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
         if (vnc->listen) {
             if (strchr(vnc->listen, ':') != NULL) {
                 if (vnc->display) {
-                    LOG(ERROR, "vncdisplay set, vnclisten contains display");
+                    LOGD(ERROR, domid, "vncdisplay set, vnclisten contains display");
                     return ERROR_INVAL;
                 }
                 vncarg = vnc->listen;
@@ -502,15 +502,15 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
         char *s;
 
         if (b_info->kernel) {
-            LOG(ERROR, "HVM direct kernel boot is not supported by "
-                "qemu-xen-traditional");
+            LOGD(ERROR, domid, "HVM direct kernel boot is not supported by "
+                 "qemu-xen-traditional");
             return ERROR_INVAL;
         }
 
         if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
             if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
             {
-                LOG(ERROR, "Both serial and serial_list set");
+                LOGD(ERROR, domid, "Both serial and serial_list set");
                 return ERROR_INVAL;
             }
             if (b_info->u.hvm.serial) {
@@ -550,7 +550,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
         case LIBXL_VGA_INTERFACE_TYPE_QXL:
             break;
         default:
-            LOG(ERROR, "Invalid emulated video card specified");
+            LOGD(ERROR, domid, "Invalid emulated video card specified");
             return ERROR_INVAL;
         }
 
@@ -562,7 +562,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
             || b_info->u.hvm.usbdevice_list) {
             if ( b_info->u.hvm.usbdevice && b_info->u.hvm.usbdevice_list )
             {
-                LOG(ERROR, "Both usbdevice and usbdevice_list set");
+                LOGD(ERROR, domid, "Both usbdevice and usbdevice_list set");
                 return ERROR_INVAL;
             }
             flexarray_append(dm_args, "-usb");
@@ -632,7 +632,7 @@ static int libxl__build_device_model_args_old(libxl__gc *gc,
                 flexarray_append(dm_args, "-gfx_passthru");
                 break;
             default:
-                LOG(ERROR, "unsupported gfx_passthru_kind.");
+                LOGD(ERROR, domid, "unsupported gfx_passthru_kind.");
                 return ERROR_INVAL;
             }
         }
@@ -970,7 +970,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                 break;
             default:
                 /* We've forgotten to add the clause */
-                LOG(ERROR, "%s: unknown channel connection %d",
+                LOGD(ERROR, guest_domid, "%s: unknown channel connection %d",
                     __func__, connection);
                 return ERROR_INVAL;
         }
@@ -1014,7 +1014,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
         if (vnc->listen) {
             if (strchr(vnc->listen, ':') != NULL) {
                 if (vnc->display) {
-                    LOG(ERROR, "vncdisplay set, vnclisten contains display");
+                    LOGD(ERROR, guest_domid,
+                         "vncdisplay set, vnclisten contains display");
                     return ERROR_INVAL;
                 }
                 vncarg = vnc->listen;
@@ -1075,7 +1076,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
         if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
             if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
             {
-                LOG(ERROR, "Both serial and serial_list set");
+                LOGD(ERROR, guest_domid, "Both serial and serial_list set");
                 return ERROR_INVAL;
             }
             if (b_info->u.hvm.serial) {
@@ -1133,7 +1134,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                 (b_info->video_memkb/2/1024), (b_info->video_memkb/2/1024) ) );
             break;
         default:
-            LOG(ERROR, "Invalid emulated video card specified");
+            LOGD(ERROR, guest_domid, "Invalid emulated video card specified");
             return ERROR_INVAL;
         }
 
@@ -1146,7 +1147,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
             || b_info->u.hvm.usbdevice_list) {
             if ( b_info->u.hvm.usbdevice && b_info->u.hvm.usbdevice_list )
             {
-                LOG(ERROR, "Both usbdevice and usbdevice_list set");
+                LOGD(ERROR, guest_domid, "Both usbdevice and usbdevice_list set");
                 return ERROR_INVAL;
             }
             flexarray_append(dm_args, "-usb");
@@ -1183,7 +1184,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                     "-device", "nec-usb-xhci,id=usb", NULL);
                 break;
             default:
-                LOG(ERROR, "usbversion parameter is invalid, "
+                LOGD(ERROR, guest_domid, "usbversion parameter is invalid, "
                     "must be between 1 and 3");
                 return ERROR_INVAL;
             }
@@ -1196,7 +1197,7 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                         GCSPRINTF("usb-redir,chardev=usbrc%d,"
                         "id=usbrc%d", i, i), NULL);
             } else {
-                LOG(ERROR, "usbredirection parameter is invalid, "
+                LOGD(ERROR, guest_domid, "usbredirection parameter is invalid, "
                     "it must be between 1 and 4");
                 return ERROR_INVAL;
             }
@@ -1282,8 +1283,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                 (b_info->u.hvm.mmio_hole_memkb << 10);
 
             if (max_ram_below_4g > HVM_BELOW_4G_MMIO_START) {
-                LOG(WARN, "mmio_hole_memkb=%"PRIu64
-                    " invalid ignored.\n",
+                LOGD(WARN, guest_domid, "mmio_hole_memkb=%"PRIu64
+                     " invalid ignored.\n",
                     b_info->u.hvm.mmio_hole_memkb);
             } else {
                 machinearg = GCSPRINTF("%s,max-ram-below-4g=%"PRIu64,
@@ -1299,10 +1300,10 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                 machinearg = GCSPRINTF("%s,igd-passthru=on", machinearg);
                 break;
             case LIBXL_GFX_PASSTHRU_KIND_DEFAULT:
-                LOG(ERROR, "unable to detect required gfx_passthru_kind");
+                LOGD(ERROR, guest_domid, "unable to detect required gfx_passthru_kind");
                 return ERROR_FAIL;
             default:
-                LOG(ERROR, "invalid value for gfx_passthru_kind");
+                LOGD(ERROR, guest_domid, "invalid value for gfx_passthru_kind");
                 return ERROR_INVAL;
             }
         }
@@ -1332,8 +1333,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
             int colo_mode;
 
             if (dev_number == -1) {
-                LOG(WARN, "unable to determine"" disk number for %s",
-                    disks[i].vdev);
+                LOGD(WARN, guest_domid, "unable to determine"" disk number for %s",
+                     disks[i].vdev);
                 continue;
             }
 
@@ -1348,17 +1349,17 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
 
             if (disks[i].format == LIBXL_DISK_FORMAT_EMPTY) {
                 if (!disks[i].is_cdrom) {
-                    LOG(WARN, "Cannot support empty disk format for %s",
-                        disks[i].vdev);
+                    LOGD(WARN, guest_domid, "Cannot support empty disk format for %s",
+                         disks[i].vdev);
                     continue;
                 }
             } else {
                 if (format == NULL) {
-                    LOG(WARN,
-                        "Unable to determine disk image format: %s\n"
-                        "Disk will be available via PV drivers but not as an"
-                        "emulated disk.",
-                        disks[i].vdev);
+                    LOGD(WARN, guest_domid,
+                         "Unable to determine disk image format: %s\n"
+                         "Disk will be available via PV drivers but not as an"
+                         "emulated disk.",
+                         disks[i].vdev);
                     continue;
                 }
 
@@ -1378,10 +1379,10 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                                                  guest_domid, &disks[i], true);
 
                 if (!target_path) {
-                    LOG(WARN, "No way to get local access disk to image: %s\n"
-                        "Disk will be available via PV drivers but not as an"
-                        "emulated disk.",
-                        disks[i].vdev);
+                    LOGD(WARN, guest_domid, "No way to get local access disk to image: %s\n"
+                         "Disk will be available via PV drivers but not as an"
+                         "emulated disk.",
+                         disks[i].vdev);
                     continue;
                 }
             }
@@ -1426,7 +1427,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                                                         colo_mode);
                 } else if (disk < 6 && b_info->u.hvm.hdtype == LIBXL_HDTYPE_AHCI) {
                     if (!disks[i].readwrite) {
-                        LOG(ERROR, "qemu-xen doesn't support read-only AHCI disk drivers");
+                        LOGD(ERROR, guest_domid,
+                             "qemu-xen doesn't support read-only AHCI disk drivers");
                         return ERROR_INVAL;
                     }
                     flexarray_vappend(dm_args, "-drive",
@@ -1437,7 +1439,8 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
                     continue;
                 } else if (disk < 4) {
                     if (!disks[i].readwrite) {
-                        LOG(ERROR, "qemu-xen doesn't support read-only IDE disk drivers");
+                        LOGD(ERROR, guest_domid,
+                             "qemu-xen doesn't support read-only IDE disk drivers");
                         return ERROR_INVAL;
                     }
                     if (colo_mode == LIBXL__COLO_SECONDARY) {
@@ -1490,14 +1493,14 @@ static int libxl__build_device_model_args_new(libxl__gc *gc,
         if (ret < 0)
             return ret;
         if (ret > 0) {
-            LOG(WARN, "Could not find user %s%d, falling back to %s",
+            LOGD(WARN, guest_domid, "Could not find user %s%d, falling back to %s",
                     LIBXL_QEMU_USER_BASE, guest_domid, LIBXL_QEMU_USER_SHARED);
             goto end_search;
         }
 
         user = NULL;
-        LOG(DEBUG, "Could not find user %s, starting QEMU as root",
-            LIBXL_QEMU_USER_SHARED);
+        LOGD(DEBUG, guest_domid, "Could not find user %s, starting QEMU as root",
+             LIBXL_QEMU_USER_SHARED);
 
 end_search:
         if (user != NULL && strcmp(user, "root")) {
@@ -1536,8 +1539,8 @@ static int libxl__build_device_model_args(libxl__gc *gc,
                                                   args, envs,
                                                   state, dm_state_fd);
     default:
-        LOGE(ERROR, "unknown device model version %d",
-             guest_config->b_info.device_model_version);
+        LOGED(ERROR, guest_domid, "unknown device model version %d",
+              guest_config->b_info.device_model_version);
         return ERROR_INVAL;
     }
 }
@@ -1764,7 +1767,8 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                      "%d", guest_domid);
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
-        LOGE(ERROR, "setting target domain %d -> %d", dm_domid, guest_domid);
+        LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
+              dm_domid, guest_domid);
         ret = ERROR_FAIL;
         goto out;
     }
@@ -1814,7 +1818,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
     uint32_t dm_domid = sdss->pvqemu.guest_domid;
 
     if (ret) {
-        LOG(ERROR, "error connecting disk devices");
+        LOGD(ERROR, guest_domid, "error connecting disk devices");
         goto out;
      }
 
@@ -1929,7 +1933,8 @@ static void stubdom_pvqemu_cb(libxl__egc *egc,
     libxl__xswait_init(&sdss->xswait);
 
     if (rc) {
-        LOGE(ERROR, "error connecting nics devices");
+        LOGED(ERROR, sdss->dm.guest_domid,
+              "error connecting nics devices");
         goto out;
     }
 
@@ -1960,7 +1965,8 @@ static void stubdom_xswait_cb(libxl__egc *egc, libxl__xswait_state *xswait,
 
     if (rc) {
         if (rc == ERROR_TIMEDOUT)
-            LOG(ERROR, "%s: startup timed out", xswait->what);
+            LOGD(ERROR, sdss->dm.guest_domid,
+                 "%s: startup timed out", xswait->what);
         goto out;
     }
 
@@ -2021,7 +2027,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)
         goto out;
     }
     if (access(dm, X_OK) < 0) {
-        LOGE(ERROR, "device model %s is not executable", dm);
+        LOGED(ERROR, domid, "device model %s is not executable", dm);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -2064,7 +2070,7 @@ void libxl__spawn_local_dm(libxl__egc *egc, libxl__dm_spawn_state *dmss)
     }
     null = open("/dev/null", O_RDONLY);
     if (null < 0) {
-        LOGE(ERROR, "unable to open /dev/null");
+        LOGED(ERROR, domid, "unable to open /dev/null");
         rc = ERROR_FAIL;
         goto out_close;
     }
@@ -2091,13 +2097,13 @@ retry_transaction:
         }
     }
 
-    LOG(DEBUG, "Spawning device-model %s with arguments:", dm);
+    LOGD(DEBUG, domid, "Spawning device-model %s with arguments:", dm);
     for (arg = args; *arg; arg++)
-        LOG(DEBUG, "  %s", *arg);
+        LOGD(DEBUG, domid, "  %s", *arg);
     if (*envs) {
-        LOG(DEBUG, "Spawning device-model %s with additional environment:", dm);
+        LOGD(DEBUG, domid, "Spawning device-model %s with additional environment:", dm);
         for (arg = envs; *arg; arg += 2)
-            LOG(DEBUG, "  %s=%s", arg[0], arg[1]);
+            LOGD(DEBUG, domid, "  %s=%s", arg[0], arg[1]);
     }
 
     spawn->what = GCSPRINTF("domain %d device model", domid);
@@ -2186,14 +2192,15 @@ static void device_model_spawn_outcome(libxl__egc *egc,
     int ret2;
 
     if (rc)
-        LOG(ERROR, "%s: spawn failed (rc=%d)", dmss->spawn.what, rc);
+        LOGD(ERROR, dmss->guest_domid,
+             "%s: spawn failed (rc=%d)", dmss->spawn.what, rc);
 
     libxl__domain_build_state *state = dmss->build_state;
 
     if (state->saved_state) {
         ret2 = unlink(state->saved_state);
         if (ret2) {
-            LOGE(ERROR, "%s: failed to remove device-model state %s",
+            LOGED(ERROR, dmss->guest_domid, "%s: failed to remove device-model state %s",
                  dmss->spawn.what, state->saved_state);
             rc = ERROR_FAIL;
             goto out;
@@ -2339,7 +2346,7 @@ int libxl__destroy_device_model(libxl__gc *gc, uint32_t domid)
 {
     char *path = DEVICE_MODEL_XS_PATH(gc, LIBXL_TOOLSTACK_DOMID, domid, "");
     if (!xs_rm(CTX->xsh, XBT_NULL, path))
-        LOG(ERROR, "xs_rm failed for %s", path);
+        LOGD(ERROR, domid, "xs_rm failed for %s", path);
     /* We should try to destroy the device model anyway. */
     return kill_device_model(gc,
                 GCSPRINTF("/local/domain/%d/image/device-model-pid", domid));
@@ -2420,7 +2427,7 @@ int libxl__dm_check_start(libxl__gc *gc, libxl_domain_config *d_config,
     if (!rc)
         return 0;
 
-    LOG(ERROR, "device model required but not running");
+    LOGD(ERROR, domid, "device model required but not running");
     rc = ERROR_FAIL;
 
 out:
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 16/35] libxl/libxl_dom_save.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (14 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 15/35] libxl/libxl_dm.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 17/35] libxl/libxl_dom_suspend.c: " Cédric Bosdonnat
                   ` (18 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_dom_save.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/tools/libxl/libxl_dom_save.c b/tools/libxl/libxl_dom_save.c
index 579039f..77fe30e 100644
--- a/tools/libxl/libxl_dom_save.c
+++ b/tools/libxl/libxl_dom_save.c
@@ -90,9 +90,9 @@ static void domain_suspend_switch_qemu_xen_traditional_logdirty
             if (rc) goto out;
 
             if (!got_ret || strcmp(got, got_ret)) {
-                LOG(ERROR,"controlling logdirty: qemu was already sent"
-                    " command `%s' (xenstore path `%s') but result is `%s'",
-                    got, lds->cmd_path, got_ret ? got_ret : "<none>");
+                LOGD(ERROR, domid, "controlling logdirty: qemu was already sent"
+                     " command `%s' (xenstore path `%s') but result is `%s'",
+                     got, lds->cmd_path, got_ret ? got_ret : "<none>");
                 rc = ERROR_FAIL;
                 goto out;
             }
@@ -115,7 +115,7 @@ static void domain_suspend_switch_qemu_xen_traditional_logdirty
     return;
 
  out:
-    LOG(ERROR,"logdirty switch failed (rc=%d), abandoning suspend",rc);
+    LOGD(ERROR, domid, "logdirty switch failed (rc=%d), abandoning suspend",rc);
     libxl__xs_transaction_abort(gc, &t);
     switch_logdirty_done(egc,lds,rc);
 }
@@ -129,7 +129,8 @@ static void domain_suspend_switch_qemu_xen_logdirty
 
     rc = libxl__qmp_set_global_dirty_log(gc, domid, enable);
     if (rc)
-        LOG(ERROR,"logdirty switch failed (rc=%d), abandoning suspend",rc);
+        LOGD(ERROR, domid,
+             "logdirty switch failed (rc=%d), abandoning suspend",rc);
 
     lds->callback(egc, lds, rc);
 }
@@ -179,8 +180,8 @@ void libxl__domain_common_switch_qemu_logdirty(libxl__egc *egc,
         lds->callback(egc, lds, 0);
         break;
     default:
-        LOG(ERROR,"logdirty switch failed"
-            ", no valid device model version found, abandoning suspend");
+        LOGD(ERROR, domid, "logdirty switch failed"
+             ", no valid device model version found, abandoning suspend");
         lds->callback(egc, lds, ERROR_FAIL);
     }
 }
@@ -346,8 +347,8 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
     libxl__domain_suspend_state *dsps = &dss->dsps;
 
     if (dss->checkpointed_stream != LIBXL_CHECKPOINTED_STREAM_NONE && !r_info) {
-        LOG(ERROR, "Migration stream is checkpointed, but there's no "
-                   "checkpoint info!");
+        LOGD(ERROR, domid, "Migration stream is checkpointed, but there's no "
+                           "checkpoint info!");
         rc = ERROR_INVAL;
         goto out;
     }
@@ -387,7 +388,7 @@ void libxl__domain_save(libxl__egc *egc, libxl__domain_save_state *dss)
     ret = xc_domain_getvnuma(CTX->xch, domid, &nr_vnodes, &nr_vmemranges,
                              &nr_vcpus, NULL, NULL, NULL);
     if (ret != -1 || errno != EOPNOTSUPP) {
-        LOG(ERROR, "Cannot save a guest with vNUMA configured");
+        LOGD(ERROR, domid, "Cannot save a guest with vNUMA configured");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -491,17 +492,17 @@ int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs,
         /* Sanitise 'key'. */
         if (!next) {
             rc = ERROR_FAIL;
-            LOG(ERROR, "Key in xenstore data not NUL terminated");
+            LOGD(ERROR, domid, "Key in xenstore data not NUL terminated");
             goto out;
         }
         if (key[0] == '\0') {
             rc = ERROR_FAIL;
-            LOG(ERROR, "empty key found in xenstore data");
+            LOGD(ERROR, domid, "empty key found in xenstore data");
             goto out;
         }
         if (key[0] == '/') {
             rc = ERROR_FAIL;
-            LOG(ERROR, "Key in xenstore data not relative");
+            LOGD(ERROR, domid, "Key in xenstore data not relative");
             goto out;
         }
 
@@ -511,7 +512,7 @@ int libxl__restore_emulator_xenstore_data(libxl__domain_create_state *dcs,
         /* Sanitise 'val'. */
         if (!next) {
             rc = ERROR_FAIL;
-            LOG(ERROR, "Val in xenstore data not NUL terminated");
+            LOGD(ERROR, domid, "Val in xenstore data not NUL terminated");
             goto out;
         }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 17/35] libxl/libxl_dom_suspend.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (15 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 16/35] libxl/libxl_dom_save.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 18/35] libxl/libxl_freebsd.c: " Cédric Bosdonnat
                   ` (17 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_dom_suspend.c | 45 ++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libxl/libxl_dom_suspend.c
index 0648919..d258a1c 100644
--- a/tools/libxl/libxl_dom_suspend.c
+++ b/tools/libxl/libxl_dom_suspend.c
@@ -54,7 +54,7 @@ int libxl__domain_suspend_init(libxl__egc *egc,
                                     domid, port, &dsps->guest_evtchn_lockfd);
 
         if (dsps->guest_evtchn.port < 0) {
-            LOG(WARN, "Suspend event channel initialization failed");
+            LOGD(WARN, domid, "Suspend event channel initialization failed");
             rc = ERROR_FAIL;
             goto out;
         }
@@ -77,7 +77,7 @@ int libxl__domain_suspend_device_model(libxl__gc *gc,
 
     switch (libxl__device_model_version_running(gc, domid)) {
     case LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL: {
-        LOG(DEBUG, "Saving device model state to %s", filename);
+        LOGD(DEBUG, domid, "Saving device model state to %s", filename);
         libxl__qemu_traditional_cmd(gc, domid, "save");
         libxl__wait_for_device_model_deprecated(gc, domid, "paused", NULL, NULL, NULL);
         break;
@@ -154,11 +154,11 @@ static void domain_suspend_callback_common(libxl__egc *egc,
     }
 
     if ((hvm_s_state == 0) && (dsps->guest_evtchn.port >= 0)) {
-        LOG(DEBUG, "issuing %s suspend request via event channel",
+        LOGD(DEBUG, domid, "issuing %s suspend request via event channel",
             dsps->type == LIBXL_DOMAIN_TYPE_HVM ? "PVHVM" : "PV");
         ret = xenevtchn_notify(CTX->xce, dsps->guest_evtchn.port);
         if (ret < 0) {
-            LOG(ERROR, "xenevtchn_notify failed ret=%d", ret);
+            LOGD(ERROR, domid, "xenevtchn_notify failed ret=%d", ret);
             rc = ERROR_FAIL;
             goto err;
         }
@@ -176,10 +176,10 @@ static void domain_suspend_callback_common(libxl__egc *egc,
     }
 
     if (dsps->type == LIBXL_DOMAIN_TYPE_HVM && (!hvm_pvdrv || hvm_s_state)) {
-        LOG(DEBUG, "Calling xc_domain_shutdown on HVM domain");
+        LOGD(DEBUG, domid, "Calling xc_domain_shutdown on HVM domain");
         ret = xc_domain_shutdown(CTX->xch, domid, SHUTDOWN_suspend);
         if (ret < 0) {
-            LOGE(ERROR, "xc_domain_shutdown failed");
+            LOGED(ERROR, domid, "xc_domain_shutdown failed");
             rc = ERROR_FAIL;
             goto err;
         }
@@ -189,7 +189,7 @@ static void domain_suspend_callback_common(libxl__egc *egc,
         return;
     }
 
-    LOG(DEBUG, "issuing %s suspend request via XenBus control node",
+    LOGD(DEBUG, domid, "issuing %s suspend request via XenBus control node",
         dsps->type == LIBXL_DOMAIN_TYPE_HVM ? "PVHVM" : "PV");
 
     libxl__domain_pvcontrol_write(gc, XBT_NULL, domid, "suspend");
@@ -260,8 +260,8 @@ static void domain_suspend_common_pvcontrol_suspending(libxl__egc *egc,
 
             rc = libxl__xs_transaction_commit(gc, &t);
             if (!rc) {
-                LOG(ERROR,
-                    "guest didn't acknowledge suspend, cancelling request");
+                LOGD(ERROR, dsps->domid,
+                     "guest didn't acknowledge suspend, cancelling request");
                 goto err;
             }
             if (rc<0) goto err;
@@ -272,7 +272,7 @@ static void domain_suspend_common_pvcontrol_suspending(libxl__egc *egc,
     }
 
     assert(domain_suspend_pvcontrol_acked(state));
-    LOG(DEBUG, "guest acknowledged suspend request");
+    LOGD(DEBUG, dsps->domid, "guest acknowledged suspend request");
 
     libxl__xs_transaction_abort(gc, &t);
     dsps->guest_responded = 1;
@@ -291,7 +291,7 @@ static void domain_suspend_common_wait_guest(libxl__egc *egc,
     STATE_AO_GC(dsps->ao);
     int rc;
 
-    LOG(DEBUG, "wait for the guest to suspend");
+    LOGD(DEBUG, dsps->domid, "wait for the guest to suspend");
 
     rc = libxl__ev_xswatch_register(gc, &dsps->guest_watch,
                                     suspend_common_wait_guest_watch,
@@ -328,13 +328,12 @@ static void suspend_common_wait_guest_check(libxl__egc *egc,
 
     ret = xc_domain_getinfolist(CTX->xch, domid, 1, &info);
     if (ret < 0) {
-        LOGE(ERROR, "unable to check for status of guest %"PRId32"", domid);
+        LOGED(ERROR, domid, "unable to check for status of guest");
         goto err;
     }
 
     if (!(ret == 1 && info.domain == domid)) {
-        LOGE(ERROR, "guest %"PRId32" we were suspending has been destroyed",
-             domid);
+        LOGED(ERROR, domid, "guest we were suspending has been destroyed");
         goto err;
     }
 
@@ -345,12 +344,12 @@ static void suspend_common_wait_guest_check(libxl__egc *egc,
     shutdown_reason = (info.flags >> XEN_DOMINF_shutdownshift)
         & XEN_DOMINF_shutdownmask;
     if (shutdown_reason != SHUTDOWN_suspend) {
-        LOG(DEBUG, "guest %"PRId32" we were suspending has shut down"
-            " with unexpected reason code %d", domid, shutdown_reason);
+        LOGD(DEBUG, domid, "guest we were suspending has shut down"
+             " with unexpected reason code %d", shutdown_reason);
         goto err;
     }
 
-    LOG(DEBUG, "guest has suspended");
+    LOGD(DEBUG, domid, "guest has suspended");
     domain_suspend_common_guest_suspended(egc, dsps);
     return;
 
@@ -364,7 +363,7 @@ static void suspend_common_wait_guest_timeout(libxl__egc *egc,
     libxl__domain_suspend_state *dsps = CONTAINER_OF(ev, *dsps, guest_timeout);
     STATE_AO_GC(dsps->ao);
     if (rc == ERROR_TIMEDOUT) {
-        LOG(ERROR, "guest did not suspend, timed out");
+        LOGD(ERROR, dsps->domid, "guest did not suspend, timed out");
         rc = ERROR_GUEST_TIMEDOUT;
     }
     domain_suspend_common_done(egc, dsps, rc);
@@ -383,7 +382,8 @@ static void domain_suspend_common_guest_suspended(libxl__egc *egc,
     if (dsps->type == LIBXL_DOMAIN_TYPE_HVM) {
         rc = libxl__domain_suspend_device_model(gc, dsps);
         if (rc) {
-            LOG(ERROR, "libxl__domain_suspend_device_model failed ret=%d", rc);
+            LOGD(ERROR, dsps->domid,
+                 "libxl__domain_suspend_device_model failed ret=%d", rc);
             domain_suspend_common_done(egc, dsps, rc);
             return;
         }
@@ -457,7 +457,7 @@ int libxl__domain_resume(libxl__gc *gc, uint32_t domid, int suspend_cancel)
     int rc = 0;
 
     if (xc_domain_resume(CTX->xch, domid, suspend_cancel)) {
-        LOGE(ERROR, "xc_domain_resume failed for domain %u", domid);
+        LOGED(ERROR, domid, "xc_domain_resume failed");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -471,14 +471,13 @@ int libxl__domain_resume(libxl__gc *gc, uint32_t domid, int suspend_cancel)
     if (type == LIBXL_DOMAIN_TYPE_HVM) {
         rc = libxl__domain_resume_device_model(gc, domid);
         if (rc) {
-            LOG(ERROR, "failed to resume device model for domain %u:%d",
-                domid, rc);
+            LOGD(ERROR, domid, "failed to resume device model:%d", rc);
             goto out;
         }
     }
 
     if (!xs_resume_domain(CTX->xsh, domid)) {
-        LOGE(ERROR, "xs_resume_domain failed for domain %u", domid);
+        LOGED(ERROR, domid, "xs_resume_domain failed");
         rc = ERROR_FAIL;
     }
 out:
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 18/35] libxl/libxl_freebsd.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (16 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 17/35] libxl/libxl_dom_suspend.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 19/35] libxl/libxl_internal.c: " Cédric Bosdonnat
                   ` (16 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_freebsd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_freebsd.c b/tools/libxl/libxl_freebsd.c
index c527455..6442cce 100644
--- a/tools/libxl/libxl_freebsd.c
+++ b/tools/libxl/libxl_freebsd.c
@@ -121,7 +121,7 @@ static int libxl__hotplug_nic(libxl__gc *gc, libxl__device *dev,
 
     rc = libxl__nic_type(gc, dev, &nictype);
     if (rc) {
-        LOG(ERROR, "error when fetching nic type");
+        LOGD(ERROR, dev->domid, "error when fetching nic type");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -143,7 +143,8 @@ static int libxl__hotplug_nic(libxl__gc *gc, libxl__device *dev,
     script = libxl__xs_read(gc, XBT_NULL,
                             GCSPRINTF("%s/%s", be_path, "script"));
     if (!script) {
-        LOGEV(ERROR, errno, "unable to read script from %s", be_path);
+        LOGEVD(ERROR, errno, dev->domid,
+               "unable to read script from %s", be_path);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -172,7 +173,8 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev,
     script = libxl__xs_read(gc, XBT_NULL,
                             GCSPRINTF("%s/%s", be_path, "script"));
     if (!script) {
-        LOGEV(ERROR, errno, "unable to read script from %s", be_path);
+        LOGEVD(ERROR, errno, dev->domid,
+               "unable to read script from %s", be_path);
         rc = ERROR_FAIL;
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 19/35] libxl/libxl_internal.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (17 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 18/35] libxl/libxl_freebsd.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 20/35] libxl/libxl_linux.c: " Cédric Bosdonnat
                   ` (15 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_internal.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index 78ed2f6..7bf5620 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -380,7 +380,7 @@ int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid)
     }
 
     if (libxl_device_model_version_from_string(dm_version, &value) < 0) {
-        LOG(ERROR, "fatal: %s contain a wrong value (%s)", path, dm_version);
+        LOGD(ERROR, domid, "fatal: %s contain a wrong value (%s)", path, dm_version);
         return -1;
     }
     return value;
@@ -407,7 +407,8 @@ libxl__domain_userdata_lock *libxl__lock_domain_userdata(libxl__gc *gc,
         libxl__carefd_begin();
         fd = open(lockfile, O_RDWR|O_CREAT, 0666);
         if (fd < 0)
-            LOGE(ERROR, "cannot open lockfile %s, errno=%d", lockfile, errno);
+            LOGED(ERROR, domid,
+                  "cannot open lockfile %s, errno=%d", lockfile, errno);
         lock->carefd = libxl__carefd_opened(CTX, fd);
         if (fd < 0) goto out;
 
@@ -421,21 +422,21 @@ libxl__domain_userdata_lock *libxl__lock_domain_userdata(libxl__gc *gc,
                 continue;
             default:
                 /* All other errno: EBADF, EINVAL, ENOLCK, EWOULDBLOCK */
-                LOGE(ERROR,
-                     "unexpected error while trying to lock %s, fd=%d, errno=%d",
-                     lockfile, fd, errno);
+                LOGED(ERROR, domid,
+                      "unexpected error while trying to lock %s, fd=%d, errno=%d",
+                      lockfile, fd, errno);
                 goto out;
             }
         }
 
         if (fstat(fd, &fstab)) {
-            LOGE(ERROR, "cannot fstat %s, fd=%d, errno=%d",
-                 lockfile, fd, errno);
+            LOGED(ERROR, domid, "cannot fstat %s, fd=%d, errno=%d",
+                  lockfile, fd, errno);
             goto out;
         }
         if (stat(lockfile, &stab)) {
             if (errno != ENOENT) {
-                LOGE(ERROR, "cannot stat %s, errno=%d", lockfile, errno);
+                LOGED(ERROR, domid, "cannot stat %s, errno=%d", lockfile, errno);
                 goto out;
             }
         } else {
@@ -489,8 +490,8 @@ int libxl__get_domain_configuration(libxl__gc *gc, uint32_t domid,
 
     rc = libxl__userdata_retrieve(gc, domid, "libxl-json", &data, &len);
     if (rc) {
-        LOGEV(ERROR, rc,
-              "failed to retrieve domain configuration for domain %d", domid);
+        LOGEVD(ERROR, rc, domid,
+              "failed to retrieve domain configuration");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -515,9 +516,8 @@ int libxl__set_domain_configuration(libxl__gc *gc, uint32_t domid,
 
     d_config_json = libxl_domain_config_to_json(CTX, d_config);
     if (!d_config_json) {
-        LOGE(ERROR,
-             "failed to convert domain configuration to JSON for domain %d",
-             domid);
+        LOGED(ERROR, domid,
+              "failed to convert domain configuration to JSON");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -526,8 +526,7 @@ int libxl__set_domain_configuration(libxl__gc *gc, uint32_t domid,
                                (const uint8_t *)d_config_json,
                                strlen(d_config_json) + 1 /* include '\0' */);
     if (rc) {
-        LOGEV(ERROR, rc, "failed to store domain configuration for domain %d",
-              domid);
+        LOGEVD(ERROR, rc, domid, "failed to store domain configuration");
         rc = ERROR_FAIL;
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 20/35] libxl/libxl_linux.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (18 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 19/35] libxl/libxl_internal.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:18 ` [PATCH 21/35] libxl/libxl_netbsd.c: " Cédric Bosdonnat
                   ` (14 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_linux.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/tools/libxl/libxl_linux.c b/tools/libxl/libxl_linux.c
index 0033a0e..6ef0abc 100644
--- a/tools/libxl/libxl_linux.c
+++ b/tools/libxl/libxl_linux.c
@@ -61,7 +61,7 @@ static char **get_hotplug_env(libxl__gc *gc,
         env[nr++] = gatewaydev ? : "";
 
         if (libxl__nic_type(gc, dev, &nictype)) {
-            LOG(ERROR, "unable to get nictype");
+            LOGD(ERROR, dev->domid, "unable to get nictype");
             return NULL;
         }
         switch (nictype) {
@@ -107,14 +107,15 @@ static int libxl__hotplug_nic(libxl__gc *gc, libxl__device *dev,
     script = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/%s", be_path,
                                                              "script"));
     if (!script) {
-        LOGE(ERROR, "unable to read script from %s", be_path);
+        LOGED(ERROR, dev->domid,
+              "unable to read script from %s", be_path);
         rc = ERROR_FAIL;
         goto out;
     }
 
     rc = libxl__nic_type(gc, dev, &nictype);
     if (rc) {
-        LOG(ERROR, "error when fetching nic type");
+        LOGD(ERROR, dev->domid, "error when fetching nic type");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -161,14 +162,15 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev,
     script = libxl__xs_read(gc, XBT_NULL,
                             GCSPRINTF("%s/%s", be_path, "script"));
     if (!script) {
-        LOGEV(ERROR, errno, "unable to read script from %s", be_path);
+        LOGEVD(ERROR, errno, dev->domid,
+               "unable to read script from %s", be_path);
         rc = ERROR_FAIL;
         goto error;
     }
 
     *env = get_hotplug_env(gc, script, dev);
     if (!*env) {
-        LOG(ERROR, "Failed to get hotplug environment");
+        LOGD(ERROR, dev->domid, "Failed to get hotplug environment");
         rc = ERROR_FAIL;
         goto error;
     }
@@ -180,7 +182,7 @@ static int libxl__hotplug_disk(libxl__gc *gc, libxl__device *dev,
     (*args)[nr++] = NULL;
     assert(nr == arraysize);
 
-    LOG(DEBUG, "Args and environment ready");
+    LOGD(DEBUG, dev->domid, "Args and environment ready");
     rc = 1;
 
 error:
@@ -197,7 +199,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
     switch (dev->backend_kind) {
     case LIBXL__DEVICE_KIND_VBD:
         if (num_exec != 0) {
-            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
+            LOGD(DEBUG, dev->domid,
+                 "num_exec %d, not running hotplug scripts", num_exec);
             rc = 0;
             goto out;
         }
@@ -210,7 +213,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
          */
         if ((num_exec > 1) ||
             (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
-            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
+            LOGD(DEBUG, dev->domid,
+                 "num_exec %d, not running hotplug scripts", num_exec);
             rc = 0;
             goto out;
         }
@@ -218,7 +222,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
         break;
     default:
         /* No need to execute any hotplug scripts */
-        LOG(DEBUG, "backend_kind %d, no need to execute scripts", dev->backend_kind);
+        LOGD(DEBUG, dev->domid,
+             "backend_kind %d, no need to execute scripts", dev->backend_kind);
         rc = 0;
         break;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 21/35] libxl/libxl_netbsd.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (19 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 20/35] libxl/libxl_linux.c: " Cédric Bosdonnat
@ 2016-11-15 10:18 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 22/35] libxl/libxl_netbuffer.c: " Cédric Bosdonnat
                   ` (13 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:18 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_netbsd.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_netbsd.c b/tools/libxl/libxl_netbsd.c
index a79b8aa..2edfb00 100644
--- a/tools/libxl/libxl_netbsd.c
+++ b/tools/libxl/libxl_netbsd.c
@@ -42,7 +42,8 @@ static int libxl__hotplug(libxl__gc *gc, libxl__device *dev, char ***args,
     script = libxl__xs_read(gc, XBT_NULL,
                             GCSPRINTF("%s/%s", be_path, "script"));
     if (!script) {
-        LOGEV(ERROR, errno, "unable to read script from %s", be_path);
+        LOGEVD(ERROR, errno, dev->domid,
+               "unable to read script from %s", be_path);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -69,7 +70,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
     switch (dev->backend_kind) {
     case LIBXL__DEVICE_KIND_VBD:
         if (num_exec != 0) {
-            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
+            LOGD(DEBUG, dev->domid,
+                 "num_exec %d, not running hotplug scripts", num_exec);
             rc = 0;
             goto out;
         }
@@ -86,7 +88,8 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
          */
         if ((num_exec != 0) ||
             (libxl_get_stubdom_id(CTX, dev->domid) && num_exec)) {
-            LOG(DEBUG, "num_exec %d, not running hotplug scripts", num_exec);
+            LOGD(DEBUG, dev->domid,
+                 "num_exec %d, not running hotplug scripts", num_exec);
             rc = 0;
             goto out;
         }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 22/35] libxl/libxl_netbuffer.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (20 preceding siblings ...)
  2016-11-15 10:18 ` [PATCH 21/35] libxl/libxl_netbsd.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 23/35] libxl/libxl_nic.c: " Cédric Bosdonnat
                   ` (12 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Ian Jackson, Cédric Bosdonnat, Yang Hongyang,
	Cédric Bosdonnat, Shriram Rajagopalan

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_netbuffer.c | 43 ++++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/tools/libxl/libxl_netbuffer.c b/tools/libxl/libxl_netbuffer.c
index 5c7e8a2..323cdd8 100644
--- a/tools/libxl/libxl_netbuffer.c
+++ b/tools/libxl/libxl_netbuffer.c
@@ -48,15 +48,15 @@ int init_subkind_nic(libxl__checkpoint_devices_state *cds)
 
     rs->nlsock = nl_socket_alloc();
     if (!rs->nlsock) {
-        LOG(ERROR, "cannot allocate nl socket");
+        LOGD(ERROR, dss->domid, "cannot allocate nl socket");
         rc = ERROR_FAIL;
         goto out;
     }
 
     ret = nl_connect(rs->nlsock, NETLINK_ROUTE);
     if (ret) {
-        LOG(ERROR, "failed to open netlink socket: %s",
-            nl_geterror(ret));
+        LOGD(ERROR, dss->domid, "failed to open netlink socket: %s",
+             nl_geterror(ret));
         rc = ERROR_FAIL;
         goto out;
     }
@@ -64,8 +64,8 @@ int init_subkind_nic(libxl__checkpoint_devices_state *cds)
     /* get list of all qdiscs installed on network devs. */
     ret = rtnl_qdisc_alloc_cache(rs->nlsock, &rs->qdisc_cache);
     if (ret) {
-        LOG(ERROR, "failed to allocate qdisc cache: %s",
-            nl_geterror(ret));
+        LOGD(ERROR, dss->domid, "failed to allocate qdisc cache: %s",
+             nl_geterror(ret));
         rc = ERROR_FAIL;
         goto out;
     }
@@ -162,7 +162,8 @@ static int init_qdisc(libxl__checkpoint_devices_state *cds,
      */
     ret = nl_cache_refill(rs->nlsock, rs->qdisc_cache);
     if (ret) {
-        LOG(ERROR, "cannot refill qdisc cache: %s", nl_geterror(ret));
+        LOGD(ERROR, cds->domid,
+             "cannot refill qdisc cache: %s", nl_geterror(ret));
         rc = ERROR_FAIL;
         goto out;
     }
@@ -170,7 +171,8 @@ static int init_qdisc(libxl__checkpoint_devices_state *cds,
     /* get a handle to the REMUS_IFB interface */
     ret = rtnl_link_get_kernel(rs->nlsock, 0, remus_nic->ifb, &ifb);
     if (ret) {
-        LOG(ERROR, "cannot obtain handle for %s: %s", remus_nic->ifb,
+        LOGD(ERROR, cds->domid,
+             "cannot obtain handle for %s: %s", remus_nic->ifb,
             nl_geterror(ret));
         rc = ERROR_FAIL;
         goto out;
@@ -178,7 +180,8 @@ static int init_qdisc(libxl__checkpoint_devices_state *cds,
 
     ifindex = rtnl_link_get_ifindex(ifb);
     if (!ifindex) {
-        LOG(ERROR, "interface %s has no index", remus_nic->ifb);
+        LOGD(ERROR, cds->domid,
+             "interface %s has no index", remus_nic->ifb);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -196,13 +199,15 @@ static int init_qdisc(libxl__checkpoint_devices_state *cds,
         const char *tc_kind = rtnl_tc_get_kind(TC_CAST(qdisc));
         /* Sanity check: Ensure that the root qdisc is a plug qdisc. */
         if (!tc_kind || strcmp(tc_kind, "plug")) {
-            LOG(ERROR, "plug qdisc is not installed on %s", remus_nic->ifb);
+            LOGD(ERROR, cds->domid,
+                 "plug qdisc is not installed on %s", remus_nic->ifb);
             rc = ERROR_FAIL;
             goto out;
         }
         remus_nic->qdisc = qdisc;
     } else {
-        LOG(ERROR, "Cannot get qdisc handle from ifb %s", remus_nic->ifb);
+        LOGD(ERROR, cds->domid,
+             "Cannot get qdisc handle from ifb %s", remus_nic->ifb);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -366,8 +371,8 @@ static void netbuf_setup_script_cb(libxl__egc *egc,
         goto out;
 
     if (!(*ifb)) {
-        LOG(ERROR, "Cannot get ifb dev name for domain %u dev %s",
-            domid, vif);
+        LOGD(ERROR, domid, "Cannot get ifb dev name for domain %u dev %s",
+             domid, vif);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -382,8 +387,8 @@ static void netbuf_setup_script_cb(libxl__egc *egc,
         goto out;
 
     if (hotplug_error) {
-        LOG(ERROR, "netbuf script %s setup failed for vif %s: %s",
-            rs->netbufscript, vif, hotplug_error);
+        LOGD(ERROR, domid, "netbuf script %s setup failed for vif %s: %s",
+             rs->netbufscript, vif, hotplug_error);
         rc = ERROR_FAIL;
         goto out;
     }
@@ -393,7 +398,7 @@ static void netbuf_setup_script_cb(libxl__egc *egc,
         goto out;
     }
 
-    LOG(DEBUG, "%s will buffer packets from vif %s", *ifb, vif);
+    LOGD(DEBUG, domid, "%s will buffer packets from vif %s", *ifb, vif);
     rc = init_qdisc(cds, remus_nic);
 
 out:
@@ -475,10 +480,10 @@ static int remus_netbuf_op(libxl__remus_device_nic *remus_nic,
 
 out:
     if (rc)
-        LOG(ERROR, "Remus: cannot do netbuf op %s on %s:%s",
-            ((buffer_op == tc_buffer_start) ?
-            "start_new_epoch" : "release_prev_epoch"),
-            remus_nic->ifb, nl_geterror(ret));
+        LOGD(ERROR, cds-> domid, "Remus: cannot do netbuf op %s on %s:%s",
+             ((buffer_op == tc_buffer_start) ?
+             "start_new_epoch" : "release_prev_epoch"),
+             remus_nic->ifb, nl_geterror(ret));
     return rc;
 }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 23/35] libxl/libxl_nic.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (21 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 22/35] libxl/libxl_netbuffer.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 24/35] libxl/libxl_no_colo.c: " Cédric Bosdonnat
                   ` (11 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_nic.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c
index 220a028..61b55ca 100644
--- a/tools/libxl/libxl_nic.c
+++ b/tools/libxl/libxl_nic.c
@@ -101,7 +101,8 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
         break;
     case LIBXL_DOMAIN_TYPE_PV:
         if (nic->nictype == LIBXL_NIC_TYPE_VIF_IOEMU) {
-            LOG(ERROR, "trying to create PV guest with an emulated interface");
+            LOGD(ERROR, domid,
+                 "trying to create PV guest with an emulated interface");
             return ERROR_INVAL;
         }
         nic->nictype = LIBXL_NIC_TYPE_VIF;
@@ -254,7 +255,7 @@ static void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
         rc = libxl__device_exists(gc, t, device);
         if (rc < 0) goto out;
         if (rc == 1) {              /* already exists in xenstore */
-            LOG(ERROR, "device already exists in xenstore");
+            LOGD(ERROR, domid, "device already exists in xenstore");
             aodev->action = LIBXL__DEVICE_ACTION_ADD; /* for error message */
             rc = ERROR_DEVICE_EXISTS;
             goto out;
@@ -440,7 +441,7 @@ libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, uint32_t domid, int *num
     return nics;
 
 out_err:
-    LOG(ERROR, "Unable to list nics");
+    LOGD(ERROR, domid, "Unable to list nics");
     while (*num) {
         (*num)--;
         libxl_device_nic_dispose(&nics[*num]);
@@ -531,7 +532,7 @@ int libxl__device_nic_set_devids(libxl__gc *gc, libxl_domain_config *d_config,
         ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid,
                                            false);
         if (ret) {
-            LOG(ERROR, "Unable to set nic defaults for nic %d", i);
+            LOGD(ERROR, domid, "Unable to set nic defaults for nic %d", i);
             goto out;
         }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 24/35] libxl/libxl_no_colo.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (22 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 23/35] libxl/libxl_nic.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 25/35] libxl/libxl_pci.c: " Cédric Bosdonnat
                   ` (10 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_no_colo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_no_colo.c b/tools/libxl/libxl_no_colo.c
index 152f198..2e1315c 100644
--- a/tools/libxl/libxl_no_colo.c
+++ b/tools/libxl/libxl_no_colo.c
@@ -22,7 +22,7 @@ void libxl__colo_restore_setup(libxl__egc *egc,
 {
     STATE_AO_GC(crs->ao);
 
-    LOG(ERROR, "COLO is not supported");
+    LOGD(ERROR, crs->domid, "COLO is not supported");
 
     crs->callback(egc, crs, ERROR_FAIL);
 }
@@ -39,7 +39,7 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css)
     libxl__domain_save_state *dss = CONTAINER_OF(css, *dss, css);
     STATE_AO_GC(dss->ao);
 
-    LOG(ERROR, "COLO is not supported");
+    LOGD(ERROR, dss->domid, "COLO is not supported");
 
     dss->callback(egc, dss, ERROR_FAIL);
 }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 25/35] libxl/libxl_pci.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (23 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 24/35] libxl/libxl_no_colo.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 26/35] libxl/libxl_psr.c: " Cédric Bosdonnat
                   ` (9 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_pci.c | 153 +++++++++++++++++++++++++-----------------------
 1 file changed, 79 insertions(+), 74 deletions(-)

diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 6f8f49c..3b707f3 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -86,7 +86,7 @@ int libxl__create_pci_backend(libxl__gc *gc, uint32_t domid,
     front = flexarray_make(gc, 16, 1);
     back = flexarray_make(gc, 16, 1);
 
-    LOG(DEBUG, "Creating pci backend");
+    LOGD(DEBUG, domid, "Creating pci backend");
 
     /* add pci device */
     libxl__device_from_pcidev(gc, domid, pcidev, &device);
@@ -141,7 +141,7 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d
 
     back = flexarray_make(gc, 16, 1);
 
-    LOG(DEBUG, "Adding new pci device to xenstore");
+    LOGD(DEBUG, domid, "Adding new pci device to xenstore");
     num = atoi(num_devs);
     libxl_create_pci_backend_device(gc, back, num, pcidev);
     flexarray_append_pair(back, "num_devs", GCSPRINTF("%d", num + 1));
@@ -207,7 +207,7 @@ static int libxl__device_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, libx
 
     if (domtype == LIBXL_DOMAIN_TYPE_PV) {
         if (libxl__wait_for_backend(gc, be_path, GCSPRINTF("%d", XenbusStateConnected)) < 0) {
-            LOG(DEBUG, "pci backend at %s is not ready", be_path);
+            LOGD(DEBUG, domid, "pci backend at %s is not ready", be_path);
             return ERROR_FAIL;
         }
     }
@@ -222,7 +222,7 @@ static int libxl__device_pci_remove_xenstore(libxl__gc *gc, uint32_t domid, libx
         }
     }
     if (i == num) {
-        LOG(ERROR, "Couldn't find the device on xenstore");
+        LOGD(ERROR, domid, "Couldn't find the device on xenstore");
         return ERROR_INVAL;
     }
 
@@ -236,7 +236,7 @@ retry_transaction:
 
     if (domtype == LIBXL_DOMAIN_TYPE_PV) {
         if (libxl__wait_for_backend(gc, be_path, GCSPRINTF("%d", XenbusStateConnected)) < 0) {
-            LOG(DEBUG, "pci backend at %s is not ready", be_path);
+            LOGD(DEBUG, domid, "pci backend at %s is not ready", be_path);
             return ERROR_FAIL;
         }
     }
@@ -981,9 +981,9 @@ static int qemu_pci_add_xenstore(libxl__gc *gc, uint32_t domid,
     vdevfn = libxl__xs_read(gc, XBT_NULL, path);
     path = DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, "/state");
     if ( rc < 0 )
-        LOG(ERROR, "qemu refused to add device: %s", vdevfn);
+        LOGD(ERROR, domid, "qemu refused to add device: %s", vdevfn);
     else if ( sscanf(vdevfn, "0x%x", &pcidev->vdevfn) != 1 ) {
-        LOG(ERROR, "wrong format for the vdevfn: '%s'", vdevfn);
+        LOGD(ERROR, domid, "wrong format for the vdevfn: '%s'", vdevfn);
         rc = -1;
     }
     xs_write(ctx->xsh, XBT_NULL, path, state, strlen(state));
@@ -1000,6 +1000,8 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i
     unsigned long long start, end, flags, size;
     int irq, i, rc, hvm = 0;
     uint32_t flag = XEN_DOMCTL_DEV_RDM_RELAXED;
+    uint32_t domainid = domid;
+    bool isstubdom = !libxl_is_stubdom(ctx, domid, &domainid);
 
     if (type == LIBXL_DOMAIN_TYPE_INVALID)
         return ERROR_FAIL;
@@ -1031,7 +1033,7 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i
     irq = 0;
 
     if (f == NULL) {
-        LOGE(ERROR, "Couldn't open %s", sysfs_path);
+        LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path);
         return ERROR_FAIL;
     }
     for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) {
@@ -1042,10 +1044,10 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i
             if (flags & PCI_BAR_IO) {
                 rc = xc_domain_ioport_permission(ctx->xch, domid, start, size, 1);
                 if (rc < 0) {
-                    LOGE(ERROR,
-                         "Error: xc_domain_ioport_permission error 0x%llx/0x%llx",
-                         start,
-                         size);
+                    LOGED(ERROR, domainid,
+                          "Error: xc_domain_ioport_permission error 0x%llx/0x%llx",
+                          start,
+                          size);
                     fclose(f);
                     return ERROR_FAIL;
                 }
@@ -1053,10 +1055,10 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i
                 rc = xc_domain_iomem_permission(ctx->xch, domid, start>>XC_PAGE_SHIFT,
                                                 (size+(XC_PAGE_SIZE-1))>>XC_PAGE_SHIFT, 1);
                 if (rc < 0) {
-                    LOGE(ERROR,
-                         "Error: xc_domain_iomem_permission error 0x%llx/0x%llx",
-                         start,
-                         size);
+                    LOGED(ERROR, domainid,
+                          "Error: xc_domain_iomem_permission error 0x%llx/0x%llx",
+                          start,
+                          size);
                     fclose(f);
                     return ERROR_FAIL;
                 }
@@ -1068,19 +1070,19 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i
                                 pcidev->bus, pcidev->dev, pcidev->func);
     f = fopen(sysfs_path, "r");
     if (f == NULL) {
-        LOGE(ERROR, "Couldn't open %s", sysfs_path);
+        LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path);
         goto out;
     }
     if ((fscanf(f, "%u", &irq) == 1) && irq) {
         rc = xc_physdev_map_pirq(ctx->xch, domid, irq, &irq);
         if (rc < 0) {
-            LOGE(ERROR, "Error: xc_physdev_map_pirq irq=%d", irq);
+            LOGED(ERROR, domainid, "Error: xc_physdev_map_pirq irq=%d", irq);
             fclose(f);
             return ERROR_FAIL;
         }
         rc = xc_domain_irq_permission(ctx->xch, domid, irq, 1);
         if (rc < 0) {
-            LOGE(ERROR, "Error: xc_domain_irq_permission irq=%d", irq);
+            LOGED(ERROR, domainid, "Error: xc_domain_irq_permission irq=%d", irq);
             fclose(f);
             return ERROR_FAIL;
         }
@@ -1091,22 +1093,22 @@ static int do_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcidev, i
     if (pcidev->permissive) {
         if ( sysfs_write_bdf(gc, SYSFS_PCIBACK_DRIVER"/permissive",
                              pcidev) < 0 ) {
-            LOG(ERROR, "Setting permissive for device");
+            LOGD(ERROR, domainid, "Setting permissive for device");
             return ERROR_FAIL;
         }
     }
 
 out:
-    if (!libxl_is_stubdom(ctx, domid, NULL)) {
+    if (!isstubdom) {
         if (pcidev->rdm_policy == LIBXL_RDM_RESERVE_POLICY_STRICT) {
             flag &= ~XEN_DOMCTL_DEV_RDM_RELAXED;
         } else if (pcidev->rdm_policy != LIBXL_RDM_RESERVE_POLICY_RELAXED) {
-            LOGE(ERROR, "unknown rdm check flag.");
+            LOGED(ERROR, domainid, "unknown rdm check flag.");
             return ERROR_FAIL;
         }
         rc = xc_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev), flag);
         if (rc < 0 && (hvm || errno != ENOSYS)) {
-            LOGE(ERROR, "xc_assign_device failed");
+            LOGED(ERROR, domainid, "xc_assign_device failed");
             return ERROR_FAIL;
         }
     }
@@ -1130,27 +1132,27 @@ static int libxl__device_pci_reset(libxl__gc *gc, unsigned int domain, unsigned
         char *buf = GCSPRINTF(PCI_BDF, domain, bus, dev, func);
         rc = write(fd, buf, strlen(buf));
         if (rc < 0)
-            LOG(ERROR, "write to %s returned %d", reset, rc);
+            LOGD(ERROR, domain, "write to %s returned %d", reset, rc);
         close(fd);
         return rc < 0 ? rc : 0;
     }
     if (errno != ENOENT)
-        LOGE(ERROR, "Failed to access pciback path %s", reset);
+        LOGED(ERROR, domain, "Failed to access pciback path %s", reset);
     reset = GCSPRINTF("%s/"PCI_BDF"/reset", SYSFS_PCI_DEV, domain, bus, dev, func);
     fd = open(reset, O_WRONLY);
     if (fd >= 0) {
         rc = write(fd, "1", 1);
         if (rc < 0)
-            LOGE(ERROR, "write to %s returned %d", reset, rc);
+            LOGED(ERROR, domain, "write to %s returned %d", reset, rc);
         close(fd);
         return rc < 0 ? rc : 0;
     }
     if (errno == ENOENT) {
-        LOG(ERROR,
-            "The kernel doesn't support reset from sysfs for PCI device "PCI_BDF,
-            domain, bus, dev, func);
+        LOGD(ERROR, domain,
+             "The kernel doesn't support reset from sysfs for PCI device "PCI_BDF,
+             domain, bus, dev, func);
     } else {
-        LOGE(ERROR, "Failed to access reset path %s", reset);
+        LOGED(ERROR, domain, "Failed to access reset path %s", reset);
     }
     return -1;
 }
@@ -1202,11 +1204,11 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcide
     if (libxl__domain_type(gc, domid) == LIBXL_DOMAIN_TYPE_HVM) {
         rc = xc_test_assign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
         if (rc) {
-            LOG(ERROR,
-                "PCI device %04x:%02x:%02x.%u %s?",
-                pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func,
-                errno == ENOSYS ? "cannot be assigned - no IOMMU"
-                : "already assigned to a different guest");
+            LOGD(ERROR, domid,
+                 "PCI device %04x:%02x:%02x.%u %s?",
+                 pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func,
+                 errno == ENOSYS ? "cannot be assigned - no IOMMU"
+                 : "already assigned to a different guest");
             goto out;
         }
     }
@@ -1221,21 +1223,21 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcide
     }
 
     if (!libxl_pcidev_assignable(ctx, pcidev)) {
-        LOG(ERROR, "PCI device %x:%x:%x.%x is not assignable",
-            pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+        LOGD(ERROR, domid, "PCI device %x:%x:%x.%x is not assignable",
+             pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
         rc = ERROR_FAIL;
         goto out;
     }
 
     rc = get_all_assigned_devices(gc, &assigned, &num_assigned);
     if ( rc ) {
-        LOG(ERROR,
-            "cannot determine if device is assigned, refusing to continue");
+        LOGD(ERROR, domid,
+             "cannot determine if device is assigned, refusing to continue");
         goto out;
     }
     if ( is_pcidev_in_array(assigned, num_assigned, pcidev->domain,
                      pcidev->bus, pcidev->dev, pcidev->func) ) {
-        LOG(ERROR, "PCI device already attached to a domain");
+        LOGD(ERROR, domid, "PCI device already attached to a domain");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1255,7 +1257,7 @@ int libxl__device_pci_add(libxl__gc *gc, uint32_t domid, libxl_device_pci *pcide
 
     if ( pcidev->vfunc_mask == LIBXL_PCI_FUNC_ALL ) {
         if ( !(pcidev->vdevfn >> 3) ) {
-            LOG(ERROR, "Must specify a v-slot for multi-function devices");
+            LOGD(ERROR, domid, "Must specify a v-slot for multi-function devices");
             rc = ERROR_INVAL;
             goto out;
         }
@@ -1301,7 +1303,7 @@ static void libxl__add_pcidevs(libxl__egc *egc, libxl__ao *ao, uint32_t domid,
     for (i = 0; i < d_config->num_pcidevs; i++) {
         rc = libxl__device_pci_add(gc, domid, &d_config->pcidevs[i], 1);
         if (rc < 0) {
-            LOG(ERROR, "libxl_device_pci_add failed: %d", rc);
+            LOGD(ERROR, domid, "libxl_device_pci_add failed: %d", rc);
             goto out;
         }
     }
@@ -1310,7 +1312,7 @@ static void libxl__add_pcidevs(libxl__egc *egc, libxl__ao *ao, uint32_t domid,
         rc = libxl__create_pci_backend(gc, domid, d_config->pcidevs,
             d_config->num_pcidevs);
         if (rc < 0) {
-            LOG(ERROR, "libxl_create_pci_backend failed: %d", rc);
+            LOGD(ERROR, domid, "libxl_create_pci_backend failed: %d", rc);
             goto out;
         }
     }
@@ -1342,7 +1344,7 @@ static int qemu_pci_remove_xenstore(libxl__gc *gc, uint32_t domid,
         libxl__qemu_traditional_cmd(gc, domid, "pci-rem");
         if (libxl__wait_for_device_model_deprecated(gc, domid, "pci-removed",
                                          NULL, NULL, NULL) < 0) {
-            LOG(ERROR, "Device Model didn't respond in time");
+            LOGD(ERROR, domid, "Device Model didn't respond in time");
             /* This depends on guest operating system acknowledging the
              * SCI, if it doesn't respond in time then we may wish to
              * force the removal.
@@ -1367,6 +1369,9 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
     libxl_domain_type type = libxl__domain_type(gc, domid);
     int hvm = 0, rc, num;
     int stubdomid = 0;
+    uint32_t domainid = domid;
+    bool isstubdom = !libxl_is_stubdom(ctx, domid, &domainid);
+
 
     assigned = libxl_device_pci_list(ctx, domid, &num);
     if ( assigned == NULL )
@@ -1375,7 +1380,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
     rc = ERROR_INVAL;
     if ( !is_pcidev_in_array(assigned, num, pcidev->domain,
                       pcidev->bus, pcidev->dev, pcidev->func) ) {
-        LOG(ERROR, "PCI device not attached to this domain");
+        LOGD(ERROR, domainid, "PCI device not attached to this domain");
         goto out_fail;
     }
 
@@ -1412,7 +1417,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
         int i;
 
         if (f == NULL) {
-            LOGE(ERROR, "Couldn't open %s", sysfs_path);
+            LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path);
             goto skip1;
         }
         for (i = 0; i < PROC_PCI_NUM_RESOURCES; i++) {
@@ -1423,18 +1428,18 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
                 if (flags & PCI_BAR_IO) {
                     rc = xc_domain_ioport_permission(ctx->xch, domid, start, size, 0);
                     if (rc < 0)
-                        LOGE(ERROR,
-                             "xc_domain_ioport_permission error 0x%x/0x%x",
-                             start,
-                             size);
+                        LOGED(ERROR, domainid,
+                              "xc_domain_ioport_permission error 0x%x/0x%x",
+                              start,
+                              size);
                 } else {
                     rc = xc_domain_iomem_permission(ctx->xch, domid, start>>XC_PAGE_SHIFT,
                                                     (size+(XC_PAGE_SIZE-1))>>XC_PAGE_SHIFT, 0);
                     if (rc < 0)
-                        LOGE(ERROR,
-                             "xc_domain_iomem_permission error 0x%x/0x%x",
-                             start,
-                             size);
+                        LOGED(ERROR, domainid,
+                              "xc_domain_iomem_permission error 0x%x/0x%x",
+                              start,
+                              size);
                 }
             }
         }
@@ -1444,17 +1449,17 @@ skip1:
                                pcidev->bus, pcidev->dev, pcidev->func);
         f = fopen(sysfs_path, "r");
         if (f == NULL) {
-            LOGE(ERROR, "Couldn't open %s", sysfs_path);
+            LOGED(ERROR, domainid, "Couldn't open %s", sysfs_path);
             goto out;
         }
         if ((fscanf(f, "%u", &irq) == 1) && irq) {
             rc = xc_physdev_unmap_pirq(ctx->xch, domid, irq);
             if (rc < 0) {
-                LOGE(ERROR, "xc_physdev_unmap_pirq irq=%d", irq);
+                LOGED(ERROR, domainid, "xc_physdev_unmap_pirq irq=%d", irq);
             }
             rc = xc_domain_irq_permission(ctx->xch, domid, irq, 0);
             if (rc < 0) {
-                LOGE(ERROR, "xc_domain_irq_permission irq=%d", irq);
+                LOGED(ERROR, domainid, "xc_domain_irq_permission irq=%d", irq);
             }
         }
         fclose(f);
@@ -1465,10 +1470,10 @@ out:
         libxl__device_pci_reset(gc, pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
     }
 
-    if (!libxl_is_stubdom(ctx, domid, NULL)) {
+    if (!isstubdom) {
         rc = xc_deassign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
         if (rc < 0 && (hvm || errno != ENOSYS))
-            LOGE(ERROR, "xc_deassign_device failed");
+            LOGED(ERROR, domainid, "xc_deassign_device failed");
     }
 
     stubdomid = libxl_get_stubdom_id(ctx, domid);
@@ -1655,17 +1660,17 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid,
 
         FILE *f = fopen(pci_device_class_path, "r");
         if (!f) {
-            LOGE(ERROR,
-                 "pci device "PCI_BDF" does not have class attribute",
-                 pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+            LOGED(ERROR, domid,
+                  "pci device "PCI_BDF" does not have class attribute",
+                  pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
             continue;
         }
         read_items = fscanf(f, "0x%lx\n", &pci_device_class);
         fclose(f);
         if (read_items != 1) {
-            LOGE(ERROR,
-                 "cannot read class of pci device "PCI_BDF,
-                 pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+            LOGED(ERROR, domid,
+                  "cannot read class of pci device "PCI_BDF,
+                  pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
             continue;
         }
         if (pci_device_class != 0x030000) /* VGA class */
@@ -1675,20 +1680,20 @@ int libxl__grant_vga_iomem_permission(libxl__gc *gc, const uint32_t domid,
         ret = xc_domain_iomem_permission(CTX->xch, stubdom_domid,
                                          vga_iomem_start, 0x20, 1);
         if (ret < 0) {
-            LOGE(ERROR,
-                 "failed to give stubdom%d access to iomem range "
-                 "%"PRIx64"-%"PRIx64" for VGA passthru",
-                 stubdom_domid,
-                 vga_iomem_start, (vga_iomem_start + 0x20 - 1));
+            LOGED(ERROR, domid,
+                  "failed to give stubdom%d access to iomem range "
+                  "%"PRIx64"-%"PRIx64" for VGA passthru",
+                  stubdom_domid,
+                  vga_iomem_start, (vga_iomem_start + 0x20 - 1));
             return ret;
         }
         ret = xc_domain_iomem_permission(CTX->xch, domid,
                                          vga_iomem_start, 0x20, 1);
         if (ret < 0) {
-            LOGE(ERROR,
-                 "failed to give dom%d access to iomem range "
-                 "%"PRIx64"-%"PRIx64" for VGA passthru",
-                 domid, vga_iomem_start, (vga_iomem_start + 0x20 - 1));
+            LOGED(ERROR, domid,
+                  "failed to give dom%d access to iomem range "
+                  "%"PRIx64"-%"PRIx64" for VGA passthru",
+                  domid, vga_iomem_start, (vga_iomem_start + 0x20 - 1));
             return ret;
         }
         break;
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 26/35] libxl/libxl_psr.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (24 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 25/35] libxl/libxl_pci.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 27/35] libxl/libxl_pvusb.c: " Cédric Bosdonnat
                   ` (8 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_psr.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 786183c..ec5c79d 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -241,15 +241,15 @@ int libxl_psr_cmt_get_sample(libxl_ctx *ctx,
 
     rc = xc_psr_cmt_get_domain_rmid(ctx->xch, domid, &rmid);
     if (rc < 0 || rmid == 0) {
-        LOGE(ERROR, "fail to get the domain rmid, "
-            "or domain is not attached with platform QoS monitoring service");
+        LOGED(ERROR, domid, "fail to get the domain rmid, "
+              "or domain is not attached with platform QoS monitoring service");
         rc = ERROR_FAIL;
         goto out;
     }
 
     cpu = libxl__pick_socket_cpu(gc, scope);
     if (cpu < 0) {
-        LOGE(ERROR, "failed to get socket cpu");
+        LOGED(ERROR, domid, "failed to get socket cpu");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -257,14 +257,14 @@ int libxl_psr_cmt_get_sample(libxl_ctx *ctx,
     rc = xc_psr_cmt_get_data(ctx->xch, rmid, cpu, type - 1,
                              &monitor_data, tsc_r);
     if (rc < 0) {
-        LOGE(ERROR, "failed to get monitoring data");
+        LOGED(ERROR, domid, "failed to get monitoring data");
         rc = ERROR_FAIL;
         goto out;
     }
 
     rc = xc_psr_cmt_get_l3_upscaling_factor(ctx->xch, &upscaling_factor);
     if (rc < 0) {
-        LOGE(ERROR, "failed to get L3 upscaling factor");
+        LOGED(ERROR, domid, "failed to get L3 upscaling factor");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -311,7 +311,7 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
 
     rc = libxl__count_physical_sockets(gc, &nr_sockets);
     if (rc) {
-        LOGE(ERROR, "failed to get system socket count");
+        LOGED(ERROR, domid, "failed to get system socket count");
         goto out;
     }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 27/35] libxl/libxl_pvusb.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (25 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 26/35] libxl/libxl_psr.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 28/35] libxl/libxl_qmp.c: " Cédric Bosdonnat
                   ` (7 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_usb.c | 57 ++++++++++++++++++++++++++-----------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c
index 76260b1..ea7a2ab 100644
--- a/tools/libxl/libxl_usb.c
+++ b/tools/libxl/libxl_usb.c
@@ -254,7 +254,7 @@ static int libxl__device_usbctrl_add_xenstore(libxl__gc *gc, uint32_t domid,
         if (usbctrl->type == LIBXL_USBCTRL_TYPE_QUSB) {
             if (!libxl__query_qemu_backend(gc, domid, usbctrl->backend_domid,
                                            "qusb", false)) {
-                LOG(ERROR, "backend type not supported by device model");
+                LOGD(ERROR, domid, "backend type not supported by device model");
                 rc = ERROR_FAIL;
                 goto out;
             }
@@ -269,7 +269,7 @@ static int libxl__device_usbctrl_add_xenstore(libxl__gc *gc, uint32_t domid,
         if (rc < 0) goto out;
         if (rc == 1) {
             /* already exists in xenstore */
-            LOG(ERROR, "device already exists in xenstore");
+            LOGD(ERROR, domid, "device already exists in xenstore");
             rc = ERROR_DEVICE_EXISTS;
             goto out;
         }
@@ -536,7 +536,7 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc *egc,
     for (i = 0; i < num_usbdev; i++) {
         rc = libxl__device_usbdev_remove(gc, domid, &usbdevs[i]);
         if (rc) {
-            LOG(ERROR, "libxl__device_usbdev_remove failed: controller %d, "
+            LOGD(ERROR, domid, "libxl__device_usbdev_remove failed: controller %d, "
                 "port %d", usbdevs[i].ctrl, usbdevs[i].port);
             goto out;
         }
@@ -633,7 +633,7 @@ libxl_device_usbctrl_list(libxl_ctx *ctx, uint32_t domid, int *num)
     return usbctrls;
 
 out:
-    LOG(ERROR, "Unable to list USB Controllers");
+    LOGD(ERROR, domid, "Unable to list USB Controllers");
     libxl_device_usbctrl_list_free(usbctrls, *num);
     GC_FREE;
     *num = 0;
@@ -1067,7 +1067,8 @@ static int libxl__device_usbdev_setdefault(libxl__gc *gc,
 
     if (usbdev->ctrl == -1) {
         if (usbdev->port) {
-            LOG(ERROR, "USB controller must be specified if you specify port");
+            LOGD(ERROR, domid,
+                 "USB controller must be specified if you specify port");
             return ERROR_INVAL;
         }
 
@@ -1119,7 +1120,7 @@ static int libxl__device_usbdev_setdefault(libxl__gc *gc,
             if (rc) goto out;
 
             if (tmp && strcmp(tmp, "")) {
-                LOG(ERROR, "The controller port isn't available");
+                LOGD(ERROR, domid, "The controller port isn't available");
                 rc = ERROR_FAIL;
                 goto out;
             }
@@ -1146,7 +1147,7 @@ static int libxl__device_usbdev_setdefault(libxl__gc *gc,
             }
 
             if (!usbdev->port) {
-                LOG(ERROR, "No available port under specified controller");
+                LOGD(ERROR, domid, "No available port under specified controller");
                 rc = ERROR_FAIL;
                 goto out;
             }
@@ -1183,7 +1184,7 @@ static int libxl__device_usbdev_add_xenstore(libxl__gc *gc, uint32_t domid,
     busid = usbdev_busaddr_to_busid(gc, usbdev->u.hostdev.hostbus,
                                     usbdev->u.hostdev.hostaddr);
     if (!busid) {
-        LOG(DEBUG, "Fail to get busid of usb device");
+        LOGD(DEBUG, domid, "Fail to get busid of usb device");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1217,7 +1218,7 @@ static int libxl__device_usbdev_add_xenstore(libxl__gc *gc, uint32_t domid,
         be_path = vusb_get_port_path(gc, domid, type, usbdev->ctrl,
                                      usbdev->port);
 
-        LOG(DEBUG, "Adding usb device %s to xenstore: controller %d, port %d",
+        LOGD(DEBUG, domid, "Adding usb device %s to xenstore: controller %d, port %d",
             busid, usbdev->ctrl, usbdev->port);
 
         rc = libxl__xs_write_checked(gc, t, be_path, busid);
@@ -1245,8 +1246,8 @@ static int libxl__device_usbdev_remove_xenstore(libxl__gc *gc, uint32_t domid,
 
     be_path = vusb_get_port_path(gc, domid, type, usbdev->ctrl, usbdev->port);
 
-    LOG(DEBUG, "Removing usb device from xenstore: controller %d, port %d",
-        usbdev->ctrl, usbdev->port);
+    LOGD(DEBUG, domid, "Removing usb device from xenstore: controller %d, port %d",
+         usbdev->ctrl, usbdev->port);
 
     return libxl__xs_write_checked(gc, XBT_NULL, be_path, "");
 }
@@ -1634,7 +1635,7 @@ static int do_usbdev_add(libxl__gc *gc, uint32_t domid,
         }
         break;
     default:
-        LOG(ERROR, "Unsupported usb controller type");
+        LOGD(ERROR, domid, "Unsupported usb controller type");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1687,7 +1688,8 @@ static void libxl__device_usbdev_add(libxl__egc *egc, uint32_t domid,
         if (rc) goto out;
 
         if (usbctrlinfo.backend_id != LIBXL_TOOLSTACK_DOMID) {
-            LOG(ERROR, "Don't support adding USB device from non-Dom0 backend");
+            LOGD(ERROR, domid,
+                 "Don't support adding USB device from non-Dom0 backend");
             rc = ERROR_INVAL;
             goto out;
         }
@@ -1695,7 +1697,7 @@ static void libxl__device_usbdev_add(libxl__egc *egc, uint32_t domid,
 
     /* check usb device is assignable type */
     if (!is_usbdev_assignable(gc, usbdev)) {
-        LOG(ERROR, "USB device is not assignable.");
+        LOGD(ERROR, domid, "USB device is not assignable.");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1703,13 +1705,13 @@ static void libxl__device_usbdev_add(libxl__egc *egc, uint32_t domid,
     /* check usb device is already assigned */
     rc = get_assigned_devices(gc, &assigned, &num_assigned);
     if (rc) {
-        LOG(ERROR, "cannot determine if device is assigned,"
-                   " refusing to continue");
+        LOGD(ERROR, domid, "cannot determine if device is assigned,"
+                           " refusing to continue");
         goto out;
     }
 
     if (is_usbdev_in_array(assigned, num_assigned, usbdev)) {
-        LOG(ERROR, "USB device already attached to a domain");
+        LOGD(ERROR, domid, "USB device already attached to a domain");
         rc = ERROR_INVAL;
         goto out;
     }
@@ -1771,24 +1773,24 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid,
          */
         rc = usbback_dev_unassign(gc, busid);
         if (rc) {
-            LOG(ERROR, "Error removing device from guest."
-                " Try running usbdev-detach again.");
+            LOGD(ERROR, domid, "Error removing device from guest."
+                 " Try running usbdev-detach again.");
             goto out;
         }
 
         rc = libxl__device_usbdev_remove_xenstore(gc, domid, usbdev,
                                                   LIBXL_USBCTRL_TYPE_PV);
         if (rc) {
-            LOG(ERROR, "Error removing device from guest."
-                " Try running usbdev-detach again.");
+            LOGD(ERROR, domid, "Error removing device from guest."
+                 " Try running usbdev-detach again.");
             goto out;
         }
 
         rc = usbdev_rebind(gc, busid);
         if (rc) {
-            LOG(ERROR, "USB device removed from guest, but couldn't"
-                " re-bind to domain 0. Try removing and re-inserting"
-                " the USB device or reloading the driver modules.");
+            LOGD(ERROR, domid, "USB device removed from guest, but couldn't"
+                 " re-bind to domain 0. Try removing and re-inserting"
+                 " the USB device or reloading the driver modules.");
             goto out;
         }
 
@@ -1814,7 +1816,7 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid,
 
         break;
     default:
-        LOG(ERROR, "Unsupported usb controller type");
+        LOGD(ERROR, domid, "Unsupported usb controller type");
         rc = ERROR_FAIL;
         goto out;
     }
@@ -1843,7 +1845,7 @@ static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid,
     int rc;
 
     if (usbdev->ctrl < 0 || usbdev->port < 1) {
-        LOG(ERROR, "Invalid USB device");
+        LOGD(ERROR, domid, "Invalid USB device");
         return ERROR_FAIL;
     }
 
@@ -1855,7 +1857,8 @@ static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid,
     if (rc) goto out;
 
     if (usbctrlinfo.backend_id != LIBXL_TOOLSTACK_DOMID) {
-        LOG(ERROR, "Don't support removing USB device from non-Dom0 backend");
+        LOGD(ERROR, domid,
+             "Don't support removing USB device from non-Dom0 backend");
         rc = ERROR_INVAL;
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 28/35] libxl/libxl_qmp.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (26 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 27/35] libxl/libxl_pvusb.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 29/35] libxl/libxl_remus.c: " Cédric Bosdonnat
                   ` (6 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_qmp.c | 56 ++++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/tools/libxl/libxl_qmp.c b/tools/libxl/libxl_qmp.c
index f8addf9..ad22ad4 100644
--- a/tools/libxl/libxl_qmp.c
+++ b/tools/libxl/libxl_qmp.c
@@ -30,10 +30,10 @@
 /* #define DEBUG_RECEIVED */
 
 #ifdef DEBUG_RECEIVED
-#  define DEBUG_REPORT_RECEIVED(buf, len) \
-    LOG(DEBUG, "received: '%.*s'", len, buf)
+#  define DEBUG_REPORT_RECEIVED(dom, buf, len) \
+    LOGD(DEBUG, dom, "received: '%.*s'", len, buf)
 #else
-#  define DEBUG_REPORT_RECEIVED(buf, len) ((void)0)
+#  define DEBUG_REPORT_RECEIVED(dom, buf, len) ((void)0)
 #endif
 
 /*
@@ -137,15 +137,15 @@ static int register_serials_chardev_callback(libxl__qmp_handler *qmp,
             s += strlen("serial");
             port_number = strtol(s, &endptr, 10);
             if (*s == 0 || *endptr != 0) {
-                LIBXL__LOG(qmp->ctx, LIBXL__LOG_ERROR,
-                           "Invalid serial port number: %s", s);
+                LIBXL__LOGD(qmp->ctx, LIBXL__LOG_ERROR, qmp->domid,
+                            "Invalid serial port number: %s", s);
                 return -1;
             }
             ret = store_serial_port_info(qmp, chardev, port_number);
             if (ret) {
-                LIBXL__LOG_ERRNO(qmp->ctx, LIBXL__LOG_ERROR,
-                                 "Failed to store serial port information"
-                                 " in xenstore");
+                LIBXL__LOGD_ERRNO(qmp->ctx, LIBXL__LOG_ERROR, qmp->domid,
+                                  "Failed to store serial port information"
+                                  " in xenstore");
                 return ret;
             }
         }
@@ -190,7 +190,7 @@ static int qmp_register_vnc_callback(libxl__qmp_handler *qmp,
     port = libxl__json_object_get_string(obj);
 
     if (!addr || !port) {
-        LOG(ERROR, "Failed to retreive VNC connect information.");
+        LOGD(ERROR, qmp->domid, "Failed to retreive VNC connect information.");
         goto out;
     }
 
@@ -283,8 +283,8 @@ static void qmp_handle_error_response(libxl__gc *gc, libxl__qmp_handler *qmp,
         free(pp);
     }
 
-    LOG(ERROR, "received an error message from QMP server: %s",
-        libxl__json_object_get_string(resp));
+    LOGD(ERROR, qmp->domid, "received an error message from QMP server: %s",
+         libxl__json_object_get_string(resp));
 }
 
 static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp,
@@ -293,7 +293,7 @@ static int qmp_handle_response(libxl__gc *gc, libxl__qmp_handler *qmp,
     libxl__qmp_message_type type = LIBXL__QMP_MESSAGE_TYPE_INVALID;
 
     type = qmp_response_type(qmp, resp);
-    LOG(DEBUG, "message type: %s", libxl__qmp_message_type_to_string(type));
+    LOGD(DEBUG, qmp->domid, "message type: %s", libxl__qmp_message_type_to_string(type));
 
     switch (type) {
     case LIBXL__QMP_MESSAGE_TYPE_QMP:
@@ -342,7 +342,7 @@ static libxl__qmp_handler *qmp_init_handler(libxl__gc *gc, uint32_t domid)
 
     qmp = calloc(1, sizeof (libxl__qmp_handler));
     if (qmp == NULL) {
-        LOGE(ERROR, "Failed to allocate qmp_handler");
+        LOGED(ERROR, domid, "Failed to allocate qmp_handler");
         return NULL;
     }
     qmp->ctx = CTX;
@@ -440,26 +440,26 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp)
 
         ret = select(qmp->qmp_fd + 1, &rfds, NULL, NULL, &timeout);
         if (ret == 0) {
-            LOG(ERROR, "timeout");
+            LOGD(ERROR, qmp->domid, "timeout");
             return -1;
         } else if (ret < 0) {
             if (errno == EINTR)
                 continue;
-            LOGE(ERROR, "Select error");
+            LOGED(ERROR, qmp->domid, "Select error");
             return -1;
         }
 
         rd = read(qmp->qmp_fd, qmp->buffer, QMP_RECEIVE_BUFFER_SIZE);
         if (rd == 0) {
-            LOG(ERROR, "Unexpected end of socket");
+            LOGD(ERROR, qmp->domid, "Unexpected end of socket");
             return -1;
         } else if (rd < 0) {
-            LOGE(ERROR, "Socket read error");
+            LOGED(ERROR, qmp->domid, "Socket read error");
             return rd;
         }
         qmp->buffer[rd] = '\0';
 
-        DEBUG_REPORT_RECEIVED(qmp->buffer, rd);
+        DEBUG_REPORT_RECEIVED(qmp->domid, qmp->buffer, rd);
 
         do {
             char *end = NULL;
@@ -490,7 +490,7 @@ static int qmp_next(libxl__gc *gc, libxl__qmp_handler *qmp)
                 if (o) {
                     rc = qmp_handle_response(gc, qmp, o);
                 } else {
-                    LOG(ERROR, "Parse error of : %s", s);
+                    LOGD(ERROR, qmp->domid, "Parse error of : %s", s);
                     return -1;
                 }
 
@@ -536,13 +536,13 @@ static char *qmp_send_prepare(libxl__gc *gc, libxl__qmp_handler *qmp,
     s = yajl_gen_get_buf(hand, &buf, &len);
 
     if (s) {
-        LOG(ERROR, "Failed to generate a qmp command");
+        LOGD(ERROR, qmp->domid, "Failed to generate a qmp command");
         goto out;
     }
 
     elm = malloc(sizeof (callback_id_pair));
     if (elm == NULL) {
-        LOGE(ERROR, "Failed to allocate a QMP callback");
+        LOGED(ERROR, qmp->domid, "Failed to allocate a QMP callback");
         goto out;
     }
     elm->id = qmp->last_id_used;
@@ -553,7 +553,7 @@ static char *qmp_send_prepare(libxl__gc *gc, libxl__qmp_handler *qmp,
 
     ret = libxl__strndup(gc, (const char*)buf, len);
 
-    LOG(DEBUG, "next qmp command: '%s'", buf);
+    LOGD(DEBUG, qmp->domid, "next qmp command: '%s'", buf);
 
 out:
     yajl_gen_free(hand);
@@ -699,12 +699,12 @@ libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid)
 
     qmp_socket = GCSPRINTF("%s/qmp-libxl-%d", libxl__run_dir_path(), domid);
     if ((ret = qmp_open(qmp, qmp_socket, QMP_SOCKET_CONNECT_TIMEOUT)) < 0) {
-        LOGE(ERROR, "Connection error");
+        LOGED(ERROR, domid, "Connection error");
         qmp_free_handler(qmp);
         return NULL;
     }
 
-    LOG(DEBUG, "connected to %s", qmp_socket);
+    LOGD(DEBUG, domid, "connected to %s", qmp_socket);
 
     /* Wait for the response to qmp_capabilities */
     while (!qmp->connected) {
@@ -714,7 +714,7 @@ libxl__qmp_handler *libxl__qmp_initialize(libxl__gc *gc, uint32_t domid)
     }
 
     if (!qmp->connected) {
-        LOG(ERROR, "Failed to connect to QMP");
+        LOGD(ERROR, domid, "Failed to connect to QMP");
         libxl__qmp_close(qmp);
         return NULL;
     }
@@ -736,14 +736,14 @@ void libxl__qmp_cleanup(libxl__gc *gc, uint32_t domid)
     qmp_socket = GCSPRINTF("%s/qmp-libxl-%d", libxl__run_dir_path(), domid);
     if (unlink(qmp_socket) == -1) {
         if (errno != ENOENT) {
-            LOGE(ERROR, "Failed to remove QMP socket file %s", qmp_socket);
+            LOGED(ERROR, domid, "Failed to remove QMP socket file %s", qmp_socket);
         }
     }
 
     qmp_socket = GCSPRINTF("%s/qmp-libxenstat-%d", libxl__run_dir_path(), domid);
     if (unlink(qmp_socket) == -1) {
         if (errno != ENOENT) {
-            LOGE(ERROR, "Failed to remove QMP socket file %s", qmp_socket);
+            LOGED(ERROR, domid, "Failed to remove QMP socket file %s", qmp_socket);
         }
     }
 }
@@ -1012,7 +1012,7 @@ static int query_cpus_callback(libxl__qmp_handler *qmp,
 
         o = libxl__json_map_get("CPU", cpu, JSON_INTEGER);
         if (!o) {
-            LOG(ERROR, "Failed to retrieve CPU index.");
+            LOGD(ERROR, qmp->domid, "Failed to retrieve CPU index.");
             rc = ERROR_FAIL;
             goto out;
         }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 29/35] libxl/libxl_remus.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (27 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 28/35] libxl/libxl_qmp.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 30/35] libxl/libxl_save_callout.c: " Cédric Bosdonnat
                   ` (5 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_remus.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/tools/libxl/libxl_remus.c b/tools/libxl/libxl_remus.c
index 54ec7de..29a4783 100644
--- a/tools/libxl/libxl_remus.c
+++ b/tools/libxl/libxl_remus.c
@@ -84,7 +84,8 @@ void libxl__remus_setup(libxl__egc *egc, libxl__remus_state *rs)
 
     if (libxl_defbool_val(info->netbuf)) {
         if (!libxl__netbuffer_enabled(gc)) {
-            LOG(ERROR, "Remus: No support for network buffering");
+            LOGD(ERROR, dss->domid,
+                 "Remus: No support for network buffering");
             goto out;
         }
         cds->device_kind_flags |= (1 << LIBXL__DEVICE_KIND_VIF);
@@ -101,8 +102,8 @@ void libxl__remus_setup(libxl__egc *egc, libxl__remus_state *rs)
     rs->interval = info->interval;
 
     if (init_device_subkind(cds)) {
-        LOG(ERROR, "Remus: failed to init device subkind for guest %u",
-            dss->domid);
+        LOGD(ERROR, dss->domid,
+             "Remus: failed to init device subkind");
         goto out;
     }
 
@@ -130,8 +131,7 @@ static void remus_setup_done(libxl__egc *egc,
         return;
     }
 
-    LOG(ERROR, "Remus: failed to setup device for guest with domid %u, rc %d",
-        dss->domid, rc);
+    LOGD(ERROR, dss->domid, "Remus: failed to setup device, rc %d", rc);
     cds->callback = remus_setup_failed;
     libxl__checkpoint_devices_teardown(egc, cds);
 }
@@ -143,8 +143,8 @@ static void remus_setup_failed(libxl__egc *egc,
     STATE_AO_GC(dss->ao);
 
     if (rc)
-        LOG(ERROR, "Remus: failed to teardown device after setup failed"
-            " for guest with domid %u, rc %d", dss->domid, rc);
+        LOGD(ERROR, dss->domid,
+             "Remus: failed to teardown device after setup failed, rc %d", rc);
 
     cleanup_device_subkind(cds);
 
@@ -165,8 +165,8 @@ void libxl__remus_teardown(libxl__egc *egc,
 
     EGC_GC;
 
-    LOG(WARN, "Remus: Domain suspend terminated with rc %d,"
-        " teardown Remus devices...", rc);
+    LOGD(WARN, dss->domid, "Remus: Domain suspend terminated with rc %d,"
+         " teardown Remus devices...", rc);
     cds->callback = remus_teardown_done;
     libxl__checkpoint_devices_teardown(egc, cds);
 }
@@ -179,8 +179,8 @@ static void remus_teardown_done(libxl__egc *egc,
     STATE_AO_GC(dss->ao);
 
     if (rc)
-        LOG(ERROR, "Remus: failed to teardown device for guest with domid %u,"
-            " rc %d", dss->domid, rc);
+        LOGD(ERROR, dss->domid, "Remus: failed to teardown device,"
+            " rc %d", rc);
 
     cleanup_device_subkind(cds);
 
@@ -309,7 +309,8 @@ static void remus_checkpoint_stream_written(
     STATE_AO_GC(dss->ao);
 
     if (rc) {
-        LOG(ERROR, "Failed to save device model. Terminating Remus..");
+        LOGD(ERROR, dss->domid, "Failed to save device model."
+             " Terminating Remus..");
         goto out;
     }
 
@@ -331,7 +332,7 @@ static void remus_devices_commit_cb(libxl__egc *egc,
     STATE_AO_GC(dss->ao);
 
     if (rc) {
-        LOG(ERROR, "Failed to do device commit op."
+        LOGD(ERROR, dss->domid, "Failed to do device commit op."
             " Terminating Remus..");
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 30/35] libxl/libxl_save_callout.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (28 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 29/35] libxl/libxl_remus.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 31/35] libxl/libxl_stream_write.c: " Cédric Bosdonnat
                   ` (4 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_save_callout.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_save_callout.c b/tools/libxl/libxl_save_callout.c
index 2e6267d..46b892c 100644
--- a/tools/libxl/libxl_save_callout.c
+++ b/tools/libxl/libxl_save_callout.c
@@ -294,8 +294,8 @@ static void helper_stdout_readable(libxl__egc *egc, libxl__ev_fd *ev,
     int rc, errnoval;
 
     if (revents & (POLLERR|POLLPRI)) {
-        LOG(ERROR, "%s signaled POLLERR|POLLPRI (%#x)",
-            shs->stdout_what, revents);
+        LOGD(ERROR, shs->domid, "%s signaled POLLERR|POLLPRI (%#x)",
+             shs->stdout_what, revents);
         rc = ERROR_FAIL;
  out:
         /* this is here because otherwise we bypass the decl of msg[] */
@@ -339,14 +339,14 @@ static void helper_exited(libxl__egc *egc, libxl__ev_child *ch,
 
     if (shs->need_results) {
         if (!shs->rc) {
-            LOG(ERROR,"%s exited without providing results",what);
+            LOGD(ERROR,shs->domid,"%s exited without providing results",what);
             shs->rc = ERROR_FAIL;
         }
     }
 
     if (!shs->completed) {
         if (!shs->rc) {
-            LOG(ERROR,"%s exited without signaling completion",what);
+            LOGD(ERROR,shs->domid,"%s exited without signaling completion",what);
             shs->rc = ERROR_FAIL;
         }
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 31/35] libxl/libxl_stream_write.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (29 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 30/35] libxl/libxl_save_callout.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 32/35] libxl/libxl_vnuma.c: " Cédric Bosdonnat
                   ` (3 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_stream_write.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/libxl/libxl_stream_write.c b/tools/libxl/libxl_stream_write.c
index aba554b..c96a6a2 100644
--- a/tools/libxl/libxl_stream_write.c
+++ b/tools/libxl/libxl_stream_write.c
@@ -267,7 +267,7 @@ void libxl__stream_write_start(libxl__egc *egc,
 
         default:
             rc = ERROR_FAIL;
-            LOG(ERROR, "Unknown emulator for HVM domain");
+            LOGD(ERROR, dss->domid, "Unknown emulator for HVM domain");
             goto err;
         }
         stream->emu_sub_hdr.index = 0;
@@ -349,7 +349,7 @@ void libxl__xc_domain_save_done(libxl__egc *egc, void *dss_void,
         goto err;
 
     if (retval) {
-        LOGEV(ERROR, errnoval, "saving domain: %s",
+        LOGEVD(ERROR, errnoval, dss->domid, "saving domain: %s",
               dss->dsps.guest_responded ?
               "domain responded to suspend request" :
               "domain did not respond to suspend request");
@@ -464,19 +464,19 @@ static void write_emulator_context_record(libxl__egc *egc,
     stream->emu_carefd = libxl__carefd_opened(CTX, readfd);
     if (readfd == -1) {
         rc = ERROR_FAIL;
-        LOGE(ERROR, "unable to open %s", filename);
+        LOGED(ERROR, dss->domid, "unable to open %s", filename);
         goto err;
     }
 
     if (fstat(readfd, &st)) {
         rc = ERROR_FAIL;
-        LOGE(ERROR, "unable to fstat %s", filename);
+        LOGED(ERROR, dss->domid, "unable to fstat %s", filename);
         goto err;
     }
 
     if (!S_ISREG(st.st_mode)) {
         rc = ERROR_FAIL;
-        LOG(ERROR, "%s is not a plain file!", filename);
+        LOGD(ERROR, dss->domid, "%s is not a plain file!", filename);
         goto err;
     }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 32/35] libxl/libxl_vnuma.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (30 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 31/35] libxl/libxl_stream_write.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 33/35] libxl/libxl_vtpm.c: " Cédric Bosdonnat
                   ` (2 subsequent siblings)
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_vnuma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_vnuma.c b/tools/libxl/libxl_vnuma.c
index db22799..8ec2abb 100644
--- a/tools/libxl/libxl_vnuma.c
+++ b/tools/libxl/libxl_vnuma.c
@@ -283,7 +283,7 @@ int libxl__vnuma_build_vmemrange_hvm(libxl__gc *gc,
         /* Consider video ram belongs to vnode 0 */
         if (nid == 0) {
             if (p->memkb < b_info->video_memkb) {
-                LOG(ERROR, "vnode 0 too small to contain video ram");
+                LOGD(ERROR, domid, "vnode 0 too small to contain video ram");
                 rc = ERROR_INVAL;
                 goto out;
             }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 33/35] libxl/libxl_vtpm.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (31 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 32/35] libxl/libxl_vnuma.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 34/35] libxl/libxl_x86.c: " Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 35/35] libxl/libxl_xshelp.c: " Cédric Bosdonnat
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_vtpm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c
index 8588569..9ee8cce 100644
--- a/tools/libxl/libxl_vtpm.c
+++ b/tools/libxl/libxl_vtpm.c
@@ -129,7 +129,7 @@ static void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid,
         rc = libxl__device_exists(gc, t, device);
         if (rc < 0) goto out;
         if (rc == 1) {              /* already exists in xenstore */
-            LOG(ERROR, "device already exists in xenstore");
+            LOGD(ERROR, domid, "device already exists in xenstore");
             aodev->action = LIBXL__DEVICE_ACTION_ADD; /* for error message */
             rc = ERROR_DEVICE_EXISTS;
             goto out;
@@ -200,7 +200,7 @@ libxl_device_vtpm *libxl_device_vtpm_list(libxl_ctx *ctx, uint32_t domid, int *n
           tmp = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/uuid", libxl_path));
           if (tmp) {
               if(libxl_uuid_from_string(&(vtpm->uuid), tmp)) {
-                  LOG(ERROR, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
+                  LOGD(ERROR, domid, "%s/uuid is a malformed uuid?? (%s) Probably a bug!!\n", be_path, tmp);
                   free(vtpms);
                   return NULL;
               }
@@ -259,11 +259,11 @@ int libxl_device_vtpm_getinfo(libxl_ctx *ctx,
     val = libxl__xs_read(gc, XBT_NULL,
           GCSPRINTF("%s/uuid", libxl_path));
     if(val == NULL) {
-       LOG(ERROR, "%s/uuid does not exist!", vtpminfo->backend);
+       LOGD(ERROR, domid, "%s/uuid does not exist!", vtpminfo->backend);
        goto err;
     }
     if(libxl_uuid_from_string(&(vtpminfo->uuid), val)) {
-       LOG(ERROR,
+       LOGD(ERROR, domid,
              "%s/uuid is a malformed uuid?? (%s) Probably a bug!\n",
              vtpminfo->backend, val);
        goto err;
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 34/35] libxl/libxl_x86.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (32 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 33/35] libxl/libxl_vtpm.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  2016-11-15 10:19 ` [PATCH 35/35] libxl/libxl_xshelp.c: " Cédric Bosdonnat
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_x86.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index e1844c8..5da7504 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -327,7 +327,7 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
         tm = localtime_r(&t, &result);
 
         if (!tm) {
-            LOGE(ERROR, "Failed to call localtime_r");
+            LOGED(ERROR, domid, "Failed to call localtime_r");
             ret = ERROR_FAIL;
             goto out;
         }
@@ -350,7 +350,7 @@ int libxl__arch_domain_create(libxl__gc *gc, libxl_domain_config *d_config,
             libxl_defbool_val(d_config->b_info.u.pv.e820_host)) {
         ret = libxl__e820_alloc(gc, domid, d_config);
         if (ret) {
-            LOGE(ERROR, "Failed while collecting E820 with: %d (errno:%d)\n",
+            LOGED(ERROR, domid, "Failed while collecting E820 with: %d (errno:%d)\n",
                  ret, errno);
         }
     }
@@ -532,7 +532,7 @@ int libxl__arch_domain_construct_memmap(libxl__gc *gc,
             e820_entries++;
 
     if (e820_entries >= E820MAX) {
-        LOG(ERROR, "Ooops! Too many entries in the memory map!");
+        LOGD(ERROR, domid, "Ooops! Too many entries in the memory map!");
         rc = ERROR_INVAL;
         goto out;
     }
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* [PATCH 35/35] libxl/libxl_xshelp.c: used LOG*D functions
  2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
                   ` (33 preceding siblings ...)
  2016-11-15 10:19 ` [PATCH 34/35] libxl/libxl_x86.c: " Cédric Bosdonnat
@ 2016-11-15 10:19 ` Cédric Bosdonnat
  34 siblings, 0 replies; 47+ messages in thread
From: Cédric Bosdonnat @ 2016-11-15 10:19 UTC (permalink / raw)
  To: xen-devel
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, Cédric Bosdonnat

From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>

Use LOG*D logging functions where possible instead of the LOG* ones.

Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
---
 tools/libxl/libxl_xshelp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_xshelp.c b/tools/libxl/libxl_xshelp.c
index b3bac6d..a50805f 100644
--- a/tools/libxl/libxl_xshelp.c
+++ b/tools/libxl/libxl_xshelp.c
@@ -146,7 +146,7 @@ char *libxl__xs_get_dompath(libxl__gc *gc, uint32_t domid)
     libxl_ctx *ctx = libxl__gc_owner(gc);
     char *s = xs_get_domain_path(ctx->xsh, domid);
     if (!s) {
-        LOGE(ERROR, "failed to get dompath for %"PRIu32, domid);
+        LOGED(ERROR, domid, "Failed to get dompath");
         return NULL;
     }
     libxl__ptr_add(gc, s);
@@ -189,7 +189,7 @@ char *libxl__xs_libxl_path(libxl__gc *gc, uint32_t domid)
 {
     char *s = GCSPRINTF("/libxl/%i", domid);
     if (!s)
-        LOG(ERROR, "cannot allocate create paths");
+        LOGD(ERROR, domid, "cannot allocate create paths");
     return s;
 }
 
-- 
2.10.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 47+ messages in thread

* Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-15 10:18 ` [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families Cédric Bosdonnat
@ 2016-11-17 14:41   ` Wei Liu
  2016-11-17 16:01     ` Cedric Bosdonnat
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-11-17 14:41 UTC (permalink / raw)
  To: Cédric Bosdonnat
  Cc: Cédric Bosdonnat, Wei Liu, Ian Jackson, xen-devel

On Tue, Nov 15, 2016 at 11:18:39AM +0100, Cédric Bosdonnat wrote:
> From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>
> 
> These functions should be used to log messages when the domain
> id is known. libxl__log will now prepend the log message by
> "Domain %PRIu32:" if the domain id is a valid one.
> 
> This aims at helping consumers filter logs on domain IDs.
> 
> Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
> ---
>  tools/libxl/libxl_event.c    |  6 +++---
>  tools/libxl/libxl_internal.c | 16 ++++++++++------
>  tools/libxl/libxl_internal.h | 38 +++++++++++++++++++++++++++++++-------
>  3 files changed, 44 insertions(+), 16 deletions(-)
> 
> diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
> index 02b39e6..fc9bdc9 100644
> --- a/tools/libxl/libxl_event.c
> +++ b/tools/libxl/libxl_event.c
> @@ -1362,7 +1362,7 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,
>  {
>      EGC_GC;
>  
> -    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func,
> +    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMID,
>                 "DISASTER in event loop: %s%s%s%s",
>                 msg,
>                 type ? " (relates to event type " : "",
> @@ -1943,7 +1943,7 @@ libxl__ao *libxl__ao_create(libxl_ctx *ctx, uint32_t domid,
>          ao->poller = libxl__poller_get(&ao->gc);
>          if (!ao->poller) goto out;
>      }
> -    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,
> +    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,domid,
>                 "ao %p: create: how=%p callback=%p poller=%p",
>                 ao, how, ao->how.callback, ao->poller);
>  
> @@ -1968,7 +1968,7 @@ int libxl__ao_inprogress(libxl__ao *ao,
>      assert(ao->in_initiator);
>      ao->constructing = 0;
>  
> -    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,
> +    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,INVALID_DOMID,

You should be able to use ao->domid here, right?

>                 "ao %p: inprogress: poller=%p, flags=%s%s%s%s",
>                 ao, ao->poller,
>                 ao->constructing ? "o" : "",
> diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
> index 448dd61..78ed2f6 100644
> --- a/tools/libxl/libxl_internal.c
> +++ b/tools/libxl/libxl_internal.c
> @@ -22,7 +22,7 @@ void libxl__alloc_failed(libxl_ctx *ctx, const char *func,
>  #define M "libxl: FATAL ERROR: memory allocation failure"
>  #define L (size ? M " (%s, %lu x %lu)\n" : M " (%s)\n"), \
>            func, (unsigned long)nmemb, (unsigned long)size
> -    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, L);
> +    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, INVALID_DOMID, L);
>      fprintf(stderr, L);
>      fflush(stderr);
>      _exit(-1);
> @@ -202,7 +202,7 @@ char *libxl__dirname(libxl__gc *gc, const char *s)
>  
>  void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
>               const char *file, int line, const char *func,
> -             const char *fmt, va_list ap)
> +             uint32_t domid, const char *fmt, va_list ap)
>  {
>      /* WARNING this function may not call any libxl-provided
>       * memory allocation function, as those may
> @@ -211,6 +211,7 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
>      char *base = NULL;
>      int rc, esave;
>      char fileline[256];
> +    char domain[256];
>  
>      esave = errno;
>  
> @@ -221,22 +222,25 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
>      if (file) snprintf(fileline, sizeof(fileline), "%s:%d",file,line);
>      fileline[sizeof(fileline)-1] = 0;
>  
> +    domain[0] = 0;
> +    if (domid != INVALID_DOMID) snprintf(domain, sizeof(domain), "Domain %"PRIu32":", domid);

Coding style issue, please put snprintf in a new line.

> +    domain[sizeof(domain)-1] = 0;

This probably does do what you want it to do - sizeof(domain) -> 256.  I
don't think you need this at all because IIRC snprintf puts a \0 at the
end.

Overall I think this is in line with what we discussed before.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 04/35] libxl.c: switch to LOG*D use
  2016-11-15 10:18 ` [PATCH 04/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
@ 2016-11-17 14:50   ` Wei Liu
  2016-11-17 16:03     ` Cedric Bosdonnat
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-11-17 14:50 UTC (permalink / raw)
  To: Cédric Bosdonnat; +Cc: Wei Liu, Ian Jackson, xen-devel

On Tue, Nov 15, 2016 at 11:18:42AM +0100, Cédric Bosdonnat wrote:
> Use LOG*D functions to output the domain ID in logs as much as
> possible. This will help consumer code sorting the logs by
> domain.
> 
> This commit includes all LOG* to LOG*D changes where the domain
> ID is not just a domid variable. We want the domain ID provided
> to the LOG*D functions to be the one of the publicly known
> domain, not a stubdom one.
> 
> Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>

I skimmed through the rest of this series. The code looks good to me.

The only thing I don't understand is why you had patch 2-4 for libxl.c.
These three patches can probably be merged into one patch.

Another thing is the From: field email address differs from patch to
patch. That's probably ok to you, but I think I should point that out in
case SuSE require you to always use your @suse.com address to
contribute.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-17 14:41   ` Wei Liu
@ 2016-11-17 16:01     ` Cedric Bosdonnat
  2016-11-17 16:12       ` Wei Liu
  2016-11-17 16:29       ` Ian Jackson
  0 siblings, 2 replies; 47+ messages in thread
From: Cedric Bosdonnat @ 2016-11-17 16:01 UTC (permalink / raw)
  To: Wei Liu; +Cc: Ian Jackson, xen-devel

On Thu, 2016-11-17 at 14:41 +0000, Wei Liu wrote:
> On Tue, Nov 15, 2016 at 11:18:39AM +0100, Cédric Bosdonnat wrote:
> > From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>
> > 
> > These functions should be used to log messages when the domain
> > id is known. libxl__log will now prepend the log message by
> > "Domain %PRIu32:" if the domain id is a valid one.
> > 
> > This aims at helping consumers filter logs on domain IDs.
> > 
> > Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
> > ---
> >  tools/libxl/libxl_event.c    |  6 +++---
> >  tools/libxl/libxl_internal.c | 16 ++++++++++------
> >  tools/libxl/libxl_internal.h | 38 +++++++++++++++++++++++++++++++-------
> >  3 files changed, 44 insertions(+), 16 deletions(-)
> > 
> > diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
> > index 02b39e6..fc9bdc9 100644
> > --- a/tools/libxl/libxl_event.c
> > +++ b/tools/libxl/libxl_event.c
> > @@ -1362,7 +1362,7 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,
> >  {
> >      EGC_GC;
> >  
> > -    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func,
> > +    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMID,
> >                 "DISASTER in event loop: %s%s%s%s",
> >                 msg,
> >                 type ? " (relates to event type " : "",
> > @@ -1943,7 +1943,7 @@ libxl__ao *libxl__ao_create(libxl_ctx *ctx, uint32_t domid,
> >          ao->poller = libxl__poller_get(&ao->gc);
> >          if (!ao->poller) goto out;
> >      }
> > -    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,
> > +    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,domid,
> >                 "ao %p: create: how=%p callback=%p poller=%p",
> >                 ao, how, ao->how.callback, ao->poller);
> >  
> > @@ -1968,7 +1968,7 @@ int libxl__ao_inprogress(libxl__ao *ao,
> >      assert(ao->in_initiator);
> >      ao->constructing = 0;
> >  
> > -    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,
> > +    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,INVALID_DOMID,
> 
> You should be able to use ao->domid here, right?

Oh indeed. I discovered this one after writing this patch and forgot
about it here. Could it be possible that ao->domid is not the publicly
known domain id?

> >                 "ao %p: inprogress: poller=%p, flags=%s%s%s%s",
> >                 ao, ao->poller,
> >                 ao->constructing ? "o" : "",
> > diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
> > index 448dd61..78ed2f6 100644
> > --- a/tools/libxl/libxl_internal.c
> > +++ b/tools/libxl/libxl_internal.c
> > @@ -22,7 +22,7 @@ void libxl__alloc_failed(libxl_ctx *ctx, const char *func,
> >  #define M "libxl: FATAL ERROR: memory allocation failure"
> >  #define L (size ? M " (%s, %lu x %lu)\n" : M " (%s)\n"), \
> >            func, (unsigned long)nmemb, (unsigned long)size
> > -    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, L);
> > +    libxl__log(ctx, XTL_CRITICAL, ENOMEM, 0,0, func, INVALID_DOMID, L);
> >      fprintf(stderr, L);
> >      fflush(stderr);
> >      _exit(-1);
> > @@ -202,7 +202,7 @@ char *libxl__dirname(libxl__gc *gc, const char *s)
> >  
> >  void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
> >               const char *file, int line, const char *func,
> > -             const char *fmt, va_list ap)
> > +             uint32_t domid, const char *fmt, va_list ap)
> >  {
> >      /* WARNING this function may not call any libxl-provided
> >       * memory allocation function, as those may
> > @@ -211,6 +211,7 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
> >      char *base = NULL;
> >      int rc, esave;
> >      char fileline[256];
> > +    char domain[256];
> >  
> >      esave = errno;
> >  
> > @@ -221,22 +222,25 @@ void libxl__logv(libxl_ctx *ctx, xentoollog_level msglevel, int errnoval,
> >      if (file) snprintf(fileline, sizeof(fileline), "%s:%d",file,line);
> >      fileline[sizeof(fileline)-1] = 0;
> >  
> > +    domain[0] = 0;
> > +    if (domid != INVALID_DOMID) snprintf(domain, sizeof(domain), "Domain %"PRIu32":", domid);
> 
> Coding style issue, please put snprintf in a new line.

I've mimicked what is a few lines above (see first line of the hunk context).
I agree it doesn't look too pretty. but then may be I should reformat the one above ;)

> > +    domain[sizeof(domain)-1] = 0;
> 
> This probably does do what you want it to do - sizeof(domain) -> 256.  I
> don't think you need this at all because IIRC snprintf puts a \0 at the
> end.

Oh indeed. I'll remove it then.

> Overall I think this is in line with what we discussed before.

I expected to send a v2 anyway, I'll resend with the changes.
--
Cedric

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 04/35] libxl.c: switch to LOG*D use
  2016-11-17 14:50   ` Wei Liu
@ 2016-11-17 16:03     ` Cedric Bosdonnat
  2016-11-17 16:15       ` Wei Liu
  2016-11-17 16:30       ` Ian Jackson
  0 siblings, 2 replies; 47+ messages in thread
From: Cedric Bosdonnat @ 2016-11-17 16:03 UTC (permalink / raw)
  To: Wei Liu; +Cc: Ian Jackson, xen-devel

On Thu, 2016-11-17 at 14:50 +0000, Wei Liu wrote:
> On Tue, Nov 15, 2016 at 11:18:42AM +0100, Cédric Bosdonnat wrote:
> > Use LOG*D functions to output the domain ID in logs as much as
> > possible. This will help consumer code sorting the logs by
> > domain.
> > 
> > This commit includes all LOG* to LOG*D changes where the domain
> > ID is not just a domid variable. We want the domain ID provided
> > to the LOG*D functions to be the one of the publicly known
> > domain, not a stubdom one.
> > 
> > Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
> 
> I skimmed through the rest of this series. The code looks good to me.
> 
> The only thing I don't understand is why you had patch 2-4 for libxl.c.
> These three patches can probably be merged into one patch.

That was to ease the review by isolating the cases that could be problematic.
But I'll resubmit them merged together then.

> Another thing is the From: field email address differs from patch to
> patch. That's probably ok to you, but I think I should point that out in
> case SuSE require you to always use your @suse.com address to
> contribute.

Hum, I though I've fixed those, I'll need to check them again before resending.

--
Cedric

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-17 16:01     ` Cedric Bosdonnat
@ 2016-11-17 16:12       ` Wei Liu
  2016-11-17 16:29       ` Ian Jackson
  1 sibling, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-11-17 16:12 UTC (permalink / raw)
  To: Cedric Bosdonnat; +Cc: Ian Jackson, Wei Liu, xen-devel

On Thu, Nov 17, 2016 at 05:01:08PM +0100, Cedric Bosdonnat wrote:
> On Thu, 2016-11-17 at 14:41 +0000, Wei Liu wrote:
> > On Tue, Nov 15, 2016 at 11:18:39AM +0100, Cédric Bosdonnat wrote:
> > > From: Cédric Bosdonnat <cedric.bosdonnat@free.fr>
> > > 
> > > These functions should be used to log messages when the domain
> > > id is known. libxl__log will now prepend the log message by
> > > "Domain %PRIu32:" if the domain id is a valid one.
> > > 
> > > This aims at helping consumers filter logs on domain IDs.
> > > 
> > > Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
> > > ---
> > >  tools/libxl/libxl_event.c    |  6 +++---
> > >  tools/libxl/libxl_internal.c | 16 ++++++++++------
> > >  tools/libxl/libxl_internal.h | 38 +++++++++++++++++++++++++++++++-------
> > >  3 files changed, 44 insertions(+), 16 deletions(-)
> > > 
> > > diff --git a/tools/libxl/libxl_event.c b/tools/libxl/libxl_event.c
> > > index 02b39e6..fc9bdc9 100644
> > > --- a/tools/libxl/libxl_event.c
> > > +++ b/tools/libxl/libxl_event.c
> > > @@ -1362,7 +1362,7 @@ void libxl__event_disaster(libxl__egc *egc, const char *msg, int errnoval,
> > >  {
> > >      EGC_GC;
> > >  
> > > -    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func,
> > > +    libxl__log(CTX, XTL_CRITICAL, errnoval, file, line, func, INVALID_DOMID,
> > >                 "DISASTER in event loop: %s%s%s%s",
> > >                 msg,
> > >                 type ? " (relates to event type " : "",
> > > @@ -1943,7 +1943,7 @@ libxl__ao *libxl__ao_create(libxl_ctx *ctx, uint32_t domid,
> > >          ao->poller = libxl__poller_get(&ao->gc);
> > >          if (!ao->poller) goto out;
> > >      }
> > > -    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,
> > > +    libxl__log(ctx,XTL_DEBUG,-1,file,line,func,domid,
> > >                 "ao %p: create: how=%p callback=%p poller=%p",
> > >                 ao, how, ao->how.callback, ao->poller);
> > >  
> > > @@ -1968,7 +1968,7 @@ int libxl__ao_inprogress(libxl__ao *ao,
> > >      assert(ao->in_initiator);
> > >      ao->constructing = 0;
> > >  
> > > -    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,
> > > +    libxl__log(CTX,XTL_DEBUG,-1,file,line,func,INVALID_DOMID,
> > 
> > You should be able to use ao->domid here, right?
> 
> Oh indeed. I discovered this one after writing this patch and forgot
> about it here. Could it be possible that ao->domid is not the publicly
> known domain id?

I think it is the publicly known domain id -- it was initialised in
libxl__ao_create which got domid from caller.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 04/35] libxl.c: switch to LOG*D use
  2016-11-17 16:03     ` Cedric Bosdonnat
@ 2016-11-17 16:15       ` Wei Liu
  2016-11-17 16:30       ` Ian Jackson
  1 sibling, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-11-17 16:15 UTC (permalink / raw)
  To: Cedric Bosdonnat; +Cc: Ian Jackson, Wei Liu, xen-devel

On Thu, Nov 17, 2016 at 05:03:03PM +0100, Cedric Bosdonnat wrote:
> On Thu, 2016-11-17 at 14:50 +0000, Wei Liu wrote:
> > On Tue, Nov 15, 2016 at 11:18:42AM +0100, Cédric Bosdonnat wrote:
> > > Use LOG*D functions to output the domain ID in logs as much as
> > > possible. This will help consumer code sorting the logs by
> > > domain.
> > > 
> > > This commit includes all LOG* to LOG*D changes where the domain
> > > ID is not just a domid variable. We want the domain ID provided
> > > to the LOG*D functions to be the one of the publicly known
> > > domain, not a stubdom one.
> > > 
> > > Signed-off-by: Cédric Bosdonnat <cbosdonnat@suse.com>
> > 
> > I skimmed through the rest of this series. The code looks good to me.
> > 
> > The only thing I don't understand is why you had patch 2-4 for libxl.c.
> > These three patches can probably be merged into one patch.
> 
> That was to ease the review by isolating the cases that could be problematic.
> But I'll resubmit them merged together then.
> 

In that case please keep them separated.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-17 16:01     ` Cedric Bosdonnat
  2016-11-17 16:12       ` Wei Liu
@ 2016-11-17 16:29       ` Ian Jackson
  2016-11-17 16:34         ` Wei Liu
  1 sibling, 1 reply; 47+ messages in thread
From: Ian Jackson @ 2016-11-17 16:29 UTC (permalink / raw)
  To: Cedric Bosdonnat; +Cc: Ian Jackson, Wei Liu, xen-devel

Cedric Bosdonnat writes ("Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families."):
> On Thu, 2016-11-17 at 14:41 +0000, Wei Liu wrote:
> > You should be able to use ao->domid here, right?
> 
> Oh indeed. I discovered this one after writing this patch and forgot
> about it here. Could it be possible that ao->domid is not the publicly
> known domain id?

I think it might conceivably sometimes be a stubdom id.  That depends
on who sets it when and whether they make a nested ao for a stubdom...

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 04/35] libxl.c: switch to LOG*D use
  2016-11-17 16:03     ` Cedric Bosdonnat
  2016-11-17 16:15       ` Wei Liu
@ 2016-11-17 16:30       ` Ian Jackson
  1 sibling, 0 replies; 47+ messages in thread
From: Ian Jackson @ 2016-11-17 16:30 UTC (permalink / raw)
  To: Cedric Bosdonnat; +Cc: Wei Liu, xen-devel

Cedric Bosdonnat writes ("Re: [PATCH 04/35] libxl.c: switch to LOG*D use"):
> On Thu, 2016-11-17 at 14:50 +0000, Wei Liu wrote:
> > The only thing I don't understand is why you had patch 2-4 for libxl.c.
> > These three patches can probably be merged into one patch.
> 
> That was to ease the review by isolating the cases that could be problematic.
> But I'll resubmit them merged together then.

I think splitting things up is slightly nicer.  You can explain the
split in the commit messages.  But please don't bother splitting it
out again if you've already merged it....

Thanks,
Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-17 16:29       ` Ian Jackson
@ 2016-11-17 16:34         ` Wei Liu
  2016-11-17 16:36           ` Ian Jackson
  0 siblings, 1 reply; 47+ messages in thread
From: Wei Liu @ 2016-11-17 16:34 UTC (permalink / raw)
  To: Ian Jackson; +Cc: Wei Liu, Cedric Bosdonnat, xen-devel

On Thu, Nov 17, 2016 at 04:29:35PM +0000, Ian Jackson wrote:
> Cedric Bosdonnat writes ("Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families."):
> > On Thu, 2016-11-17 at 14:41 +0000, Wei Liu wrote:
> > > You should be able to use ao->domid here, right?
> > 
> > Oh indeed. I discovered this one after writing this patch and forgot
> > about it here. Could it be possible that ao->domid is not the publicly
> > known domain id?
> 
> I think it might conceivably sometimes be a stubdom id.  That depends
> on who sets it when and whether they make a nested ao for a stubdom...
> 

Oh, yes. I misunderstood. In that case libxl_is_stubdom could be handy.

> Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-17 16:34         ` Wei Liu
@ 2016-11-17 16:36           ` Ian Jackson
  2016-11-17 16:38             ` Wei Liu
  0 siblings, 1 reply; 47+ messages in thread
From: Ian Jackson @ 2016-11-17 16:36 UTC (permalink / raw)
  To: Wei Liu; +Cc: Cedric Bosdonnat, xen-devel

Wei Liu writes ("Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families."):
> Oh, yes. I misunderstood. In that case libxl_is_stubdom could be handy.

How about this: check whether the ao is a nested ao, and if so, fish
the domid out of its parent ?

Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

* Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families.
  2016-11-17 16:36           ` Ian Jackson
@ 2016-11-17 16:38             ` Wei Liu
  0 siblings, 0 replies; 47+ messages in thread
From: Wei Liu @ 2016-11-17 16:38 UTC (permalink / raw)
  To: Ian Jackson; +Cc: Wei Liu, Cedric Bosdonnat, xen-devel

On Thu, Nov 17, 2016 at 04:36:54PM +0000, Ian Jackson wrote:
> Wei Liu writes ("Re: [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families."):
> > Oh, yes. I misunderstood. In that case libxl_is_stubdom could be handy.
> 
> How about this: check whether the ao is a nested ao, and if so, fish
> the domid out of its parent ?
> 

Yes, this is better than calling libxl_is_stubdom.

> Ian.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2016-11-17 16:38 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15 10:18 [PATCH 00/35] libxl LOG*D functions Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 01/35] libxl: add LIBXL_LOGD_* and LOG*D function families Cédric Bosdonnat
2016-11-17 14:41   ` Wei Liu
2016-11-17 16:01     ` Cedric Bosdonnat
2016-11-17 16:12       ` Wei Liu
2016-11-17 16:29       ` Ian Jackson
2016-11-17 16:34         ` Wei Liu
2016-11-17 16:36           ` Ian Jackson
2016-11-17 16:38             ` Wei Liu
2016-11-15 10:18 ` [PATCH 02/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 03/35] libxl.c: switch to LOG*D use (refactored messages) Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 04/35] libxl.c: switch to LOG*D use Cédric Bosdonnat
2016-11-17 14:50   ` Wei Liu
2016-11-17 16:03     ` Cedric Bosdonnat
2016-11-17 16:15       ` Wei Liu
2016-11-17 16:30       ` Ian Jackson
2016-11-15 10:18 ` [PATCH 05/35] libxl/libxl_bootloader.c: used LOG*D functions Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 06/35] libxl/libxl_checkpoint_device.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 07/35] libxl/libxl_colo.h: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 08/35] libxl/libxl_colo_nic.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 09/35] libxl/libxl_colo_proxy.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 10/35] libxl/libxl_colo_qdisk.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 11/35] libxl/libxl_colo_restore.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 12/35] libxl/libxl_colo_save.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 13/35] libxl/libxl_create.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 14/35] libxl/libxl_device.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 15/35] libxl/libxl_dm.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 16/35] libxl/libxl_dom_save.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 17/35] libxl/libxl_dom_suspend.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 18/35] libxl/libxl_freebsd.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 19/35] libxl/libxl_internal.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 20/35] libxl/libxl_linux.c: " Cédric Bosdonnat
2016-11-15 10:18 ` [PATCH 21/35] libxl/libxl_netbsd.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 22/35] libxl/libxl_netbuffer.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 23/35] libxl/libxl_nic.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 24/35] libxl/libxl_no_colo.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 25/35] libxl/libxl_pci.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 26/35] libxl/libxl_psr.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 27/35] libxl/libxl_pvusb.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 28/35] libxl/libxl_qmp.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 29/35] libxl/libxl_remus.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 30/35] libxl/libxl_save_callout.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 31/35] libxl/libxl_stream_write.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 32/35] libxl/libxl_vnuma.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 33/35] libxl/libxl_vtpm.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 34/35] libxl/libxl_x86.c: " Cédric Bosdonnat
2016-11-15 10:19 ` [PATCH 35/35] libxl/libxl_xshelp.c: " Cédric Bosdonnat

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.