mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
bitkeeper revision 1.1159.120.2 (4177c0c45rkuaBFhtYj9E1LEJ8ti4w)
Unify 2.4 and 2.6 balloon drivers, xm can now control balloon in 2.4 domains. More random docs work.
This commit is contained in:
1 parent
b1688459b9
commit
607ffb8476
5 files changed
+165
-4
No files matched your search
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,7 +11,12 @@
|
||||
#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>
|
||||
@@ -21,8 +26,14 @@
|
||||
#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);
|
||||
|
||||