ia64/xen-unstable

changeset 18533:0c8d2e44126d

x86: Add sysctl for cpu online/offline

Signed-off-by: Shan Haitao <haitao.shan@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Sep 22 16:07:04 2008 +0100 (2008-09-22)
parents 415c3da25b26
children df6f9fe48f11
files xen/arch/x86/sysctl.c xen/include/public/sysctl.h
line diff
     1.1 --- a/xen/arch/x86/sysctl.c	Mon Sep 22 15:56:12 2008 +0100
     1.2 +++ b/xen/arch/x86/sysctl.c	Mon Sep 22 16:07:04 2008 +0100
     1.3 @@ -29,6 +29,12 @@
     1.4  
     1.5  #define get_xen_guest_handle(val, hnd)  do { val = (hnd).p; } while (0)
     1.6  
     1.7 +static long cpu_down_helper(void *data)
     1.8 +{
     1.9 +    int cpu = (unsigned long)data;
    1.10 +    return cpu_down(cpu);
    1.11 +}
    1.12 +
    1.13  long arch_do_sysctl(
    1.14      struct xen_sysctl *sysctl, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
    1.15  {
    1.16 @@ -92,6 +98,25 @@ long arch_do_sysctl(
    1.17      }
    1.18      break;
    1.19      
    1.20 +    case XEN_SYSCTL_cpu_hotplug:
    1.21 +    {
    1.22 +        unsigned int cpu = sysctl->u.cpu_hotplug.cpu;
    1.23 +
    1.24 +        switch ( sysctl->u.cpu_hotplug.op )
    1.25 +        {
    1.26 +        case XEN_SYSCTL_CPU_HOTPLUG_ONLINE:
    1.27 +            ret = cpu_up(cpu);
    1.28 +            break;
    1.29 +        case XEN_SYSCTL_CPU_HOTPLUG_OFFLINE:
    1.30 +            ret = continue_hypercall_on_cpu(
    1.31 +                0, cpu_down_helper, (void *)(unsigned long)cpu);
    1.32 +            break;
    1.33 +        default:
    1.34 +            ret = -EINVAL;
    1.35 +            break;
    1.36 +        }
    1.37 +    }
    1.38 +    break;
    1.39  
    1.40      default:
    1.41          ret = -ENOSYS;
     2.1 --- a/xen/include/public/sysctl.h	Mon Sep 22 15:56:12 2008 +0100
     2.2 +++ b/xen/include/public/sysctl.h	Mon Sep 22 16:07:04 2008 +0100
     2.3 @@ -262,6 +262,18 @@ struct xen_sysctl_get_pmstat {
     2.4  typedef struct xen_sysctl_get_pmstat xen_sysctl_get_pmstat_t;
     2.5  DEFINE_XEN_GUEST_HANDLE(xen_sysctl_get_pmstat_t);
     2.6  
     2.7 +#define XEN_SYSCTL_cpu_hotplug       11
     2.8 +struct xen_sysctl_cpu_hotplug {
     2.9 +    /* IN variables */
    2.10 +    uint32_t cpu;   /* Physical cpu. */
    2.11 +#define XEN_SYSCTL_CPU_HOTPLUG_ONLINE  0
    2.12 +#define XEN_SYSCTL_CPU_HOTPLUG_OFFLINE 1
    2.13 +    uint32_t op;    /* hotplug opcode */
    2.14 +};
    2.15 +typedef struct xen_sysctl_cpu_hotplug xen_sysctl_cpu_hotplug_t;
    2.16 +DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_hotplug_t);
    2.17 +
    2.18 +
    2.19  struct xen_sysctl {
    2.20      uint32_t cmd;
    2.21      uint32_t interface_version; /* XEN_SYSCTL_INTERFACE_VERSION */
    2.22 @@ -276,6 +288,7 @@ struct xen_sysctl {
    2.23          struct xen_sysctl_getcpuinfo        getcpuinfo;
    2.24          struct xen_sysctl_availheap         availheap;
    2.25          struct xen_sysctl_get_pmstat        get_pmstat;
    2.26 +        struct xen_sysctl_cpu_hotplug       cpu_hotplug;
    2.27          uint8_t                             pad[128];
    2.28      } u;
    2.29  };