[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2 of 2] libxc: Print domain ID in save restore messages



XenServer redirects all libxc output to /var/log/messages, so when a
large stress test is running, it's hard to tell which message belongs
to which domain.

This patch adds the domain ID to output made by the save/restore
functions.

To do this, we introduce a layer of indirection in the libxc print
macros, so that they can be "interposed on" by individual functions.

We then add the domain ID to the context structs in the save and restore
paths, and replace the toplevel macros with ones which add the domain to the
output.

Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxxxxx>

diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c
+++ b/tools/libxc/xc_domain_restore.c
@@ -33,7 +33,20 @@
 #include <xen/hvm/ioreq.h>
 #include <xen/hvm/params.h>
 
+/* Override default output f'ns with functions that include the domain id */
+#undef IPRINTF
+#define IPRINTF(_F, _A...) _IPRINTF("d%d:" _F, ctx->dom, ## _A)
+#undef DPRINTF
+#define DPRINTF(_F, _A...) _DPRINTF("d%d:" _F, ctx->dom, ## _A)
+#undef DBGPRINTF
+#define DBGPRINTF(_F, _A...) _DBGPRINTF("d%d:" _F, ctx->dom, ## _A)
+#undef ERROR
+#define ERROR(_F, _A...) _ERROR("d%d:" _F, ctx->dom, ## _A)
+#undef PERROR
+#define PERROR(_F, _A...) _PERROR("d%d:" _F, ctx->dom, ## _A)
+
 struct restore_ctx {
+    int dom;
     unsigned long max_mfn; /* max mfn of the current host machine */
     unsigned long hvirt_start; /* virtual starting address of the hypervisor */
     unsigned int pt_levels; /* #levels of page tables used by the current 
guest */
@@ -1362,6 +1375,9 @@ int xc_domain_restore(xc_interface *xch,
 
     memset(ctx, 0, sizeof(*ctx));
 
+    /* Tag all errors with domain */
+    ctx->dom=dom;
+
     ctxt = xc_hypercall_buffer_alloc(xch, ctxt, sizeof(*ctxt));
 
     if ( ctxt == NULL )
diff --git a/tools/libxc/xc_domain_save.c b/tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c
+++ b/tools/libxc/xc_domain_save.c
@@ -34,6 +34,19 @@
 
 #include <xen/hvm/params.h>
 
+/* Override default output f'ns with functions that include the domain id */
+#undef IPRINTF
+#define IPRINTF(_F, _A...) _IPRINTF("d%d:" _F, ctx->dom, ## _A)
+#undef DPRINTF
+#define DPRINTF(_F, _A...) _DPRINTF("d%d:" _F, ctx->dom, ## _A)
+#undef DBGPRINTF
+#define DBGPRINTF(_F, _A...) _DBGPRINTF("d%d:" _F, ctx->dom, ## _A)
+#undef ERROR
+#define ERROR(_F, _A...) _ERROR("d%d:" _F, ctx->dom, ## _A)
+#undef PERROR
+#define PERROR(_F, _A...) _PERROR("d%d:" _F, ctx->dom, ## _A)
+
+
 /*
 ** Default values for important tuning parameters. Can override by passing
 ** non-zero replacement values to xc_domain_save().
@@ -45,6 +58,7 @@
 #define DEF_MAX_FACTOR   3   /* never send more than 3x p2m_size  */
 
 struct save_ctx {
+    int dom;
     unsigned long hvirt_start; /* virtual starting address of the hypervisor */
     unsigned int pt_levels; /* #levels of page tables used by the current 
guest */
     unsigned long max_mfn; /* max mfn of the whole machine */
@@ -529,6 +543,7 @@ static int canonicalize_pagetable(struct
     return race;
 }
 
+/* NB Since this is a public function, we can't use the defined print macros */
 xen_pfn_t *xc_map_m2p(xc_interface *xch,
                                  unsigned long max_mfn,
                                  int prot,
@@ -547,20 +562,20 @@ xen_pfn_t *xc_map_m2p(xc_interface *xch,
     extent_start = calloc(m2p_chunks, sizeof(xen_pfn_t));
     if ( !extent_start )
     {
-        ERROR("failed to allocate space for m2p mfns");
+        _ERROR("failed to allocate space for m2p mfns");
         goto err0;
     }
 
     if ( xc_machphys_mfn_list(xch, m2p_chunks, extent_start) )
     {
-        PERROR("xc_get_m2p_mfns");
+        _PERROR("xc_get_m2p_mfns");
         goto err1;
     }
 
     entries = calloc(m2p_chunks, sizeof(privcmd_mmap_entry_t));
     if (entries == NULL)
     {
-        ERROR("failed to allocate space for mmap entries");
+        _ERROR("failed to allocate space for mmap entries");
         goto err1;
     }
 
@@ -572,7 +587,7 @@ xen_pfn_t *xc_map_m2p(xc_interface *xch,
                        entries, m2p_chunks);
     if (m2p == NULL)
     {
-        PERROR("xc_mmap_foreign_ranges failed");
+        _PERROR("xc_mmap_foreign_ranges failed");
         goto err2;
     }
 
@@ -913,6 +928,9 @@ int xc_domain_save(xc_interface *xch, in
 
     memset(ctx, 0, sizeof(*ctx));
 
+    /* Tag all errors with domain */
+    ctx->dom=dom;
+
     /* If no explicit control parameters given, use defaults */
     max_iters  = max_iters  ? : DEF_MAX_ITERS;
     max_factor = max_factor ? : DEF_MAX_FACTOR;
diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h
+++ b/tools/libxc/xc_private.h
@@ -119,14 +119,21 @@ void xc_report_progress_step(xc_interfac
 
 /* anamorphic macros:  struct xc_interface *xch  must be in scope */
 
-#define IPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_INFO,0, _f , 
## _a)
-#define DPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DETAIL,0, _f 
, ## _a)
-#define DBGPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DEBUG,0, 
_f , ## _a)
+/* Provide these macros, as well as macros that can be #undef'd and 
over-ridden */
+#define _IPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_INFO,0, _f 
, ## _a)
+#define _DPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DETAIL,0, 
_f , ## _a)
+#define _DBGPRINTF(_f, _a...) xc_report(xch, xch->error_handler, XTL_DEBUG,0, 
_f , ## _a)
 
-#define ERROR(_m, _a...)  xc_report_error(xch,XC_INTERNAL_ERROR,_m , ## _a )
-#define PERROR(_m, _a...) xc_report_error(xch,XC_INTERNAL_ERROR,_m \
+#define _ERROR(_m, _a...)  xc_report_error(xch,XC_INTERNAL_ERROR,_m , ## _a )
+#define _PERROR(_m, _a...) xc_report_error(xch,XC_INTERNAL_ERROR,_m \
                   " (%d = %s)", ## _a , errno, xc_strerror(xch, errno))
 
+#define IPRINTF(_f, _a...) _IPRINTF(_f, ## _a)
+#define DPRINTF(_f, _a...) _DPRINTF(_f, ## _a)
+#define DBGPRINTF(_f, _a...) _DBGPRINTF(_f, ## _a)
+#define ERROR(_m, _a...) _ERROR(_m, ## _a)
+#define PERROR(_m, _a...) _PERROR(_m, ## _a)
+
 /*
  * HYPERCALL ARGUMENT BUFFERS
  *

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.