diff -r 86640f3de07f tools/libxc/xc_hcall_buf.c --- a/tools/libxc/xc_hcall_buf.c Mon Nov 01 10:03:55 2010 +0000 +++ b/tools/libxc/xc_hcall_buf.c Mon Nov 01 10:21:05 2010 +0000 @@ -120,17 +120,22 @@ int xc__hypercall_bounce_pre(xc_interfac */ if ( b->ubuf == NULL ) { + fprintf(stderr, "%s user buffer is NULL at %d\n", __func__, __LINE__); b->hbuf = NULL; return 0; } p = xc__hypercall_buffer_alloc(xch, b, b->sz); if ( p == NULL ) + { + fprintf(stderr, "%s failed at %d\n", __func__, __LINE__); return -1; + } if ( b->dir == XC_HYPERCALL_BUFFER_BOUNCE_IN || b->dir == XC_HYPERCALL_BUFFER_BOUNCE_BOTH ) memcpy(b->hbuf, b->ubuf, b->sz); + fprintf(stderr, "%s bounced %zd bytes from user buf %p into hcall buf %p\n", __func__, b->sz, b->ubuf, b->hbuf); return 0; } @@ -143,11 +148,15 @@ void xc__hypercall_bounce_post(xc_interf abort(); if ( b->hbuf == NULL ) + { + fprintf(stderr, "%s hcall buffer is NULL at %d (%p, %p)\n", __func__, __LINE__, b->hbuf, b->ubuf); return; + } if ( b->dir == XC_HYPERCALL_BUFFER_BOUNCE_OUT || b->dir == XC_HYPERCALL_BUFFER_BOUNCE_BOTH ) memcpy(b->ubuf, b->hbuf, b->sz); + fprintf(stderr, "%s bounced %zd bytes back from hcall buf %p into user buf %p\n", __func__, b->sz, b->hbuf, b->ubuf); xc__hypercall_buffer_free(xch, b); } diff -r 86640f3de07f tools/libxc/xc_pm.c --- a/tools/libxc/xc_pm.c Mon Nov 01 10:03:55 2010 +0000 +++ b/tools/libxc/xc_pm.c Mon Nov 01 10:21:05 2010 +0000 @@ -128,20 +128,32 @@ int xc_pm_get_cxstat(xc_interface *xch, DECLARE_NAMED_HYPERCALL_BOUNCE(residencies, &cxpt->residencies, 0, XC_HYPERCALL_BUFFER_BOUNCE_BOTH); int max_cx, ret; - if( !cxpt || !(cxpt->triggers) || !(cxpt->residencies) ) - return -EINVAL; + if( !cxpt || !(cxpt->triggers) || !(cxpt->residencies) ) { + fprintf(stderr, "%s failing at %d\n", __func__, __LINE__); + errno = EINVAL; + return -1; + } if ( (ret = xc_pm_get_max_cx(xch, cpuid, &max_cx)) ) + { + fprintf(stderr, "%s failing at %d\n", __func__, __LINE__); goto unlock_0; + } HYPERCALL_BOUNCE_SET_SIZE(triggers, max_cx * sizeof(uint64_t)); HYPERCALL_BOUNCE_SET_SIZE(residencies, max_cx * sizeof(uint64_t)); ret = -1; if ( xc_hypercall_bounce_pre(xch, triggers) ) + { + fprintf(stderr, "%s failing at %d\n", __func__, __LINE__); goto unlock_0; + } if ( xc_hypercall_bounce_pre(xch, residencies) ) + { + fprintf(stderr, "%s failing at %d\n", __func__, __LINE__); goto unlock_1; + } sysctl.cmd = XEN_SYSCTL_get_pmstat; sysctl.u.get_pmstat.type = PMSTAT_get_cxstat; @@ -150,7 +162,10 @@ int xc_pm_get_cxstat(xc_interface *xch, set_xen_guest_handle(sysctl.u.get_pmstat.u.getcx.residencies, residencies); if ( (ret = xc_sysctl(xch, &sysctl)) ) + { + fprintf(stderr, "%s failing at %d\n", __func__, __LINE__); goto unlock_2; + } cxpt->nr = sysctl.u.get_pmstat.u.getcx.nr; cxpt->last = sysctl.u.get_pmstat.u.getcx.last; @@ -166,6 +181,7 @@ unlock_1: unlock_1: xc_hypercall_bounce_post(xch, triggers); unlock_0: + fprintf(stderr, "%s done returning %d\n", __func__, ret); return ret; } diff -r 86640f3de07f tools/misc/xenpm.c --- a/tools/misc/xenpm.c Mon Nov 01 10:03:55 2010 +0000 +++ b/tools/misc/xenpm.c Mon Nov 01 10:21:05 2010 +0000 @@ -115,12 +115,15 @@ static int get_cxstat_by_cpuid(xc_interf if ( !cxstat ) return -EINVAL; + fprintf(stderr, "get_cxstat_by_cpuid: max_cx %d for cpuid %d\n", max_cx_num, cpuid); + cxstat->triggers = malloc(max_cx_num * sizeof(uint64_t)); if ( !cxstat->triggers ) return -ENOMEM; cxstat->residencies = malloc(max_cx_num * sizeof(uint64_t)); if ( !cxstat->residencies ) { + fprintf(stderr, "failed to allocate residencies, freeing triggers\n"); free(cxstat->triggers); return -ENOMEM; } @@ -129,13 +132,14 @@ static int get_cxstat_by_cpuid(xc_interf if( ret ) { int temp = errno; + fprintf(stderr, "xc_pm_get_cx_stat failed %d %d, freeing buffers\n", ret, errno); free(cxstat->triggers); free(cxstat->residencies); cxstat->triggers = NULL; cxstat->residencies = NULL; return temp; } - + fprintf(stderr, "get_cx_stat_by_cpuid succeeded for cpu %d\n", cpuid); return 0; }