From 5cc436c1d2b3b0be3f42104582f53eec3969b43a Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 28 May 2010 09:30:19 +0100 Subject: libxc: eliminate static variables, use xentoollog; API change This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson --- tools/libxc/xc_dom_core.c | 253 ++++++++++++++++++++++++---------------------- 1 file changed, 133 insertions(+), 120 deletions(-) (limited to 'tools/libxc/xc_dom_core.c') diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c index df8e83b6ba..3dbb00fc37 100644 --- a/tools/libxc/xc_dom_core.c +++ b/tools/libxc/xc_dom_core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "xg_private.h" #include "xc_dom.h" @@ -23,74 +24,79 @@ /* ------------------------------------------------------------------------ */ /* debugging */ -FILE *xc_dom_logfile = NULL; -void xc_dom_loginit(void) -{ - if ( xc_dom_logfile ) - return; - xc_dom_logfile = fopen("/var/log/xen/domain-builder-ng.log", "a"); - setvbuf(xc_dom_logfile, NULL, _IONBF, 0); - xc_dom_printf("### ----- xc domain builder logfile opened -----\n"); + +static const char *default_logfile = "/var/log/xen/domain-builder-ng.log"; + +int xc_dom_loginit(xc_interface *xch) { + if (xch->dombuild_logger) return 0; + + if (!xch->dombuild_logger_file) { + xch->dombuild_logger_file = fopen(default_logfile, "a"); + if (!xch->dombuild_logger_file) { + PERROR("Could not open logfile `%s'", default_logfile); + return -1; + } + } + + xch->dombuild_logger = xch->dombuild_logger_tofree = + (xentoollog_logger*) + xtl_createlogger_stdiostream(xch->dombuild_logger_file, XTL_DETAIL, + XTL_STDIOSTREAM_SHOW_DATE|XTL_STDIOSTREAM_SHOW_PID); + if (!xch->dombuild_logger) + return -1; + + xc_dom_printf(xch, "### ----- xc domain builder logfile opened -----"); + + return 0; } -int xc_dom_printf(const char *fmt, ...) +void xc_dom_printf(xc_interface *xch, const char *fmt, ...) { va_list args; - char buf[1024]; - int rc; - - if ( !xc_dom_logfile ) - return 0; - + if (!xch->dombuild_logger) return; va_start(args, fmt); - rc = vsnprintf(buf, sizeof(buf), fmt, args); + xtl_logv(xch->dombuild_logger, XTL_DETAIL, -1, "domainbuilder", fmt, args); va_end(args); - rc = fwrite(buf, rc, 1, xc_dom_logfile); - - return rc; } -int xc_dom_panic_func(const char *file, int line, xc_error_code err, - const char *fmt, ...) +void xc_dom_panic_func(xc_interface *xch, + const char *file, int line, xc_error_code err, + const char *fmt, ...) { va_list args; - FILE *fp = stderr; - int rc = 0; - char pos[256]; char msg[XC_MAX_ERROR_MSG_LEN]; - if ( xc_dom_logfile ) - fp = xc_dom_logfile; - - snprintf(pos, sizeof(pos), "%s:%d: panic: ", file, line); va_start(args, fmt); vsnprintf(msg, sizeof(msg), fmt, args); va_end(args); - xc_set_error(err, "%s", msg); - rc = fprintf(fp, "%s%s", pos, msg); - return rc; + msg[sizeof(msg)-1] = 0; + + xc_report(xch, + xch->dombuild_logger ? xch->dombuild_logger : xch->error_handler, + XTL_ERROR, err, "panic: %s:%d: %s", + file, line, msg); } -static void print_mem(const char *name, size_t mem) +static void print_mem(struct xc_dom_image *dom, const char *name, size_t mem) { if ( mem > (32 * 1024 * 1024) ) - xc_dom_printf("%-24s : %zd MB\n", name, mem / (1024 * 1024)); + DOMPRINTF("%-24s : %zd MB", name, mem / (1024 * 1024)); else if ( mem > (32 * 1024) ) - xc_dom_printf("%-24s : %zd kB\n", name, mem / 1024); + DOMPRINTF("%-24s : %zd kB", name, mem / 1024); else - xc_dom_printf("%-24s : %zd bytes\n", name, mem); + DOMPRINTF("%-24s : %zd bytes", name, mem); } void xc_dom_log_memory_footprint(struct xc_dom_image *dom) { - xc_dom_printf("domain builder memory footprint\n"); - xc_dom_printf(" allocated\n"); - print_mem(" malloc", dom->alloc_malloc); - print_mem(" anon mmap", dom->alloc_mem_map); - xc_dom_printf(" mapped\n"); - print_mem(" file mmap", dom->alloc_file_map); - print_mem(" domU mmap", dom->alloc_domU_map); + DOMPRINTF("domain builder memory footprint"); + DOMPRINTF(" allocated"); + print_mem(dom, " malloc", dom->alloc_malloc); + print_mem(dom, " anon mmap", dom->alloc_mem_map); + DOMPRINTF(" mapped"); + print_mem(dom, " file mmap", dom->alloc_file_map); + print_mem(dom, " domU mmap", dom->alloc_domU_map); } /* ------------------------------------------------------------------------ */ @@ -108,7 +114,7 @@ void *xc_dom_malloc(struct xc_dom_image *dom, size_t size) dom->memblocks = block; dom->alloc_malloc += sizeof(*block) + size; if ( size > (100 * 1024) ) - print_mem(__FUNCTION__, size); + print_mem(dom, __FUNCTION__, size); return block->memory; } @@ -134,7 +140,7 @@ void *xc_dom_malloc_page_aligned(struct xc_dom_image *dom, size_t size) dom->alloc_malloc += sizeof(*block); dom->alloc_mem_map += block->mmap_len; if ( size > (100 * 1024) ) - print_mem(__FUNCTION__, size); + print_mem(dom, __FUNCTION__, size); return block->mmap_ptr; } @@ -166,7 +172,7 @@ void *xc_dom_malloc_filemap(struct xc_dom_image *dom, dom->alloc_file_map += block->mmap_len; close(fd); if ( *size > (100 * 1024) ) - print_mem(__FUNCTION__, *size); + print_mem(dom, __FUNCTION__, *size); return block->mmap_ptr; err: @@ -204,7 +210,7 @@ char *xc_dom_strdup(struct xc_dom_image *dom, const char *str) /* ------------------------------------------------------------------------ */ /* read files, copy memory blocks, with transparent gunzip */ -size_t xc_dom_check_gzip(void *blob, size_t ziplen) +size_t xc_dom_check_gzip(xc_interface *xch, void *blob, size_t ziplen) { unsigned char *gzlen; size_t unziplen; @@ -218,7 +224,8 @@ size_t xc_dom_check_gzip(void *blob, size_t ziplen) if ( (unziplen < 0) || (unziplen > (1024*1024*1024)) ) /* 1GB limit */ { xc_dom_printf - ("%s: size (zip %zd, unzip %zd) looks insane, skip gunzip\n", + (xch, + "%s: size (zip %zd, unzip %zd) looks insane, skip gunzip", __FUNCTION__, ziplen, unziplen); return 0; } @@ -226,7 +233,8 @@ size_t xc_dom_check_gzip(void *blob, size_t ziplen) return unziplen + 16; } -int xc_dom_do_gunzip(void *src, size_t srclen, void *dst, size_t dstlen) +int xc_dom_do_gunzip(xc_interface *xch, + void *src, size_t srclen, void *dst, size_t dstlen) { z_stream zStream; int rc; @@ -239,20 +247,20 @@ int xc_dom_do_gunzip(void *src, size_t srclen, void *dst, size_t dstlen) rc = inflateInit2(&zStream, (MAX_WBITS + 32)); /* +32 means "handle gzip" */ if ( rc != Z_OK ) { - xc_dom_panic(XC_INTERNAL_ERROR, - "%s: inflateInit2 failed (rc=%d)\n", __FUNCTION__, rc); + xc_dom_panic(xch, XC_INTERNAL_ERROR, + "%s: inflateInit2 failed (rc=%d)", __FUNCTION__, rc); return -1; } rc = inflate(&zStream, Z_FINISH); inflateEnd(&zStream); if ( rc != Z_STREAM_END ) { - xc_dom_panic(XC_INTERNAL_ERROR, - "%s: inflate failed (rc=%d)\n", __FUNCTION__, rc); + xc_dom_panic(xch, XC_INTERNAL_ERROR, + "%s: inflate failed (rc=%d)", __FUNCTION__, rc); return -1; } - xc_dom_printf("%s: unzip ok, 0x%zx -> 0x%zx\n", + xc_dom_printf(xch, "%s: unzip ok, 0x%zx -> 0x%zx", __FUNCTION__, srclen, dstlen); return 0; } @@ -262,7 +270,7 @@ int xc_dom_try_gunzip(struct xc_dom_image *dom, void **blob, size_t * size) void *unzip; size_t unziplen; - unziplen = xc_dom_check_gzip(*blob, *size); + unziplen = xc_dom_check_gzip(dom->xch, *blob, *size); if ( unziplen == 0 ) return 0; @@ -270,7 +278,7 @@ int xc_dom_try_gunzip(struct xc_dom_image *dom, void **blob, size_t * size) if ( unzip == NULL ) return -1; - if ( xc_dom_do_gunzip(*blob, *size, unzip, unziplen) == -1 ) + if ( xc_dom_do_gunzip(dom->xch, *blob, *size, unzip, unziplen) == -1 ) return -1; *blob = unzip; @@ -292,8 +300,8 @@ void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t pfn, count > dom->total_pages || pfn > dom->total_pages - count ) { - xc_dom_printf("%s: pfn out of range (0x%" PRIpfn " > 0x%" PRIpfn ")\n", - __FUNCTION__, pfn, dom->total_pages); + DOMPRINTF("%s: pfn out of range (0x%" PRIpfn " > 0x%" PRIpfn ")", + __FUNCTION__, pfn, dom->total_pages); return NULL; } @@ -310,11 +318,11 @@ void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t pfn, if ( (pfn < phys->first) || ((pfn + count) > (phys->first + phys->count)) ) { - xc_dom_printf("%s: request overlaps allocated block" - " (req 0x%" PRIpfn "+0x%" PRIpfn "," - " blk 0x%" PRIpfn "+0x%" PRIpfn ")\n", - __FUNCTION__, pfn, count, phys->first, - phys->count); + DOMPRINTF("%s: request overlaps allocated block" + " (req 0x%" PRIpfn "+0x%" PRIpfn "," + " blk 0x%" PRIpfn "+0x%" PRIpfn ")", + __FUNCTION__, pfn, count, phys->first, + phys->count); return NULL; } } @@ -331,9 +339,9 @@ void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t pfn, /* allocating is allowed with size specified only */ if ( count == 0 ) { - xc_dom_printf("%s: no block found, no size given," - " can't malloc (pfn 0x%" PRIpfn ")\n", - __FUNCTION__, pfn); + DOMPRINTF("%s: no block found, no size given," + " can't malloc (pfn 0x%" PRIpfn ")", + __FUNCTION__, pfn); return NULL; } @@ -364,9 +372,9 @@ void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t pfn, if ( phys->ptr == MAP_FAILED ) { err = errno; - xc_dom_panic(XC_OUT_OF_MEMORY, + xc_dom_panic(dom->xch, XC_OUT_OF_MEMORY, "%s: oom: can't allocate 0x%" PRIpfn " pages" - " [mmap, errno=%i (%s)]\n", + " [mmap, errno=%i (%s)]", __FUNCTION__, count, err, strerror(err)); return NULL; } @@ -374,8 +382,8 @@ void *xc_dom_pfn_to_ptr(struct xc_dom_image *dom, xen_pfn_t pfn, } #if 1 - xc_dom_printf("%s: %s: pfn 0x%" PRIpfn "+0x%" PRIpfn " at %p\n", - __FUNCTION__, mode, phys->first, phys->count, phys->ptr); + DOMPRINTF("%s: %s: pfn 0x%" PRIpfn "+0x%" PRIpfn " at %p", + __FUNCTION__, mode, phys->first, phys->count, phys->ptr); #endif phys->next = dom->phys_pages; dom->phys_pages = phys; @@ -395,16 +403,16 @@ int xc_dom_alloc_segment(struct xc_dom_image *dom, if ( start & (page_size - 1) ) { - xc_dom_panic(XC_INTERNAL_ERROR, - "%s: segment start isn't page aligned (0x%" PRIx64 ")\n", + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: segment start isn't page aligned (0x%" PRIx64 ")", __FUNCTION__, start); return -1; } if ( start < dom->virt_alloc_end ) { - xc_dom_panic(XC_INTERNAL_ERROR, + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, "%s: segment start too low (0x%" PRIx64 " < 0x%" PRIx64 - ")\n", __FUNCTION__, start, dom->virt_alloc_end); + ")", __FUNCTION__, start, dom->virt_alloc_end); return -1; } @@ -414,9 +422,9 @@ int xc_dom_alloc_segment(struct xc_dom_image *dom, if ( pages > dom->total_pages || /* double test avoids overflow probs */ pages > dom->total_pages - seg->pfn) { - xc_dom_panic(XC_OUT_OF_MEMORY, + xc_dom_panic(dom->xch, XC_OUT_OF_MEMORY, "%s: segment %s too large (0x%"PRIpfn" > " - "0x%"PRIpfn" - 0x%"PRIpfn" pages)\n", + "0x%"PRIpfn" - 0x%"PRIpfn" pages)", __FUNCTION__, name, pages, dom->total_pages, seg->pfn); return -1; } @@ -426,9 +434,9 @@ int xc_dom_alloc_segment(struct xc_dom_image *dom, if (dom->allocate) dom->allocate(dom, dom->virt_alloc_end); - xc_dom_printf("%-20s: %-12s : 0x%" PRIx64 " -> 0x%" PRIx64 - " (pfn 0x%" PRIpfn " + 0x%" PRIpfn " pages)\n", - __FUNCTION__, name, seg->vstart, seg->vend, seg->pfn, pages); + DOMPRINTF("%-20s: %-12s : 0x%" PRIx64 " -> 0x%" PRIx64 + " (pfn 0x%" PRIpfn " + 0x%" PRIpfn " pages)", + __FUNCTION__, name, seg->vstart, seg->vend, seg->pfn, pages); /* map and clear pages */ ptr = xc_dom_seg_to_ptr(dom, seg); @@ -451,8 +459,8 @@ int xc_dom_alloc_page(struct xc_dom_image *dom, char *name) dom->allocate(dom, dom->virt_alloc_end); pfn = (start - dom->parms.virt_base) / page_size; - xc_dom_printf("%-20s: %-12s : 0x%" PRIx64 " (pfn 0x%" PRIpfn ")\n", - __FUNCTION__, name, start, pfn); + DOMPRINTF("%-20s: %-12s : 0x%" PRIx64 " (pfn 0x%" PRIpfn ")", + __FUNCTION__, name, start, pfn); return pfn; } @@ -469,8 +477,8 @@ void xc_dom_unmap_one(struct xc_dom_image *dom, xen_pfn_t pfn) } if ( !phys ) { - xc_dom_printf("%s: Huh? no mapping with pfn 0x%" PRIpfn "\n", - __FUNCTION__, pfn); + DOMPRINTF("%s: Huh? no mapping with pfn 0x%" PRIpfn "", + __FUNCTION__, pfn); return; } @@ -505,16 +513,17 @@ static struct xc_dom_loader *xc_dom_find_loader(struct xc_dom_image *dom) while ( loader != NULL ) { - xc_dom_printf("%s: trying %s loader ... ", __FUNCTION__, loader->name); + DOMPRINTF("%s: trying %s loader ... ", __FUNCTION__, loader->name); if ( loader->probe(dom) == 0 ) { - xc_dom_printf("OK\n"); + DOMPRINTF("loader probe OK"); return loader; } - xc_dom_printf("failed\n"); + DOMPRINTF("loader probe failed"); loader = loader->next; } - xc_dom_panic(XC_INVALID_KERNEL, "%s: no loader found\n", __FUNCTION__); + xc_dom_panic(dom->xch, + XC_INVALID_KERNEL, "%s: no loader found", __FUNCTION__); return NULL; } @@ -524,7 +533,7 @@ void xc_dom_register_arch_hooks(struct xc_dom_arch *hooks) first_hook = hooks; } -struct xc_dom_arch *xc_dom_find_arch_hooks(char *guest_type) +struct xc_dom_arch *xc_dom_find_arch_hooks(xc_interface *xch, char *guest_type) { struct xc_dom_arch *hooks = first_hook; @@ -534,8 +543,8 @@ struct xc_dom_arch *xc_dom_find_arch_hooks(char *guest_type) return hooks; hooks = hooks->next; } - xc_dom_panic(XC_INVALID_KERNEL, - "%s: not found (type %s)\n", __FUNCTION__, guest_type); + xc_dom_panic(xch, XC_INVALID_KERNEL, + "%s: not found (type %s)", __FUNCTION__, guest_type); return NULL; } @@ -544,24 +553,27 @@ struct xc_dom_arch *xc_dom_find_arch_hooks(char *guest_type) void xc_dom_release(struct xc_dom_image *dom) { - xc_dom_printf("%s: called\n", __FUNCTION__); + DOMPRINTF_CALLED(dom->xch); if ( dom->phys_pages ) xc_dom_unmap_all(dom); xc_dom_free_all(dom); free(dom); } -struct xc_dom_image *xc_dom_allocate(const char *cmdline, const char *features) +struct xc_dom_image *xc_dom_allocate(xc_interface *xch, + const char *cmdline, const char *features) { struct xc_dom_image *dom; - xc_dom_printf("%s: cmdline=\"%s\", features=\"%s\"\n", + xc_dom_printf(xch, "%s: cmdline=\"%s\", features=\"%s\"", __FUNCTION__, cmdline, features); dom = malloc(sizeof(*dom)); if ( !dom ) goto err; memset(dom, 0, sizeof(*dom)); + dom->xch = xch; + if ( cmdline ) dom->cmdline = xc_dom_strdup(dom, cmdline); if ( features ) @@ -584,7 +596,7 @@ struct xc_dom_image *xc_dom_allocate(const char *cmdline, const char *features) int xc_dom_kernel_file(struct xc_dom_image *dom, const char *filename) { - xc_dom_printf("%s: filename=\"%s\"\n", __FUNCTION__, filename); + DOMPRINTF("%s: filename=\"%s\"", __FUNCTION__, filename); dom->kernel_blob = xc_dom_malloc_filemap(dom, filename, &dom->kernel_size); if ( dom->kernel_blob == NULL ) return -1; @@ -593,7 +605,7 @@ int xc_dom_kernel_file(struct xc_dom_image *dom, const char *filename) int xc_dom_ramdisk_file(struct xc_dom_image *dom, const char *filename) { - xc_dom_printf("%s: filename=\"%s\"\n", __FUNCTION__, filename); + DOMPRINTF("%s: filename=\"%s\"", __FUNCTION__, filename); dom->ramdisk_blob = xc_dom_malloc_filemap(dom, filename, &dom->ramdisk_size); if ( dom->ramdisk_blob == NULL ) @@ -604,7 +616,7 @@ int xc_dom_ramdisk_file(struct xc_dom_image *dom, const char *filename) int xc_dom_kernel_mem(struct xc_dom_image *dom, const void *mem, size_t memsize) { - xc_dom_printf("%s: called\n", __FUNCTION__); + DOMPRINTF_CALLED(dom->xch); dom->kernel_blob = (void *)mem; dom->kernel_size = memsize; return xc_dom_try_gunzip(dom, &dom->kernel_blob, &dom->kernel_size); @@ -613,7 +625,7 @@ int xc_dom_kernel_mem(struct xc_dom_image *dom, const void *mem, size_t memsize) int xc_dom_ramdisk_mem(struct xc_dom_image *dom, const void *mem, size_t memsize) { - xc_dom_printf("%s: called\n", __FUNCTION__); + DOMPRINTF_CALLED(dom->xch); dom->ramdisk_blob = (void *)mem; dom->ramdisk_size = memsize; // return xc_dom_try_gunzip(dom, &dom->ramdisk_blob, &dom->ramdisk_size); @@ -624,7 +636,7 @@ int xc_dom_parse_image(struct xc_dom_image *dom) { int i; - xc_dom_printf("%s: called\n", __FUNCTION__); + DOMPRINTF_CALLED(dom->xch); /* parse kernel image */ dom->kernel_loader = xc_dom_find_loader(dom); @@ -634,8 +646,8 @@ int xc_dom_parse_image(struct xc_dom_image *dom) goto err; if ( dom->guest_type == NULL ) { - xc_dom_panic(XC_INTERNAL_ERROR, - "%s: guest_type not set\n", __FUNCTION__); + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, + "%s: guest_type not set", __FUNCTION__); goto err; } @@ -647,8 +659,8 @@ int xc_dom_parse_image(struct xc_dom_image *dom) if ( (dom->f_active[i] & dom->parms.f_supported[i]) != dom->f_active[i] ) { - xc_dom_panic(XC_INVALID_PARAM, - "%s: unsupported feature requested\n", __FUNCTION__); + xc_dom_panic(dom->xch, XC_INVALID_PARAM, + "%s: unsupported feature requested", __FUNCTION__); goto err; } } @@ -663,10 +675,10 @@ int xc_dom_mem_init(struct xc_dom_image *dom, unsigned int mem_mb) unsigned int page_shift; xen_pfn_t nr_pages; - dom->arch_hooks = xc_dom_find_arch_hooks(dom->guest_type); + dom->arch_hooks = xc_dom_find_arch_hooks(dom->xch, dom->guest_type); if ( dom->arch_hooks == NULL ) { - xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n", + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, "%s: arch hooks not set", __FUNCTION__); return -1; } @@ -674,12 +686,12 @@ int xc_dom_mem_init(struct xc_dom_image *dom, unsigned int mem_mb) page_shift = XC_DOM_PAGE_SHIFT(dom); nr_pages = mem_mb << (20 - page_shift); - xc_dom_printf("%s: mem %d MB, pages 0x%" PRIpfn " pages, %dk each\n", - __FUNCTION__, mem_mb, nr_pages, 1 << (page_shift-10)); + DOMPRINTF("%s: mem %d MB, pages 0x%" PRIpfn " pages, %dk each", + __FUNCTION__, mem_mb, nr_pages, 1 << (page_shift-10)); dom->total_pages = nr_pages; - xc_dom_printf("%s: 0x%" PRIpfn " pages\n", - __FUNCTION__, dom->total_pages); + DOMPRINTF("%s: 0x%" PRIpfn " pages", + __FUNCTION__, dom->total_pages); return 0; } @@ -696,8 +708,8 @@ int xc_dom_update_guest_p2m(struct xc_dom_image *dom) switch ( dom->arch_hooks->sizeof_pfn ) { case 4: - xc_dom_printf("%s: dst 32bit, pages 0x%" PRIpfn " \n", - __FUNCTION__, dom->total_pages); + DOMPRINTF("%s: dst 32bit, pages 0x%" PRIpfn "", + __FUNCTION__, dom->total_pages); p2m_32 = dom->p2m_guest; for ( i = 0; i < dom->total_pages; i++ ) if ( dom->p2m_host[i] != INVALID_P2M_ENTRY ) @@ -706,8 +718,8 @@ int xc_dom_update_guest_p2m(struct xc_dom_image *dom) p2m_32[i] = (uint32_t) - 1; break; case 8: - xc_dom_printf("%s: dst 64bit, pages 0x%" PRIpfn " \n", - __FUNCTION__, dom->total_pages); + DOMPRINTF("%s: dst 64bit, pages 0x%" PRIpfn "", + __FUNCTION__, dom->total_pages); p2m_64 = dom->p2m_guest; for ( i = 0; i < dom->total_pages; i++ ) if ( dom->p2m_host[i] != INVALID_P2M_ENTRY ) @@ -716,7 +728,7 @@ int xc_dom_update_guest_p2m(struct xc_dom_image *dom) p2m_64[i] = (uint64_t) - 1; break; default: - xc_dom_panic(XC_INTERNAL_ERROR, + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, "sizeof_pfn is invalid (is %d, can be 4 or 8)", dom->arch_hooks->sizeof_pfn); return -1; @@ -728,12 +740,12 @@ int xc_dom_build_image(struct xc_dom_image *dom) { unsigned int page_size; - xc_dom_printf("%s: called\n", __FUNCTION__); + DOMPRINTF_CALLED(dom->xch); /* check for arch hooks */ if ( dom->arch_hooks == NULL ) { - xc_dom_panic(XC_INTERNAL_ERROR, "%s: arch hooks not set\n", + xc_dom_panic(dom->xch, XC_INTERNAL_ERROR, "%s: arch hooks not set", __FUNCTION__); goto err; } @@ -754,7 +766,7 @@ int xc_dom_build_image(struct xc_dom_image *dom) size_t unziplen, ramdisklen; void *ramdiskmap; - unziplen = xc_dom_check_gzip(dom->ramdisk_blob, dom->ramdisk_size); + unziplen = xc_dom_check_gzip(dom->xch, dom->ramdisk_blob, dom->ramdisk_size); ramdisklen = unziplen ? unziplen : dom->ramdisk_size; if ( xc_dom_alloc_segment(dom, &dom->ramdisk_seg, "ramdisk", 0, ramdisklen) != 0 ) @@ -762,7 +774,8 @@ int xc_dom_build_image(struct xc_dom_image *dom) ramdiskmap = xc_dom_seg_to_ptr(dom, &dom->ramdisk_seg); if ( unziplen ) { - if ( xc_dom_do_gunzip(dom->ramdisk_blob, dom->ramdisk_size, + if ( xc_dom_do_gunzip(dom->xch, + dom->ramdisk_blob, dom->ramdisk_size, ramdiskmap, ramdisklen) == -1 ) goto err; } @@ -783,10 +796,10 @@ int xc_dom_build_image(struct xc_dom_image *dom) } if ( dom->alloc_bootstack ) dom->bootstack_pfn = xc_dom_alloc_page(dom, "boot stack"); - xc_dom_printf("%-20s: virt_alloc_end : 0x%" PRIx64 "\n", - __FUNCTION__, dom->virt_alloc_end); - xc_dom_printf("%-20s: virt_pgtab_end : 0x%" PRIx64 "\n", - __FUNCTION__, dom->virt_pgtab_end); + DOMPRINTF("%-20s: virt_alloc_end : 0x%" PRIx64 "", + __FUNCTION__, dom->virt_alloc_end); + DOMPRINTF("%-20s: virt_pgtab_end : 0x%" PRIx64 "", + __FUNCTION__, dom->virt_pgtab_end); return 0; err: -- cgit v1.2.3