ia64/xen-unstable

changeset 19687:84c1f7c46444

Export page offline hypercalls to user space tools.

Signed-off-by: Jiang, Yunhong <yunhong.jiang@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Jun 01 14:08:58 2009 +0100 (2009-06-01)
parents 50134a902c66
children bd39df93a29e
files tools/libxc/Makefile tools/libxc/xc_offline_page.c tools/libxc/xenguest.h
line diff
     1.1 --- a/tools/libxc/Makefile	Mon Jun 01 14:07:46 2009 +0100
     1.2 +++ b/tools/libxc/Makefile	Mon Jun 01 14:08:58 2009 +0100
     1.3 @@ -32,6 +32,7 @@ CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.
     1.4  GUEST_SRCS-y :=
     1.5  GUEST_SRCS-y += xg_private.c xc_suspend.c
     1.6  GUEST_SRCS-$(CONFIG_MIGRATE) += xc_domain_restore.c xc_domain_save.c
     1.7 +GUEST_SRCS-y += xc_offline_page.c
     1.8  GUEST_SRCS-$(CONFIG_HVM) += xc_hvm_build.c
     1.9  
    1.10  vpath %.c ../../xen/common/libelf
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/libxc/xc_offline_page.c	Mon Jun 01 14:08:58 2009 +0100
     2.3 @@ -0,0 +1,100 @@
     2.4 +/******************************************************************************
     2.5 + * xc_offline_page.c
     2.6 + *
     2.7 + * Helper functions to offline/online one page
     2.8 + *
     2.9 + * Copyright (c) 2003, K A Fraser.
    2.10 + * Copyright (c) 2009, Intel Corporation.
    2.11 + */
    2.12 +
    2.13 +#include <inttypes.h>
    2.14 +#include <time.h>
    2.15 +#include <stdlib.h>
    2.16 +#include <unistd.h>
    2.17 +#include <sys/time.h>
    2.18 +
    2.19 +#include "xc_private.h"
    2.20 +#include "xc_dom.h"
    2.21 +#include "xg_private.h"
    2.22 +#include "xg_save_restore.h"
    2.23 +
    2.24 +int xc_mark_page_online(int xc, unsigned long start,
    2.25 +                        unsigned long end, uint32_t *status)
    2.26 +{
    2.27 +    DECLARE_SYSCTL;
    2.28 +    int ret = -1;
    2.29 +
    2.30 +    if ( !status || (end < start) )
    2.31 +        return -EINVAL;
    2.32 +
    2.33 +    if (lock_pages(status, sizeof(uint32_t)*(end - start + 1)))
    2.34 +    {
    2.35 +        ERROR("Could not lock memory for xc_mark_page_online\n");
    2.36 +        return -EINVAL;
    2.37 +    }
    2.38 +
    2.39 +    sysctl.cmd = XEN_SYSCTL_page_offline_op;
    2.40 +    sysctl.u.page_offline.start = start;
    2.41 +    sysctl.u.page_offline.cmd = sysctl_page_online;
    2.42 +    sysctl.u.page_offline.end = end;
    2.43 +    set_xen_guest_handle(sysctl.u.page_offline.status, status);
    2.44 +    ret = xc_sysctl(xc, &sysctl);
    2.45 +
    2.46 +    unlock_pages(status, sizeof(uint32_t)*(end - start + 1));
    2.47 +
    2.48 +    return ret;
    2.49 +}
    2.50 +
    2.51 +int xc_mark_page_offline(int xc, unsigned long start,
    2.52 +                          unsigned long end, uint32_t *status)
    2.53 +{
    2.54 +    DECLARE_SYSCTL;
    2.55 +    int ret = -1;
    2.56 +
    2.57 +    if ( !status || (end < start) )
    2.58 +        return -EINVAL;
    2.59 +
    2.60 +    if (lock_pages(status, sizeof(uint32_t)*(end - start + 1)))
    2.61 +    {
    2.62 +        ERROR("Could not lock memory for xc_mark_page_offline");
    2.63 +        return -EINVAL;
    2.64 +    }
    2.65 +
    2.66 +    sysctl.cmd = XEN_SYSCTL_page_offline_op;
    2.67 +    sysctl.u.page_offline.start = start;
    2.68 +    sysctl.u.page_offline.cmd = sysctl_page_offline;
    2.69 +    sysctl.u.page_offline.end = end;
    2.70 +    set_xen_guest_handle(sysctl.u.page_offline.status, status);
    2.71 +    ret = xc_sysctl(xc, &sysctl);
    2.72 +
    2.73 +    unlock_pages(status, sizeof(uint32_t)*(end - start + 1));
    2.74 +
    2.75 +    return ret;
    2.76 +}
    2.77 +
    2.78 +int xc_query_page_offline_status(int xc, unsigned long start,
    2.79 +                                 unsigned long end, uint32_t *status)
    2.80 +{
    2.81 +    DECLARE_SYSCTL;
    2.82 +    int ret = -1;
    2.83 +
    2.84 +    if ( !status || (end < start) )
    2.85 +        return -EINVAL;
    2.86 +
    2.87 +    if (lock_pages(status, sizeof(uint32_t)*(end - start + 1)))
    2.88 +    {
    2.89 +        ERROR("Could not lock memory for xc_query_page_offline_status\n");
    2.90 +        return -EINVAL;
    2.91 +    }
    2.92 +
    2.93 +    sysctl.cmd = XEN_SYSCTL_page_offline_op;
    2.94 +    sysctl.u.page_offline.start = start;
    2.95 +    sysctl.u.page_offline.cmd = sysctl_query_page_offline;
    2.96 +    sysctl.u.page_offline.end = end;
    2.97 +    set_xen_guest_handle(sysctl.u.page_offline.status, status);
    2.98 +    ret = xc_sysctl(xc, &sysctl);
    2.99 +
   2.100 +    unlock_pages(status, sizeof(uint32_t)*(end - start + 1));
   2.101 +
   2.102 +    return ret;
   2.103 +}
     3.1 --- a/tools/libxc/xenguest.h	Mon Jun 01 14:07:46 2009 +0100
     3.2 +++ b/tools/libxc/xenguest.h	Mon Jun 01 14:08:58 2009 +0100
     3.3 @@ -154,4 +154,13 @@ int xc_suspend_evtchn_init(int xc, int x
     3.4  
     3.5  int xc_await_suspend(int xce, int suspend_evtchn);
     3.6  
     3.7 +int xc_mark_page_online(int xc, unsigned long start,
     3.8 +                        unsigned long end, uint32_t *status);
     3.9 +
    3.10 +int xc_mark_page_offline(int xc, unsigned long start,
    3.11 +                          unsigned long end, uint32_t *status);
    3.12 +
    3.13 +int xc_query_page_offline_status(int xc, unsigned long start,
    3.14 +                                 unsigned long end, uint32_t *status);
    3.15 +
    3.16  #endif /* XENGUEST_H */