aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-06-07 14:07:36 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-06-07 14:07:36 +0100
commit2928514138945c3ed7e5d34ca726d2904476852c (patch)
treef7485ca1a67cd730f61783b40872761ff5386aa6
parente56ed2dc521d9eccbcfb4db7de22ab621705864f (diff)
downloadxen-2928514138945c3ed7e5d34ca726d2904476852c.tar.gz
xen-2928514138945c3ed7e5d34ca726d2904476852c.tar.bz2
xen-2928514138945c3ed7e5d34ca726d2904476852c.zip
[LIBXC] Convert all printf/fprintf uses to use a macro instead.
Thus all can be disabled at compile time. It would be easy to make enabling/disabling a run-time option too. Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r--tools/libxc/xc_core.c4
-rw-r--r--tools/libxc/xc_domain.c8
-rw-r--r--tools/libxc/xc_hvm_build.c4
-rw-r--r--tools/libxc/xc_ia64_stubs.c2
-rw-r--r--tools/libxc/xc_linux_build.c38
-rw-r--r--tools/libxc/xc_linux_restore.c2
-rw-r--r--tools/libxc/xc_linux_save.c12
-rw-r--r--tools/libxc/xc_pagetab.c20
-rw-r--r--tools/libxc/xc_private.c10
-rw-r--r--tools/libxc/xc_private.h51
-rw-r--r--tools/libxc/xc_ptrace.c18
-rw-r--r--tools/libxc/xc_ptrace.h1
-rw-r--r--tools/libxc/xc_ptrace_core.c8
-rw-r--r--tools/libxc/xg_private.h18
-rw-r--r--tools/libxc/xg_save_restore.h22
15 files changed, 102 insertions, 116 deletions
diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c
index ca2ad0bfb5..efaf397abf 100644
--- a/tools/libxc/xc_core.c
+++ b/tools/libxc/xc_core.c
@@ -83,12 +83,12 @@ xc_domain_dumpcore_via_callback(int xc_handle,
if ( (page_array = malloc(nr_pages * sizeof(xen_pfn_t))) == NULL )
{
- printf("Could not allocate memory\n");
+ IPRINTF("Could not allocate memory\n");
goto error_out;
}
if ( xc_get_pfn_list(xc_handle, domid, page_array, nr_pages) != nr_pages )
{
- printf("Could not get the page frame list\n");
+ IPRINTF("Could not get the page frame list\n");
goto error_out;
}
sts = dump_rtn(args, (char *)page_array, nr_pages * sizeof(xen_pfn_t));
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index da508f7435..4f1d8561da 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -310,7 +310,7 @@ int xc_domain_memory_increase_reservation(int xc_handle,
if ( err > 0 )
{
- fprintf(stderr, "Failed allocation for dom %d: "
+ DPRINTF("Failed allocation for dom %d: "
"%ld pages order %d addr_bits %d\n",
domid, nr_extents, extent_order, address_bits);
errno = ENOMEM;
@@ -338,7 +338,7 @@ int xc_domain_memory_decrease_reservation(int xc_handle,
if ( extent_start == NULL )
{
- fprintf(stderr,"decrease_reservation extent_start is NULL!\n");
+ DPRINTF("decrease_reservation extent_start is NULL!\n");
errno = EINVAL;
return -1;
}
@@ -349,7 +349,7 @@ int xc_domain_memory_decrease_reservation(int xc_handle,
if ( err > 0 )
{
- fprintf(stderr,"Failed deallocation for dom %d: %ld pages order %d\n",
+ DPRINTF("Failed deallocation for dom %d: %ld pages order %d\n",
domid, nr_extents, extent_order);
errno = EBUSY;
err = -1;
@@ -380,7 +380,7 @@ int xc_domain_memory_populate_physmap(int xc_handle,
if ( err > 0 )
{
- fprintf(stderr,"Failed deallocation for dom %d: %ld pages order %d\n",
+ DPRINTF("Failed deallocation for dom %d: %ld pages order %d\n",
domid, nr_extents, extent_order);
errno = EBUSY;
err = -1;
diff --git a/tools/libxc/xc_hvm_build.c b/tools/libxc/xc_hvm_build.c
index ac2749ccbd..c6a911b6cf 100644
--- a/tools/libxc/xc_hvm_build.c
+++ b/tools/libxc/xc_hvm_build.c
@@ -207,12 +207,12 @@ static int setup_guest(int xc_handle,
/* memsize is in megabytes */
v_end = (unsigned long long)memsize << 20;
- printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+ IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n"
" Loaded HVM loader: %08lx->%08lx\n"
" TOTAL: %08lx->%016llx\n",
dsi.v_kernstart, dsi.v_kernend,
dsi.v_start, v_end);
- printf(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
+ IPRINTF(" ENTRY ADDRESS: %08lx\n", dsi.v_kernentry);
if ( (v_end - dsi.v_start) > ((unsigned long long)nr_pages << PAGE_SHIFT) )
{
diff --git a/tools/libxc/xc_ia64_stubs.c b/tools/libxc/xc_ia64_stubs.c
index abb3c1f44c..20a02e2b21 100644
--- a/tools/libxc/xc_ia64_stubs.c
+++ b/tools/libxc/xc_ia64_stubs.c
@@ -655,7 +655,7 @@ static int setup_guest( int xc_handle,
vp_eport = xc_evtchn_alloc_unbound(xc_handle, dom, 0);
if (vp_eport < 0) {
- fprintf(stderr, "Couldn't get unbound port from VMX guest.\n");
+ DPRINTF("Couldn't get unbound port from VMX guest.\n");
goto error_out;
}
sp->vcpu_iodata[i].vp_eport = vp_eport;
diff --git a/tools/libxc/xc_linux_build.c b/tools/libxc/xc_linux_build.c
index 40ae8fbd5e..ad3b50f634 100644
--- a/tools/libxc/xc_linux_build.c
+++ b/tools/libxc/xc_linux_build.c
@@ -276,7 +276,7 @@ static int setup_pg_tables_pae(int xc_handle, uint32_t dom,
nmfn = xc_make_page_below_4G(xc_handle, dom, page_array[ppt_alloc]);
if ( nmfn == 0 )
{
- fprintf(stderr, "Couldn't get a page below 4GB :-(\n");
+ DPRINTF("Couldn't get a page below 4GB :-(\n");
goto error_out;
}
page_array[ppt_alloc] = nmfn;
@@ -510,14 +510,14 @@ static int setup_guest(int xc_handle,
#define _p(a) ((void *) (a))
- printf("VIRTUAL MEMORY ARRANGEMENT:\n"
+ IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n"
" Loaded kernel: %p->%p\n"
" Init. ramdisk: %p->%p\n"
" TOTAL: %p->%p\n",
_p(dsi.v_kernstart), _p(dsi.v_kernend),
_p(vinitrd_start), _p(vinitrd_end),
_p(dsi.v_start), _p(v_end));
- printf(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
+ IPRINTF(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
(load_funcs.loadimage)(image, image_size, xc_handle, dom, page_array,
&dsi);
@@ -541,7 +541,7 @@ static int setup_guest(int xc_handle,
*store_mfn = page_array[1];
*console_mfn = page_array[2];
- printf("start_info: 0x%lx at 0x%lx, "
+ IPRINTF("start_info: 0x%lx at 0x%lx, "
"store_mfn: 0x%lx at 0x%lx, "
"console_mfn: 0x%lx at 0x%lx\n",
page_array[0], nr_pages,
@@ -684,8 +684,8 @@ static int setup_guest(int xc_handle,
goto error_out;
}
- printf("Supported features = { %08x }.\n", supported_features[0]);
- printf("Required features = { %08x }.\n", required_features[0]);
+ IPRINTF("Supported features = { %08x }.\n", supported_features[0]);
+ IPRINTF("Required features = { %08x }.\n", required_features[0]);
}
for ( i = 0; i < XENFEAT_NR_SUBMAPS; i++ )
@@ -766,22 +766,22 @@ static int setup_guest(int xc_handle,
#define _p(a) ((void *) (a))
- printf("VIRTUAL MEMORY ARRANGEMENT:\n");
- printf(" Loaded kernel: %p->%p\n", _p(dsi.v_kernstart),
+ IPRINTF("VIRTUAL MEMORY ARRANGEMENT:\n");
+ IPRINTF(" Loaded kernel: %p->%p\n", _p(dsi.v_kernstart),
_p(dsi.v_kernend));
if ( initrd->len )
- printf(" Initial ramdisk: %p->%p\n", _p(vinitrd_start),
+ IPRINTF(" Initial ramdisk: %p->%p\n", _p(vinitrd_start),
_p(vinitrd_start + initrd->len));
- printf(" Phys-Mach map: %p\n", _p(vphysmap_start));
- printf(" Start info: %p\n", _p(vstartinfo_start));
- printf(" Store page: %p\n", _p(vstoreinfo_start));
- printf(" Console page: %p\n", _p(vconsole_start));
+ IPRINTF(" Phys-Mach map: %p\n", _p(vphysmap_start));
+ IPRINTF(" Start info: %p\n", _p(vstartinfo_start));
+ IPRINTF(" Store page: %p\n", _p(vstoreinfo_start));
+ IPRINTF(" Console page: %p\n", _p(vconsole_start));
if ( shadow_mode_enabled )
- printf(" Shared Info page: %p\n", _p(vsharedinfo_start));
- printf(" Page tables: %p\n", _p(vpt_start));
- printf(" Boot stack: %p\n", _p(vstack_start));
- printf(" TOTAL: %p->%p\n", _p(dsi.v_start), _p(v_end));
- printf(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
+ IPRINTF(" Shared Info page: %p\n", _p(vsharedinfo_start));
+ IPRINTF(" Page tables: %p\n", _p(vpt_start));
+ IPRINTF(" Boot stack: %p\n", _p(vstack_start));
+ IPRINTF(" TOTAL: %p->%p\n", _p(dsi.v_start), _p(v_end));
+ IPRINTF(" ENTRY ADDRESS: %p\n", _p(dsi.v_kernentry));
if ( ((v_end - dsi.v_start)>>PAGE_SHIFT) > nr_pages )
{
@@ -883,7 +883,7 @@ static int setup_guest(int xc_handle,
((uint64_t)page_array[count] << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
count) )
{
- fprintf(stderr,"m2p update failure p=%lx m=%"PRIx64"\n",
+ DPRINTF("m2p update failure p=%lx m=%"PRIx64"\n",
count, (uint64_t)page_array[count]);
munmap(physmap, PAGE_SIZE);
goto error_out;
diff --git a/tools/libxc/xc_linux_restore.c b/tools/libxc/xc_linux_restore.c
index c15282a376..da365dffd7 100644
--- a/tools/libxc/xc_linux_restore.c
+++ b/tools/libxc/xc_linux_restore.c
@@ -320,7 +320,7 @@ int xc_linux_restore(int xc_handle, int io_fd,
if (j == -1) {
verify = 1;
- fprintf(stderr, "Entering page verify mode\n");
+ DPRINTF("Entering page verify mode\n");
continue;
}
diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c
index 0a554ee272..fed95cf315 100644
--- a/tools/libxc/xc_linux_save.c
+++ b/tools/libxc/xc_linux_save.c
@@ -288,7 +288,7 @@ static int print_stats(int xc_handle, uint32_t domid, int pages_sent,
d1_cpu_now = xc_domain_get_cpu_usage(xc_handle, domid, /* FIXME */ 0)/1000;
if ( (d0_cpu_now == -1) || (d1_cpu_now == -1) )
- fprintf(stderr, "ARRHHH!!\n");
+ DPRINTF("ARRHHH!!\n");
wall_delta = tv_delta(&wall_now,&wall_last)/1000;
@@ -298,7 +298,7 @@ static int print_stats(int xc_handle, uint32_t domid, int pages_sent,
d1_cpu_delta = (d1_cpu_now - d1_cpu_last)/1000;
if (print)
- fprintf(stderr,
+ DPRINTF(
"delta %lldms, dom0 %d%%, target %d%%, sent %dMb/s, "
"dirtied %dMb/s %" PRId32 " pages\n",
wall_delta,
@@ -339,14 +339,14 @@ static int analysis_phase(int xc_handle, uint32_t domid, int max_pfn,
xc_shadow_control(xc_handle, domid, DOM0_SHADOW_CONTROL_OP_CLEAN,
arr, max_pfn, NULL);
- fprintf(stderr, "#Flush\n");
+ DPRINTF("#Flush\n");
for ( i = 0; i < 40; i++ ) {
usleep(50000);
now = llgettimeofday();
xc_shadow_control(xc_handle, domid, DOM0_SHADOW_CONTROL_OP_PEEK,
NULL, 0, &stats);
- fprintf(stderr, "now= %lld faults= %" PRId32 " dirty= %" PRId32
+ DPRINTF("now= %lld faults= %" PRId32 " dirty= %" PRId32
" dirty_net= %" PRId32 " dirty_block= %" PRId32"\n",
((now-start)+500)/1000,
stats.fault_count, stats.dirty_count,
@@ -961,7 +961,7 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
}
if (debug)
- fprintf(stderr, "%d pfn= %08lx mfn= %08lx [mfn]= %08lx"
+ DPRINTF("%d pfn= %08lx mfn= %08lx [mfn]= %08lx"
" sum= %08lx\n",
iter,
(pfn_type[j] & LTAB_MASK) | pfn_batch[j],
@@ -1042,7 +1042,7 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
int minusone = -1;
memset(to_send, 0xff, BITMAP_SIZE);
debug = 0;
- fprintf(stderr, "Entering debug resend-all mode\n");
+ DPRINTF("Entering debug resend-all mode\n");
/* send "-1" to put receiver into debug mode */
if(!write_exact(io_fd, &minusone, sizeof(int))) {
diff --git a/tools/libxc/xc_pagetab.c b/tools/libxc/xc_pagetab.c
index 64c05c74e6..38843fefb9 100644
--- a/tools/libxc/xc_pagetab.c
+++ b/tools/libxc/xc_pagetab.c
@@ -75,7 +75,7 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
#endif
if (xc_vcpu_getcontext(xc_handle, dom, vcpu, &ctx) != 0) {
- fprintf(stderr, "failed to retreive vcpu context\n");
+ DPRINTF("failed to retreive vcpu context\n");
goto out;
}
cr3 = ((unsigned long long)xen_cr3_to_pfn(ctx.ctrlreg[3])) << PAGE_SHIFT;
@@ -87,12 +87,12 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
#elif defined(__x86_64__)
pml = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ, cr3 >> PAGE_SHIFT);
if (pml == NULL) {
- fprintf(stderr, "failed to map PML4\n");
+ DPRINTF("failed to map PML4\n");
goto out;
}
pmle = *(unsigned long long *)(pml + 8 * ((virt >> L4_PAGETABLE_SHIFT_PAE) & L4_PAGETABLE_MASK_PAE));
if((pmle & 1) == 0) {
- fprintf(stderr, "page entry not present in PML4\n");
+ DPRINTF("page entry not present in PML4\n");
goto out_unmap_pml;
}
#endif
@@ -102,7 +102,7 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
if (pt_levels >= 3) {
pdppage = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ, pmle >> PAGE_SHIFT);
if (pdppage == NULL) {
- fprintf(stderr, "failed to map PDP\n");
+ DPRINTF("failed to map PDP\n");
goto out_unmap_pml;
}
if (pt_levels >= 4)
@@ -114,7 +114,7 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
pdpe = *(unsigned long long *)(pdp + 8 * ((virt >> L3_PAGETABLE_SHIFT_PAE) & L3_PAGETABLE_MASK_PAE));
if((pdpe & 1) == 0) {
- fprintf(stderr, "page entry not present in PDP\n");
+ DPRINTF("page entry not present in PDP\n");
goto out_unmap_pdp;
}
} else {
@@ -125,7 +125,7 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
pd = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ, pdpe >> PAGE_SHIFT);
if (pd == NULL) {
- fprintf(stderr, "failed to map PD\n");
+ DPRINTF("failed to map PD\n");
goto out_unmap_pdp;
}
@@ -135,21 +135,21 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
pde = *(unsigned long long *)(pd + 4 * ((virt >> L2_PAGETABLE_SHIFT) & L2_PAGETABLE_MASK));
if ((pde & 1) == 0) {
- fprintf(stderr, "page entry not present in PD\n");
+ DPRINTF("page entry not present in PD\n");
goto out_unmap_pd;
}
/* Page Table */
if (pde & 0x00000008) { /* 4M page (or 2M in PAE mode) */
- fprintf(stderr, "Cannot currently cope with 2/4M pages\n");
+ DPRINTF("Cannot currently cope with 2/4M pages\n");
exit(-1);
} else { /* 4k page */
pt = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, PROT_READ,
pde >> PAGE_SHIFT);
if (pt == NULL) {
- fprintf(stderr, "failed to map PT\n");
+ DPRINTF("failed to map PT\n");
goto out_unmap_pd;
}
@@ -159,7 +159,7 @@ unsigned long xc_translate_foreign_address(int xc_handle, uint32_t dom,
pte = *(unsigned long long *)(pt + 4 * ((virt >> L1_PAGETABLE_SHIFT) & L1_PAGETABLE_MASK));
if ((pte & 0x00000001) == 0) {
- fprintf(stderr, "page entry not present in PT\n");
+ DPRINTF("page entry not present in PT\n");
goto out_unmap_pt;
}
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 4b238e3a84..1fa2601887 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -294,10 +294,10 @@ int xc_get_pfn_list(int xc_handle,
if (ret >= 0) {
int i, j;
for (i = 0; i < op.u.getmemlist.num_pfns; i += 16) {
- fprintf(stderr, "0x%x: ", i);
+ DPRINTF("0x%x: ", i);
for (j = 0; j < 16; j++)
- fprintf(stderr, "0x%lx ", pfn_buf[i + j]);
- fprintf(stderr, "\n");
+ DPRINTF("0x%lx ", pfn_buf[i + j]);
+ DPRINTF("\n");
}
}
#endif
@@ -440,14 +440,14 @@ unsigned long xc_make_page_below_4G(
if ( xc_domain_memory_decrease_reservation(
xc_handle, domid, 1, 0, &old_mfn) != 0 )
{
- fprintf(stderr,"xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn);
+ DPRINTF("xc_make_page_below_4G decrease failed. mfn=%lx\n",mfn);
return 0;
}
if ( xc_domain_memory_increase_reservation(
xc_handle, domid, 1, 0, 32, &new_mfn) != 0 )
{
- fprintf(stderr,"xc_make_page_below_4G increase failed. mfn=%lx\n",mfn);
+ DPRINTF("xc_make_page_below_4G increase failed. mfn=%lx\n",mfn);
return 0;
}
diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h
index f0ee3cc0ed..6e1b262375 100644
--- a/tools/libxc/xc_private.h
+++ b/tools/libxc/xc_private.h
@@ -28,27 +28,52 @@
#define DECLARE_DOM0_OP dom0_op_t op
#endif
-
#define PAGE_SHIFT XC_PAGE_SHIFT
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
-#define ERROR(_m, _a...) \
+#define DEBUG 1
+#define INFO 1
+#define PROGRESS 0
+
+#if INFO
+#define IPRINTF(_f, _a...) printf(_f , ## _a)
+#else
+#define IPRINTF(_f, _a...) ((void)0)
+#endif
+
+#if DEBUG
+#define DPRINTF(_f, _a...) fprintf(stderr, _f , ## _a)
+#else
+#define DPRINTF(_f, _a...) ((void)0)
+#endif
+
+#if PROGRESS
+#define PPRINTF(_f, _a...) fprintf(stderr, _f , ## _a)
+#else
+#define PPRINTF(_f, _a...)
+#endif
+
+#define ERR(_f, _a...) do { \
+ DPRINTF(_f ": %d\n" , ## _a, errno); \
+ fflush(stderr); } \
+while (0)
+
+#define ERROR(_m, _a...) \
+do { \
+ int __saved_errno = errno; \
+ DPRINTF("ERROR: " _m "\n" , ## _a ); \
+ errno = __saved_errno; \
+} while (0)
+
+#define PERROR(_m, _a...) \
do { \
int __saved_errno = errno; \
- fprintf(stderr, "ERROR: " _m "\n" , ## _a ); \
+ DPRINTF("ERROR: " _m " (%d = %s)\n" , ## _a , \
+ __saved_errno, strerror(__saved_errno)); \
errno = __saved_errno; \
} while (0)
-
-#define PERROR(_m, _a...) \
-do { \
- int __saved_errno = errno; \
- fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
- __saved_errno, strerror(__saved_errno)); \
- errno = __saved_errno; \
-} while (0)
-
static inline void safe_munlock(const void *addr, size_t len)
{
int saved_errno = errno;
@@ -88,7 +113,7 @@ static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
{
if ( errno == EACCES )
- fprintf(stderr, "Dom0 operation failed -- need to"
+ DPRINTF("Dom0 operation failed -- need to"
" rebuild the user-space tool set?\n");
}
diff --git a/tools/libxc/xc_ptrace.c b/tools/libxc/xc_ptrace.c
index e39f3fc775..bfe455bd5a 100644
--- a/tools/libxc/xc_ptrace.c
+++ b/tools/libxc/xc_ptrace.c
@@ -143,7 +143,7 @@ online_vcpus_changed(cpumap_t cpumap)
{
if (handlers.td_create) handlers.td_create(index - 1);
} else {
- printf("thread death: %d\n", index - 1);
+ IPRINTF("thread death: %d\n", index - 1);
if (handlers.td_death) handlers.td_death(index - 1);
}
changed_cpumap &= ~(1 << (index - 1));
@@ -368,13 +368,13 @@ map_domain_va(
nr_pages = npgs;
if ( (page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL )
{
- printf("Could not allocate memory\n");
+ IPRINTF("Could not allocate memory\n");
return NULL;
}
if ( xc_get_pfn_list(xc_handle, current_domid,
page_array, nr_pages) != nr_pages )
{
- printf("Could not get the page frame list\n");
+ IPRINTF("Could not get the page frame list\n");
return NULL;
}
}
@@ -433,7 +433,7 @@ __xc_waitdomain(
retval = do_dom0_op(xc_handle, &op);
if ( retval || (op.u.getdomaininfo.domain != domain) )
{
- printf("getdomaininfo failed\n");
+ IPRINTF("getdomaininfo failed\n");
goto done;
}
*status = op.u.getdomaininfo.flags;
@@ -454,7 +454,7 @@ __xc_waitdomain(
}
done:
if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
- printf("get_online_cpumap failed\n");
+ IPRINTF("get_online_cpumap failed\n");
if (online_cpumap != cpumap)
online_vcpus_changed(cpumap);
return retval;
@@ -595,7 +595,7 @@ xc_ptrace(
if ( retval || (op.u.getdomaininfo.domain != current_domid) )
goto out_error_dom0;
if ( op.u.getdomaininfo.flags & DOMFLAGS_PAUSED )
- printf("domain currently paused\n");
+ IPRINTF("domain currently paused\n");
else if ((retval = xc_domain_pause(xc_handle, current_domid)))
goto out_error_dom0;
op.cmd = DOM0_SETDEBUGGING;
@@ -605,7 +605,7 @@ xc_ptrace(
goto out_error_dom0;
if (get_online_cpumap(xc_handle, &op.u.getdomaininfo, &cpumap))
- printf("get_online_cpumap failed\n");
+ IPRINTF("get_online_cpumap failed\n");
if (online_cpumap != cpumap)
online_vcpus_changed(cpumap);
break;
@@ -619,7 +619,7 @@ xc_ptrace(
goto out_unsupported; /* XXX not yet supported */
case PTRACE_TRACEME:
- printf("PTRACE_TRACEME is an invalid request under Xen\n");
+ IPRINTF("PTRACE_TRACEME is an invalid request under Xen\n");
goto out_error;
}
@@ -633,7 +633,7 @@ xc_ptrace(
out_unsupported:
#ifdef DEBUG
- printf("unsupported xc_ptrace request %s\n", ptrace_names[request]);
+ IPRINTF("unsupported xc_ptrace request %s\n", ptrace_names[request]);
#endif
errno = ENOSYS;
return -1;
diff --git a/tools/libxc/xc_ptrace.h b/tools/libxc/xc_ptrace.h
index 284c648dfc..1c3f10b1d0 100644
--- a/tools/libxc/xc_ptrace.h
+++ b/tools/libxc/xc_ptrace.h
@@ -160,7 +160,6 @@ struct gdb_regs {
}
#endif
-#define printval(x) printf("%s = %lx\n", #x, (long)x);
#endif
typedef void (*thr_ev_handler_t)(long);
diff --git a/tools/libxc/xc_ptrace_core.c b/tools/libxc/xc_ptrace_core.c
index b413c6c658..d57da3f172 100644
--- a/tools/libxc/xc_ptrace_core.c
+++ b/tools/libxc/xc_ptrace_core.c
@@ -85,7 +85,7 @@ map_domain_va_core(unsigned long domfd, int cpu, void * guest_va,
map_mtop_offset(page_phys[cpu]));
if (v == MAP_FAILED)
{
- printf("cr3 %lx pde %lx page %lx pti %lx\n", cr3[cpu], pde, page, l1_table_offset_i386(va));
+ IPRINTF("cr3 %lx pde %lx page %lx pti %lx\n", cr3[cpu], pde, page, l1_table_offset_i386(va));
page_phys[cpu] = 0;
return NULL;
}
@@ -113,7 +113,7 @@ xc_waitdomain_core(
return -1;
if (header.xch_magic != XC_CORE_MAGIC) {
- printf("Magic number missmatch: 0x%08x (file) != "
+ IPRINTF("Magic number missmatch: 0x%08x (file) != "
" 0x%08x (code)\n", header.xch_magic,
XC_CORE_MAGIC);
return -1;
@@ -132,7 +132,7 @@ xc_waitdomain_core(
if ((p2m_array = malloc(nr_pages * sizeof(unsigned long))) == NULL)
{
- printf("Could not allocate p2m_array\n");
+ IPRINTF("Could not allocate p2m_array\n");
return -1;
}
@@ -142,7 +142,7 @@ xc_waitdomain_core(
if ((m2p_array = malloc((1<<20) * sizeof(unsigned long))) == NULL)
{
- printf("Could not allocate m2p array\n");
+ IPRINTF("Could not allocate m2p array\n");
return -1;
}
bzero(m2p_array, sizeof(unsigned long)* 1 << 20);
diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h
index 3dbcf4f51b..16dcc966d5 100644
--- a/tools/libxc/xg_private.h
+++ b/tools/libxc/xg_private.h
@@ -12,6 +12,7 @@
#include "xenctrl.h"
#include "xenguest.h"
+#include "xc_private.h"
#include <xen/sys/privcmd.h>
#include <xen/memory.h>
@@ -129,23 +130,6 @@ typedef unsigned long l4_pgentry_t;
(((_a) >> L4_PAGETABLE_SHIFT) & (L4_PAGETABLE_ENTRIES - 1))
#endif
-#define ERROR(_m, _a...) \
-do { \
- int __saved_errno = errno; \
- fprintf(stderr, "ERROR: " _m "\n" , ## _a ); \
- errno = __saved_errno; \
-} while (0)
-
-
-#define PERROR(_m, _a...) \
-do { \
- int __saved_errno = errno; \
- fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
- __saved_errno, strerror(__saved_errno)); \
- errno = __saved_errno; \
-} while (0)
-
-
struct domain_setup_info
{
unsigned long v_start;
diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h
index e3fd1f2821..0000eb7843 100644
--- a/tools/libxc/xg_save_restore.h
+++ b/tools/libxc/xg_save_restore.h
@@ -6,28 +6,6 @@
#include "xc_private.h"
-#define DEBUG 1
-#define PROGRESS 0
-
-#define ERR(_f, _a...) do { \
- fprintf(stderr, _f ": %d\n" , ## _a, errno);\
- fflush(stderr); } \
-while (0)
-
-#if DEBUG
-#define DPRINTF(_f, _a...) fprintf(stderr, _f , ## _a)
-#else
-#define DPRINTF(_f, _a...) ((void)0)
-#endif
-
-
-#if PROGRESS
-#define PPRINTF(_f, _a...) fprintf(stderr, _f , ## _a)
-#else
-#define PPRINTF(_f, _a...)
-#endif
-
-
/*
** We process save/restore/migrate in batches of pages; the below
** determines how many pages we (at maximum) deal with in each batch.