# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 5b036362c1b0919c3a0bf85f7fe5fe7dd5565414
# Parent 479b17f312b03b8b416e02fdd12fc971d6c81a0e
Remove ERR() macro from libxc. Use ERROR/PERROR as appropriate.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
tools/libxc/ia64/xc_ia64_linux_restore.c | 44 ++++++-------
tools/libxc/ia64/xc_ia64_linux_save.c | 64 +++++++++----------
tools/libxc/xc_linux_restore.c | 94 ++++++++++++++--------------
tools/libxc/xc_linux_save.c | 104 +++++++++++++++----------------
tools/libxc/xc_private.h | 5 -
5 files changed, 153 insertions(+), 158 deletions(-)
diff -r 479b17f312b0 -r 5b036362c1b0 tools/libxc/ia64/xc_ia64_linux_restore.c
--- a/tools/libxc/ia64/xc_ia64_linux_restore.c Tue Oct 17 18:00:51 2006 +0100
+++ b/tools/libxc/ia64/xc_ia64_linux_restore.c Tue Oct 17 18:05:42 2006 +0100
@@ -44,11 +44,11 @@ read_page(int xc_handle, int io_fd, uint
mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
PROT_READ|PROT_WRITE, pfn);
if (mem == NULL) {
- ERR("cannot map page");
+ ERROR("cannot map page");
return -1;
}
if (!read_exact(io_fd, mem, PAGE_SIZE)) {
- ERR("Error when reading from state file (5)");
+ ERROR("Error when reading from state file (5)");
return -1;
}
munmap(mem, PAGE_SIZE);
@@ -85,17 +85,17 @@ xc_linux_restore(int xc_handle, int io_f
if (!read_exact(io_fd, &ver, sizeof(unsigned long))) {
- ERR("Error when reading version");
+ ERROR("Error when reading version");
goto out;
}
if (ver != 1) {
- ERR("version of save doesn't match");
+ ERROR("version of save doesn't match");
goto out;
}
if (mlock(&ctxt, sizeof(ctxt))) {
/* needed for build domctl, but might as well do early */
- ERR("Unable to mlock ctxt");
+ ERROR("Unable to mlock ctxt");
return 1;
}
@@ -103,7 +103,7 @@ xc_linux_restore(int xc_handle, int io_f
domctl.cmd = XEN_DOMCTL_getdomaininfo;
domctl.domain = (domid_t)dom;
if (xc_domctl(xc_handle, &domctl) < 0) {
- ERR("Could not get information on new domain");
+ ERROR("Could not get information on new domain");
goto out;
}
shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
@@ -115,7 +115,7 @@ xc_linux_restore(int xc_handle, int io_f
if (xc_domain_memory_increase_reservation(xc_handle, dom, max_pfn,
0, 0, NULL) != 0) {
- ERR("Failed to increase reservation by %ld KB", PFN_TO_KB(max_pfn));
+ ERROR("Failed to increase reservation by %ld KB", PFN_TO_KB(max_pfn));
errno = ENOMEM;
goto out;
}
@@ -123,7 +123,7 @@ xc_linux_restore(int xc_handle, int io_f
DPRINTF("Increased domain reservation by %ld KB\n", PFN_TO_KB(max_pfn));
if (!read_exact(io_fd, &domctl.u.arch_setup, sizeof(domctl.u.arch_setup)))
{
- ERR("read: domain setup");
+ ERROR("read: domain setup");
goto out;
}
@@ -141,13 +141,13 @@ xc_linux_restore(int xc_handle, int io_f
/* Get pages. */
page_array = malloc(max_pfn * sizeof(unsigned long));
if (page_array == NULL ) {
- ERR("Could not allocate memory");
+ ERROR("Could not allocate memory");
goto out;
}
if (xc_ia64_get_pfn_list(xc_handle, dom, page_array,
0, max_pfn) != max_pfn) {
- ERR("Could not get the page frame list");
+ ERROR("Could not get the page frame list");
goto out;
}
@@ -155,7 +155,7 @@ xc_linux_restore(int xc_handle, int io_f
while (1) {
if (!read_exact(io_fd, &mfn, sizeof(unsigned long))) {
- ERR("Error when reading batch size");
+ ERROR("Error when reading batch size");
goto out;
}
if (mfn == INVALID_MFN)
@@ -178,18 +178,18 @@ xc_linux_restore(int xc_handle, int io_f
int rc;
if (!read_exact(io_fd, &count, sizeof(count))) {
- ERR("Error when reading pfn count");
+ ERROR("Error when reading pfn count");
goto out;
}
pfntab = malloc(sizeof(unsigned long) * count);
if (!pfntab) {
- ERR("Out of memory");
+ ERROR("Out of memory");
goto out;
}
if (!read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) {
- ERR("Error when reading pfntab");
+ ERROR("Error when reading pfntab");
goto out;
}
@@ -211,7 +211,7 @@ xc_linux_restore(int xc_handle, int io_f
rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
&reservation);
if (rc != 1) {
- ERR("Could not decrease reservation : %d", rc);
+ ERROR("Could not decrease reservation : %d", rc);
goto out;
}
}
@@ -221,7 +221,7 @@ xc_linux_restore(int xc_handle, int io_f
if (!read_exact(io_fd, &ctxt, sizeof(ctxt))) {
- ERR("Error when reading ctxt");
+ ERROR("Error when reading ctxt");
goto out;
}
@@ -231,7 +231,7 @@ xc_linux_restore(int xc_handle, int io_f
domctl.u.vcpucontext.vcpu = 0;
set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt);
if (xc_domctl(xc_handle, &domctl) != 0) {
- ERR("Couldn't set vcpu context");
+ ERROR("Couldn't set vcpu context");
goto out;
}
@@ -242,19 +242,19 @@ xc_linux_restore(int xc_handle, int io_f
domctl.u.vcpucontext.vcpu = 0;
set_xen_guest_handle(domctl.u.vcpucontext.ctxt, &ctxt);
if (xc_domctl(xc_handle, &domctl) != 0) {
- ERR("Couldn't set vcpu context");
+ ERROR("Couldn't set vcpu context");
goto out;
}
/* Just a check. */
if (xc_vcpu_getcontext(xc_handle, dom, 0 /* XXX */, &ctxt)) {
- ERR("Could not get vcpu context");
+ ERROR("Could not get vcpu context");
goto out;
}
/* Then get privreg page. */
if (read_page(xc_handle, io_fd, dom, ctxt.privregs_pfn) < 0) {
- ERR("Could not read vcpu privregs");
+ ERROR("Could not read vcpu privregs");
goto out;
}
@@ -262,11 +262,11 @@ xc_linux_restore(int xc_handle, int io_f
shared_info = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
PROT_READ|PROT_WRITE,
shared_info_frame);
if (shared_info == NULL) {
- ERR("cannot map page");
+ ERROR("cannot map page");
goto out;
}
if (!read_exact(io_fd, shared_info, PAGE_SIZE)) {
- ERR("Error when reading shared_info page");
+ ERROR("Error when reading shared_info page");
goto out;
}
diff -r 479b17f312b0 -r 5b036362c1b0 tools/libxc/ia64/xc_ia64_linux_save.c
--- a/tools/libxc/ia64/xc_ia64_linux_save.c Tue Oct 17 18:00:51 2006 +0100
+++ b/tools/libxc/ia64/xc_ia64_linux_save.c Tue Oct 17 18:05:42 2006 +0100
@@ -97,14 +97,14 @@ suspend_and_state(int (*suspend)(int), i
int i = 0;
if (!(*suspend)(dom)) {
- ERR("Suspend request failed");
+ ERROR("Suspend request failed");
return -1;
}
retry:
if (xc_domain_getinfo(xc_handle, dom, 1, info) != 1) {
- ERR("Could not get domain info");
+ ERROR("Could not get domain info");
return -1;
}
@@ -115,7 +115,7 @@ retry:
// try unpausing domain, wait, and retest
xc_domain_unpause(xc_handle, dom);
- ERR("Domain was paused. Wait and re-test.");
+ ERROR("Domain was paused. Wait and re-test.");
usleep(10000); // 10ms
goto retry;
@@ -123,12 +123,12 @@ retry:
if(++i < 100) {
- ERR("Retry suspend domain.");
+ ERROR("Retry suspend domain.");
usleep(10000); // 10ms
goto retry;
}
- ERR("Unable to suspend domain.");
+ ERROR("Unable to suspend domain.");
return -1;
}
@@ -191,7 +191,7 @@ xc_linux_save(int xc_handle, int io_fd,
//initialize_mbit_rate();
if (xc_domain_getinfo(xc_handle, dom, 1, &info) != 1) {
- ERR("Could not get domain info");
+ ERROR("Could not get domain info");
return 1;
}
@@ -200,7 +200,7 @@ xc_linux_save(int xc_handle, int io_fd,
#if 0
/* cheesy sanity check */
if ((info.max_memkb >> (PAGE_SHIFT - 10)) > max_mfn) {
- ERR("Invalid state record -- pfn count out of range: %lu",
+ ERROR("Invalid state record -- pfn count out of range: %lu",
(info.max_memkb >> (PAGE_SHIFT - 10)));
goto out;
}
@@ -210,7 +210,7 @@ xc_linux_save(int xc_handle, int io_fd,
live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
PROT_READ, shared_info_frame);
if (!live_shinfo) {
- ERR("Couldn't map live_shinfo");
+ ERROR("Couldn't map live_shinfo");
goto out;
}
@@ -218,13 +218,13 @@ xc_linux_save(int xc_handle, int io_fd,
page_array = malloc(max_pfn * sizeof(unsigned long));
if (page_array == NULL) {
- ERR("Could not allocate memory");
+ ERROR("Could not allocate memory");
goto out;
}
/* This is expected by xm restore. */
if (!write_exact(io_fd, &max_pfn, sizeof(unsigned long))) {
- ERR("write: max_pfn");
+ ERROR("write: max_pfn");
goto out;
}
@@ -237,7 +237,7 @@ xc_linux_save(int xc_handle, int io_fd,
unsigned long version = 1;
if (!write_exact(io_fd, &version, sizeof(unsigned long))) {
- ERR("write: version");
+ ERROR("write: version");
goto out;
}
}
@@ -246,12 +246,12 @@ xc_linux_save(int xc_handle, int io_fd,
domctl.domain = (domid_t)dom;
domctl.u.arch_setup.flags = XEN_DOMAINSETUP_query;
if (xc_domctl(xc_handle, &domctl) < 0) {
- ERR("Could not get domain setup");
+ ERROR("Could not get domain setup");
goto out;
}
if (!write_exact(io_fd, &domctl.u.arch_setup,
sizeof(domctl.u.arch_setup))) {
- ERR("write: domain setup");
+ ERROR("write: domain setup");
goto out;
}
@@ -261,7 +261,7 @@ xc_linux_save(int xc_handle, int io_fd,
if (xc_ia64_shadow_control(xc_handle, dom,
XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY,
NULL, 0, NULL ) < 0) {
- ERR("Couldn't enable shadow mode");
+ ERROR("Couldn't enable shadow mode");
goto out;
}
@@ -272,7 +272,7 @@ xc_linux_save(int xc_handle, int io_fd,
to_skip = malloc(bitmap_size);
if (!to_send || !to_skip) {
- ERR("Couldn't allocate bitmap array");
+ ERROR("Couldn't allocate bitmap array");
goto out;
}
@@ -280,11 +280,11 @@ xc_linux_save(int xc_handle, int io_fd,
memset(to_send, 0xff, bitmap_size);
if (mlock(to_send, bitmap_size)) {
- ERR("Unable to mlock to_send");
+ ERROR("Unable to mlock to_send");
goto out;
}
if (mlock(to_skip, bitmap_size)) {
- ERR("Unable to mlock to_skip");
+ ERROR("Unable to mlock to_skip");
goto out;
}
@@ -296,7 +296,7 @@ xc_linux_save(int xc_handle, int io_fd,
last_iter = 1;
if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info)) {
- ERR("Domain appears not to have suspended");
+ ERROR("Domain appears not to have suspended");
goto out;
}
@@ -315,7 +315,7 @@ xc_linux_save(int xc_handle, int io_fd,
/* Get the pfn list, as it may change. */
if (xc_ia64_get_pfn_list(xc_handle, dom, page_array,
0, max_pfn) != max_pfn) {
- ERR("Could not get the page frame list");
+ ERROR("Could not get the page frame list");
goto out;
}
@@ -326,7 +326,7 @@ xc_linux_save(int xc_handle, int io_fd,
if (xc_ia64_shadow_control(xc_handle, dom,
XEN_DOMCTL_SHADOW_OP_PEEK,
to_skip, max_pfn, NULL) != max_pfn) {
- ERR("Error peeking shadow bitmap");
+ ERROR("Error peeking shadow bitmap");
goto out;
}
}
@@ -358,12 +358,12 @@ xc_linux_save(int xc_handle, int io_fd,
}
if (!write_exact(io_fd, &N, sizeof(N))) {
- ERR("write: max_pfn");
+ ERROR("write: max_pfn");
goto out;
}
if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) {
- ERR("Error when writing to state file (5)");
+ ERROR("Error when writing to state file (5)");
goto out;
}
munmap(mem, PAGE_SIZE);
@@ -385,7 +385,7 @@ xc_linux_save(int xc_handle, int io_fd,
last_iter = 1;
if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info)) {
- ERR("Domain appears not to have suspended");
+ ERROR("Domain appears not to have suspended");
goto out;
}
}
@@ -394,7 +394,7 @@ xc_linux_save(int xc_handle, int io_fd,
if (xc_ia64_shadow_control(xc_handle, dom,
XEN_DOMCTL_SHADOW_OP_CLEAN,
to_send, max_pfn, NULL ) != max_pfn) {
- ERR("Error flushing shadow PT");
+ ERROR("Error flushing shadow PT");
goto out;
}
@@ -411,7 +411,7 @@ xc_linux_save(int xc_handle, int io_fd,
{
unsigned long pfn = INVALID_MFN;
if (!write_exact(io_fd, &pfn, sizeof(pfn))) {
- ERR("Error when writing to state file (6)");
+ ERROR("Error when writing to state file (6)");
goto out;
}
}
@@ -427,7 +427,7 @@ xc_linux_save(int xc_handle, int io_fd,
}
if (!write_exact(io_fd, &j, sizeof(unsigned int))) {
- ERR("Error when writing to state file (6a)");
+ ERROR("Error when writing to state file (6a)");
goto out;
}
@@ -439,7 +439,7 @@ xc_linux_save(int xc_handle, int io_fd,
i++;
if (j == 1024 || i == max_pfn) {
if (!write_exact(io_fd, &pfntab, sizeof(unsigned long)*j)) {
- ERR("Error when writing to state file (6b)");
+ ERROR("Error when writing to state file (6b)");
goto out;
}
j = 0;
@@ -449,29 +449,29 @@ xc_linux_save(int xc_handle, int io_fd,
}
if (xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt)) {
- ERR("Could not get vcpu context");
+ ERROR("Could not get vcpu context");
goto out;
}
if (!write_exact(io_fd, &ctxt, sizeof(ctxt))) {
- ERR("Error when writing to state file (1)");
+ ERROR("Error when writing to state file (1)");
goto out;
}
mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
PROT_READ|PROT_WRITE, ctxt.privregs_pfn);
if (mem == NULL) {
- ERR("cannot map privreg page");
+ ERROR("cannot map privreg page");
goto out;
}
if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) {
- ERR("Error when writing privreg to state file (5)");
+ ERROR("Error when writing privreg to state file (5)");
goto out;
}
munmap(mem, PAGE_SIZE);
if (!write_exact(io_fd, live_shinfo, PAGE_SIZE)) {
- ERR("Error when writing to state file (1)");
+ ERROR("Error when writing to state file (1)");
goto out;
}
diff -r 479b17f312b0 -r 5b036362c1b0 tools/libxc/xc_linux_restore.c
--- a/tools/libxc/xc_linux_restore.c Tue Oct 17 18:00:51 2006 +0100
+++ b/tools/libxc/xc_linux_restore.c Tue Oct 17 18:05:42 2006 +0100
@@ -79,7 +79,7 @@ int uncanonicalize_pagetable(unsigned lo
if(pfn >= max_pfn) {
/* This "page table page" is probably not one; bail. */
- ERR("Frame number in type %lu page table is out of range: "
+ ERROR("Frame number in type %lu page table is out of range: "
"i=%d pfn=0x%lx max_pfn=%lu",
type >> 28, i, pfn, max_pfn);
return 0;
@@ -158,24 +158,24 @@ int xc_linux_restore(int xc_handle, int
if(!get_platform_info(xc_handle, dom,
&max_mfn, &hvirt_start, &pt_levels)) {
- ERR("Unable to get platform info.");
+ ERROR("Unable to get platform info.");
return 1;
}
if (mlock(&ctxt, sizeof(ctxt))) {
/* needed for build domctl, but might as well do early */
- ERR("Unable to mlock ctxt");
+ ERROR("Unable to mlock ctxt");
return 1;
}
if (!(p2m_frame_list = malloc(P2M_FL_SIZE))) {
- ERR("Couldn't allocate p2m_frame_list array");
+ ERROR("Couldn't allocate p2m_frame_list array");
goto out;
}
/* Read first entry of P2M list, or extended-info signature (~0UL). */
if (!read_exact(io_fd, p2m_frame_list, sizeof(long))) {
- ERR("read extended-info signature failed");
+ ERROR("read extended-info signature failed");
goto out;
}
@@ -184,7 +184,7 @@ int xc_linux_restore(int xc_handle, int
/* Next 4 bytes: total size of following extended info. */
if (!read_exact(io_fd, &tot_bytes, sizeof(tot_bytes))) {
- ERR("read extended-info size failed");
+ ERROR("read extended-info size failed");
goto out;
}
@@ -195,7 +195,7 @@ int xc_linux_restore(int xc_handle, int
/* 4-character chunk signature + 4-byte remaining chunk size. */
if (!read_exact(io_fd, chunk_sig, sizeof(chunk_sig)) ||
!read_exact(io_fd, &chunk_bytes, sizeof(chunk_bytes))) {
- ERR("read extended-info chunk signature failed");
+ ERROR("read extended-info chunk signature failed");
goto out;
}
tot_bytes -= 8;
@@ -203,7 +203,7 @@ int xc_linux_restore(int xc_handle, int
/* VCPU context structure? */
if (!strncmp(chunk_sig, "vcpu", 4)) {
if (!read_exact(io_fd, &ctxt, sizeof(ctxt))) {
- ERR("read extended-info vcpu context failed");
+ ERROR("read extended-info vcpu context failed");
goto out;
}
tot_bytes -= sizeof(struct vcpu_guest_context);
@@ -219,7 +219,7 @@ int xc_linux_restore(int xc_handle, int
if ( sz > P2M_FL_SIZE )
sz = P2M_FL_SIZE;
if (!read_exact(io_fd, p2m_frame_list, sz)) {
- ERR("read-and-discard extended-info chunk bytes failed");
+ ERROR("read-and-discard extended-info chunk bytes failed");
goto out;
}
chunk_bytes -= sz;
@@ -229,14 +229,14 @@ int xc_linux_restore(int xc_handle, int
/* Now read the real first entry of P2M list. */
if (!read_exact(io_fd, p2m_frame_list, sizeof(long))) {
- ERR("read first entry of p2m_frame_list failed");
+ ERROR("read first entry of p2m_frame_list failed");
goto out;
}
}
/* First entry is already read into the p2m array. */
if (!read_exact(io_fd, &p2m_frame_list[1], P2M_FL_SIZE - sizeof(long))) {
- ERR("read p2m_frame_list failed");
+ ERROR("read p2m_frame_list failed");
goto out;
}
@@ -246,13 +246,13 @@ int xc_linux_restore(int xc_handle, int
region_mfn = calloc(MAX_BATCH_SIZE, sizeof(xen_pfn_t));
if ((p2m == NULL) || (pfn_type == NULL) || (region_mfn == NULL)) {
- ERR("memory alloc failed");
+ ERROR("memory alloc failed");
errno = ENOMEM;
goto out;
}
if (mlock(region_mfn, sizeof(xen_pfn_t) * MAX_BATCH_SIZE)) {
- ERR("Could not mlock region_mfn");
+ ERROR("Could not mlock region_mfn");
goto out;
}
@@ -260,7 +260,7 @@ int xc_linux_restore(int xc_handle, int
domctl.cmd = XEN_DOMCTL_getdomaininfo;
domctl.domain = (domid_t)dom;
if (xc_domctl(xc_handle, &domctl) < 0) {
- ERR("Could not get information on new domain");
+ ERROR("Could not get information on new domain");
goto out;
}
shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
@@ -272,7 +272,7 @@ int xc_linux_restore(int xc_handle, int
if(xc_domain_memory_increase_reservation(
xc_handle, dom, max_pfn, 0, 0, NULL) != 0) {
- ERR("Failed to increase reservation by %lx KB", PFN_TO_KB(max_pfn));
+ ERROR("Failed to increase reservation by %lx KB", PFN_TO_KB(max_pfn));
errno = ENOMEM;
goto out;
}
@@ -281,12 +281,12 @@ int xc_linux_restore(int xc_handle, int
/* Build the pfn-to-mfn table. We choose MFN ordering returned by Xen. */
if (xc_get_pfn_list(xc_handle, dom, p2m, max_pfn) != max_pfn) {
- ERR("Did not read correct number of frame numbers for new dom");
+ ERROR("Did not read correct number of frame numbers for new dom");
goto out;
}
if(!(mmu = xc_init_mmu_updates(xc_handle, dom))) {
- ERR("Could not initialise for MMU updates");
+ ERROR("Could not initialise for MMU updates");
goto out;
}
@@ -312,7 +312,7 @@ int xc_linux_restore(int xc_handle, int
}
if (!read_exact(io_fd, &j, sizeof(int))) {
- ERR("Error when reading batch size");
+ ERROR("Error when reading batch size");
goto out;
}
@@ -328,12 +328,12 @@ int xc_linux_restore(int xc_handle, int
break; /* our work here is done */
if (j > MAX_BATCH_SIZE) {
- ERR("Max batch size exceeded. Giving up.");
+ ERROR("Max batch size exceeded. Giving up.");
goto out;
}
if (!read_exact(io_fd, region_pfn_type, j*sizeof(unsigned long))) {
- ERR("Error when reading region pfn types");
+ ERROR("Error when reading region pfn types");
goto out;
}
@@ -353,7 +353,7 @@ int xc_linux_restore(int xc_handle, int
xc_handle, dom, PROT_WRITE, region_mfn, j);
if ( region_base == NULL )
{
- ERR("map batch failed");
+ ERROR("map batch failed");
goto out;
}
@@ -371,7 +371,7 @@ int xc_linux_restore(int xc_handle, int
if ( pfn > max_pfn )
{
- ERR("pfn out of range");
+ ERROR("pfn out of range");
goto out;
}
@@ -383,7 +383,7 @@ int xc_linux_restore(int xc_handle, int
page = verify ? (void *)buf : (region_base + i*PAGE_SIZE);
if (!read_exact(io_fd, page, PAGE_SIZE)) {
- ERR("Error when reading page (type was %lx)", pagetype);
+ ERROR("Error when reading page (type was %lx)", pagetype);
goto out;
}
@@ -422,7 +422,7 @@ int xc_linux_restore(int xc_handle, int
}
else if ( pagetype != XEN_DOMCTL_PFINFO_NOTAB )
{
- ERR("Bogus page type %lx page table is out of range: "
+ ERROR("Bogus page type %lx page table is out of range: "
"i=%d max_pfn=%lu", pagetype, i, max_pfn);
goto out;
@@ -455,7 +455,7 @@ int xc_linux_restore(int xc_handle, int
if (xc_add_mmu_update(xc_handle, mmu,
(((unsigned long long)mfn) << PAGE_SHIFT)
| MMU_MACHPHYS_UPDATE, pfn)) {
- ERR("failed machpys update mfn=%lx pfn=%lx", mfn, pfn);
+ ERROR("failed machpys update mfn=%lx pfn=%lx", mfn, pfn);
goto out;
}
} /* end of 'batch' for loop */
@@ -469,7 +469,7 @@ int xc_linux_restore(int xc_handle, int
* reallocations below.
*/
if (xc_finish_mmu_updates(xc_handle, mmu)) {
- ERR("Error doing finish_mmu_updates()");
+ ERROR("Error doing finish_mmu_updates()");
goto out;
}
@@ -512,7 +512,7 @@ int xc_linux_restore(int xc_handle, int
munmap(l3tab, PAGE_SIZE);
if (!(new_mfn=xc_make_page_below_4G(xc_handle, dom, p2m[i]))) {
- ERR("Couldn't get a page below 4GB :-(");
+ ERROR("Couldn't get a page below 4GB :-(");
goto out;
}
@@ -521,7 +521,7 @@ int xc_linux_restore(int xc_handle, int
(((unsigned long long)new_mfn)
<< PAGE_SHIFT) |
MMU_MACHPHYS_UPDATE, i)) {
- ERR("Couldn't m2p on PAE root pgdir");
+ ERROR("Couldn't m2p on PAE root pgdir");
goto out;
}
@@ -554,14 +554,14 @@ int xc_linux_restore(int xc_handle, int
if (!(region_base = xc_map_foreign_batch(
xc_handle, dom, PROT_READ | PROT_WRITE,
region_mfn, j))) {
- ERR("map batch failed");
+ ERROR("map batch failed");
goto out;
}
for(k = 0; k < j; k++) {
if(!uncanonicalize_pagetable(XEN_DOMCTL_PFINFO_L1TAB,
region_base + k*PAGE_SIZE)) {
- ERR("failed uncanonicalize pt!");
+ ERROR("failed uncanonicalize pt!");
goto out;
}
}
@@ -572,7 +572,7 @@ int xc_linux_restore(int xc_handle, int
}
if (xc_finish_mmu_updates(xc_handle, mmu)) {
- ERR("Error doing finish_mmu_updates()");
+ ERROR("Error doing finish_mmu_updates()");
goto out;
}
}
@@ -615,7 +615,7 @@ int xc_linux_restore(int xc_handle, int
/* Batch full? Then flush. */
if (nr_pins == MAX_PIN_BATCH) {
if (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0) {
- ERR("Failed to pin batch of %d page tables", nr_pins);
+ ERROR("Failed to pin batch of %d page tables", nr_pins);
goto out;
}
nr_pins = 0;
@@ -624,7 +624,7 @@ int xc_linux_restore(int xc_handle, int
/* Flush final partial batch. */
if ((nr_pins != 0) && (xc_mmuext_op(xc_handle, pin, nr_pins, dom) < 0)) {
- ERR("Failed to pin batch of %d page tables", nr_pins);
+ ERROR("Failed to pin batch of %d page tables", nr_pins);
goto out;
}
@@ -638,17 +638,17 @@ int xc_linux_restore(int xc_handle, int
int rc;
if (!read_exact(io_fd, &count, sizeof(count))) {
- ERR("Error when reading pfn count");
+ ERROR("Error when reading pfn count");
goto out;
}
if(!(pfntab = malloc(sizeof(unsigned long) * count))) {
- ERR("Out of memory");
+ ERROR("Out of memory");
goto out;
}
if (!read_exact(io_fd, pfntab, sizeof(unsigned long)*count)) {
- ERR("Error when reading pfntab");
+ ERROR("Error when reading pfntab");
goto out;
}
@@ -675,7 +675,7 @@ int xc_linux_restore(int xc_handle, int
if ((rc = xc_memory_op(xc_handle, XENMEM_decrease_reservation,
&reservation)) != count) {
- ERR("Could not decrease reservation : %d", rc);
+ ERROR("Could not decrease reservation : %d", rc);
goto out;
} else
DPRINTF("Decreased reservation by %d pages\n", count);
@@ -684,14 +684,14 @@ int xc_linux_restore(int xc_handle, int
if (!read_exact(io_fd, &ctxt, sizeof(ctxt)) ||
!read_exact(io_fd, shared_info_page, PAGE_SIZE)) {
- ERR("Error when reading ctxt or shared info page");
+ ERROR("Error when reading ctxt or shared info page");
goto out;
}
/* Uncanonicalise the suspend-record frame number and poke resume rec. */
pfn = ctxt.user_regs.edx;
if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
- ERR("Suspend record frame number is bad");
+ ERROR("Suspend record frame number is bad");
goto out;
}
ctxt.user_regs.edx = mfn = p2m[pfn];
@@ -709,14 +709,14 @@ int xc_linux_restore(int xc_handle, int
/* Uncanonicalise each GDT frame number. */
if (ctxt.gdt_ents > 8192) {
- ERR("GDT entry count out of range");
+ ERROR("GDT entry count out of range");
goto out;
}
for (i = 0; i < ctxt.gdt_ents; i += 512) {
pfn = ctxt.gdt_frames[i];
if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
- ERR("GDT frame number is bad");
+ ERROR("GDT frame number is bad");
goto out;
}
ctxt.gdt_frames[i] = p2m[pfn];
@@ -726,14 +726,14 @@ int xc_linux_restore(int xc_handle, int
pfn = xen_cr3_to_pfn(ctxt.ctrlreg[3]);
if (pfn >= max_pfn) {
- ERR("PT base is bad: pfn=%lu max_pfn=%lu type=%08lx",
+ ERROR("PT base is bad: pfn=%lu max_pfn=%lu type=%08lx",
pfn, max_pfn, pfn_type[pfn]);
goto out;
}
if ( (pfn_type[pfn] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK) !=
((unsigned long)pt_levels<<XEN_DOMCTL_PFINFO_LTAB_SHIFT) ) {
- ERR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx",
+ ERROR("PT base is bad. pfn=%lu nr=%lu type=%08lx %08lx",
pfn, max_pfn, pfn_type[pfn],
(unsigned long)pt_levels<<XEN_DOMCTL_PFINFO_LTAB_SHIFT);
goto out;
@@ -757,7 +757,7 @@ int xc_linux_restore(int xc_handle, int
for (i = 0; i < P2M_FL_ENTRIES; i++) {
pfn = p2m_frame_list[i];
if ((pfn >= max_pfn) || (pfn_type[pfn] != XEN_DOMCTL_PFINFO_NOTAB)) {
- ERR("PFN-to-MFN frame number is bad");
+ ERROR("PFN-to-MFN frame number is bad");
goto out;
}
@@ -767,7 +767,7 @@ int xc_linux_restore(int xc_handle, int
/* Copy the P2M we've constructed to the 'live' P2M */
if (!(live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_WRITE,
p2m_frame_list, P2M_FL_ENTRIES))) {
- ERR("Couldn't map p2m table");
+ ERROR("Couldn't map p2m table");
goto out;
}
@@ -803,7 +803,7 @@ int xc_linux_restore(int xc_handle, int
(ctxt.ldt_ents > 8192) ||
(ctxt.ldt_base > hvirt_start) ||
((ctxt.ldt_base + ctxt.ldt_ents*8) > hvirt_start)) {
- ERR("Bad LDT base or size");
+ ERROR("Bad LDT base or size");
goto out;
}
@@ -816,7 +816,7 @@ int xc_linux_restore(int xc_handle, int
rc = xc_domctl(xc_handle, &domctl);
if (rc != 0) {
- ERR("Couldn't build the domain");
+ ERROR("Couldn't build the domain");
goto out;
}
diff -r 479b17f312b0 -r 5b036362c1b0 tools/libxc/xc_linux_save.c
--- a/tools/libxc/xc_linux_save.c Tue Oct 17 18:00:51 2006 +0100
+++ b/tools/libxc/xc_linux_save.c Tue Oct 17 18:05:42 2006 +0100
@@ -363,19 +363,19 @@ static int suspend_and_state(int (*suspe
int i = 0;
if (!(*suspend)(dom)) {
- ERR("Suspend request failed");
+ ERROR("Suspend request failed");
return -1;
}
retry:
if (xc_domain_getinfo(xc_handle, dom, 1, info) != 1) {
- ERR("Could not get domain info");
+ ERROR("Could not get domain info");
return -1;
}
if ( xc_vcpu_getcontext(xc_handle, dom, 0 /* XXX */, ctxt))
- ERR("Could not get vcpu context");
+ ERROR("Could not get vcpu context");
if (info->shutdown && info->shutdown_reason == SHUTDOWN_suspend)
@@ -385,7 +385,7 @@ static int suspend_and_state(int (*suspe
// try unpausing domain, wait, and retest
xc_domain_unpause( xc_handle, dom );
- ERR("Domain was paused. Wait and re-test.");
+ ERROR("Domain was paused. Wait and re-test.");
usleep(10000); // 10ms
goto retry;
@@ -393,12 +393,12 @@ static int suspend_and_state(int (*suspe
if( ++i < 100 ) {
- ERR("Retry suspend domain.");
+ ERROR("Retry suspend domain.");
usleep(10000); // 10ms
goto retry;
}
- ERR("Unable to suspend domain.");
+ ERROR("Unable to suspend domain.");
return -1;
}
@@ -516,25 +516,25 @@ static xen_pfn_t *xc_map_m2p(int xc_hand
xmml.max_extents = m2p_chunks;
if (!(extent_start = malloc(m2p_chunks * sizeof(xen_pfn_t)))) {
- ERR("failed to allocate space for m2p mfns");
+ ERROR("failed to allocate space for m2p mfns");
return NULL;
}
set_xen_guest_handle(xmml.extent_start, extent_start);
if (xc_memory_op(xc_handle, XENMEM_machphys_mfn_list, &xmml) ||
(xmml.nr_extents != m2p_chunks)) {
- ERR("xc_get_m2p_mfns");
+ ERROR("xc_get_m2p_mfns");
return NULL;
}
if ((m2p = mmap(NULL, m2p_size, prot,
MAP_SHARED, xc_handle, 0)) == MAP_FAILED) {
- ERR("failed to mmap m2p");
+ ERROR("failed to mmap m2p");
return NULL;
}
if (!(entries = malloc(m2p_chunks * sizeof(privcmd_mmap_entry_t)))) {
- ERR("failed to allocate space for mmap entries");
+ ERROR("failed to allocate space for mmap entries");
return NULL;
}
@@ -546,7 +546,7 @@ static xen_pfn_t *xc_map_m2p(int xc_hand
if ((rc = xc_map_foreign_ranges(xc_handle, DOMID_XEN,
entries, m2p_chunks)) < 0) {
- ERR("xc_mmap_foreign_ranges failed (rc = %d)", rc);
+ ERROR("xc_mmap_foreign_ranges failed (rc = %d)", rc);
return NULL;
}
@@ -619,23 +619,23 @@ int xc_linux_save(int xc_handle, int io_
if(!get_platform_info(xc_handle, dom,
&max_mfn, &hvirt_start, &pt_levels)) {
- ERR("Unable to get platform info.");
+ ERROR("Unable to get platform info.");
return 1;
}
if (xc_domain_getinfo(xc_handle, dom, 1, &info) != 1) {
- ERR("Could not get domain info");
+ ERROR("Could not get domain info");
return 1;
}
if (mlock(&ctxt, sizeof(ctxt))) {
- ERR("Unable to mlock ctxt");
+ ERROR("Unable to mlock ctxt");
return 1;
}
/* Only have to worry about vcpu 0 even for SMP */
if (xc_vcpu_getcontext(xc_handle, dom, 0, &ctxt)) {
- ERR("Could not get vcpu context");
+ ERROR("Could not get vcpu context");
goto out;
}
shared_info_frame = info.shared_info_frame;
@@ -643,13 +643,13 @@ int xc_linux_save(int xc_handle, int io_
/* A cheesy test to see whether the domain contains valid state. */
if (ctxt.ctrlreg[3] == 0)
{
- ERR("Domain is not in a valid Linux guest OS state");
+ ERROR("Domain is not in a valid Linux guest OS state");
goto out;
}
/* cheesy sanity check */
if ((info.max_memkb >> (PAGE_SHIFT - 10)) > max_mfn) {
- ERR("Invalid state record -- pfn count out of range: %lu",
+ ERROR("Invalid state record -- pfn count out of range: %lu",
(info.max_memkb >> (PAGE_SHIFT - 10)));
goto out;
}
@@ -657,7 +657,7 @@ int xc_linux_save(int xc_handle, int io_
/* Map the shared info frame */
if(!(live_shinfo = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
PROT_READ, shared_info_frame))) {
- ERR("Couldn't map live_shinfo");
+ ERROR("Couldn't map live_shinfo");
goto out;
}
@@ -668,7 +668,7 @@ int xc_linux_save(int xc_handle, int io_
live_shinfo->arch.pfn_to_mfn_frame_list_list);
if (!live_p2m_frame_list_list) {
- ERR("Couldn't map p2m_frame_list_list (errno %d)", errno);
+ ERROR("Couldn't map p2m_frame_list_list (errno %d)", errno);
goto out;
}
@@ -678,7 +678,7 @@ int xc_linux_save(int xc_handle, int io_
P2M_FLL_ENTRIES);
if (!live_p2m_frame_list) {
- ERR("Couldn't map p2m_frame_list");
+ ERROR("Couldn't map p2m_frame_list");
goto out;
}
@@ -692,20 +692,20 @@ int xc_linux_save(int xc_handle, int io_
P2M_FL_ENTRIES);
if (!live_p2m) {
- ERR("Couldn't map p2m table");
+ ERROR("Couldn't map p2m table");
goto out;
}
/* Setup the mfn_to_pfn table mapping */
if(!(live_m2p = xc_map_m2p(xc_handle, max_mfn, PROT_READ))) {
- ERR("Failed to map live M2P table");
+ ERROR("Failed to map live M2P table");
goto out;
}
/* Get a local copy of the live_P2M_frame_list */
if(!(p2m_frame_list = malloc(P2M_FL_SIZE))) {
- ERR("Couldn't allocate p2m_frame_list array");
+ ERROR("Couldn't allocate p2m_frame_list array");
goto out;
}
memcpy(p2m_frame_list, live_p2m_frame_list, P2M_FL_SIZE);
@@ -713,8 +713,8 @@ int xc_linux_save(int xc_handle, int io_
/* Canonicalise the pfn-to-mfn table frame-number list. */
for (i = 0; i < max_pfn; i += fpp) {
if (!translate_mfn_to_pfn(&p2m_frame_list[i/fpp])) {
- ERR("Frame# in pfn-to-mfn frame list is not in pseudophys");
- ERR("entry %d: p2m_frame_list[%ld] is 0x%"PRIx64, i, i/fpp,
+ ERROR("Frame# in pfn-to-mfn frame list is not in pseudophys");
+ ERROR("entry %d: p2m_frame_list[%ld] is 0x%"PRIx64, i, i/fpp,
(uint64_t)p2m_frame_list[i/fpp]);
goto out;
}
@@ -726,7 +726,7 @@ int xc_linux_save(int xc_handle, int io_
if (xc_shadow_control(xc_handle, dom,
XEN_DOMCTL_SHADOW_OP_ENABLE_LOGDIRTY,
NULL, 0, NULL, 0, NULL) < 0) {
- ERR("Couldn't enable shadow mode");
+ ERROR("Couldn't enable shadow mode");
goto out;
}
@@ -740,7 +740,7 @@ int xc_linux_save(int xc_handle, int io_
last_iter = 1;
if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info, &ctxt)) {
- ERR("Domain appears not to have suspended");
+ ERROR("Domain appears not to have suspended");
goto out;
}
@@ -761,20 +761,20 @@ int xc_linux_save(int xc_handle, int io_
to_skip = malloc(BITMAP_SIZE);
if (!to_send || !to_fix || !to_skip) {
- ERR("Couldn't allocate to_send array");
+ ERROR("Couldn't allocate to_send array");
goto out;
}
memset(to_send, 0xff, BITMAP_SIZE);
if (mlock(to_send, BITMAP_SIZE)) {
- ERR("Unable to mlock to_send");
+ ERROR("Unable to mlock to_send");
return 1;
}
/* (to fix is local only) */
if (mlock(to_skip, BITMAP_SIZE)) {
- ERR("Unable to mlock to_skip");
+ ERROR("Unable to mlock to_skip");
return 1;
}
@@ -785,13 +785,13 @@ int xc_linux_save(int xc_handle, int io_
pfn_batch = calloc(MAX_BATCH_SIZE, sizeof(*pfn_batch));
if ((pfn_type == NULL) || (pfn_batch == NULL)) {
- ERR("failed to alloc memory for pfn_type and/or pfn_batch arrays");
+ ERROR("failed to alloc memory for pfn_type and/or pfn_batch arrays");
errno = ENOMEM;
goto out;
}
if (mlock(pfn_type, MAX_BATCH_SIZE * sizeof(*pfn_type))) {
- ERR("Unable to mlock");
+ ERROR("Unable to mlock");
goto out;
}
@@ -817,7 +817,7 @@ int xc_linux_save(int xc_handle, int io_
/* Start writing out the saved-domain record. */
if (!write_exact(io_fd, &max_pfn, sizeof(unsigned long))) {
- ERR("write: max_pfn");
+ ERROR("write: max_pfn");
goto out;
}
@@ -837,13 +837,13 @@ int xc_linux_save(int xc_handle, int io_
!write_exact(io_fd, &chunk_sig, 4) ||
!write_exact(io_fd, &chunk_sz, sizeof(chunk_sz)) ||
!write_exact(io_fd, &ctxt, sizeof(ctxt))) {
- ERR("write: extended info");
+ ERROR("write: extended info");
goto out;
}
}
if (!write_exact(io_fd, p2m_frame_list, P2M_FL_SIZE)) {
- ERR("write: p2m_frame_list");
+ ERROR("write: p2m_frame_list");
goto out;
}
@@ -877,7 +877,7 @@ int xc_linux_save(int xc_handle, int io_
if (!last_iter && xc_shadow_control(
xc_handle, dom, XEN_DOMCTL_SHADOW_OP_PEEK,
to_skip, max_pfn, NULL, 0, NULL) != max_pfn) {
- ERR("Error peeking shadow bitmap");
+ ERROR("Error peeking shadow bitmap");
goto out;
}
@@ -942,12 +942,12 @@ int xc_linux_save(int xc_handle, int io_
if ((region_base = xc_map_foreign_batch(
xc_handle, dom, PROT_READ, pfn_type, batch)) == 0) {
- ERR("map batch failed");
+ ERROR("map batch failed");
goto out;
}
if (xc_get_pfn_type_batch(xc_handle, dom, batch, pfn_type)) {
- ERR("get_pfn_type_batch failed");
+ ERROR("get_pfn_type_batch failed");
goto out;
}
@@ -978,12 +978,12 @@ int xc_linux_save(int xc_handle, int io_
}
if(!write_exact(io_fd, &batch, sizeof(unsigned int))) {
- ERR("Error when writing to state file (2)");
+ ERROR("Error when writing to state file (2)");
goto out;
}
if(!write_exact(io_fd, pfn_type, sizeof(unsigned long)*j)) {
- ERR("Error when writing to state file (3)");
+ ERROR("Error when writing to state file (3)");
goto out;
}
@@ -1013,7 +1013,7 @@ int xc_linux_save(int xc_handle, int io_
goto out;
if (ratewrite(io_fd, page, PAGE_SIZE) != PAGE_SIZE) {
- ERR("Error when writing to state file (4)");
+ ERROR("Error when writing to state file (4)");
goto out;
}
@@ -1021,7 +1021,7 @@ int xc_linux_save(int xc_handle, int io_
/* We have a normal page: just write it directly. */
if (ratewrite(io_fd, spage, PAGE_SIZE) != PAGE_SIZE) {
- ERR("Error when writing to state file (5)");
+ ERROR("Error when writing to state file (5)");
goto out;
}
}
@@ -1056,7 +1056,7 @@ int xc_linux_save(int xc_handle, int io_
/* send "-1" to put receiver into debug mode */
if(!write_exact(io_fd, &minusone, sizeof(int))) {
- ERR("Error when writing to state file (6)");
+ ERROR("Error when writing to state file (6)");
goto out;
}
@@ -1079,7 +1079,7 @@ int xc_linux_save(int xc_handle, int io_
if (suspend_and_state(suspend, xc_handle, io_fd, dom, &info,
&ctxt)) {
- ERR("Domain appears not to have suspended");
+ ERROR("Domain appears not to have suspended");
goto out;
}
@@ -1092,7 +1092,7 @@ int xc_linux_save(int xc_handle, int io_
if (xc_shadow_control(xc_handle, dom,
XEN_DOMCTL_SHADOW_OP_CLEAN, to_send,
max_pfn, NULL, 0, &stats) != max_pfn) {
- ERR("Error flushing shadow PT");
+ ERROR("Error flushing shadow PT");
goto out;
}
@@ -1110,7 +1110,7 @@ int xc_linux_save(int xc_handle, int io_
/* Zero terminate */
i = 0;
if (!write_exact(io_fd, &i, sizeof(int))) {
- ERR("Error when writing to state file (6)");
+ ERROR("Error when writing to state file (6)");
goto out;
}
@@ -1125,7 +1125,7 @@ int xc_linux_save(int xc_handle, int io_
}
if(!write_exact(io_fd, &j, sizeof(unsigned int))) {
- ERR("Error when writing to state file (6a)");
+ ERROR("Error when writing to state file (6a)");
goto out;
}
@@ -1137,7 +1137,7 @@ int xc_linux_save(int xc_handle, int io_
i++;
if (j == 1024 || i == max_pfn) {
if(!write_exact(io_fd, &pfntab, sizeof(unsigned long)*j)) {
- ERR("Error when writing to state file (6b)");
+ ERROR("Error when writing to state file (6b)");
goto out;
}
j = 0;
@@ -1148,21 +1148,21 @@ int xc_linux_save(int xc_handle, int io_
/* Canonicalise the suspend-record frame number. */
if ( !translate_mfn_to_pfn(&ctxt.user_regs.edx) ){
- ERR("Suspend record is not in range of pseudophys map");
+ ERROR("Suspend record is not in range of pseudophys map");
goto out;
}
/* Canonicalise each GDT frame number. */
for ( i = 0; i < ctxt.gdt_ents; i += 512 ) {
if ( !translate_mfn_to_pfn(&ctxt.gdt_frames[i]) ) {
- ERR("GDT frame is not in range of pseudophys map");
+ ERROR("GDT frame is not in range of pseudophys map");
goto out;
}
}
/* Canonicalise the page table base pointer. */
if ( !MFN_IS_IN_PSEUDOPHYS_MAP(xen_cr3_to_pfn(ctxt.ctrlreg[3])) ) {
- ERR("PT base is not in range of pseudophys map");
+ ERROR("PT base is not in range of pseudophys map");
goto out;
}
ctxt.ctrlreg[3] =
@@ -1170,7 +1170,7 @@ int xc_linux_save(int xc_handle, int io_
if (!write_exact(io_fd, &ctxt, sizeof(ctxt)) ||
!write_exact(io_fd, live_shinfo, PAGE_SIZE)) {
- ERR("Error when writing to state file (1)");
+ ERROR("Error when writing to state file (1)");
goto out;
}
diff -r 479b17f312b0 -r 5b036362c1b0 tools/libxc/xc_private.h
--- a/tools/libxc/xc_private.h Tue Oct 17 18:00:51 2006 +0100
+++ b/tools/libxc/xc_private.h Tue Oct 17 18:05:42 2006 +0100
@@ -58,11 +58,6 @@
#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 { \
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|