ia64/xen-unstable

changeset 5964:3f1785f02d89

Manual merge.
author smh22@firebug.cl.cam.ac.uk
date Tue Aug 02 11:35:45 2005 +0000 (2005-08-02)
parents 2609af9986e6 3a11dbf5e4b6
children 1640c137c847
files .hgignore linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c tools/Makefile tools/libxc/xc_ia64_stubs.c tools/pygrub/src/fsys/ext2/ext2module.c tools/python/xen/xend/XendDomainInfo.py xen/arch/x86/shadow_public.c
line diff
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Aug 02 11:34:38 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/balloon/balloon.c	Tue Aug 02 11:35:45 2005 +0000
     2.3 @@ -5,6 +5,7 @@
     2.4   *
     2.5   * Copyright (c) 2003, B Dragovic
     2.6   * Copyright (c) 2003-2004, M Williamson, K Fraser
     2.7 + * Copyright (c) 2005 Dan M. Smith, IBM Corporation
     2.8   * 
     2.9   * This file may be distributed separately from the Linux kernel, or
    2.10   * incorporated into other software packages, subject to the following license:
    2.11 @@ -42,7 +43,6 @@
    2.12  #include <linux/vmalloc.h>
    2.13  #include <asm-xen/xen_proc.h>
    2.14  #include <asm-xen/hypervisor.h>
    2.15 -#include <asm-xen/ctrl_if.h>
    2.16  #include <asm-xen/balloon.h>
    2.17  #include <asm/pgalloc.h>
    2.18  #include <asm/pgtable.h>
    2.19 @@ -50,6 +50,10 @@
    2.20  #include <asm/tlb.h>
    2.21  #include <linux/list.h>
    2.22  
    2.23 +#include<asm-xen/xenbus.h>
    2.24 +
    2.25 +#define PAGES2KB(_p) ((_p)<<(PAGE_SHIFT-10))
    2.26 +
    2.27  static struct proc_dir_entry *balloon_pde;
    2.28  
    2.29  static DECLARE_MUTEX(balloon_mutex);
    2.30 @@ -77,11 +81,17 @@ static void balloon_process(void *unused
    2.31  static DECLARE_WORK(balloon_worker, balloon_process, NULL);
    2.32  static struct timer_list balloon_timer;
    2.33  
    2.34 +/* Flag for dom0 xenstore workaround */
    2.35 +static int balloon_xenbus_init=0;
    2.36 +
    2.37 +/* Init Function */
    2.38 +void balloon_init_watcher(void);
    2.39 +
    2.40  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
    2.41  /* Use the private and mapping fields of struct page as a list. */
    2.42  #define PAGE_TO_LIST(p) ( (struct list_head *)&p->private )
    2.43  #define LIST_TO_PAGE(l) ( list_entry( ((unsigned long *)l),   \
    2.44 -				      struct page, private ) )
    2.45 +                                      struct page, private ) )
    2.46  #define UNLIST_PAGE(p)  do { list_del(PAGE_TO_LIST(p));       \
    2.47                               p->mapping = NULL;               \
    2.48                               p->private = 0; } while(0)
    2.49 @@ -297,26 +307,97 @@ static void set_new_target(unsigned long
    2.50      schedule_work(&balloon_worker);
    2.51  }
    2.52  
    2.53 -static void balloon_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
    2.54 +static struct xenbus_watch xb_watch =
    2.55 +{
    2.56 +    .node = "memory"
    2.57 +};
    2.58 +
    2.59 +/* FIXME: This is part of a dom0 sequencing workaround */
    2.60 +static struct xenbus_watch root_watch =
    2.61  {
    2.62 -    switch ( msg->subtype )
    2.63 -    {
    2.64 -    case CMSG_MEM_REQUEST_SET:
    2.65 +    .node = "/"
    2.66 +};
    2.67 +
    2.68 +/* React to a change in the target key */
    2.69 +static void watch_target(struct xenbus_watch *watch, const char *node)
    2.70 +{
    2.71 +    unsigned long new_target;
    2.72 +    int err;
    2.73 +
    2.74 +    if(watch == &root_watch)
    2.75      {
    2.76 -        mem_request_t *req = (mem_request_t *)&msg->msg[0];
    2.77 -        set_new_target(req->target);
    2.78 -        req->status = 0;
    2.79 -    }
    2.80 -    break;        
    2.81 -
    2.82 -    default:
    2.83 -        msg->length = 0;
    2.84 -        break;
    2.85 +        /* FIXME: This is part of a dom0 sequencing workaround */
    2.86 +        if(register_xenbus_watch(&xb_watch) == 0)
    2.87 +        {
    2.88 +            /* 
    2.89 +               We successfully set a watch on memory/target:
    2.90 +               now we can stop watching root 
    2.91 +            */
    2.92 +            unregister_xenbus_watch(&root_watch);
    2.93 +            balloon_xenbus_init=1;
    2.94 +        } 
    2.95 +        else 
    2.96 +        {
    2.97 +            return;
    2.98 +        }
    2.99      }
   2.100  
   2.101 -    ctrl_if_send_response(msg);
   2.102 +    err = xenbus_scanf("memory", "target", "%lu", &new_target);
   2.103 +        
   2.104 +    if(err != 1) 
   2.105 +    {
   2.106 +        IPRINTK("Unable to read memory/target\n");
   2.107 +        return;
   2.108 +    } 
   2.109 +        
   2.110 +    set_new_target(new_target >> PAGE_SHIFT);
   2.111 +    
   2.112  }
   2.113  
   2.114 +/* 
   2.115 +   Try to set up our watcher, if not already set
   2.116 +   
   2.117 +*/
   2.118 +void balloon_init_watcher(void) 
   2.119 +{
   2.120 +    int err;
   2.121 +
   2.122 +    if(!xen_start_info.store_evtchn)
   2.123 +    {
   2.124 +        IPRINTK("Delaying watcher init until xenstore is available\n");
   2.125 +        return;
   2.126 +    }
   2.127 +
   2.128 +    down(&xenbus_lock);
   2.129 +
   2.130 +    if(! balloon_xenbus_init) 
   2.131 +    {
   2.132 +        err = register_xenbus_watch(&xb_watch);
   2.133 +        if(err) 
   2.134 +        {
   2.135 +            /* BIG FAT FIXME: dom0 sequencing workaround
   2.136 +             * dom0 can't set a watch on memory/target until
   2.137 +             * after the tools create it.  So, we have to watch
   2.138 +             * the whole store until that happens.
   2.139 +             *
   2.140 +             * This will go away when we have the ability to watch
   2.141 +             * non-existant keys
   2.142 +             */
   2.143 +            register_xenbus_watch(&root_watch);
   2.144 +        } 
   2.145 +        else
   2.146 +        {
   2.147 +            IPRINTK("Balloon xenbus watcher initialized\n");
   2.148 +            balloon_xenbus_init = 1;
   2.149 +        }
   2.150 +    }
   2.151 +
   2.152 +    up(&xenbus_lock);
   2.153 +
   2.154 +}
   2.155 +
   2.156 +EXPORT_SYMBOL(balloon_init_watcher);
   2.157 +
   2.158  static int balloon_write(struct file *file, const char __user *buffer,
   2.159                           unsigned long count, void *data)
   2.160  {
   2.161 @@ -346,7 +427,6 @@ static int balloon_read(char *page, char
   2.162  {
   2.163      int len;
   2.164  
   2.165 -#define K(_p) ((_p)<<(PAGE_SHIFT-10))
   2.166      len = sprintf(
   2.167          page,
   2.168          "Current allocation: %8lu kB\n"
   2.169 @@ -354,13 +434,14 @@ static int balloon_read(char *page, char
   2.170          "Low-mem balloon:    %8lu kB\n"
   2.171          "High-mem balloon:   %8lu kB\n"
   2.172          "Xen hard limit:     ",
   2.173 -        K(current_pages), K(target_pages), K(balloon_low), K(balloon_high));
   2.174 +        PAGES2KB(current_pages), PAGES2KB(target_pages), 
   2.175 +        PAGES2KB(balloon_low), PAGES2KB(balloon_high));
   2.176  
   2.177      if ( hard_limit != ~0UL )
   2.178          len += sprintf(
   2.179              page + len, 
   2.180              "%8lu kB (inc. %8lu kB driver headroom)\n",
   2.181 -            K(hard_limit), K(driver_pages));
   2.182 +            PAGES2KB(hard_limit), PAGES2KB(driver_pages));
   2.183      else
   2.184          len += sprintf(
   2.185              page + len,
   2.186 @@ -396,9 +477,7 @@ static int __init balloon_init(void)
   2.187  
   2.188      balloon_pde->read_proc  = balloon_read;
   2.189      balloon_pde->write_proc = balloon_write;
   2.190 -
   2.191 -    (void)ctrl_if_register_receiver(CMSG_MEM_REQUEST, balloon_ctrlif_rx, 0);
   2.192 -
   2.193 +    
   2.194      /* Initialise the balloon with excess memory space. */
   2.195      for ( pfn = xen_start_info.nr_pages; pfn < max_pfn; pfn++ )
   2.196      {
   2.197 @@ -407,6 +486,11 @@ static int __init balloon_init(void)
   2.198              balloon_append(page);
   2.199      }
   2.200  
   2.201 +    xb_watch.callback = watch_target;
   2.202 +    root_watch.callback = watch_target;
   2.203 +
   2.204 +    balloon_init_watcher();
   2.205 +
   2.206      return 0;
   2.207  }
   2.208  
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Aug 02 11:34:38 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Aug 02 11:35:45 2005 +0000
     3.3 @@ -309,6 +309,9 @@ int do_xenbus_probe(void *unused)
     3.4  		return err;
     3.5  	}
     3.6  
     3.7 +	/* Initialize non-xenbus drivers */
     3.8 +	balloon_init_watcher();
     3.9 +
    3.10  	down(&xenbus_lock);
    3.11  	/* Enumerate devices in xenstore. */
    3.12  	xenbus_probe_devices("device");
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/libxc/xc_ia64_stubs.c	Tue Aug 02 11:35:45 2005 +0000
     5.3 @@ -0,0 +1,39 @@
     5.4 +#include "xc_private.h"
     5.5 +
     5.6 +int xc_linux_save(int xc_handle, int io_fd, u32 dom)
     5.7 +{
     5.8 +    PERROR("xc_linux_save not implemented\n");
     5.9 +    return -1;
    5.10 +}
    5.11 +
    5.12 +int xc_linux_restore(int xc_handle, int io_fd, u32 dom, unsigned long nr_pfns)
    5.13 +{
    5.14 +    PERROR("xc_linux_restore not implemented\n");
    5.15 +    return -1;
    5.16 +}
    5.17 +
    5.18 +int xc_vmx_build(int xc_handle,
    5.19 +                   u32 domid,
    5.20 +                   int memsize,
    5.21 +                   const char *image_name,
    5.22 +                   struct mem_map *mem_mapp,
    5.23 +                   const char *ramdisk_name,
    5.24 +                   const char *cmdline,
    5.25 +                   unsigned int control_evtchn,
    5.26 +                   unsigned long flags)
    5.27 +{
    5.28 +    PERROR("xc_vmx_build not implemented\n");
    5.29 +    return -1;
    5.30 +}
    5.31 +
    5.32 +int
    5.33 +xc_plan9_build(int xc_handle,
    5.34 +               u32 domid,
    5.35 +               const char *image_name,
    5.36 +               const char *cmdline,
    5.37 +               unsigned int control_evtchn, unsigned long flags)
    5.38 +{
    5.39 +    PERROR("xc_plan9_build not implemented\n");
    5.40 +    return -1;
    5.41 +}
    5.42 +
     7.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 02 11:34:38 2005 +0000
     7.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Tue Aug 02 11:35:45 2005 +0000
     7.3 @@ -152,6 +152,9 @@ class XendDomainInfo:
     7.4          vm = cls(db)
     7.5          vm.construct(config)
     7.6          vm.saveToDB(sync=True)
     7.7 +        # Flush info to xenstore immediately
     7.8 +        vm.exportToDB()
     7.9 +
    7.10          return vm
    7.11  
    7.12      create = classmethod(create)
    7.13 @@ -172,6 +175,7 @@ class XendDomainInfo:
    7.14          log.debug('config=' + prettyprintstring(config))
    7.15  
    7.16          vm.memory = info['mem_kb']/1024
    7.17 +        vm.target = info['mem_kb'] * 1024
    7.18  
    7.19          if config:
    7.20              try:
    7.21 @@ -222,6 +226,7 @@ class XendDomainInfo:
    7.22          DBVar('restart_state', ty='str'),
    7.23          DBVar('restart_time',  ty='float'),
    7.24          DBVar('restart_count', ty='int'),
    7.25 +        DBVar('target',        ty='long', path="memory/target"),
    7.26          ]
    7.27      
    7.28      def __init__(self, db):
    7.29 @@ -240,6 +245,8 @@ class XendDomainInfo:
    7.30          self.ssidref = None
    7.31          self.image = None
    7.32  
    7.33 +        self.target = None
    7.34 +
    7.35          self.channel = None
    7.36          self.store_channel = None
    7.37          self.store_mfn = None
    7.38 @@ -315,6 +322,7 @@ class XendDomainInfo:
    7.39          self.info = info
    7.40          self.memory = self.info['mem_kb'] / 1024
    7.41          self.ssidref = self.info['ssidref']
    7.42 +        self.target = self.info['mem_kb'] * 1024
    7.43  
    7.44      def state_set(self, state):
    7.45          self.state_updated.acquire()
    7.46 @@ -399,7 +407,8 @@ class XendDomainInfo:
    7.47                  ['id', self.id],
    7.48                  ['name', self.name],
    7.49                  ['memory', self.memory],
    7.50 -                ['ssidref', self.ssidref] ]
    7.51 +                ['ssidref', self.ssidref],
    7.52 +                ['target', self.target] ]
    7.53          if self.uuid:
    7.54              sxpr.append(['uuid', self.uuid])
    7.55          if self.info:
    7.56 @@ -536,6 +545,7 @@ class XendDomainInfo:
    7.57          self.memory = int(sxp.child_value(config, 'memory'))
    7.58          if self.memory is None:
    7.59              raise VmError('missing memory size')
    7.60 +        self.target = self.memory * (1 << 20)
    7.61          self.ssidref = int(sxp.child_value(config, 'ssidref'))
    7.62          cpu = sxp.child_value(config, 'cpu')
    7.63          if self.recreate and self.id and cpu is not None and int(cpu) >= 0:
    7.64 @@ -947,11 +957,12 @@ class XendDomainInfo:
    7.65              index[field_name] = field_index + 1
    7.66  
    7.67      def mem_target_set(self, target):
    7.68 -        """Set domain memory target in pages.
    7.69 +        """Set domain memory target in bytes.
    7.70          """
    7.71 -        if self.channel:
    7.72 -            msg = messages.packMsg('mem_request_t', { 'target' : target * (1 << 8)} )
    7.73 -            self.channel.writeRequest(msg)
    7.74 +        if target:
    7.75 +            self.target = target * (1 << 20)
    7.76 +            # Commit to XenStore immediately
    7.77 +            self.exportToDB()
    7.78  
    7.79      def vcpu_hotplug(self, vcpu, state):
    7.80          """Disable or enable VCPU in domain.
     8.1 --- a/xen/arch/x86/shadow_public.c	Tue Aug 02 11:34:38 2005 +0000
     8.2 +++ b/xen/arch/x86/shadow_public.c	Tue Aug 02 11:35:45 2005 +0000
     8.3 @@ -30,7 +30,7 @@
     8.4  #include <xen/sched.h>
     8.5  #include <xen/trace.h>
     8.6  
     8.7 -#if CONFIG_PAGING_LEVELS >= 4 
     8.8 +#if CONFIG_PAGING_LEVELS >= 3
     8.9  #include <asm/shadow_64.h>
    8.10  
    8.11  extern struct shadow_ops MODE_F_HANDLER;
    8.12 @@ -233,7 +233,20 @@ void free_monitor_pagetable(struct vcpu 
    8.13      v->arch.monitor_vtable = 0;
    8.14  }
    8.15  
    8.16 +#elif CONFIG_PAGING_LEVELS == 3
    8.17 +
    8.18 +static void alloc_monitor_pagetable(struct vcpu *v)
    8.19 +{
    8.20 +    BUG(); /* PAE not implemented yet */
    8.21 +}
    8.22 +
    8.23 +void free_monitor_pagetable(struct vcpu *v)
    8.24 +{
    8.25 +    BUG(); /* PAE not implemented yet */
    8.26 +}
    8.27 +
    8.28  #elif CONFIG_PAGING_LEVELS == 2
    8.29 +
    8.30  static void alloc_monitor_pagetable(struct vcpu *v)
    8.31  {
    8.32      unsigned long mmfn;