]> xenbits.xensource.com Git - xen.git/commitdiff
bitkeeper revision 1.1159.120.2 (4177c0c45rkuaBFhtYj9E1LEJ8ti4w)
authormwilli2@equilibrium.research <mwilli2@equilibrium.research>
Thu, 21 Oct 2004 13:59:32 +0000 (13:59 +0000)
committermwilli2@equilibrium.research <mwilli2@equilibrium.research>
Thu, 21 Oct 2004 13:59:32 +0000 (13:59 +0000)
Unify 2.4 and 2.6 balloon drivers, xm can now control balloon in 2.4 domains.
More random docs work.

.bk-to-hg
.hg-to-bk
.rootkeys
docs/user.tex
linux-2.6.8.1-xen-sparse/drivers/xen/balloon/balloon.c

index 039e4d0069c5c26909f86c505b9de66182e6d1f3..12a1c40d891ffefa0990137249e67059443e0e6a 100755 (executable)
--- a/.bk-to-hg
+++ b/.bk-to-hg
@@ -1,2 +1,6 @@
-#!/bin/sh
+#!/bin/sh -x
+set -e
+test -L linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c
+rm      linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c
+(find -depth -type d -print | xargs -r rmdir 2>/dev/null) || true
 exit 0
index 039e4d0069c5c26909f86c505b9de66182e6d1f3..61fc3a1ccf096d3a0ef60b48eb340d61d1e6e5b6 100755 (executable)
--- a/.hg-to-bk
+++ b/.hg-to-bk
@@ -1,2 +1,10 @@
-#!/bin/sh
+#!/bin/sh -x
+set -e
+mkdir -p linux-2.4.27-xen-sparse
+mkdir -p linux-2.4.27-xen-sparse/arch
+mkdir -p linux-2.4.27-xen-sparse/arch/xen
+mkdir -p linux-2.4.27-xen-sparse/arch/xen/drivers
+mkdir -p linux-2.4.27-xen-sparse/arch/xen/drivers/balloon
+ln -s ../../../../../linux-2.6.8.1-xen-sparse/drivers/xen/balloon/balloon.c linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c
+(find -depth -type d -print | xargs -r rmdir 2>/dev/null) || true
 exit 0
index 68d490af9f03887f37fa068eef40f6f68c724d83..e438a2178303ece19550d26bd14058f00903f665 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
@@ -50,7 +50,7 @@
 40648526SxcA4lGIHB_k7ID8VlRSzw linux-2.4.27-xen-sparse/arch/xen/defconfig-xen0
 40c73c77QesbL7eIvG-fJGAtVwhGRg linux-2.4.27-xen-sparse/arch/xen/defconfig-xenU
 3e6377f5xwPfYZkPHPrDbEq1PRN7uQ linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/Makefile
-3e6377f8Me8IqtvEhb70XFgOvqQH7A linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c
+4177c0c3ju-Bo3TJaQHh4fOsy06UgQ linux-2.4.27-xen-sparse/arch/xen/drivers/balloon/balloon.c
 4083dc16z0jvZEH4PiVDbDRreaNp6w linux-2.4.27-xen-sparse/arch/xen/drivers/blkif/Makefile
 4083dc16KQus88a4U3uCV6qVCA6_8Q linux-2.4.27-xen-sparse/arch/xen/drivers/blkif/backend/Makefile
 4075806dI5kfeMD5RV-DA0PYoThx_w linux-2.4.27-xen-sparse/arch/xen/drivers/blkif/frontend/Makefile
index 31d57ed06db42f7db22d239885e431d44fd52363..eb77180d1cb3dda926deb923f689f73987b67548 100644 (file)
@@ -696,6 +696,31 @@ The {\tt xm list} command also supports a long output format when the
 {\tt -l} switch is used.  This outputs the fulls details of the
 running domains in Xend's SXP configuration format.
 
+For example, suppose the system is running the ttylinux domain as
+described earlier.  The list command should produce output somewhat
+like the following:
+\begin{verbatim}
+# xm list
+Name              Id  Mem(MB)  CPU  State  Time(s)  Console
+Domain-0           0      251    0  r----    172.2        
+ttylinux           5       63    0  -b---      3.0    9605
+\end{verbatim}
+
+Here we can see the details for the ttylinux domain, as well as for
+domain 0 (which of course is always running).  Note that the console
+port for the ttylinux domain is 9605.  This can be connected to by TCP
+using a terminal program (e.g. {\tt telnet} or, better, {\tt
+xencons}).  The simplest way to connect is to use the {\tt xm console}
+command, specifying the domain name or ID.  To connect to the console
+of the ttylinux domain, we could use:
+\begin{verbatim}
+# xm console ttylinux
+\end{verbatim}
+or:
+\begin{verbatim}
+# xm console 5
+\end{verbatim}
+
 \chapter{Other kinds of storage}
 
 It is possible to use any Linux block device to store virtual machine
index 47b7c796ec6a062fd69fc8fbb72053a4548b6350..d270cbf0cb5f3f9d975006401046cf9ac290f302 100644 (file)
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/errno.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #include <asm-xen/xen_proc.h>
+#else
+#include <asm/xen_proc.h>
+#endif
 
 #include <linux/mm.h>
 #include <linux/mman.h>
 #include <linux/highmem.h>
 #include <linux/vmalloc.h>
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #include <asm-xen/hypervisor.h>
 #include <asm-xen/ctrl_if.h>
+#else
+#include <asm/hypervisor.h>
+#include <asm/ctrl_if.h>
+#endif
+
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
@@ -58,7 +69,11 @@ static inline pte_t *get_ptep(unsigned long addr)
     pmd = pmd_offset(pgd, addr);
     if ( pmd_none(*pmd) || pmd_bad(*pmd) ) BUG();
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
     ptep = pte_offset_kernel(pmd, addr);
+#else
+    ptep = pte_offset(pmd, addr);
+#endif
 
     return ptep;
 }
@@ -258,7 +273,11 @@ static void pagetable_extend (int cur_low_pfn, int newpages)
     end = (unsigned long)__va(low_pfn*PAGE_SIZE);
 
     pgd_base = init_mm.pgd;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
     i = pgd_index(PAGE_OFFSET);
+#else
+    i = __pgd_offset(PAGE_OFFSET);
+#endif
     pgd = pgd_base + i;
 
     for (; i < PTRS_PER_PGD; pgd++, i++) {
@@ -281,11 +300,19 @@ static void pagetable_extend (int cur_low_pfn, int newpages)
                 vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE;
                 if (end && (vaddr >= end))
                     break;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
                 *pte = mk_pte(virt_to_page(vaddr), PAGE_KERNEL);
+#else
+               *pte = mk_pte_phys(__pa(vaddr), PAGE_KERNEL);
+#endif
             }
             kpgd = pgd_offset_k((unsigned long)pte_base);
             kpmd = pmd_offset(kpgd, (unsigned long)pte_base);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
             kpte = pte_offset_kernel(kpmd, (unsigned long)pte_base);
+#else
+           kpte = pte_offset(kpmd, (unsigned long)pte_base);
+#endif
             queue_l1_entry_update(kpte,
                                   (*(unsigned long *)kpte)&~_PAGE_RW);
             set_pmd(pmd, __pmd(_KERNPG_TABLE + __pa(pte_base)));
@@ -453,6 +480,7 @@ static void balloon_ctrlif_rx(ctrl_msg_t *msg, unsigned long id)
 }
 
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 static int balloon_write(struct file *file, const char *buffer,
                          size_t count, loff_t *offp)
 {
@@ -492,7 +520,6 @@ static int balloon_write(struct file *file, const char *buffer,
     return len;
 }
 
-
 static int balloon_read(struct file *filp, char *buffer,
                         size_t count, loff_t *offp)
 {
@@ -516,6 +543,98 @@ static struct file_operations balloon_fops = {
     .read  = balloon_read,
     .write = balloon_write
 };
+#else
+
+
+static int balloon_write(struct file *file, const char *buffer,
+                         u_long count, void *data)
+{
+    char memstring[64], *endchar;
+    int len, i;
+    unsigned long target;
+    unsigned long long targetbytes;
+
+    /* Only admin can play with the balloon :) */
+    if ( !capable(CAP_SYS_ADMIN) )
+        return -EPERM;
+
+    if ( count > sizeof(memstring) )
+        return -EFBIG;
+
+    len = strnlen_user(buffer, count);
+    if ( len == 0 ) return -EBADMSG;
+    if ( len == 1 ) return 1; /* input starts with a NUL char */
+    if ( strncpy_from_user(memstring, buffer, len) < 0 )
+        return -EFAULT;
+
+    endchar = memstring;
+    for ( i = 0; i < len; ++i, ++endchar )
+        if ( (memstring[i] < '0') || (memstring[i] > '9') )
+            break;
+    if ( i == 0 )
+        return -EBADMSG;
+
+    targetbytes = memparse(memstring,&endchar);
+    target = targetbytes >> PAGE_SHIFT;
+
+    if ( target < current_pages )
+    {
+        int change = inflate_balloon(current_pages-target);
+        if ( change <= 0 )
+            return change;
+
+        current_pages -= change;
+        printk(KERN_INFO "Relinquish %dMB to xen. Domain now has %luMB\n",
+            change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
+    }
+    else if ( target > current_pages )
+    {
+        int change, reclaim = min(target,most_seen_pages) - current_pages;
+
+        if ( reclaim )
+        {
+            change = deflate_balloon( reclaim);
+            if ( change <= 0 )
+                return change;
+            current_pages += change;
+            printk(KERN_INFO "Reclaim %dMB from xen. Domain now has %luMB\n",
+                change>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
+        }
+
+        if ( most_seen_pages < target )
+        {
+            int growth = claim_new_pages(target-most_seen_pages);
+            if ( growth <= 0 )
+                return growth;
+            most_seen_pages += growth;
+            current_pages += growth;
+            printk(KERN_INFO "Granted %dMB new mem. Dom now has %luMB\n",
+                growth>>PAGE_TO_MB_SHIFT, current_pages>>PAGE_TO_MB_SHIFT);
+        }
+    }
+
+
+    return len;
+}
+
+static int balloon_read(char *page, char **start, off_t off,
+                       int count, int *eof, void *data)
+{
+  int len;
+  len = sprintf(page,"%lu\n",current_pages<<PAGE_SHIFT);
+  
+  if (len <= off+count) *eof = 1;
+  *start = page + off;
+  len -= off;
+  if (len>count) len = count;
+  if (len<0) len = 0;
+  return len;
+}
+
+
+
+#endif
+
 
 static int __init balloon_init(void)
 {
@@ -528,9 +647,14 @@ static int __init balloon_init(void)
         return -1;
     }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
     balloon_pde->owner     = THIS_MODULE;
     balloon_pde->nlink     = 1;
     balloon_pde->proc_fops = &balloon_fops;
+#else
+    balloon_pde->write_proc = balloon_write;
+    balloon_pde->read_proc  = balloon_read;
+#endif
 
     (void)ctrl_if_register_receiver(CMSG_MEM_REQUEST, balloon_ctrlif_rx,
                                     CALLBACK_IN_BLOCKING_CONTEXT);