diff -r 02b341ca3612 tools/libxc/xc_private.c --- a/tools/libxc/xc_private.c Wed Aug 18 16:36:25 2010 +0100 +++ b/tools/libxc/xc_private.c Wed Aug 18 17:22:34 2010 +0100 @@ -49,6 +49,7 @@ xc_interface *xc_interface_open(xentooll goto err; } + fprintf(stderr, "%s %p\n", __func__, xch); return xch; err: @@ -62,6 +63,8 @@ int xc_interface_close(xc_interface *xch int xc_interface_close(xc_interface *xch) { int rc = 0; + + fprintf(stderr, "%s xch:%p\n", __func__, xch); xtl_logger_destroy(xch->dombuild_logger_tofree); xtl_logger_destroy(xch->error_handler_tofree); @@ -218,14 +221,17 @@ static void _xc_clean_hcall_buf(void *m) { struct hcall_buf *hcall_buf = m; + fprintf(stderr, "%s\n", __func__); if ( hcall_buf ) { if ( hcall_buf->buf ) { + fprintf(stderr, "%s unlock and free hcall_buf->buf %p\n", __func__, hcall_buf->buf); unlock_pages(hcall_buf->buf, PAGE_SIZE); free(hcall_buf->buf); } + fprintf(stderr, "%s free hcall_buf %p\n", __func__, hcall_buf); free(hcall_buf); } @@ -234,11 +240,14 @@ static void _xc_clean_hcall_buf(void *m) static void _xc_init_hcall_buf(void) { + fprintf(stderr, "%s\n", __func__); pthread_key_create(&hcall_buf_pkey, _xc_clean_hcall_buf); } static void xc_clean_hcall_buf(void) { + fprintf(stderr, "%s\n", __func__); + pthread_once(&hcall_buf_pkey_once, _xc_init_hcall_buf); _xc_clean_hcall_buf(pthread_getspecific(hcall_buf_pkey)); @@ -247,6 +256,8 @@ int hcall_buf_prep(void **addr, size_t l int hcall_buf_prep(void **addr, size_t len) { struct hcall_buf *hcall_buf; + + fprintf(stderr, "%s(%p,%zd)\n", __func__, *addr, len); pthread_once(&hcall_buf_pkey_once, _xc_init_hcall_buf); @@ -257,6 +268,7 @@ int hcall_buf_prep(void **addr, size_t l if ( !hcall_buf ) goto out; pthread_setspecific(hcall_buf_pkey, hcall_buf); + fprintf(stderr, "%s hcall_buf allocated at %p\n", __func__, hcall_buf); } if ( !hcall_buf->buf ) @@ -268,10 +280,12 @@ int hcall_buf_prep(void **addr, size_t l hcall_buf->buf = NULL; goto out; } + fprintf(stderr, "%s hcall_buf->buf allocated at %p\n", __func__, hcall_buf->buf); } if ( (len < PAGE_SIZE) && !hcall_buf->oldbuf ) { + fprintf(stderr, "%s using preallocated buffer at %p for %p\n", __func__, hcall_buf->buf, *addr); memcpy(hcall_buf->buf, *addr, len); hcall_buf->oldbuf = *addr; *addr = hcall_buf->buf; @@ -279,6 +293,7 @@ int hcall_buf_prep(void **addr, size_t l } out: + fprintf(stderr, "%s locking buffer at %p %zd\n", __func__, *addr, len); return lock_pages(*addr, len); } @@ -286,14 +301,18 @@ void hcall_buf_release(void **addr, size { struct hcall_buf *hcall_buf = pthread_getspecific(hcall_buf_pkey); + fprintf(stderr, "%s(%p,%zd)\n", __func__, *addr, len); + if ( hcall_buf && (hcall_buf->buf == *addr) ) { + fprintf(stderr, "%s releasing preallocated buffer at %p for %p\n", __func__, hcall_buf->buf, hcall_buf->oldbuf); memcpy(hcall_buf->oldbuf, *addr, len); *addr = hcall_buf->oldbuf; hcall_buf->oldbuf = NULL; } else { + fprintf(stderr, "%s unlocking buffer at %p %zd\n", __func__, *addr, len); unlock_pages(*addr, len); } }