mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
bitkeeper revision 1.997 (40d818e5-TNUTwvYPW-Y6E4RqoNong)
Merge
This commit is contained in:
commit
3a4e065088
41 files changed
+218
-654
No files matched your search
@@ -152,7 +152,6 @@
|
||||
3e5a4e681xMPdF9xCMwpyfuYMySU5g linux-2.4.26-xen-sparse/mm/mremap.c
|
||||
409ba2e7akOFqQUg6Qyg2s28xcXiMg linux-2.4.26-xen-sparse/mm/page_alloc.c
|
||||
3e5a4e683HKVU-sxtagrDasRB8eBVw linux-2.4.26-xen-sparse/mm/swapfile.c
|
||||
3f108af81Thhb242EmKjGCYkjx-GJA linux-2.4.26-xen-sparse/mm/vmalloc.c
|
||||
3f776bd1Hy9rn69ntXBhPReUFw9IEA tools/Makefile
|
||||
3e6377b24eQqYMsDi9XrFkIgTzZ47A tools/balloon/Makefile
|
||||
3e6377d6eiFjF1hHIS6JEIOFk62xSA tools/balloon/README
|
||||
|
||||
@@ -148,7 +148,7 @@ static inline int HYPERVISOR_shutdown(void)
|
||||
__asm__ __volatile__ (
|
||||
TRAP_INSTR
|
||||
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
|
||||
"b" (SCHEDOP_suspend | (STOPCODE_shutdown << SCHEDOP_reasonshift))
|
||||
"b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
|
||||
: "memory" );
|
||||
|
||||
return ret;
|
||||
@@ -160,7 +160,7 @@ static inline int HYPERVISOR_reboot(void)
|
||||
__asm__ __volatile__ (
|
||||
TRAP_INSTR
|
||||
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
|
||||
"b" (SCHEDOP_suspend | (STOPCODE_reboot << SCHEDOP_reasonshift))
|
||||
"b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
|
||||
: "memory" );
|
||||
|
||||
return ret;
|
||||
@@ -173,7 +173,7 @@ static inline int HYPERVISOR_suspend(unsigned long srec)
|
||||
__asm__ __volatile__ (
|
||||
TRAP_INSTR
|
||||
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
|
||||
"b" (SCHEDOP_suspend | (STOPCODE_suspend << SCHEDOP_reasonshift)),
|
||||
"b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
|
||||
"S" (srec) : "memory" );
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -157,10 +157,10 @@ static int privcmd_ioctl(struct inode *inode, struct file *file,
|
||||
addr = m.addr;
|
||||
for ( i = 0; i < m.num; i++, addr += PAGE_SIZE, p++ )
|
||||
{
|
||||
if ( get_user(mfn, p) ) return -EFAULT;
|
||||
if ( get_user(mfn, p) )
|
||||
return -EFAULT;
|
||||
|
||||
v->val = (mfn << PAGE_SHIFT) | pgprot_val(vma->vm_page_prot) |
|
||||
_PAGE_IO;
|
||||
v->val = (mfn << PAGE_SHIFT) | pgprot_val(vma->vm_page_prot);
|
||||
|
||||
__direct_remap_area_pages(vma->vm_mm,
|
||||
addr,
|
||||
|
||||
@@ -1142,26 +1142,6 @@ void __init cpu_init (void)
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Time-to-die callback handling.
|
||||
*/
|
||||
|
||||
static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
|
||||
{
|
||||
extern void ctrl_alt_del(void);
|
||||
ctrl_if_send_response(msg);
|
||||
ctrl_alt_del();
|
||||
}
|
||||
|
||||
static int __init setup_shutdown_event(void)
|
||||
{
|
||||
ctrl_if_register_receiver(CMSG_SHUTDOWN, shutdown_handler, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
__initcall(setup_shutdown_event);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Stop/pickle callback handling.
|
||||
*/
|
||||
@@ -1294,9 +1274,15 @@ static void suspend_task(void *unused)
|
||||
|
||||
static struct tq_struct suspend_tq;
|
||||
|
||||
static void suspend_handler(ctrl_msg_t *msg, unsigned long id)
|
||||
static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
|
||||
{
|
||||
if ( !suspending )
|
||||
if ( msg->subtype != CMSG_SHUTDOWN_SUSPEND )
|
||||
{
|
||||
extern void ctrl_alt_del(void);
|
||||
ctrl_if_send_response(msg);
|
||||
ctrl_alt_del();
|
||||
}
|
||||
else if ( !suspending )
|
||||
{
|
||||
suspending = 1;
|
||||
suspend_tq.routine = suspend_task;
|
||||
@@ -1310,10 +1296,10 @@ static void suspend_handler(ctrl_msg_t *msg, unsigned long id)
|
||||
ctrl_if_send_response(msg);
|
||||
}
|
||||
|
||||
static int __init setup_suspend_event(void)
|
||||
static int __init setup_shutdown_event(void)
|
||||
{
|
||||
ctrl_if_register_receiver(CMSG_SUSPEND, suspend_handler, 0);
|
||||
ctrl_if_register_receiver(CMSG_SHUTDOWN, shutdown_handler, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
__initcall(setup_suspend_event);
|
||||
__initcall(setup_shutdown_event);
|
||||
@@ -150,7 +150,7 @@ int direct_remap_area_pages(struct mm_struct *mm,
|
||||
* Fill in the machine address: PTE ptr is done later by
|
||||
* __direct_remap_area_pages().
|
||||
*/
|
||||
v->val = (machine_addr & PAGE_MASK) | pgprot_val(prot) | _PAGE_IO;
|
||||
v->val = (machine_addr & PAGE_MASK) | pgprot_val(prot);
|
||||
|
||||
machine_addr += PAGE_SIZE;
|
||||
address += PAGE_SIZE;
|
||||
@@ -262,8 +262,7 @@ void __init *bt_ioremap(unsigned long machine_addr, unsigned long size)
|
||||
*/
|
||||
idx = FIX_BTMAP_BEGIN;
|
||||
while (nrpages > 0) {
|
||||
__set_fixmap(idx, machine_addr,
|
||||
__pgprot(__PAGE_KERNEL|_PAGE_IO));
|
||||
__set_fixmap(idx, machine_addr, PAGE_KERNEL);
|
||||
machine_addr += PAGE_SIZE;
|
||||
--idx;
|
||||
--nrpages;
|
||||
|
||||
@@ -248,7 +248,7 @@ static inline int HYPERVISOR_shutdown(void)
|
||||
__asm__ __volatile__ (
|
||||
TRAP_INSTR
|
||||
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
|
||||
"b" (SCHEDOP_suspend | (STOPCODE_shutdown << SCHEDOP_reasonshift))
|
||||
"b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
|
||||
: "memory" );
|
||||
|
||||
return ret;
|
||||
@@ -260,7 +260,7 @@ static inline int HYPERVISOR_reboot(void)
|
||||
__asm__ __volatile__ (
|
||||
TRAP_INSTR
|
||||
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
|
||||
"b" (SCHEDOP_suspend | (STOPCODE_reboot << SCHEDOP_reasonshift))
|
||||
"b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
|
||||
: "memory" );
|
||||
|
||||
return ret;
|
||||
@@ -273,7 +273,7 @@ static inline int HYPERVISOR_suspend(unsigned long srec)
|
||||
__asm__ __volatile__ (
|
||||
TRAP_INSTR
|
||||
: "=a" (ret) : "0" (__HYPERVISOR_sched_op),
|
||||
"b" (SCHEDOP_suspend | (STOPCODE_suspend << SCHEDOP_reasonshift)),
|
||||
"b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)),
|
||||
"S" (srec) : "memory" );
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -48,7 +48,26 @@ static inline pmd_t * pmd_offset(pgd_t * dir, unsigned long address)
|
||||
}
|
||||
|
||||
#define pte_same(a, b) ((a).pte_low == (b).pte_low)
|
||||
#define pte_page(x) (mem_map+((unsigned long)((pte_val(x) >> PAGE_SHIFT))))
|
||||
|
||||
/*
|
||||
* We detect special mappings in one of two ways:
|
||||
* 1. If the MFN is an I/O page then Xen will set the m2p entry
|
||||
* to be outside our maximum possible pseudophys range.
|
||||
* 2. If the MFN belongs to a different domain then we will certainly
|
||||
* not have MFN in our p2m table. Conversely, if the page is ours,
|
||||
* then we'll have p2m(m2p(MFN))==MFN.
|
||||
* If we detect a special mapping then it doesn't have a 'struct page'.
|
||||
* We force !VALID_PAGE() by returning an out-of-range pointer.
|
||||
*/
|
||||
#define pte_page(_pte) \
|
||||
({ \
|
||||
unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT; \
|
||||
unsigned long pfn = mfn_to_pfn(mfn); \
|
||||
if ( (pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn) ) \
|
||||
pfn = max_mapnr; /* specia: force !VALID_PAGE() */ \
|
||||
&mem_map[pfn]; \
|
||||
})
|
||||
|
||||
#define pte_none(x) (!(x).pte_low)
|
||||
#define __mk_pte(page_nr,pgprot) __pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
|
||||
|
||||
|
||||
@@ -116,7 +116,6 @@ extern void * high_memory;
|
||||
#define _PAGE_BIT_DIRTY 6
|
||||
#define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page, Pentium+, if present.. */
|
||||
#define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
|
||||
#define _PAGE_BIT_IO 9
|
||||
|
||||
#define _PAGE_PRESENT 0x001
|
||||
#define _PAGE_RW 0x002
|
||||
@@ -127,7 +126,6 @@ extern void * high_memory;
|
||||
#define _PAGE_DIRTY 0x040
|
||||
#define _PAGE_PSE 0x080 /* 4 MB (or 2MB) page, Pentium+, if present.. */
|
||||
#define _PAGE_GLOBAL 0x100 /* Global TLB entry PPro+ */
|
||||
#define _PAGE_IO 0x200
|
||||
|
||||
#define _PAGE_PROTNONE 0x080 /* If not present */
|
||||
|
||||
@@ -200,7 +198,6 @@ static inline int pte_exec(pte_t pte) { return (pte).pte_low & _PAGE_USER; }
|
||||
static inline int pte_dirty(pte_t pte) { return (pte).pte_low & _PAGE_DIRTY; }
|
||||
static inline int pte_young(pte_t pte) { return (pte).pte_low & _PAGE_ACCESSED; }
|
||||
static inline int pte_write(pte_t pte) { return (pte).pte_low & _PAGE_RW; }
|
||||
static inline int pte_io(pte_t pte) { return (pte).pte_low & _PAGE_IO; }
|
||||
|
||||
static inline pte_t pte_rdprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_USER; return pte; }
|
||||
static inline pte_t pte_exprotect(pte_t pte) { (pte).pte_low &= ~_PAGE_USER; return pte; }
|
||||
@@ -212,7 +209,6 @@ static inline pte_t pte_mkexec(pte_t pte) { (pte).pte_low |= _PAGE_USER; return
|
||||
static inline pte_t pte_mkdirty(pte_t pte) { (pte).pte_low |= _PAGE_DIRTY; return pte; }
|
||||
static inline pte_t pte_mkyoung(pte_t pte) { (pte).pte_low |= _PAGE_ACCESSED; return pte; }
|
||||
static inline pte_t pte_mkwrite(pte_t pte) { (pte).pte_low |= _PAGE_RW; return pte; }
|
||||
static inline pte_t pte_mkio(pte_t pte) { (pte).pte_low |= _PAGE_IO; return pte; }
|
||||
|
||||
static inline int ptep_test_and_clear_dirty(pte_t *ptep)
|
||||
{
|
||||
|
||||
@@ -318,12 +318,6 @@ static inline int zap_pte_range(mmu_gather_t *tlb, pmd_t * pmd, unsigned long ad
|
||||
continue;
|
||||
if (pte_present(pte)) {
|
||||
struct page *page = pte_page(pte);
|
||||
#if defined(CONFIG_XEN_PRIVILEGED_GUEST)
|
||||
if (pte_io(pte)) {
|
||||
queue_l1_entry_update(ptep, 0);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (VALID_PAGE(page) && !PageReserved(page))
|
||||
freed ++;
|
||||
/* This will eventually call __free_pte on the pte. */
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
/*
|
||||
* linux/mm/vmalloc.c
|
||||
*
|
||||
* Copyright (C) 1993 Linus Torvalds
|
||||
* Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
|
||||
* SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
|
||||
*/
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/smp_lock.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/pgalloc.h>
|
||||
|
||||
rwlock_t vmlist_lock = RW_LOCK_UNLOCKED;
|
||||
struct vm_struct * vmlist;
|
||||
|
||||
static inline void free_area_pte(pmd_t * pmd, unsigned long address, unsigned long size)
|
||||
{
|
||||
pte_t * pte;
|
||||
unsigned long end;
|
||||
|
||||
if (pmd_none(*pmd))
|
||||
return;
|
||||
if (pmd_bad(*pmd)) {
|
||||
pmd_ERROR(*pmd);
|
||||
pmd_clear(pmd);
|
||||
return;
|
||||
}
|
||||
pte = pte_offset(pmd, address);
|
||||
address &= ~PMD_MASK;
|
||||
end = address + size;
|
||||
if (end > PMD_SIZE)
|
||||
end = PMD_SIZE;
|
||||
do {
|
||||
pte_t page;
|
||||
page = ptep_get_and_clear(pte);
|
||||
address += PAGE_SIZE;
|
||||
pte++;
|
||||
if (pte_none(page))
|
||||
continue;
|
||||
if (pte_present(page)) {
|
||||
struct page *ptpage = pte_page(page);
|
||||
#if defined(CONFIG_XEN_PRIVILEGED_GUEST)
|
||||
if (pte_io(page))
|
||||
continue;
|
||||
#endif
|
||||
if (VALID_PAGE(ptpage) && (!PageReserved(ptpage)))
|
||||
__free_page(ptpage);
|
||||
continue;
|
||||
}
|
||||
printk(KERN_CRIT "Whee.. Swapped out page in kernel page table\n");
|
||||
} while (address < end);
|
||||
}
|
||||
|
||||
static inline void free_area_pmd(pgd_t * dir, unsigned long address, unsigned long size)
|
||||
{
|
||||
pmd_t * pmd;
|
||||
unsigned long end;
|
||||
|
||||
if (pgd_none(*dir))
|
||||
return;
|
||||
if (pgd_bad(*dir)) {
|
||||
pgd_ERROR(*dir);
|
||||
pgd_clear(dir);
|
||||
return;
|
||||
}
|
||||
pmd = pmd_offset(dir, address);
|
||||
address &= ~PGDIR_MASK;
|
||||
end = address + size;
|
||||
if (end > PGDIR_SIZE)
|
||||
end = PGDIR_SIZE;
|
||||
do {
|
||||
free_area_pte(pmd, address, end - address);
|
||||
address = (address + PMD_SIZE) & PMD_MASK;
|
||||
pmd++;
|
||||
} while (address < end);
|
||||
}
|
||||
|
||||
void vmfree_area_pages(unsigned long address, unsigned long size)
|
||||
{
|
||||
pgd_t * dir;
|
||||
unsigned long end = address + size;
|
||||
|
||||
dir = pgd_offset_k(address);
|
||||
flush_cache_all();
|
||||
do {
|
||||
free_area_pmd(dir, address, end - address);
|
||||
address = (address + PGDIR_SIZE) & PGDIR_MASK;
|
||||
dir++;
|
||||
} while (address && (address < end));
|
||||
flush_tlb_all();
|
||||
}
|
||||
|
||||
static inline int alloc_area_pte (pte_t * pte, unsigned long address,
|
||||
unsigned long size, int gfp_mask,
|
||||
pgprot_t prot, struct page ***pages)
|
||||
{
|
||||
unsigned long end;
|
||||
|
||||
address &= ~PMD_MASK;
|
||||
end = address + size;
|
||||
if (end > PMD_SIZE)
|
||||
end = PMD_SIZE;
|
||||
do {
|
||||
struct page * page;
|
||||
|
||||
if (!pages) {
|
||||
spin_unlock(&init_mm.page_table_lock);
|
||||
page = alloc_page(gfp_mask);
|
||||
spin_lock(&init_mm.page_table_lock);
|
||||
} else {
|
||||
page = (**pages);
|
||||
(*pages)++;
|
||||
|
||||
/* Add a reference to the page so we can free later */
|
||||
if (page)
|
||||
atomic_inc(&page->count);
|
||||
|
||||
}
|
||||
if (!pte_none(*pte))
|
||||
printk(KERN_ERR "alloc_area_pte: page already exists\n");
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
set_pte(pte, mk_pte(page, prot));
|
||||
address += PAGE_SIZE;
|
||||
pte++;
|
||||
} while (address < end);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int alloc_area_pmd(pmd_t * pmd, unsigned long address,
|
||||
unsigned long size, int gfp_mask,
|
||||
pgprot_t prot, struct page ***pages)
|
||||
{
|
||||
unsigned long end;
|
||||
|
||||
address &= ~PGDIR_MASK;
|
||||
end = address + size;
|
||||
if (end > PGDIR_SIZE)
|
||||
end = PGDIR_SIZE;
|
||||
do {
|
||||
pte_t * pte = pte_alloc(&init_mm, pmd, address);
|
||||
if (!pte)
|
||||
return -ENOMEM;
|
||||
if (alloc_area_pte(pte, address, end - address,
|
||||
gfp_mask, prot, pages))
|
||||
return -ENOMEM;
|
||||
address = (address + PMD_SIZE) & PMD_MASK;
|
||||
pmd++;
|
||||
} while (address < end);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int __vmalloc_area_pages (unsigned long address,
|
||||
unsigned long size,
|
||||
int gfp_mask,
|
||||
pgprot_t prot,
|
||||
struct page ***pages)
|
||||
{
|
||||
pgd_t * dir;
|
||||
unsigned long start = address;
|
||||
unsigned long end = address + size;
|
||||
|
||||
dir = pgd_offset_k(address);
|
||||
spin_lock(&init_mm.page_table_lock);
|
||||
do {
|
||||
pmd_t *pmd;
|
||||
|
||||
pmd = pmd_alloc(&init_mm, dir, address);
|
||||
if (!pmd)
|
||||
goto err;
|
||||
|
||||
if (alloc_area_pmd(pmd, address, end - address, gfp_mask, prot, pages))
|
||||
goto err; // The kernel NEVER reclaims pmds, so no need to undo pmd_alloc() here
|
||||
|
||||
address = (address + PGDIR_SIZE) & PGDIR_MASK;
|
||||
dir++;
|
||||
} while (address && (address < end));
|
||||
spin_unlock(&init_mm.page_table_lock);
|
||||
flush_cache_all();
|
||||
return 0;
|
||||
err:
|
||||
spin_unlock(&init_mm.page_table_lock);
|
||||
flush_cache_all();
|
||||
if (address > start)
|
||||
vmfree_area_pages(start, address - start);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
int vmalloc_area_pages(unsigned long address, unsigned long size,
|
||||
int gfp_mask, pgprot_t prot)
|
||||
{
|
||||
return __vmalloc_area_pages(address, size, gfp_mask, prot, NULL);
|
||||
}
|
||||
|
||||
struct vm_struct * get_vm_area(unsigned long size, unsigned long flags)
|
||||
{
|
||||
unsigned long addr, next;
|
||||
struct vm_struct **p, *tmp, *area;
|
||||
|
||||
area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
|
||||
if (!area)
|
||||
return NULL;
|
||||
|
||||
size += PAGE_SIZE;
|
||||
if (!size) {
|
||||
kfree (area);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
addr = VMALLOC_START;
|
||||
write_lock(&vmlist_lock);
|
||||
for (p = &vmlist; (tmp = *p) ; p = &tmp->next) {
|
||||
if ((size + addr) < addr)
|
||||
goto out;
|
||||
if (size + addr <= (unsigned long) tmp->addr)
|
||||
break;
|
||||
next = tmp->size + (unsigned long) tmp->addr;
|
||||
if (next > addr)
|
||||
addr = next;
|
||||
if (addr > VMALLOC_END-size)
|
||||
goto out;
|
||||
}
|
||||
area->flags = flags;
|
||||
area->addr = (void *)addr;
|
||||
area->size = size;
|
||||
area->next = *p;
|
||||
*p = area;
|
||||
write_unlock(&vmlist_lock);
|
||||
return area;
|
||||
|
||||
out:
|
||||
write_unlock(&vmlist_lock);
|
||||
kfree(area);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void __vfree(void * addr, int free_area_pages)
|
||||
{
|
||||
struct vm_struct **p, *tmp;
|
||||
|
||||
if (!addr)
|
||||
return;
|
||||
if ((PAGE_SIZE-1) & (unsigned long) addr) {
|
||||
printk(KERN_ERR "Trying to vfree() bad address (%p)\n", addr);
|
||||
return;
|
||||
}
|
||||
write_lock(&vmlist_lock);
|
||||
for (p = &vmlist ; (tmp = *p) ; p = &tmp->next) {
|
||||
if (tmp->addr == addr) {
|
||||
*p = tmp->next;
|
||||
if (free_area_pages)
|
||||
vmfree_area_pages(VMALLOC_VMADDR(tmp->addr), tmp->size);
|
||||
write_unlock(&vmlist_lock);
|
||||
kfree(tmp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
write_unlock(&vmlist_lock);
|
||||
printk(KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n", addr);
|
||||
}
|
||||
|
||||
void vfree(void * addr)
|
||||
{
|
||||
__vfree(addr,1);
|
||||
}
|
||||
|
||||
void * __vmalloc (unsigned long size, int gfp_mask, pgprot_t prot)
|
||||
{
|
||||
void * addr;
|
||||
struct vm_struct *area;
|
||||
|
||||
size = PAGE_ALIGN(size);
|
||||
if (!size || (size >> PAGE_SHIFT) > num_physpages)
|
||||
return NULL;
|
||||
area = get_vm_area(size, VM_ALLOC);
|
||||
if (!area)
|
||||
return NULL;
|
||||
addr = area->addr;
|
||||
if (__vmalloc_area_pages(VMALLOC_VMADDR(addr), size, gfp_mask,
|
||||
prot, NULL)) {
|
||||
__vfree(addr, 0);
|
||||
return NULL;
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
void * vmap(struct page **pages, int count,
|
||||
unsigned long flags, pgprot_t prot)
|
||||
{
|
||||
void * addr;
|
||||
struct vm_struct *area;
|
||||
unsigned long size = count << PAGE_SHIFT;
|
||||
|
||||
if (!size || size > (max_mapnr << PAGE_SHIFT))
|
||||
return NULL;
|
||||
area = get_vm_area(size, flags);
|
||||
if (!area) {
|
||||
return NULL;
|
||||
}
|
||||
addr = area->addr;
|
||||
if (__vmalloc_area_pages(VMALLOC_VMADDR(addr), size, 0,
|
||||
prot, &pages)) {
|
||||
__vfree(addr, 0);
|
||||
return NULL;
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
long vread(char *buf, char *addr, unsigned long count)
|
||||
{
|
||||
struct vm_struct *tmp;
|
||||
char *vaddr, *buf_start = buf;
|
||||
unsigned long n;
|
||||
|
||||
/* Don't allow overflow */
|
||||
if ((unsigned long) addr + count < count)
|
||||
count = -(unsigned long) addr;
|
||||
|
||||
read_lock(&vmlist_lock);
|
||||
for (tmp = vmlist; tmp; tmp = tmp->next) {
|
||||
vaddr = (char *) tmp->addr;
|
||||
if (addr >= vaddr + tmp->size - PAGE_SIZE)
|
||||
continue;
|
||||
while (addr < vaddr) {
|
||||
if (count == 0)
|
||||
goto finished;
|
||||
*buf = '\0';
|
||||
buf++;
|
||||
addr++;
|
||||
count--;
|
||||
}
|
||||
n = vaddr + tmp->size - PAGE_SIZE - addr;
|
||||
do {
|
||||
if (count == 0)
|
||||
goto finished;
|
||||
*buf = *addr;
|
||||
buf++;
|
||||
addr++;
|
||||
count--;
|
||||
} while (--n > 0);
|
||||
}
|
||||
finished:
|
||||
read_unlock(&vmlist_lock);
|
||||
return buf - buf_start;
|
||||
}
|
||||
|
||||
long vwrite(char *buf, char *addr, unsigned long count)
|
||||
{
|
||||
struct vm_struct *tmp;
|
||||
char *vaddr, *buf_start = buf;
|
||||
unsigned long n;
|
||||
|
||||
/* Don't allow overflow */
|
||||
if ((unsigned long) addr + count < count)
|
||||
count = -(unsigned long) addr;
|
||||
|
||||
read_lock(&vmlist_lock);
|
||||
for (tmp = vmlist; tmp; tmp = tmp->next) {
|
||||
vaddr = (char *) tmp->addr;
|
||||
if (addr >= vaddr + tmp->size - PAGE_SIZE)
|
||||
continue;
|
||||
while (addr < vaddr) {
|
||||
if (count == 0)
|
||||
goto finished;
|
||||
buf++;
|
||||
addr++;
|
||||
count--;
|
||||
}
|
||||
n = vaddr + tmp->size - PAGE_SIZE - addr;
|
||||
do {
|
||||
if (count == 0)
|
||||
goto finished;
|
||||
*addr = *buf;
|
||||
buf++;
|
||||
addr++;
|
||||
count--;
|
||||
} while (--n > 0);
|
||||
}
|
||||
finished:
|
||||
read_unlock(&vmlist_lock);
|
||||
return buf - buf_start;
|
||||
}
|
||||
@@ -9,8 +9,8 @@ def usage ():
|
||||
print >>sys.stderr, """
|
||||
Usage: %s [command] <params>
|
||||
|
||||
stop [dom] -- pause a domain
|
||||
start [dom] -- un-pause a domain
|
||||
pause [dom] -- pause a domain
|
||||
unpause [dom] -- un-pause a domain
|
||||
shutdown [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
|
||||
(optionally wait for complete shutdown)
|
||||
destroy [dom] -- immediately terminate a domain
|
||||
@@ -45,21 +45,21 @@ dom = None
|
||||
if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]):
|
||||
dom = int(sys.argv[2])
|
||||
|
||||
if cmd == 'stop':
|
||||
rc = xc.domain_stop( dom=dom )
|
||||
if cmd == 'pause':
|
||||
rc = xc.domain_pause( dom=dom )
|
||||
|
||||
elif cmd == 'start':
|
||||
rc = xc.domain_start( dom=dom )
|
||||
elif cmd == 'unpause':
|
||||
rc = xc.domain_unpause( dom=dom )
|
||||
|
||||
elif cmd == 'shutdown':
|
||||
list = []
|
||||
if dom != None:
|
||||
rc = xc.domain_destroy( dom=dom, force=0 )
|
||||
rc = xc.domain_destroy( dom=dom ) # should be CMSG_SHUTDOWN
|
||||
list.append(dom)
|
||||
elif sys.argv[2] == 'all':
|
||||
for i in xc.domain_getinfo():
|
||||
if i['dom'] != 0: # don't shutdown dom0!
|
||||
ret = xc.domain_destroy( dom=i['dom'], force=0 )
|
||||
ret = xc.domain_destroy( dom=i['dom'] ) # should be CMSG_SHUTDOWN
|
||||
if ret !=0: rc = ret
|
||||
else: list.append(i['dom'])
|
||||
|
||||
@@ -72,7 +72,7 @@ elif cmd == 'shutdown':
|
||||
time.sleep(1)
|
||||
|
||||
elif cmd == 'destroy':
|
||||
rc = xc.domain_destroy( dom=dom, force=1 )
|
||||
rc = xc.domain_destroy( dom=dom )
|
||||
|
||||
elif cmd == 'pincpu':
|
||||
|
||||
@@ -90,8 +90,8 @@ elif cmd == 'list':
|
||||
|
||||
run = (domain['running'] and 'r') or '-'
|
||||
block = (domain['blocked'] and 'b') or '-'
|
||||
stop = (domain['stopped'] and 's') or '-'
|
||||
susp = (domain['suspended'] and 'S') or '-'
|
||||
stop = (domain['paused'] and 'p') or '-'
|
||||
susp = (domain['shutdown'] and 's') or '-'
|
||||
crash = (domain['crashed'] and 'c') or '-'
|
||||
|
||||
domain['state'] = run + block + stop + susp + crash
|
||||
|
||||
@@ -364,7 +364,7 @@ def make_domain():
|
||||
if not nlb: print >>open('/proc/sys/net/ipv4/ip_nonlocal_bind','w'), '0'
|
||||
|
||||
if not dontstart:
|
||||
if xc.domain_start( dom=id ) < 0:
|
||||
if xc.domain_unpause( dom=id ) < 0:
|
||||
print "Error starting domain"
|
||||
xc.domain_destroy ( dom=id )
|
||||
sys.exit()
|
||||
|
||||
@@ -25,8 +25,8 @@ def usage (rc=0):
|
||||
Usage: %s [command] <params>
|
||||
|
||||
help -- print usage
|
||||
stop [dom] -- pause a domain
|
||||
start [dom] -- un-pause a domain
|
||||
pause [dom] -- pause a domain
|
||||
unpause [dom] -- un-pause a domain
|
||||
shutdown [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
|
||||
(optionally wait for complete shutdown)
|
||||
destroy [dom] -- immediately terminate a domain
|
||||
@@ -89,11 +89,11 @@ if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]):
|
||||
if cmd == "help":
|
||||
usage()
|
||||
|
||||
elif cmd == 'stop':
|
||||
rc = server.xend_domain_stop(dom)
|
||||
elif cmd == 'pause':
|
||||
rc = server.xend_domain_pause(dom)
|
||||
|
||||
elif cmd == 'start':
|
||||
rc = server.xend_domain_start(dom)
|
||||
elif cmd == 'unpause':
|
||||
rc = server.xend_domain_unpause(dom)
|
||||
|
||||
elif cmd == 'shutdown':
|
||||
doms = []
|
||||
|
||||
@@ -305,7 +305,7 @@ def make_domain(config):
|
||||
else:
|
||||
console_port = None
|
||||
|
||||
if server.xend_domain_start(dom) < 0:
|
||||
if server.xend_domain_unpause(dom) < 0:
|
||||
print "Error starting domain"
|
||||
server.xend_domain_halt(dom)
|
||||
sys.exit()
|
||||
|
||||
+7
-7
@@ -25,8 +25,9 @@ int xc_interface_close(int xc_handle);
|
||||
typedef struct {
|
||||
u32 domid;
|
||||
unsigned int cpu;
|
||||
unsigned int dying:1, crashed:1, suspended:1,
|
||||
stopped:1, blocked:1, running:1;
|
||||
unsigned int dying:1, crashed:1, shutdown:1,
|
||||
paused:1, blocked:1, running:1;
|
||||
unsigned int shutdown_reason; /* only meaningful if shutdown==1 */
|
||||
unsigned long nr_pages;
|
||||
unsigned long shared_info_frame;
|
||||
u64 cpu_time;
|
||||
@@ -40,13 +41,12 @@ int xc_domain_create(int xc_handle,
|
||||
const char *name,
|
||||
int cpu,
|
||||
u32 *pdomid);
|
||||
int xc_domain_start(int xc_handle,
|
||||
int xc_domain_pause(int xc_handle,
|
||||
u32 domid);
|
||||
int xc_domain_stop(int xc_handle,
|
||||
u32 domid);
|
||||
int xc_domain_unpause(int xc_handle,
|
||||
u32 domid);
|
||||
int xc_domain_destroy(int xc_handle,
|
||||
u32 domid,
|
||||
int force);
|
||||
u32 domid);
|
||||
int xc_domain_pincpu(int xc_handle,
|
||||
u32 domid,
|
||||
int cpu);
|
||||
|
||||
+18
-16
@@ -30,34 +30,32 @@ int xc_domain_create(int xc_handle,
|
||||
}
|
||||
|
||||
|
||||
int xc_domain_start(int xc_handle,
|
||||
int xc_domain_pause(int xc_handle,
|
||||
u32 domid)
|
||||
{
|
||||
dom0_op_t op;
|
||||
op.cmd = DOM0_STARTDOMAIN;
|
||||
op.u.startdomain.domain = (domid_t)domid;
|
||||
op.cmd = DOM0_PAUSEDOMAIN;
|
||||
op.u.pausedomain.domain = (domid_t)domid;
|
||||
return do_dom0_op(xc_handle, &op);
|
||||
}
|
||||
|
||||
|
||||
int xc_domain_stop(int xc_handle,
|
||||
u32 domid)
|
||||
int xc_domain_unpause(int xc_handle,
|
||||
u32 domid)
|
||||
{
|
||||
dom0_op_t op;
|
||||
op.cmd = DOM0_STOPDOMAIN;
|
||||
op.u.stopdomain.domain = (domid_t)domid;
|
||||
op.cmd = DOM0_UNPAUSEDOMAIN;
|
||||
op.u.unpausedomain.domain = (domid_t)domid;
|
||||
return do_dom0_op(xc_handle, &op);
|
||||
}
|
||||
|
||||
|
||||
int xc_domain_destroy(int xc_handle,
|
||||
u32 domid,
|
||||
int force)
|
||||
u32 domid)
|
||||
{
|
||||
dom0_op_t op;
|
||||
op.cmd = DOM0_DESTROYDOMAIN;
|
||||
op.u.destroydomain.domain = (domid_t)domid;
|
||||
op.u.destroydomain.force = !!force;
|
||||
return do_dom0_op(xc_handle, &op);
|
||||
}
|
||||
|
||||
@@ -94,12 +92,16 @@ int xc_domain_getinfo(int xc_handle,
|
||||
info->cpu =
|
||||
(op.u.getdomaininfo.flags>>DOMFLAGS_CPUSHIFT) & DOMFLAGS_CPUMASK;
|
||||
|
||||
info->dying = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
|
||||
info->crashed = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
|
||||
info->suspended = (op.u.getdomaininfo.flags & DOMFLAGS_SUSPENDED);
|
||||
info->stopped = (op.u.getdomaininfo.flags & DOMFLAGS_STOPPED);
|
||||
info->blocked = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
|
||||
info->running = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
|
||||
info->dying = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
|
||||
info->crashed = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
|
||||
info->shutdown = (op.u.getdomaininfo.flags & DOMFLAGS_SHUTDOWN);
|
||||
info->paused = (op.u.getdomaininfo.flags & DOMFLAGS_PAUSED);
|
||||
info->blocked = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
|
||||
info->running = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
|
||||
|
||||
info->shutdown_reason =
|
||||
(op.u.getdomaininfo.flags>>DOMFLAGS_SHUTDOWNSHIFT) &
|
||||
DOMFLAGS_SHUTDOWNMASK;
|
||||
|
||||
info->nr_pages = op.u.getdomaininfo.tot_pages;
|
||||
info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT-10);
|
||||
|
||||
@@ -436,7 +436,7 @@ int xc_linux_build(int xc_handle,
|
||||
PERROR("Could not get info on domain");
|
||||
goto error_out;
|
||||
}
|
||||
if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
|
||||
if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
|
||||
(ctxt->pt_base != 0) )
|
||||
{
|
||||
ERROR("Domain is already constructed");
|
||||
|
||||
@@ -606,13 +606,8 @@ int xc_linux_restore(int xc_handle,
|
||||
|
||||
|
||||
out:
|
||||
if ( rc != 0 )
|
||||
{
|
||||
if ( dom != 0 )
|
||||
{
|
||||
xc_domain_destroy( xc_handle, dom, 1 );
|
||||
}
|
||||
}
|
||||
if ( (rc != 0) && (dom != 0) )
|
||||
xc_domain_destroy(xc_handle, dom);
|
||||
|
||||
if ( mmu != NULL )
|
||||
free(mmu);
|
||||
|
||||
@@ -273,10 +273,9 @@ int xc_linux_save(int xc_handle,
|
||||
}
|
||||
|
||||
/* Ensure that the domain exists, and that it is stopped. */
|
||||
|
||||
if ( xc_domain_stop_sync( xc_handle, domid, &op, &ctxt ) )
|
||||
if ( xc_domain_pause(xc_handle, domid) )
|
||||
{
|
||||
PERROR("Could not sync stop domain");
|
||||
PERROR("Could not pause domain");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -381,9 +380,9 @@ int xc_linux_save(int xc_handle,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ( xc_domain_start( xc_handle, domid ) < 0 )
|
||||
if ( xc_domain_unpause(xc_handle, domid) < 0 )
|
||||
{
|
||||
ERROR("Couldn't restart domain");
|
||||
ERROR("Couldn't unpause domain");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -754,8 +753,7 @@ int xc_linux_save(int xc_handle,
|
||||
DPRINTF("Start last iteration\n");
|
||||
last_iter = 1;
|
||||
|
||||
xc_domain_stop_sync( xc_handle, domid, &op, NULL );
|
||||
|
||||
xc_domain_pause(xc_handle, domid);
|
||||
}
|
||||
|
||||
if ( xc_shadow_control( xc_handle, domid,
|
||||
|
||||
@@ -258,7 +258,7 @@ int xc_netbsd_build(int xc_handle,
|
||||
PERROR("Could not get info on domain");
|
||||
goto error_out;
|
||||
}
|
||||
if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
|
||||
if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
|
||||
(op.u.getdomaininfo.ctxt->pt_base != 0) )
|
||||
{
|
||||
ERROR("Domain is already constructed");
|
||||
|
||||
@@ -199,19 +199,6 @@ int finish_mmu_updates(int xc_handle, mmu_t *mmu)
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
/* this function is a hack until we get proper synchronous domain stop */
|
||||
|
||||
int xc_domain_stop_sync( int xc_handle, domid_t domid,
|
||||
dom0_op_t *op, full_execution_context_t *ctxt)
|
||||
{
|
||||
op->cmd = DOM0_STOPDOMAIN;
|
||||
op->u.stopdomain.domain = (domid_t)domid;
|
||||
do_dom0_op(xc_handle, op);
|
||||
return 0;
|
||||
}
|
||||
|
||||
long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid )
|
||||
{
|
||||
dom0_op_t op;
|
||||
@@ -229,8 +216,6 @@ long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid )
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
/* This is shared between save and restore, and may generally be useful. */
|
||||
unsigned long csum_page (void * page)
|
||||
{
|
||||
|
||||
@@ -200,11 +200,6 @@ int mfn_mapper_flush_queue(mfn_mapper_t *t);
|
||||
void * mfn_mapper_queue_entry(mfn_mapper_t *t, int offset,
|
||||
unsigned long mfn, int size );
|
||||
|
||||
/*********************/
|
||||
|
||||
int xc_domain_stop_sync( int xc_handle, domid_t dom,
|
||||
dom0_op_t *op, full_execution_context_t *ctxt );
|
||||
|
||||
long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid );
|
||||
|
||||
#endif /* __XC_PRIVATE_H__ */
|
||||
+32
-31
@@ -55,7 +55,7 @@ static PyObject *pyxc_domain_create(PyObject *self,
|
||||
return PyInt_FromLong(dom);
|
||||
}
|
||||
|
||||
static PyObject *pyxc_domain_start(PyObject *self,
|
||||
static PyObject *pyxc_domain_pause(PyObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
@@ -68,16 +68,16 @@ static PyObject *pyxc_domain_start(PyObject *self,
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
|
||||
return NULL;
|
||||
|
||||
if ( xc_domain_start(xc->xc_handle, dom) != 0 )
|
||||
if ( xc_domain_pause(xc->xc_handle, dom) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
Py_INCREF(zero);
|
||||
return zero;
|
||||
}
|
||||
|
||||
static PyObject *pyxc_domain_stop(PyObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
static PyObject *pyxc_domain_unpause(PyObject *self,
|
||||
PyObject *args,
|
||||
PyObject *kwds)
|
||||
{
|
||||
XcObject *xc = (XcObject *)self;
|
||||
|
||||
@@ -88,7 +88,7 @@ static PyObject *pyxc_domain_stop(PyObject *self,
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
|
||||
return NULL;
|
||||
|
||||
if ( xc_domain_stop(xc->xc_handle, dom) != 0 )
|
||||
if ( xc_domain_unpause(xc->xc_handle, dom) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
Py_INCREF(zero);
|
||||
@@ -102,15 +102,13 @@ static PyObject *pyxc_domain_destroy(PyObject *self,
|
||||
XcObject *xc = (XcObject *)self;
|
||||
|
||||
u32 dom;
|
||||
int force = 0;
|
||||
|
||||
static char *kwd_list[] = { "dom", "force", NULL };
|
||||
static char *kwd_list[] = { "dom", NULL };
|
||||
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list,
|
||||
&dom, &force) )
|
||||
if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
|
||||
return NULL;
|
||||
|
||||
if ( xc_domain_destroy(xc->xc_handle, dom, force) != 0 )
|
||||
if ( xc_domain_destroy(xc->xc_handle, dom) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
Py_INCREF(zero);
|
||||
@@ -166,19 +164,21 @@ static PyObject *pyxc_domain_getinfo(PyObject *self,
|
||||
{
|
||||
PyList_SetItem(
|
||||
list, i,
|
||||
Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:l,s:L,s:s,s:l}",
|
||||
Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
|
||||
",s:l,s:L,s:s,s:l,s:i}",
|
||||
"dom", info[i].domid,
|
||||
"cpu", info[i].cpu,
|
||||
"dying", info[i].dying,
|
||||
"crashed", info[i].crashed,
|
||||
"suspended", info[i].suspended,
|
||||
"stopped", info[i].stopped,
|
||||
"shutdown", info[i].shutdown,
|
||||
"paused", info[i].paused,
|
||||
"blocked", info[i].blocked,
|
||||
"running", info[i].running,
|
||||
"mem_kb", info[i].nr_pages*4,
|
||||
"cpu_time", info[i].cpu_time,
|
||||
"name", info[i].name,
|
||||
"maxmem_kb", info[i].max_memkb
|
||||
"maxmem_kb", info[i].max_memkb,
|
||||
"shutdown_reason", info[i].shutdown_reason
|
||||
));
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ static PyObject *pyxc_linux_save(PyObject *self,
|
||||
if ( rc == 0 )
|
||||
{
|
||||
printf("Migration succesful -- destroy local copy\n");
|
||||
xc_domain_destroy( xc->xc_handle, dom, 1 );
|
||||
xc_domain_destroy(xc->xc_handle, dom);
|
||||
close(sd);
|
||||
Py_INCREF(zero);
|
||||
return zero;
|
||||
@@ -281,7 +281,7 @@ static PyObject *pyxc_linux_save(PyObject *self,
|
||||
|
||||
serr:
|
||||
printf("Migration failed -- restart local copy\n");
|
||||
xc_domain_start( xc->xc_handle, dom );
|
||||
xc_domain_unpause(xc->xc_handle, dom);
|
||||
PyErr_SetFromErrno(xc_error);
|
||||
if ( sd >= 0 ) close(sd);
|
||||
return NULL;
|
||||
@@ -327,7 +327,7 @@ static PyObject *pyxc_linux_save(PyObject *self,
|
||||
/* kill domain. We don't want to do this for checkpointing, but
|
||||
if we don't do it here I think people will hurt themselves
|
||||
by accident... */
|
||||
xc_domain_destroy( xc->xc_handle, dom, 1 );
|
||||
xc_domain_destroy(xc->xc_handle, dom);
|
||||
gzclose(gfd);
|
||||
close(fd);
|
||||
|
||||
@@ -1015,26 +1015,25 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" name [str, '(anon)']: Informative textual name.\n\n"
|
||||
"Returns: [int] new domain identifier; -1 on error.\n" },
|
||||
|
||||
{ "domain_start",
|
||||
(PyCFunction)pyxc_domain_start,
|
||||
{ "domain_pause",
|
||||
(PyCFunction)pyxc_domain_pause,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Start execution of a domain.\n"
|
||||
" dom [int]: Identifier of domain to be started.\n\n"
|
||||
"Temporarily pause execution of a domain.\n"
|
||||
" dom [int]: Identifier of domain to be paused.\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_stop",
|
||||
(PyCFunction)pyxc_domain_stop,
|
||||
{ "domain_unpause",
|
||||
(PyCFunction)pyxc_domain_unpause,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Stop execution of a domain.\n"
|
||||
" dom [int]: Identifier of domain to be stopped.\n\n"
|
||||
"(Re)start execution of a domain.\n"
|
||||
" dom [int]: Identifier of domain to be unpaused.\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_destroy",
|
||||
(PyCFunction)pyxc_domain_destroy,
|
||||
METH_VARARGS | METH_KEYWORDS, "\n"
|
||||
"Destroy a domain.\n"
|
||||
" dom [int]: Identifier of domain to be destroyed.\n"
|
||||
" force [int, 0]: Bool - force immediate destruction?\n\n"
|
||||
" dom [int]: Identifier of domain to be destroyed.\n\n"
|
||||
"Returns: [int] 0 on success; -1 on error.\n" },
|
||||
|
||||
{ "domain_pincpu",
|
||||
@@ -1059,13 +1058,15 @@ static PyMethodDef pyxc_methods[] = {
|
||||
" cpu [int]: CPU to which this domain is bound\n"
|
||||
" dying [int]: Bool - is the domain dying?\n"
|
||||
" crashed [int]: Bool - has the domain crashed?\n"
|
||||
" suspended[int]: Bool - has the domain suspended itself?\n"
|
||||
" stopped [int]: Bool - is the domain stopped by control software?\n"
|
||||
" shutdown [int]: Bool - has the domain shut itself down?\n"
|
||||
" paused [int]: Bool - is the domain paused by control software?\n"
|
||||
" blocked [int]: Bool - is the domain blocked waiting for an event?\n"
|
||||
" running [int]: Bool - is the domain currently running?\n"
|
||||
" mem_kb [int]: Memory reservation, in kilobytes\n"
|
||||
" cpu_time [long]: CPU time consumed, in nanoseconds\n"
|
||||
" name [str]: Identifying name\n" },
|
||||
" name [str]: Identifying name\n"
|
||||
" shutdown_reason [int]: Numeric code from guest OS, explaining "
|
||||
"reason why it shut itself down.\n" },
|
||||
|
||||
{ "linux_save",
|
||||
(PyCFunction)pyxc_linux_save,
|
||||
|
||||
@@ -29,13 +29,13 @@ typedef struct {
|
||||
|
||||
|
||||
/*
|
||||
* Stop codes for SCHEDOP_suspend. These are opaque to Xen but interpreted by
|
||||
* control software to determine appropriate action.
|
||||
* Reason codes for SCHEDOP_shutdown. These are opaque to Xen but may be
|
||||
* interpreted by control software to determine the appropriate action. These
|
||||
* are only really advisories: the controller can actually do as it likes.
|
||||
*/
|
||||
|
||||
#define STOPCODE_shutdown 0 /* Domain exited normally. Clean up and kill. */
|
||||
#define STOPCODE_reboot 1 /* Clean up, kill, and then restart. */
|
||||
#define STOPCODE_suspend 2 /* Clean up, save suspend info, kill. */
|
||||
#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */
|
||||
#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */
|
||||
#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */
|
||||
|
||||
|
||||
/*
|
||||
@@ -69,7 +69,6 @@ typedef struct {
|
||||
#define CMSG_BLKIF_FE 2 /* Block-device frontend */
|
||||
#define CMSG_NETIF_BE 3 /* Network-device backend */
|
||||
#define CMSG_NETIF_FE 4 /* Network-device frontend */
|
||||
#define CMSG_SUSPEND 5 /* Suspend messages */
|
||||
#define CMSG_SHUTDOWN 6 /* Shutdown messages */
|
||||
|
||||
|
||||
@@ -518,16 +517,6 @@ typedef struct {
|
||||
} PACKED netif_be_driver_status_changed_t; /* 4 bytes */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* SUSPEND DEFINITIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Subtypes for console messages.
|
||||
*/
|
||||
/* None. */
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* CONSOLE DEFINITIONS
|
||||
*/
|
||||
@@ -535,9 +524,9 @@ typedef struct {
|
||||
/*
|
||||
* Subtypes for console messages.
|
||||
*/
|
||||
#define CMSG_SHUTDOWN_HALT 0 /* Shutdown and halt (don't die). */
|
||||
#define CMSG_SHUTDOWN_POWEROFF 1 /* 'Poweroff' => clean death. */
|
||||
#define CMSG_SHUTDOWN_REBOOT 2 /* Shutdown and restart. */
|
||||
|
||||
#define CMSG_SHUTDOWN_POWEROFF 0 /* Clean shutdown (SHUTDOWN_poweroff). */
|
||||
#define CMSG_SHUTDOWN_REBOOT 1 /* Clean shutdown (SHUTDOWN_reboot). */
|
||||
#define CMSG_SHUTDOWN_SUSPEND 2 /* Create suspend info, then */
|
||||
/* SHUTDOWN_suspend. */
|
||||
|
||||
#endif /* __DOMAIN_CONTROLLER_H__ */
|
||||
@@ -5,8 +5,8 @@
|
||||
## xend.domain.destroy: dom, reason:died/crashed
|
||||
## xend.domain.up ?
|
||||
|
||||
## xend.domain.start: dom
|
||||
## xend.domain.stop: dom
|
||||
## xend.domain.unpause: dom
|
||||
## xend.domain.pause: dom
|
||||
## xend.domain.shutdown: dom
|
||||
## xend.domain.halt: dom
|
||||
|
||||
|
||||
@@ -187,13 +187,13 @@ class Xend:
|
||||
def xend_domain(self, id):
|
||||
return xend_get(self.domainurl(id))
|
||||
|
||||
def xend_domain_start(self, id):
|
||||
def xend_domain_unpause(self, id):
|
||||
return xend_call(self.domainurl(id),
|
||||
{'op' : 'start'})
|
||||
{'op' : 'unpause'})
|
||||
|
||||
def xend_domain_stop(self, id):
|
||||
def xend_domain_pause(self, id):
|
||||
return xend_call(self.domainurl(id),
|
||||
{'op' : 'stop'})
|
||||
{'op' : 'pause'})
|
||||
|
||||
def xend_domain_shutdown(self, id):
|
||||
return xend_call(self.domainurl(id),
|
||||
|
||||
@@ -192,18 +192,18 @@ class XendDomain:
|
||||
self.refresh_domain(id)
|
||||
return self.domain[id]
|
||||
|
||||
def domain_start(self, id):
|
||||
"""Start domain running.
|
||||
def domain_unpause(self, id):
|
||||
"""(Re)start domain running.
|
||||
"""
|
||||
dom = int(id)
|
||||
eserver.inject('xend.domain.start', id)
|
||||
return xend.domain_start(dom)
|
||||
eserver.inject('xend.domain.unpause', id)
|
||||
return xc.domain_unpause(dom=dom)
|
||||
|
||||
def domain_stop(self, id):
|
||||
"""Stop domain running.
|
||||
def domain_pause(self, id):
|
||||
"""Pause domain execution.
|
||||
"""
|
||||
dom = int(id)
|
||||
return xend.domain_stop(dom)
|
||||
return xc.domain_pause(dom=dom)
|
||||
|
||||
def domain_shutdown(self, id):
|
||||
"""Shutdown domain (nicely).
|
||||
@@ -212,7 +212,7 @@ class XendDomain:
|
||||
if dom <= 0:
|
||||
return 0
|
||||
eserver.inject('xend.domain.shutdown', id)
|
||||
val = xend.domain_destroy(dom, force=0)
|
||||
val = xc.domain_destroy(dom=dom) # FIXME -- send CMSG_SHUTDOWN
|
||||
self.refresh()
|
||||
return val
|
||||
|
||||
@@ -223,7 +223,7 @@ class XendDomain:
|
||||
if dom <= 0:
|
||||
return 0
|
||||
eserver.inject('xend.domain.halt', id)
|
||||
val = xend.domain_destroy(dom, force=1)
|
||||
val = xc.domain_destroy(dom=dom)
|
||||
self.refresh()
|
||||
return val
|
||||
|
||||
@@ -237,7 +237,7 @@ class XendDomain:
|
||||
"""Save domain state to file, halt domain.
|
||||
"""
|
||||
dom = int(id)
|
||||
self.domain_stop(id)
|
||||
self.domain_pause(id)
|
||||
eserver.inject('xend.domain.save', id)
|
||||
rc = xc.linux_save(dom=dom, state_file=dst, progress=progress)
|
||||
if rc == 0:
|
||||
|
||||
@@ -118,8 +118,8 @@ class XendDomainInfo:
|
||||
if self.info:
|
||||
run = (self.info['running'] and 'r') or '-'
|
||||
block = (self.info['blocked'] and 'b') or '-'
|
||||
stop = (self.info['stopped'] and 's') or '-'
|
||||
susp = (self.info['suspended'] and 'S') or '-'
|
||||
stop = (self.info['paused'] and 'p') or '-'
|
||||
susp = (self.info['shutdown'] and 's') or '-'
|
||||
crash = (self.info['crashed'] and 'c') or '-'
|
||||
state = run + block + stop + susp + crash
|
||||
sxpr.append(['cpu', self.info['cpu']])
|
||||
@@ -177,7 +177,7 @@ class XendDomainInfo:
|
||||
def destroy(self):
|
||||
if self.dom <= 0:
|
||||
return 0
|
||||
return xc.domain_destroy(dom=self.dom, force=1)
|
||||
return xc.domain_destroy(dom=self.dom)
|
||||
|
||||
def show(self):
|
||||
"""Print virtual machine info.
|
||||
|
||||
@@ -18,12 +18,12 @@ class SrvDomain(SrvDir):
|
||||
self.xd = XendDomain.instance()
|
||||
self.xconsole = XendConsole.instance()
|
||||
|
||||
def op_start(self, op, req):
|
||||
val = self.xd.domain_start(self.dom.id)
|
||||
def op_unpause(self, op, req):
|
||||
val = self.xd.domain_unpause(self.dom.id)
|
||||
return val
|
||||
|
||||
def op_stop(self, op, req):
|
||||
val = self.xd.domain_stop(self.dom.id)
|
||||
def op_pause(self, op, req):
|
||||
val = self.xd.domain_pause(self.dom.id)
|
||||
return val
|
||||
|
||||
def op_shutdown(self, op, req):
|
||||
|
||||
@@ -275,7 +275,7 @@ def make_domain(opts, config):
|
||||
else:
|
||||
console_port = None
|
||||
|
||||
if server.xend_domain_start(dom) < 0:
|
||||
if server.xend_domain_unpause(dom) < 0:
|
||||
server.xend_domain_halt(dom)
|
||||
opts.err("Failed to start domain %d" % dom)
|
||||
opts.info("Started domain %d, console on port %d"
|
||||
|
||||
@@ -119,11 +119,11 @@ class Xm:
|
||||
"""Pause execution of a domain."""
|
||||
if help:
|
||||
print args[0], 'DOM'
|
||||
print '\nStop execution of domain DOM.'
|
||||
print '\nPause execution of domain DOM.'
|
||||
return
|
||||
if len(args) < 2: self.err("%s: Missing domain" % args[0])
|
||||
dom = args[1]
|
||||
server.xend_domain_stop(dom)
|
||||
server.xend_domain_pause(dom)
|
||||
|
||||
def xm_unpause(self, help, args):
|
||||
"""Unpause a paused domain."""
|
||||
@@ -133,7 +133,7 @@ class Xm:
|
||||
return
|
||||
if len(args) < 2: self.err("%s: Missing domain" % args[0])
|
||||
dom = args[1]
|
||||
server.xend_domain_start(dom)
|
||||
server.xend_domain_unpause(dom)
|
||||
|
||||
def xm_pincpu(self, help, args):
|
||||
"""Pin a domain to a cpu. """
|
||||
|
||||
@@ -76,7 +76,7 @@ void startup_cpu_idle_loop(void)
|
||||
{
|
||||
/* Just some sanity to ensure that the scheduler is set up okay. */
|
||||
ASSERT(current->domain == IDLE_DOMAIN_ID);
|
||||
domain_start(current);
|
||||
domain_unpause_by_systemcontroller(current);
|
||||
__enter_scheduler();
|
||||
|
||||
/*
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ void pdb_do_debug (dom0_op_t *op)
|
||||
struct domain *d = find_domain_by_id(op->u.debug.domain);
|
||||
if ( d != NULL )
|
||||
{
|
||||
domain_start(d);
|
||||
domain_unpause_by_systemcontroller(d);
|
||||
put_domain(d);
|
||||
}
|
||||
else
|
||||
@@ -94,7 +94,7 @@ void pdb_do_debug (dom0_op_t *op)
|
||||
|
||||
if ( d != NULL )
|
||||
{
|
||||
domain_stop(d);
|
||||
domain_pause_by_systemcontroller(d);
|
||||
put_domain(d);
|
||||
}
|
||||
else
|
||||
|
||||
+15
-15
@@ -80,16 +80,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
|
||||
}
|
||||
break;
|
||||
|
||||
case DOM0_STARTDOMAIN:
|
||||
case DOM0_PAUSEDOMAIN:
|
||||
{
|
||||
struct domain *d = find_domain_by_id(op->u.startdomain.domain);
|
||||
struct domain *d = find_domain_by_id(op->u.pausedomain.domain);
|
||||
ret = -ESRCH;
|
||||
if ( d != NULL )
|
||||
{
|
||||
ret = -EINVAL;
|
||||
if ( test_bit(DF_CONSTRUCTED, &d->flags) )
|
||||
if ( d != current )
|
||||
{
|
||||
domain_start(d);
|
||||
domain_pause_by_systemcontroller(d);
|
||||
ret = 0;
|
||||
}
|
||||
put_domain(d);
|
||||
@@ -97,16 +97,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
|
||||
}
|
||||
break;
|
||||
|
||||
case DOM0_STOPDOMAIN:
|
||||
case DOM0_UNPAUSEDOMAIN:
|
||||
{
|
||||
struct domain *d = find_domain_by_id(op->u.stopdomain.domain);
|
||||
struct domain *d = find_domain_by_id(op->u.unpausedomain.domain);
|
||||
ret = -ESRCH;
|
||||
if ( d != NULL )
|
||||
{
|
||||
ret = -EINVAL;
|
||||
if ( d != current )
|
||||
if ( test_bit(DF_CONSTRUCTED, &d->flags) )
|
||||
{
|
||||
domain_stop(d);
|
||||
domain_unpause_by_systemcontroller(d);
|
||||
ret = 0;
|
||||
}
|
||||
put_domain(d);
|
||||
@@ -299,16 +299,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
|
||||
strcpy(op->u.getdomaininfo.name, d->name);
|
||||
|
||||
op->u.getdomaininfo.flags =
|
||||
(test_bit(DF_DYING, &d->flags) ? DOMFLAGS_DYING : 0) |
|
||||
(test_bit(DF_CRASHED, &d->flags) ? DOMFLAGS_CRASHED : 0) |
|
||||
(test_bit(DF_SUSPENDED, &d->flags) ? DOMFLAGS_SUSPENDED : 0) |
|
||||
(test_bit(DF_STOPPED, &d->flags) ? DOMFLAGS_STOPPED : 0) |
|
||||
(test_bit(DF_BLOCKED, &d->flags) ? DOMFLAGS_BLOCKED : 0) |
|
||||
(test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
|
||||
(test_bit(DF_DYING, &d->flags) ? DOMFLAGS_DYING : 0) |
|
||||
(test_bit(DF_CRASHED, &d->flags) ? DOMFLAGS_CRASHED : 0) |
|
||||
(test_bit(DF_SHUTDOWN, &d->flags) ? DOMFLAGS_SHUTDOWN : 0) |
|
||||
(test_bit(DF_CTRLPAUSE, &d->flags) ? DOMFLAGS_PAUSED : 0) |
|
||||
(test_bit(DF_BLOCKED, &d->flags) ? DOMFLAGS_BLOCKED : 0) |
|
||||
(test_bit(DF_RUNNING, &d->flags) ? DOMFLAGS_RUNNING : 0);
|
||||
|
||||
op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
|
||||
op->u.getdomaininfo.flags |=
|
||||
d->suspend_code << DOMFLAGS_SUSPCODESHIFT;
|
||||
d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
|
||||
|
||||
op->u.getdomaininfo.tot_pages = d->tot_pages;
|
||||
op->u.getdomaininfo.max_pages = d->max_pages;
|
||||
|
||||
+5
-4
@@ -11,6 +11,7 @@
|
||||
#include <xen/shadow.h>
|
||||
#include <xen/console.h>
|
||||
#include <xen/shadow.h>
|
||||
#include <xen/irq.h>
|
||||
#include <asm/io.h>
|
||||
#include <asm/domain_page.h>
|
||||
#include <asm/flushtlb.h>
|
||||
@@ -193,19 +194,19 @@ void domain_crash(void)
|
||||
BUG();
|
||||
}
|
||||
|
||||
void domain_suspend(u8 reason)
|
||||
void domain_shutdown(u8 reason)
|
||||
{
|
||||
struct domain *d;
|
||||
|
||||
if ( current->domain == 0 )
|
||||
{
|
||||
extern void machine_restart(char *);
|
||||
printk("Domain 0 halted: rebooting machine!\n");
|
||||
printk("Domain 0 shutdown: rebooting machine!\n");
|
||||
machine_restart(0);
|
||||
}
|
||||
|
||||
current->suspend_code = reason;
|
||||
set_bit(DF_SUSPENDED, ¤t->flags);
|
||||
current->shutdown_code = reason;
|
||||
set_bit(DF_SHUTDOWN, ¤t->flags);
|
||||
|
||||
d = find_domain_by_id(0);
|
||||
send_guest_virq(d, VIRQ_DOM_EXC);
|
||||
|
||||
+2
-2
@@ -286,8 +286,8 @@ void cmain(unsigned long magic, multiboot_info_t *mbi)
|
||||
|
||||
init_trace_bufs();
|
||||
|
||||
domain_start(current);
|
||||
domain_start(new_dom);
|
||||
domain_unpause_by_systemcontroller(current);
|
||||
domain_unpause_by_systemcontroller(new_dom);
|
||||
startup_cpu_idle_loop();
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,8 @@ struct domain *alloc_domain_struct(void)
|
||||
*/
|
||||
void sched_add_domain(struct domain *d)
|
||||
{
|
||||
set_bit(DF_STOPPED, &d->flags);
|
||||
/* Must be unpaused by control software to start execution. */
|
||||
set_bit(DF_CTRLPAUSE, &d->flags);
|
||||
|
||||
if ( d->domain != IDLE_DOMAIN_ID )
|
||||
{
|
||||
@@ -269,9 +270,9 @@ long do_sched_op(unsigned long op)
|
||||
break;
|
||||
}
|
||||
|
||||
case SCHEDOP_suspend:
|
||||
case SCHEDOP_shutdown:
|
||||
{
|
||||
domain_suspend((u8)(op >> SCHEDOP_reasonshift));
|
||||
domain_shutdown((u8)(op >> SCHEDOP_reasonshift));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -417,7 +417,7 @@ static int shadow_mode_table_op(struct domain *d,
|
||||
|
||||
/* Might as well stop the domain as an optimization. */
|
||||
if ( zero )
|
||||
domain_stop(d);
|
||||
domain_pause_by_systemcontroller(d);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
* This makes sure that old versions of dom0 tools will stop working in a
|
||||
* well-defined way (rather than crashing the machine, for instance).
|
||||
*/
|
||||
#define DOM0_INTERFACE_VERSION 0xAAAA000F
|
||||
#define DOM0_INTERFACE_VERSION 0xAAAA0010
|
||||
|
||||
#define MAX_DOMAIN_NAME 16
|
||||
|
||||
@@ -63,20 +63,19 @@ typedef struct {
|
||||
typedef struct {
|
||||
/* IN variables. */
|
||||
domid_t domain; /* 0 */
|
||||
u32 force; /* 4 */
|
||||
} PACKED dom0_destroydomain_t; /* 8 bytes */
|
||||
} PACKED dom0_destroydomain_t; /* 4 bytes */
|
||||
|
||||
#define DOM0_STARTDOMAIN 10
|
||||
#define DOM0_PAUSEDOMAIN 10
|
||||
typedef struct {
|
||||
/* IN parameters. */
|
||||
domid_t domain; /* 0 */
|
||||
} PACKED dom0_startdomain_t; /* 4 bytes */
|
||||
} PACKED dom0_pausedomain_t; /* 4 bytes */
|
||||
|
||||
#define DOM0_STOPDOMAIN 11
|
||||
#define DOM0_UNPAUSEDOMAIN 11
|
||||
typedef struct {
|
||||
/* IN parameters. */
|
||||
domid_t domain; /* 0 */
|
||||
} PACKED dom0_stopdomain_t; /* 4 bytes */
|
||||
} PACKED dom0_unpausedomain_t; /* 4 bytes */
|
||||
|
||||
#define DOM0_GETDOMAININFO 12
|
||||
typedef struct {
|
||||
@@ -85,14 +84,14 @@ typedef struct {
|
||||
/* OUT variables. */
|
||||
#define DOMFLAGS_DYING (1<<0) /* Domain is scheduled to die. */
|
||||
#define DOMFLAGS_CRASHED (1<<1) /* Crashed domain; frozen for postmortem. */
|
||||
#define DOMFLAGS_SUSPENDED (1<<2) /* Domain voluntarily halted it execution. */
|
||||
#define DOMFLAGS_STOPPED (1<<3) /* Currently stopped by control software. */
|
||||
#define DOMFLAGS_SHUTDOWN (1<<2) /* The guest OS has shut itself down. */
|
||||
#define DOMFLAGS_PAUSED (1<<3) /* Currently paused by control software. */
|
||||
#define DOMFLAGS_BLOCKED (1<<4) /* Currently blocked pending an event. */
|
||||
#define DOMFLAGS_RUNNING (1<<5) /* Domain is currently running. */
|
||||
#define DOMFLAGS_CPUMASK 255 /* CPU to which this domain is bound. */
|
||||
#define DOMFLAGS_CPUSHIFT 8
|
||||
#define DOMFLAGS_SUSPCODEMASK 255 /* DOMSTATE_SUSPENDED guest-supplied code. */
|
||||
#define DOMFLAGS_SUSPCODESHIFT 16
|
||||
#define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code. */
|
||||
#define DOMFLAGS_SHUTDOWNSHIFT 16
|
||||
u32 flags; /* 4 */
|
||||
u8 name[MAX_DOMAIN_NAME]; /* 8 */
|
||||
full_execution_context_t *ctxt; /* 24 */ /* NB. IN/OUT variable. */
|
||||
@@ -319,8 +318,8 @@ typedef struct {
|
||||
union { /* 8 */
|
||||
u32 dummy[18]; /* 72 bytes */
|
||||
dom0_createdomain_t createdomain;
|
||||
dom0_startdomain_t startdomain;
|
||||
dom0_stopdomain_t stopdomain;
|
||||
dom0_pausedomain_t pausedomain;
|
||||
dom0_unpausedomain_t unpausedomain;
|
||||
dom0_destroydomain_t destroydomain;
|
||||
dom0_getmemlist_t getmemlist;
|
||||
dom0_schedctl_t schedctl;
|
||||
|
||||
@@ -164,9 +164,9 @@
|
||||
*/
|
||||
#define SCHEDOP_yield 0 /* Give up the CPU voluntarily. */
|
||||
#define SCHEDOP_block 1 /* Block until an event is received. */
|
||||
#define SCHEDOP_suspend 2 /* Stop executing this domain. */
|
||||
#define SCHEDOP_shutdown 2 /* Stop executing this domain. */
|
||||
#define SCHEDOP_cmdmask 255 /* 8-bit command. */
|
||||
#define SCHEDOP_reasonshift 8 /* 8-bit suspend code. (SCHEDOP_suspend) */
|
||||
#define SCHEDOP_reasonshift 8 /* 8-bit reason code. (SCHEDOP_shutdown) */
|
||||
|
||||
/*
|
||||
* Commands to HYPERVISOR_console_io().
|
||||
|
||||
+10
-17
@@ -96,7 +96,7 @@ struct domain
|
||||
|
||||
/* Scheduling. */
|
||||
struct list_head run_list;
|
||||
int suspend_code; /* code value from OS (if DF_SUSPENDED). */
|
||||
int shutdown_code; /* code value from OS (if DF_SHUTDOWN). */
|
||||
s_time_t lastschd; /* time this domain was last scheduled */
|
||||
s_time_t lastdeschd; /* time this domain was last descheduled */
|
||||
s_time_t cpu_time; /* total CPU time received till now */
|
||||
@@ -193,7 +193,7 @@ struct domain *find_last_domain(void);
|
||||
extern void domain_destruct(struct domain *d);
|
||||
extern void domain_kill(struct domain *d);
|
||||
extern void domain_crash(void);
|
||||
extern void domain_suspend(u8 reason);
|
||||
extern void domain_shutdown(u8 reason);
|
||||
|
||||
/* arch/process.c */
|
||||
void new_thread(struct domain *d,
|
||||
@@ -254,8 +254,8 @@ extern struct domain *task_list;
|
||||
#define DF_CONSOLEWRITEBUG 6 /* Has this domain used the obsolete console? */
|
||||
#define DF_PHYSDEV 7 /* May this domain do IO to physical devices? */
|
||||
#define DF_BLOCKED 8 /* Domain is blocked waiting for an event. */
|
||||
#define DF_STOPPED 9 /* Domain is stopped by control software. */
|
||||
#define DF_SUSPENDED 10 /* Guest suspended its execution for some reason. */
|
||||
#define DF_CTRLPAUSE 9 /* Domain is paused by controller software. */
|
||||
#define DF_SHUTDOWN 10 /* Guest shut itself down for some reason. */
|
||||
#define DF_CRASHED 11 /* Domain crashed inside Xen, cannot continue. */
|
||||
#define DF_DYING 12 /* Death rattle. */
|
||||
#define DF_RUNNING 13 /* Currently running on a CPU. */
|
||||
@@ -264,8 +264,8 @@ extern struct domain *task_list;
|
||||
static inline int domain_runnable(struct domain *d)
|
||||
{
|
||||
return ( (atomic_read(&d->pausecnt) == 0) &&
|
||||
!(d->flags & ((1<<DF_BLOCKED)|(1<<DF_STOPPED)|
|
||||
(1<<DF_SUSPENDED)|(1<<DF_CRASHED))) );
|
||||
!(d->flags & ((1<<DF_BLOCKED)|(1<<DF_CTRLPAUSE)|
|
||||
(1<<DF_SHUTDOWN)|(1<<DF_CRASHED))) );
|
||||
}
|
||||
|
||||
static inline void domain_pause(struct domain *d)
|
||||
@@ -289,24 +289,17 @@ static inline void domain_unblock(struct domain *d)
|
||||
domain_wake(d);
|
||||
}
|
||||
|
||||
static inline void domain_unsuspend(struct domain *d)
|
||||
static inline void domain_pause_by_systemcontroller(struct domain *d)
|
||||
{
|
||||
ASSERT(d != current);
|
||||
if ( test_and_clear_bit(DF_SUSPENDED, &d->flags) )
|
||||
domain_wake(d);
|
||||
}
|
||||
|
||||
static inline void domain_stop(struct domain *d)
|
||||
{
|
||||
ASSERT(d != current);
|
||||
if ( !test_and_set_bit(DF_STOPPED, &d->flags) )
|
||||
if ( !test_and_set_bit(DF_CTRLPAUSE, &d->flags) )
|
||||
domain_sleep(d);
|
||||
}
|
||||
|
||||
static inline void domain_start(struct domain *d)
|
||||
static inline void domain_unpause_by_systemcontroller(struct domain *d)
|
||||
{
|
||||
ASSERT(d != current);
|
||||
if ( test_and_clear_bit(DF_STOPPED, &d->flags) )
|
||||
if ( test_and_clear_bit(DF_CTRLPAUSE, &d->flags) )
|
||||
domain_wake(d);
|
||||
}
|
||||
|
||||
|
||||