[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v2 05/13] libxc: Return negative value and propagate errno for xc_offline_page API
Instead of returning -Exx we now return -1 for error. We could stash the -Exx values in errno values but why - the underlaying functions we call all stash the proper errno value. Hence we just propagate it up wherver it is needed. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxc/xc_offline_page.c | 36 +++++++++++++++++++++--------------- tools/libxc/xc_private.c | 2 +- tools/misc/xen-hptool.c | 6 +++--- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tools/libxc/xc_offline_page.c b/tools/libxc/xc_offline_page.c index 3147203..d46cc5b 100644 --- a/tools/libxc/xc_offline_page.c +++ b/tools/libxc/xc_offline_page.c @@ -58,12 +58,14 @@ int xc_mark_page_online(xc_interface *xch, unsigned long start, int ret = -1; if ( !status || (end < start) ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } if ( xc_hypercall_bounce_pre(xch, status) ) { ERROR("Could not bounce memory for xc_mark_page_online\n"); - return -EINVAL; + return -1; } sysctl.cmd = XEN_SYSCTL_page_offline_op; @@ -86,12 +88,14 @@ int xc_mark_page_offline(xc_interface *xch, unsigned long start, int ret = -1; if ( !status || (end < start) ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } if ( xc_hypercall_bounce_pre(xch, status) ) { ERROR("Could not bounce memory for xc_mark_page_offline"); - return -EINVAL; + return -1; } sysctl.cmd = XEN_SYSCTL_page_offline_op; @@ -114,12 +118,14 @@ int xc_query_page_offline_status(xc_interface *xch, unsigned long start, int ret = -1; if ( !status || (end < start) ) - return -EINVAL; - + { + errno = EINVAL; + return -1; + } if ( xc_hypercall_bounce_pre(xch, status) ) { ERROR("Could not bounce memory for xc_query_page_offline_status\n"); - return -EINVAL; + return -1; } sysctl.cmd = XEN_SYSCTL_page_offline_op; @@ -411,19 +417,19 @@ int xc_exchange_page(xc_interface *xch, int domid, xen_pfn_t mfn) if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 ) { ERROR("Could not get domain info"); - return -EFAULT; + return -1; } if (!info.shutdown || info.shutdown_reason != SHUTDOWN_suspend) { + errno = EINVAL; ERROR("Can't exchange page unless domain is suspended\n"); - return -EINVAL; + return -1; } - if (!is_page_exchangable(xch, domid, mfn, &info)) { ERROR("Could not exchange page\n"); - return -EINVAL; + return -1; } /* Map M2P and obtain gpfn */ @@ -431,7 +437,7 @@ int xc_exchange_page(xc_interface *xch, int domid, xen_pfn_t mfn) if ( !(m2p_table = xc_map_m2p(xch, max_mfn, PROT_READ, NULL)) ) { PERROR("Failed to map live M2P table"); - return -EFAULT; + return -1; } gpfn = m2p_table[mfn]; @@ -440,7 +446,7 @@ int xc_exchange_page(xc_interface *xch, int domid, xen_pfn_t mfn) if ( xc_map_domain_meminfo(xch, domid, &minfo) ) { PERROR("Could not map domain's memory information\n"); - return -EFAULT; + return -1; } /* For translation macros */ diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c index df6cd9b..0735e23 100644 --- a/tools/libxc/xc_private.c +++ b/tools/libxc/xc_private.c @@ -427,7 +427,7 @@ int xc_mmuext_op( { DECLARE_HYPERCALL; DECLARE_HYPERCALL_BOUNCE(op, nr_ops*sizeof(*op), XC_HYPERCALL_BUFFER_BOUNCE_BOTH); - long ret = -EINVAL; + long ret = -1; if ( xc_hypercall_bounce_pre(xch, op) ) { diff --git a/tools/misc/xen-hptool.c b/tools/misc/xen-hptool.c index 1134603..c7561a9 100644 --- a/tools/misc/xen-hptool.c +++ b/tools/misc/xen-hptool.c @@ -49,7 +49,7 @@ static int hp_mem_online_func(int argc, char *argv[]) ret = xc_mark_page_online(xch, mfn, mfn, &status); if (ret < 0) - fprintf(stderr, "Onlining page mfn %lx failed, error %x", mfn, ret); + fprintf(stderr, "Onlining page mfn %lx failed, error %x", mfn, errno); else if (status & (PG_ONLINE_FAILED |PG_ONLINE_BROKEN)) { fprintf(stderr, "Onlining page mfn %lx is broken, " "Memory online failed\n", mfn); @@ -80,7 +80,7 @@ static int hp_mem_query_func(int argc, char *argv[]) ret = xc_query_page_offline_status(xch, mfn, mfn, &status); if (ret < 0) - fprintf(stderr, "Querying page mfn %lx failed, error %x", mfn, ret); + fprintf(stderr, "Querying page mfn %lx failed, error %x", mfn, errno); else { printf("Memory Status %x: [", status); @@ -160,7 +160,7 @@ static int hp_mem_offline_func(int argc, char *argv[]) printf("Prepare to offline MEMORY mfn %lx\n", mfn); ret = xc_mark_page_offline(xch, mfn, mfn, &status); if (ret < 0) { - fprintf(stderr, "Offlining page mfn %lx failed, error %x\n", mfn, ret); + fprintf(stderr, "Offlining page mfn %lx failed, error %x\n", mfn, errno); if (status & (PG_OFFLINE_XENPAGE | PG_OFFLINE_FAILED)) fprintf(stderr, "XEN_PAGE is not permitted be offlined\n"); else if (status & (PG_OFFLINE_FAILED | PG_OFFLINE_NOT_CONV_RAM)) -- 2.1.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |