direct-io.hg

changeset 1538:cbee10dcdd93

bitkeeper revision 1.997 (40d818e5-TNUTwvYPW-Y6E4RqoNong)

Merge
author xenbk@gandalf.hpl.hp.com
date Tue Jun 22 11:32:53 2004 +0000 (2004-06-22)
parents 793f5eb5d149 b05d7cdfc7c6
children 2e43f83e8d44
files .rootkeys extras/mini-os/h/hypervisor.h linux-2.4.26-xen-sparse/arch/xen/drivers/dom0/core.c linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c linux-2.4.26-xen-sparse/arch/xen/mm/ioremap.c linux-2.4.26-xen-sparse/include/asm-xen/hypervisor.h linux-2.4.26-xen-sparse/include/asm-xen/pgtable-2level.h linux-2.4.26-xen-sparse/include/asm-xen/pgtable.h linux-2.4.26-xen-sparse/mm/memory.c linux-2.4.26-xen-sparse/mm/vmalloc.c tools/examples/xc_dom_control.py tools/examples/xc_dom_create.py tools/examples/xm_dom_control.py tools/examples/xm_dom_create.py tools/xc/lib/xc.h tools/xc/lib/xc_domain.c tools/xc/lib/xc_linux_build.c tools/xc/lib/xc_linux_restore.c tools/xc/lib/xc_linux_save.c tools/xc/lib/xc_netbsd_build.c tools/xc/lib/xc_private.c tools/xc/lib/xc_private.h tools/xc/py/Xc.c tools/xend/lib/domain_controller.h tools/xenmgr/lib/EventTypes.py tools/xenmgr/lib/XendClient.py tools/xenmgr/lib/XendDomain.py tools/xenmgr/lib/XendDomainInfo.py tools/xenmgr/lib/server/SrvDomain.py tools/xenmgr/lib/xm/create.py tools/xenmgr/lib/xm/main.py xen/arch/x86/process.c xen/common/debug.c xen/common/dom0_ops.c xen/common/domain.c xen/common/kernel.c xen/common/schedule.c xen/common/shadow.c xen/include/hypervisor-ifs/dom0_ops.h xen/include/hypervisor-ifs/hypervisor-if.h xen/include/xen/sched.h
line diff
     1.1 --- a/.rootkeys	Tue Jun 22 08:54:26 2004 +0000
     1.2 +++ b/.rootkeys	Tue Jun 22 11:32:53 2004 +0000
     1.3 @@ -152,7 +152,6 @@ 3f108af5VxPkLv13tXpXgoRKALQtXQ linux-2.4
     1.4  3e5a4e681xMPdF9xCMwpyfuYMySU5g linux-2.4.26-xen-sparse/mm/mremap.c
     1.5  409ba2e7akOFqQUg6Qyg2s28xcXiMg linux-2.4.26-xen-sparse/mm/page_alloc.c
     1.6  3e5a4e683HKVU-sxtagrDasRB8eBVw linux-2.4.26-xen-sparse/mm/swapfile.c
     1.7 -3f108af81Thhb242EmKjGCYkjx-GJA linux-2.4.26-xen-sparse/mm/vmalloc.c
     1.8  3f776bd1Hy9rn69ntXBhPReUFw9IEA tools/Makefile
     1.9  3e6377b24eQqYMsDi9XrFkIgTzZ47A tools/balloon/Makefile
    1.10  3e6377d6eiFjF1hHIS6JEIOFk62xSA tools/balloon/README
     2.1 --- a/extras/mini-os/h/hypervisor.h	Tue Jun 22 08:54:26 2004 +0000
     2.2 +++ b/extras/mini-os/h/hypervisor.h	Tue Jun 22 11:32:53 2004 +0000
     2.3 @@ -148,7 +148,7 @@ static inline int HYPERVISOR_shutdown(vo
     2.4      __asm__ __volatile__ (
     2.5          TRAP_INSTR
     2.6          : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
     2.7 -        "b" (SCHEDOP_suspend | (STOPCODE_shutdown << SCHEDOP_reasonshift))
     2.8 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
     2.9          : "memory" );
    2.10  
    2.11      return ret;
    2.12 @@ -160,7 +160,7 @@ static inline int HYPERVISOR_reboot(void
    2.13      __asm__ __volatile__ (
    2.14          TRAP_INSTR
    2.15          : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
    2.16 -        "b" (SCHEDOP_suspend | (STOPCODE_reboot << SCHEDOP_reasonshift))
    2.17 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
    2.18          : "memory" );
    2.19  
    2.20      return ret;
    2.21 @@ -173,7 +173,7 @@ static inline int HYPERVISOR_suspend(uns
    2.22      __asm__ __volatile__ (
    2.23          TRAP_INSTR
    2.24          : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
    2.25 -        "b" (SCHEDOP_suspend | (STOPCODE_suspend << SCHEDOP_reasonshift)), 
    2.26 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
    2.27          "S" (srec) : "memory" );
    2.28  
    2.29      return ret;
     3.1 --- a/linux-2.4.26-xen-sparse/arch/xen/drivers/dom0/core.c	Tue Jun 22 08:54:26 2004 +0000
     3.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/drivers/dom0/core.c	Tue Jun 22 11:32:53 2004 +0000
     3.3 @@ -157,10 +157,10 @@ static int privcmd_ioctl(struct inode *i
     3.4          addr = m.addr;
     3.5          for ( i = 0; i < m.num; i++, addr += PAGE_SIZE, p++ )
     3.6          {
     3.7 -            if ( get_user(mfn, p) ) return -EFAULT;
     3.8 +            if ( get_user(mfn, p) )
     3.9 +                return -EFAULT;
    3.10  
    3.11 -            v->val = (mfn << PAGE_SHIFT) | pgprot_val(vma->vm_page_prot) |
    3.12 -                _PAGE_IO;
    3.13 +            v->val = (mfn << PAGE_SHIFT) | pgprot_val(vma->vm_page_prot);
    3.14  
    3.15              __direct_remap_area_pages(vma->vm_mm,
    3.16                                        addr, 
     4.1 --- a/linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c	Tue Jun 22 08:54:26 2004 +0000
     4.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/kernel/setup.c	Tue Jun 22 11:32:53 2004 +0000
     4.3 @@ -1143,26 +1143,6 @@ void __init cpu_init (void)
     4.4  
     4.5  
     4.6  /******************************************************************************
     4.7 - * Time-to-die callback handling.
     4.8 - */
     4.9 -
    4.10 -static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
    4.11 -{
    4.12 -    extern void ctrl_alt_del(void);
    4.13 -    ctrl_if_send_response(msg);
    4.14 -    ctrl_alt_del();
    4.15 -}
    4.16 -
    4.17 -static int __init setup_shutdown_event(void)
    4.18 -{
    4.19 -    ctrl_if_register_receiver(CMSG_SHUTDOWN, shutdown_handler, 0);
    4.20 -    return 0;
    4.21 -}
    4.22 -
    4.23 -__initcall(setup_shutdown_event);
    4.24 -
    4.25 -
    4.26 -/******************************************************************************
    4.27   * Stop/pickle callback handling.
    4.28   */
    4.29  
    4.30 @@ -1294,9 +1274,15 @@ static void suspend_task(void *unused)
    4.31  
    4.32  static struct tq_struct suspend_tq;
    4.33  
    4.34 -static void suspend_handler(ctrl_msg_t *msg, unsigned long id)
    4.35 +static void shutdown_handler(ctrl_msg_t *msg, unsigned long id)
    4.36  {
    4.37 -    if ( !suspending )
    4.38 +    if ( msg->subtype != CMSG_SHUTDOWN_SUSPEND )
    4.39 +    {
    4.40 +        extern void ctrl_alt_del(void);
    4.41 +        ctrl_if_send_response(msg);
    4.42 +        ctrl_alt_del();
    4.43 +    }
    4.44 +    else if ( !suspending )
    4.45      {
    4.46  	suspending = 1;
    4.47  	suspend_tq.routine = suspend_task;
    4.48 @@ -1310,10 +1296,10 @@ static void suspend_handler(ctrl_msg_t *
    4.49      ctrl_if_send_response(msg);
    4.50  }
    4.51  
    4.52 -static int __init setup_suspend_event(void)
    4.53 +static int __init setup_shutdown_event(void)
    4.54  {
    4.55 -    ctrl_if_register_receiver(CMSG_SUSPEND, suspend_handler, 0);
    4.56 +    ctrl_if_register_receiver(CMSG_SHUTDOWN, shutdown_handler, 0);
    4.57      return 0;
    4.58  }
    4.59  
    4.60 -__initcall(setup_suspend_event);
    4.61 +__initcall(setup_shutdown_event);
     5.1 --- a/linux-2.4.26-xen-sparse/arch/xen/mm/ioremap.c	Tue Jun 22 08:54:26 2004 +0000
     5.2 +++ b/linux-2.4.26-xen-sparse/arch/xen/mm/ioremap.c	Tue Jun 22 11:32:53 2004 +0000
     5.3 @@ -150,7 +150,7 @@ int direct_remap_area_pages(struct mm_st
     5.4           * Fill in the machine address: PTE ptr is done later by
     5.5           * __direct_remap_area_pages(). 
     5.6           */
     5.7 -        v->val = (machine_addr & PAGE_MASK) | pgprot_val(prot) | _PAGE_IO;
     5.8 +        v->val = (machine_addr & PAGE_MASK) | pgprot_val(prot);
     5.9  
    5.10          machine_addr += PAGE_SIZE;
    5.11          address += PAGE_SIZE; 
    5.12 @@ -262,8 +262,7 @@ void __init *bt_ioremap(unsigned long ma
    5.13           */
    5.14          idx = FIX_BTMAP_BEGIN;
    5.15          while (nrpages > 0) {
    5.16 -                __set_fixmap(idx, machine_addr, 
    5.17 -                             __pgprot(__PAGE_KERNEL|_PAGE_IO));
    5.18 +                __set_fixmap(idx, machine_addr, PAGE_KERNEL);
    5.19                  machine_addr += PAGE_SIZE;
    5.20                  --idx;
    5.21                  --nrpages;
     6.1 --- a/linux-2.4.26-xen-sparse/include/asm-xen/hypervisor.h	Tue Jun 22 08:54:26 2004 +0000
     6.2 +++ b/linux-2.4.26-xen-sparse/include/asm-xen/hypervisor.h	Tue Jun 22 11:32:53 2004 +0000
     6.3 @@ -248,7 +248,7 @@ static inline int HYPERVISOR_shutdown(vo
     6.4      __asm__ __volatile__ (
     6.5          TRAP_INSTR
     6.6          : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
     6.7 -        "b" (SCHEDOP_suspend | (STOPCODE_shutdown << SCHEDOP_reasonshift))
     6.8 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_poweroff << SCHEDOP_reasonshift))
     6.9          : "memory" );
    6.10  
    6.11      return ret;
    6.12 @@ -260,7 +260,7 @@ static inline int HYPERVISOR_reboot(void
    6.13      __asm__ __volatile__ (
    6.14          TRAP_INSTR
    6.15          : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
    6.16 -        "b" (SCHEDOP_suspend | (STOPCODE_reboot << SCHEDOP_reasonshift))
    6.17 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_reboot << SCHEDOP_reasonshift))
    6.18          : "memory" );
    6.19  
    6.20      return ret;
    6.21 @@ -273,7 +273,7 @@ static inline int HYPERVISOR_suspend(uns
    6.22      __asm__ __volatile__ (
    6.23          TRAP_INSTR
    6.24          : "=a" (ret) : "0" (__HYPERVISOR_sched_op),
    6.25 -        "b" (SCHEDOP_suspend | (STOPCODE_suspend << SCHEDOP_reasonshift)), 
    6.26 +        "b" (SCHEDOP_shutdown | (SHUTDOWN_suspend << SCHEDOP_reasonshift)), 
    6.27          "S" (srec) : "memory" );
    6.28  
    6.29      return ret;
     7.1 --- a/linux-2.4.26-xen-sparse/include/asm-xen/pgtable-2level.h	Tue Jun 22 08:54:26 2004 +0000
     7.2 +++ b/linux-2.4.26-xen-sparse/include/asm-xen/pgtable-2level.h	Tue Jun 22 11:32:53 2004 +0000
     7.3 @@ -48,7 +48,26 @@ static inline pmd_t * pmd_offset(pgd_t *
     7.4  }
     7.5  
     7.6  #define pte_same(a, b)		((a).pte_low == (b).pte_low)
     7.7 -#define pte_page(x)		(mem_map+((unsigned long)((pte_val(x) >> PAGE_SHIFT))))
     7.8 +
     7.9 +/*                                 
    7.10 + * We detect special mappings in one of two ways:
    7.11 + *  1. If the MFN is an I/O page then Xen will set the m2p entry
    7.12 + *     to be outside our maximum possible pseudophys range.
    7.13 + *  2. If the MFN belongs to a different domain then we will certainly
    7.14 + *     not have MFN in our p2m table. Conversely, if the page is ours,
    7.15 + *     then we'll have p2m(m2p(MFN))==MFN.
    7.16 + * If we detect a special mapping then it doesn't have a 'struct page'.
    7.17 + * We force !VALID_PAGE() by returning an out-of-range pointer.
    7.18 + */
    7.19 +#define pte_page(_pte)                                        \
    7.20 +({                                                            \
    7.21 +    unsigned long mfn = (_pte).pte_low >> PAGE_SHIFT;         \
    7.22 +    unsigned long pfn = mfn_to_pfn(mfn);                      \
    7.23 +    if ( (pfn >= max_mapnr) || (pfn_to_mfn(pfn) != mfn) )     \
    7.24 +        pfn = max_mapnr; /* specia: force !VALID_PAGE() */    \
    7.25 +    &mem_map[pfn];                                            \
    7.26 +})
    7.27 +
    7.28  #define pte_none(x)		(!(x).pte_low)
    7.29  #define __mk_pte(page_nr,pgprot) __pte(((page_nr) << PAGE_SHIFT) | pgprot_val(pgprot))
    7.30  
     8.1 --- a/linux-2.4.26-xen-sparse/include/asm-xen/pgtable.h	Tue Jun 22 08:54:26 2004 +0000
     8.2 +++ b/linux-2.4.26-xen-sparse/include/asm-xen/pgtable.h	Tue Jun 22 11:32:53 2004 +0000
     8.3 @@ -116,7 +116,6 @@ extern void * high_memory;
     8.4  #define _PAGE_BIT_DIRTY		6
     8.5  #define _PAGE_BIT_PSE		7	/* 4 MB (or 2MB) page, Pentium+, if present.. */
     8.6  #define _PAGE_BIT_GLOBAL	8	/* Global TLB entry PPro+ */
     8.7 -#define _PAGE_BIT_IO            9
     8.8  
     8.9  #define _PAGE_PRESENT	0x001
    8.10  #define _PAGE_RW	0x002
    8.11 @@ -127,7 +126,6 @@ extern void * high_memory;
    8.12  #define _PAGE_DIRTY	0x040
    8.13  #define _PAGE_PSE	0x080	/* 4 MB (or 2MB) page, Pentium+, if present.. */
    8.14  #define _PAGE_GLOBAL	0x100	/* Global TLB entry PPro+ */
    8.15 -#define _PAGE_IO        0x200
    8.16  
    8.17  #define _PAGE_PROTNONE	0x080	/* If not present */
    8.18  
    8.19 @@ -200,7 +198,6 @@ static inline int pte_exec(pte_t pte)		{
    8.20  static inline int pte_dirty(pte_t pte)		{ return (pte).pte_low & _PAGE_DIRTY; }
    8.21  static inline int pte_young(pte_t pte)		{ return (pte).pte_low & _PAGE_ACCESSED; }
    8.22  static inline int pte_write(pte_t pte)		{ return (pte).pte_low & _PAGE_RW; }
    8.23 -static inline int pte_io(pte_t pte)		{ return (pte).pte_low & _PAGE_IO; }
    8.24  
    8.25  static inline pte_t pte_rdprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
    8.26  static inline pte_t pte_exprotect(pte_t pte)	{ (pte).pte_low &= ~_PAGE_USER; return pte; }
    8.27 @@ -212,7 +209,6 @@ static inline pte_t pte_mkexec(pte_t pte
    8.28  static inline pte_t pte_mkdirty(pte_t pte)	{ (pte).pte_low |= _PAGE_DIRTY; return pte; }
    8.29  static inline pte_t pte_mkyoung(pte_t pte)	{ (pte).pte_low |= _PAGE_ACCESSED; return pte; }
    8.30  static inline pte_t pte_mkwrite(pte_t pte)	{ (pte).pte_low |= _PAGE_RW; return pte; }
    8.31 -static inline pte_t pte_mkio(pte_t pte)		{ (pte).pte_low |= _PAGE_IO; return pte; }
    8.32  
    8.33  static inline int ptep_test_and_clear_dirty(pte_t *ptep)
    8.34  {
     9.1 --- a/linux-2.4.26-xen-sparse/mm/memory.c	Tue Jun 22 08:54:26 2004 +0000
     9.2 +++ b/linux-2.4.26-xen-sparse/mm/memory.c	Tue Jun 22 11:32:53 2004 +0000
     9.3 @@ -318,12 +318,6 @@ static inline int zap_pte_range(mmu_gath
     9.4  			continue;
     9.5  		if (pte_present(pte)) {
     9.6  			struct page *page = pte_page(pte);
     9.7 -#if defined(CONFIG_XEN_PRIVILEGED_GUEST)
     9.8 -			if (pte_io(pte)) {
     9.9 -				queue_l1_entry_update(ptep, 0);
    9.10 -				continue;
    9.11 -			}
    9.12 -#endif
    9.13  			if (VALID_PAGE(page) && !PageReserved(page))
    9.14  				freed ++;
    9.15  			/* This will eventually call __free_pte on the pte. */
    10.1 --- a/linux-2.4.26-xen-sparse/mm/vmalloc.c	Tue Jun 22 08:54:26 2004 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,388 +0,0 @@
    10.4 -/*
    10.5 - *  linux/mm/vmalloc.c
    10.6 - *
    10.7 - *  Copyright (C) 1993  Linus Torvalds
    10.8 - *  Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
    10.9 - *  SMP-safe vmalloc/vfree/ioremap, Tigran Aivazian <tigran@veritas.com>, May 2000
   10.10 - */
   10.11 -
   10.12 -#include <linux/config.h>
   10.13 -#include <linux/slab.h>
   10.14 -#include <linux/vmalloc.h>
   10.15 -#include <linux/spinlock.h>
   10.16 -#include <linux/highmem.h>
   10.17 -#include <linux/smp_lock.h>
   10.18 -
   10.19 -#include <asm/uaccess.h>
   10.20 -#include <asm/pgalloc.h>
   10.21 -
   10.22 -rwlock_t vmlist_lock = RW_LOCK_UNLOCKED;
   10.23 -struct vm_struct * vmlist;
   10.24 -
   10.25 -static inline void free_area_pte(pmd_t * pmd, unsigned long address, unsigned long size)
   10.26 -{
   10.27 -	pte_t * pte;
   10.28 -	unsigned long end;
   10.29 -
   10.30 -	if (pmd_none(*pmd))
   10.31 -		return;
   10.32 -	if (pmd_bad(*pmd)) {
   10.33 -		pmd_ERROR(*pmd);
   10.34 -		pmd_clear(pmd);
   10.35 -		return;
   10.36 -	}
   10.37 -	pte = pte_offset(pmd, address);
   10.38 -	address &= ~PMD_MASK;
   10.39 -	end = address + size;
   10.40 -	if (end > PMD_SIZE)
   10.41 -		end = PMD_SIZE;
   10.42 -	do {
   10.43 -		pte_t page;
   10.44 -		page = ptep_get_and_clear(pte);
   10.45 -		address += PAGE_SIZE;
   10.46 -		pte++;
   10.47 -		if (pte_none(page))
   10.48 -			continue;
   10.49 -		if (pte_present(page)) {
   10.50 -			struct page *ptpage = pte_page(page);
   10.51 -#if defined(CONFIG_XEN_PRIVILEGED_GUEST)
   10.52 -			if (pte_io(page))
   10.53 -				continue;
   10.54 -#endif
   10.55 -			if (VALID_PAGE(ptpage) && (!PageReserved(ptpage)))
   10.56 -				__free_page(ptpage);
   10.57 -			continue;
   10.58 -		}
   10.59 -		printk(KERN_CRIT "Whee.. Swapped out page in kernel page table\n");
   10.60 -	} while (address < end);
   10.61 -}
   10.62 -
   10.63 -static inline void free_area_pmd(pgd_t * dir, unsigned long address, unsigned long size)
   10.64 -{
   10.65 -	pmd_t * pmd;
   10.66 -	unsigned long end;
   10.67 -
   10.68 -	if (pgd_none(*dir))
   10.69 -		return;
   10.70 -	if (pgd_bad(*dir)) {
   10.71 -		pgd_ERROR(*dir);
   10.72 -		pgd_clear(dir);
   10.73 -		return;
   10.74 -	}
   10.75 -	pmd = pmd_offset(dir, address);
   10.76 -	address &= ~PGDIR_MASK;
   10.77 -	end = address + size;
   10.78 -	if (end > PGDIR_SIZE)
   10.79 -		end = PGDIR_SIZE;
   10.80 -	do {
   10.81 -		free_area_pte(pmd, address, end - address);
   10.82 -		address = (address + PMD_SIZE) & PMD_MASK;
   10.83 -		pmd++;
   10.84 -	} while (address < end);
   10.85 -}
   10.86 -
   10.87 -void vmfree_area_pages(unsigned long address, unsigned long size)
   10.88 -{
   10.89 -	pgd_t * dir;
   10.90 -	unsigned long end = address + size;
   10.91 -
   10.92 -	dir = pgd_offset_k(address);
   10.93 -	flush_cache_all();
   10.94 -	do {
   10.95 -		free_area_pmd(dir, address, end - address);
   10.96 -		address = (address + PGDIR_SIZE) & PGDIR_MASK;
   10.97 -		dir++;
   10.98 -	} while (address && (address < end));
   10.99 -	flush_tlb_all();
  10.100 -}
  10.101 -
  10.102 -static inline int alloc_area_pte (pte_t * pte, unsigned long address,
  10.103 -			unsigned long size, int gfp_mask,
  10.104 -			pgprot_t prot, struct page ***pages)
  10.105 -{
  10.106 -	unsigned long end;
  10.107 -
  10.108 -	address &= ~PMD_MASK;
  10.109 -	end = address + size;
  10.110 -	if (end > PMD_SIZE)
  10.111 -		end = PMD_SIZE;
  10.112 -	do {
  10.113 -		struct page * page;
  10.114 -
  10.115 -		if (!pages) {
  10.116 -			spin_unlock(&init_mm.page_table_lock);
  10.117 -			page = alloc_page(gfp_mask);
  10.118 -			spin_lock(&init_mm.page_table_lock);
  10.119 -		} else {
  10.120 -			page = (**pages);
  10.121 -			(*pages)++;
  10.122 -
  10.123 -			/* Add a reference to the page so we can free later */
  10.124 -			if (page)
  10.125 -				atomic_inc(&page->count);
  10.126 -
  10.127 -		}
  10.128 -		if (!pte_none(*pte))
  10.129 -			printk(KERN_ERR "alloc_area_pte: page already exists\n");
  10.130 -		if (!page)
  10.131 -			return -ENOMEM;
  10.132 -		set_pte(pte, mk_pte(page, prot));
  10.133 -		address += PAGE_SIZE;
  10.134 -		pte++;
  10.135 -	} while (address < end);
  10.136 -	return 0;
  10.137 -}
  10.138 -
  10.139 -static inline int alloc_area_pmd(pmd_t * pmd, unsigned long address,
  10.140 -			unsigned long size, int gfp_mask,
  10.141 -			pgprot_t prot, struct page ***pages)
  10.142 -{
  10.143 -	unsigned long end;
  10.144 -
  10.145 -	address &= ~PGDIR_MASK;
  10.146 -	end = address + size;
  10.147 -	if (end > PGDIR_SIZE)
  10.148 -		end = PGDIR_SIZE;
  10.149 -	do {
  10.150 -		pte_t * pte = pte_alloc(&init_mm, pmd, address);
  10.151 -		if (!pte)
  10.152 -			return -ENOMEM;
  10.153 -		if (alloc_area_pte(pte, address, end - address,
  10.154 -					gfp_mask, prot, pages))
  10.155 -			return -ENOMEM;
  10.156 -		address = (address + PMD_SIZE) & PMD_MASK;
  10.157 -		pmd++;
  10.158 -	} while (address < end);
  10.159 -	return 0;
  10.160 -}
  10.161 -
  10.162 -static inline int __vmalloc_area_pages (unsigned long address,
  10.163 -					unsigned long size,
  10.164 -					int gfp_mask,
  10.165 -					pgprot_t prot,
  10.166 -					struct page ***pages)
  10.167 -{
  10.168 -	pgd_t * dir;
  10.169 -	unsigned long start = address;
  10.170 -	unsigned long end = address + size;
  10.171 -
  10.172 -	dir = pgd_offset_k(address);
  10.173 -	spin_lock(&init_mm.page_table_lock);
  10.174 -	do {
  10.175 -		pmd_t *pmd;
  10.176 -		
  10.177 -		pmd = pmd_alloc(&init_mm, dir, address);
  10.178 -		if (!pmd)
  10.179 -			goto err;
  10.180 -
  10.181 -		if (alloc_area_pmd(pmd, address, end - address, gfp_mask, prot, pages))
  10.182 -			goto err;	// The kernel NEVER reclaims pmds, so no need to undo pmd_alloc() here
  10.183 -
  10.184 -		address = (address + PGDIR_SIZE) & PGDIR_MASK;
  10.185 -		dir++;
  10.186 -	} while (address && (address < end));
  10.187 -	spin_unlock(&init_mm.page_table_lock);
  10.188 -	flush_cache_all();
  10.189 -	return 0;
  10.190 -err:
  10.191 -	spin_unlock(&init_mm.page_table_lock);
  10.192 -	flush_cache_all();
  10.193 -	if (address > start)
  10.194 -		vmfree_area_pages(start, address - start);
  10.195 -	return -ENOMEM;
  10.196 -}
  10.197 -
  10.198 -int vmalloc_area_pages(unsigned long address, unsigned long size,
  10.199 -		       int gfp_mask, pgprot_t prot)
  10.200 -{
  10.201 -	return __vmalloc_area_pages(address, size, gfp_mask, prot, NULL);
  10.202 -}
  10.203 -
  10.204 -struct vm_struct * get_vm_area(unsigned long size, unsigned long flags)
  10.205 -{
  10.206 -	unsigned long addr, next;
  10.207 -	struct vm_struct **p, *tmp, *area;
  10.208 -
  10.209 -	area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
  10.210 -	if (!area)
  10.211 -		return NULL;
  10.212 -
  10.213 -	size += PAGE_SIZE;
  10.214 -	if (!size) {
  10.215 -		kfree (area);
  10.216 -		return NULL;
  10.217 -	}
  10.218 -
  10.219 -	addr = VMALLOC_START;
  10.220 -	write_lock(&vmlist_lock);
  10.221 -	for (p = &vmlist; (tmp = *p) ; p = &tmp->next) {
  10.222 -		if ((size + addr) < addr)
  10.223 -			goto out;
  10.224 -		if (size + addr <= (unsigned long) tmp->addr)
  10.225 -			break;
  10.226 -		next = tmp->size + (unsigned long) tmp->addr;
  10.227 -		if (next > addr) 
  10.228 -			addr = next;
  10.229 -		if (addr > VMALLOC_END-size)
  10.230 -			goto out;
  10.231 -	}
  10.232 -	area->flags = flags;
  10.233 -	area->addr = (void *)addr;
  10.234 -	area->size = size;
  10.235 -	area->next = *p;
  10.236 -	*p = area;
  10.237 -	write_unlock(&vmlist_lock);
  10.238 -	return area;
  10.239 -
  10.240 -out:
  10.241 -	write_unlock(&vmlist_lock);
  10.242 -	kfree(area);
  10.243 -	return NULL;
  10.244 -}
  10.245 -
  10.246 -void __vfree(void * addr, int free_area_pages)
  10.247 -{
  10.248 -	struct vm_struct **p, *tmp;
  10.249 -
  10.250 -	if (!addr)
  10.251 -		return;
  10.252 -	if ((PAGE_SIZE-1) & (unsigned long) addr) {
  10.253 -		printk(KERN_ERR "Trying to vfree() bad address (%p)\n", addr);
  10.254 -		return;
  10.255 -	}
  10.256 -	write_lock(&vmlist_lock);
  10.257 -	for (p = &vmlist ; (tmp = *p) ; p = &tmp->next) {
  10.258 -		if (tmp->addr == addr) {
  10.259 -			*p = tmp->next;
  10.260 -			if (free_area_pages)
  10.261 -			    vmfree_area_pages(VMALLOC_VMADDR(tmp->addr), tmp->size);
  10.262 -			write_unlock(&vmlist_lock);
  10.263 -			kfree(tmp);
  10.264 -			return;
  10.265 -		}
  10.266 -	}
  10.267 -	write_unlock(&vmlist_lock);
  10.268 -	printk(KERN_ERR "Trying to vfree() nonexistent vm area (%p)\n", addr);
  10.269 -}
  10.270 -
  10.271 -void vfree(void * addr)
  10.272 -{
  10.273 -	__vfree(addr,1);
  10.274 -}
  10.275 -
  10.276 -void * __vmalloc (unsigned long size, int gfp_mask, pgprot_t prot)
  10.277 -{
  10.278 -	void * addr;
  10.279 -	struct vm_struct *area;
  10.280 -
  10.281 -	size = PAGE_ALIGN(size);
  10.282 -	if (!size || (size >> PAGE_SHIFT) > num_physpages)
  10.283 -		return NULL;
  10.284 -	area = get_vm_area(size, VM_ALLOC);
  10.285 -	if (!area)
  10.286 -		return NULL;
  10.287 -	addr = area->addr;
  10.288 -	if (__vmalloc_area_pages(VMALLOC_VMADDR(addr), size, gfp_mask,
  10.289 -				 prot, NULL)) {
  10.290 -		__vfree(addr, 0);
  10.291 -		return NULL;
  10.292 -	}
  10.293 -	return addr;
  10.294 -}
  10.295 -
  10.296 -void * vmap(struct page **pages, int count,
  10.297 -	    unsigned long flags, pgprot_t prot)
  10.298 -{
  10.299 -	void * addr;
  10.300 -	struct vm_struct *area;
  10.301 -	unsigned long size = count << PAGE_SHIFT;
  10.302 -
  10.303 -	if (!size || size > (max_mapnr << PAGE_SHIFT))
  10.304 -		return NULL;
  10.305 -	area = get_vm_area(size, flags);
  10.306 -	if (!area) {
  10.307 -		return NULL;
  10.308 -	}
  10.309 -	addr = area->addr;
  10.310 -	if (__vmalloc_area_pages(VMALLOC_VMADDR(addr), size, 0,
  10.311 -				 prot, &pages)) {
  10.312 -		__vfree(addr, 0);
  10.313 -		return NULL;
  10.314 -	}
  10.315 -	return addr;
  10.316 -}
  10.317 -
  10.318 -long vread(char *buf, char *addr, unsigned long count)
  10.319 -{
  10.320 -	struct vm_struct *tmp;
  10.321 -	char *vaddr, *buf_start = buf;
  10.322 -	unsigned long n;
  10.323 -
  10.324 -	/* Don't allow overflow */
  10.325 -	if ((unsigned long) addr + count < count)
  10.326 -		count = -(unsigned long) addr;
  10.327 -
  10.328 -	read_lock(&vmlist_lock);
  10.329 -	for (tmp = vmlist; tmp; tmp = tmp->next) {
  10.330 -		vaddr = (char *) tmp->addr;
  10.331 -		if (addr >= vaddr + tmp->size - PAGE_SIZE)
  10.332 -			continue;
  10.333 -		while (addr < vaddr) {
  10.334 -			if (count == 0)
  10.335 -				goto finished;
  10.336 -			*buf = '\0';
  10.337 -			buf++;
  10.338 -			addr++;
  10.339 -			count--;
  10.340 -		}
  10.341 -		n = vaddr + tmp->size - PAGE_SIZE - addr;
  10.342 -		do {
  10.343 -			if (count == 0)
  10.344 -				goto finished;
  10.345 -			*buf = *addr;
  10.346 -			buf++;
  10.347 -			addr++;
  10.348 -			count--;
  10.349 -		} while (--n > 0);
  10.350 -	}
  10.351 -finished:
  10.352 -	read_unlock(&vmlist_lock);
  10.353 -	return buf - buf_start;
  10.354 -}
  10.355 -
  10.356 -long vwrite(char *buf, char *addr, unsigned long count)
  10.357 -{
  10.358 -	struct vm_struct *tmp;
  10.359 -	char *vaddr, *buf_start = buf;
  10.360 -	unsigned long n;
  10.361 -
  10.362 -	/* Don't allow overflow */
  10.363 -	if ((unsigned long) addr + count < count)
  10.364 -		count = -(unsigned long) addr;
  10.365 -
  10.366 -	read_lock(&vmlist_lock);
  10.367 -	for (tmp = vmlist; tmp; tmp = tmp->next) {
  10.368 -		vaddr = (char *) tmp->addr;
  10.369 -		if (addr >= vaddr + tmp->size - PAGE_SIZE)
  10.370 -			continue;
  10.371 -		while (addr < vaddr) {
  10.372 -			if (count == 0)
  10.373 -				goto finished;
  10.374 -			buf++;
  10.375 -			addr++;
  10.376 -			count--;
  10.377 -		}
  10.378 -		n = vaddr + tmp->size - PAGE_SIZE - addr;
  10.379 -		do {
  10.380 -			if (count == 0)
  10.381 -				goto finished;
  10.382 -			*addr = *buf;
  10.383 -			buf++;
  10.384 -			addr++;
  10.385 -			count--;
  10.386 -		} while (--n > 0);
  10.387 -	}
  10.388 -finished:
  10.389 -	read_unlock(&vmlist_lock);
  10.390 -	return buf - buf_start;
  10.391 -}
    11.1 --- a/tools/examples/xc_dom_control.py	Tue Jun 22 08:54:26 2004 +0000
    11.2 +++ b/tools/examples/xc_dom_control.py	Tue Jun 22 11:32:53 2004 +0000
    11.3 @@ -9,8 +9,8 @@ def usage ():
    11.4      print >>sys.stderr, """
    11.5  Usage: %s [command] <params>
    11.6  
    11.7 -  stop      [dom]        -- pause a domain
    11.8 -  start     [dom]        -- un-pause a domain
    11.9 +  pause     [dom]        -- pause a domain
   11.10 +  unpause   [dom]        -- un-pause a domain
   11.11    shutdown  [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
   11.12                              (optionally wait for complete shutdown)
   11.13    destroy   [dom]        -- immediately terminate a domain
   11.14 @@ -45,21 +45,21 @@ dom = None
   11.15  if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]):
   11.16      dom = int(sys.argv[2])
   11.17  
   11.18 -if cmd == 'stop':
   11.19 -    rc = xc.domain_stop( dom=dom )
   11.20 +if cmd == 'pause':
   11.21 +    rc = xc.domain_pause( dom=dom )
   11.22  
   11.23 -elif cmd == 'start':
   11.24 -    rc = xc.domain_start( dom=dom )    
   11.25 +elif cmd == 'unpause':
   11.26 +    rc = xc.domain_unpause( dom=dom )    
   11.27  
   11.28  elif cmd == 'shutdown':
   11.29      list = []
   11.30      if dom != None:
   11.31 -        rc = xc.domain_destroy( dom=dom, force=0 )
   11.32 +        rc = xc.domain_destroy( dom=dom ) # should be CMSG_SHUTDOWN
   11.33          list.append(dom)
   11.34      elif sys.argv[2] == 'all':
   11.35          for i in xc.domain_getinfo():
   11.36              if i['dom'] != 0: # don't shutdown dom0!
   11.37 -                ret = xc.domain_destroy( dom=i['dom'], force=0 )
   11.38 +                ret = xc.domain_destroy( dom=i['dom'] ) # should be CMSG_SHUTDOWN
   11.39                  if ret !=0: rc = ret
   11.40                  else: list.append(i['dom'])
   11.41  
   11.42 @@ -72,7 +72,7 @@ elif cmd == 'shutdown':
   11.43                  time.sleep(1)
   11.44  
   11.45  elif cmd == 'destroy':
   11.46 -    rc = xc.domain_destroy( dom=dom, force=1 )    
   11.47 +    rc = xc.domain_destroy( dom=dom )    
   11.48  
   11.49  elif cmd == 'pincpu':
   11.50  
   11.51 @@ -90,8 +90,8 @@ elif cmd == 'list':
   11.52  
   11.53  	run   = (domain['running'] and 'r') or '-'
   11.54          block = (domain['blocked'] and 'b') or '-'
   11.55 -	stop  = (domain['stopped'] and 's') or '-'
   11.56 -	susp  = (domain['suspended'] and 'S') or '-'
   11.57 +	stop  = (domain['paused']  and 'p') or '-'
   11.58 +	susp  = (domain['shutdown'] and 's') or '-'
   11.59  	crash = (domain['crashed'] and 'c') or '-'
   11.60  
   11.61          domain['state'] = run + block + stop + susp + crash
    12.1 --- a/tools/examples/xc_dom_create.py	Tue Jun 22 08:54:26 2004 +0000
    12.2 +++ b/tools/examples/xc_dom_create.py	Tue Jun 22 11:32:53 2004 +0000
    12.3 @@ -364,7 +364,7 @@ def make_domain():
    12.4  	if not nlb: print >>open('/proc/sys/net/ipv4/ip_nonlocal_bind','w'), '0'
    12.5  
    12.6      if not dontstart:
    12.7 -        if xc.domain_start( dom=id ) < 0:
    12.8 +        if xc.domain_unpause( dom=id ) < 0:
    12.9              print "Error starting domain"
   12.10              xc.domain_destroy ( dom=id )
   12.11              sys.exit()
    13.1 --- a/tools/examples/xm_dom_control.py	Tue Jun 22 08:54:26 2004 +0000
    13.2 +++ b/tools/examples/xm_dom_control.py	Tue Jun 22 11:32:53 2004 +0000
    13.3 @@ -25,8 +25,8 @@ def usage (rc=0):
    13.4  Usage: %s [command] <params>
    13.5  
    13.6    help                   -- print usage
    13.7 -  stop      [dom]        -- pause a domain
    13.8 -  start     [dom]        -- un-pause a domain
    13.9 +  pause     [dom]        -- pause a domain
   13.10 +  unpause   [dom]        -- un-pause a domain
   13.11    shutdown  [dom] [[-w]] -- request a domain to shutdown (can specify 'all')
   13.12                              (optionally wait for complete shutdown)
   13.13    destroy   [dom]        -- immediately terminate a domain
   13.14 @@ -89,11 +89,11 @@ if len( sys.argv ) > 2 and re.match('\d+
   13.15  if cmd == "help":
   13.16      usage()
   13.17      
   13.18 -elif cmd == 'stop':
   13.19 -    rc = server.xend_domain_stop(dom)
   13.20 +elif cmd == 'pause':
   13.21 +    rc = server.xend_domain_pause(dom)
   13.22  
   13.23 -elif cmd == 'start':
   13.24 -    rc = server.xend_domain_start(dom)    
   13.25 +elif cmd == 'unpause':
   13.26 +    rc = server.xend_domain_unpause(dom)    
   13.27  
   13.28  elif cmd == 'shutdown':
   13.29      doms = []
    14.1 --- a/tools/examples/xm_dom_create.py	Tue Jun 22 08:54:26 2004 +0000
    14.2 +++ b/tools/examples/xm_dom_create.py	Tue Jun 22 11:32:53 2004 +0000
    14.3 @@ -305,7 +305,7 @@ def make_domain(config):
    14.4      else:
    14.5          console_port = None
    14.6      
    14.7 -    if server.xend_domain_start(dom) < 0:
    14.8 +    if server.xend_domain_unpause(dom) < 0:
    14.9          print "Error starting domain"
   14.10          server.xend_domain_halt(dom)
   14.11          sys.exit()
    15.1 --- a/tools/xc/lib/xc.h	Tue Jun 22 08:54:26 2004 +0000
    15.2 +++ b/tools/xc/lib/xc.h	Tue Jun 22 11:32:53 2004 +0000
    15.3 @@ -25,8 +25,9 @@ int xc_interface_close(int xc_handle);
    15.4  typedef struct {
    15.5      u32           domid;
    15.6      unsigned int  cpu;
    15.7 -    unsigned int  dying:1, crashed:1, suspended:1, 
    15.8 -                  stopped:1, blocked:1, running:1;
    15.9 +    unsigned int  dying:1, crashed:1, shutdown:1, 
   15.10 +                  paused:1, blocked:1, running:1;
   15.11 +    unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
   15.12      unsigned long nr_pages;
   15.13      unsigned long shared_info_frame;
   15.14      u64           cpu_time;
   15.15 @@ -40,13 +41,12 @@ int xc_domain_create(int xc_handle,
   15.16                       const char *name,
   15.17  		     int cpu,
   15.18                       u32 *pdomid);
   15.19 -int xc_domain_start(int xc_handle, 
   15.20 +int xc_domain_pause(int xc_handle, 
   15.21                      u32 domid);
   15.22 -int xc_domain_stop(int xc_handle, 
   15.23 -                   u32 domid);
   15.24 +int xc_domain_unpause(int xc_handle, 
   15.25 +                      u32 domid);
   15.26  int xc_domain_destroy(int xc_handle, 
   15.27 -                      u32 domid, 
   15.28 -                      int force);
   15.29 +                      u32 domid);
   15.30  int xc_domain_pincpu(int xc_handle,
   15.31                       u32 domid,
   15.32                       int cpu);
    16.1 --- a/tools/xc/lib/xc_domain.c	Tue Jun 22 08:54:26 2004 +0000
    16.2 +++ b/tools/xc/lib/xc_domain.c	Tue Jun 22 11:32:53 2004 +0000
    16.3 @@ -30,34 +30,32 @@ int xc_domain_create(int xc_handle,
    16.4  }    
    16.5  
    16.6  
    16.7 -int xc_domain_start(int xc_handle,
    16.8 +int xc_domain_pause(int xc_handle, 
    16.9                      u32 domid)
   16.10  {
   16.11      dom0_op_t op;
   16.12 -    op.cmd = DOM0_STARTDOMAIN;
   16.13 -    op.u.startdomain.domain = (domid_t)domid;
   16.14 +    op.cmd = DOM0_PAUSEDOMAIN;
   16.15 +    op.u.pausedomain.domain = (domid_t)domid;
   16.16      return do_dom0_op(xc_handle, &op);
   16.17  }    
   16.18  
   16.19  
   16.20 -int xc_domain_stop(int xc_handle, 
   16.21 -                   u32 domid)
   16.22 +int xc_domain_unpause(int xc_handle,
   16.23 +                      u32 domid)
   16.24  {
   16.25      dom0_op_t op;
   16.26 -    op.cmd = DOM0_STOPDOMAIN;
   16.27 -    op.u.stopdomain.domain = (domid_t)domid;
   16.28 +    op.cmd = DOM0_UNPAUSEDOMAIN;
   16.29 +    op.u.unpausedomain.domain = (domid_t)domid;
   16.30      return do_dom0_op(xc_handle, &op);
   16.31  }    
   16.32  
   16.33  
   16.34  int xc_domain_destroy(int xc_handle,
   16.35 -                      u32 domid, 
   16.36 -                      int force)
   16.37 +                      u32 domid)
   16.38  {
   16.39      dom0_op_t op;
   16.40      op.cmd = DOM0_DESTROYDOMAIN;
   16.41      op.u.destroydomain.domain = (domid_t)domid;
   16.42 -    op.u.destroydomain.force  = !!force;
   16.43      return do_dom0_op(xc_handle, &op);
   16.44  }
   16.45  
   16.46 @@ -94,12 +92,16 @@ int xc_domain_getinfo(int xc_handle,
   16.47          info->cpu     =
   16.48              (op.u.getdomaininfo.flags>>DOMFLAGS_CPUSHIFT) & DOMFLAGS_CPUMASK;
   16.49  
   16.50 -        info->dying     = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
   16.51 -        info->crashed   = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
   16.52 -        info->suspended = (op.u.getdomaininfo.flags & DOMFLAGS_SUSPENDED);
   16.53 -        info->stopped   = (op.u.getdomaininfo.flags & DOMFLAGS_STOPPED);
   16.54 -        info->blocked   = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
   16.55 -        info->running   = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
   16.56 +        info->dying    = (op.u.getdomaininfo.flags & DOMFLAGS_DYING);
   16.57 +        info->crashed  = (op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
   16.58 +        info->shutdown = (op.u.getdomaininfo.flags & DOMFLAGS_SHUTDOWN);
   16.59 +        info->paused   = (op.u.getdomaininfo.flags & DOMFLAGS_PAUSED);
   16.60 +        info->blocked  = (op.u.getdomaininfo.flags & DOMFLAGS_BLOCKED);
   16.61 +        info->running  = (op.u.getdomaininfo.flags & DOMFLAGS_RUNNING);
   16.62 +
   16.63 +        info->shutdown_reason = 
   16.64 +            (op.u.getdomaininfo.flags>>DOMFLAGS_SHUTDOWNSHIFT) & 
   16.65 +            DOMFLAGS_SHUTDOWNMASK;
   16.66  
   16.67          info->nr_pages = op.u.getdomaininfo.tot_pages;
   16.68          info->max_memkb = op.u.getdomaininfo.max_pages<<(PAGE_SHIFT-10);
    17.1 --- a/tools/xc/lib/xc_linux_build.c	Tue Jun 22 08:54:26 2004 +0000
    17.2 +++ b/tools/xc/lib/xc_linux_build.c	Tue Jun 22 11:32:53 2004 +0000
    17.3 @@ -436,7 +436,7 @@ int xc_linux_build(int xc_handle,
    17.4          PERROR("Could not get info on domain");
    17.5          goto error_out;
    17.6      }
    17.7 -    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
    17.8 +    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
    17.9           (ctxt->pt_base != 0) )
   17.10      {
   17.11          ERROR("Domain is already constructed");
    18.1 --- a/tools/xc/lib/xc_linux_restore.c	Tue Jun 22 08:54:26 2004 +0000
    18.2 +++ b/tools/xc/lib/xc_linux_restore.c	Tue Jun 22 11:32:53 2004 +0000
    18.3 @@ -606,13 +606,8 @@ int xc_linux_restore(int xc_handle,
    18.4  
    18.5  
    18.6   out:
    18.7 -    if ( rc != 0 )
    18.8 -    {
    18.9 -        if ( dom != 0 )
   18.10 -        {
   18.11 -            xc_domain_destroy( xc_handle, dom, 1 );
   18.12 -        }
   18.13 -    }
   18.14 +    if ( (rc != 0) && (dom != 0) )
   18.15 +        xc_domain_destroy(xc_handle, dom);
   18.16  
   18.17      if ( mmu != NULL )
   18.18          free(mmu);
    19.1 --- a/tools/xc/lib/xc_linux_save.c	Tue Jun 22 08:54:26 2004 +0000
    19.2 +++ b/tools/xc/lib/xc_linux_save.c	Tue Jun 22 11:32:53 2004 +0000
    19.3 @@ -273,10 +273,9 @@ int xc_linux_save(int xc_handle,
    19.4      }
    19.5  
    19.6      /* Ensure that the domain exists, and that it is stopped. */
    19.7 -
    19.8 -    if ( xc_domain_stop_sync( xc_handle, domid, &op, &ctxt ) )
    19.9 +    if ( xc_domain_pause(xc_handle, domid) )
   19.10      {
   19.11 -        PERROR("Could not sync stop domain");
   19.12 +        PERROR("Could not pause domain");
   19.13          goto out;
   19.14      }
   19.15  
   19.16 @@ -381,9 +380,9 @@ int xc_linux_save(int xc_handle,
   19.17              goto out;
   19.18          }
   19.19  
   19.20 -        if ( xc_domain_start( xc_handle, domid ) < 0 )
   19.21 +        if ( xc_domain_unpause(xc_handle, domid) < 0 )
   19.22          {
   19.23 -            ERROR("Couldn't restart domain");
   19.24 +            ERROR("Couldn't unpause domain");
   19.25              goto out;
   19.26          }
   19.27  
   19.28 @@ -754,8 +753,7 @@ int xc_linux_save(int xc_handle,
   19.29                  DPRINTF("Start last iteration\n");
   19.30                  last_iter = 1;
   19.31  
   19.32 -                xc_domain_stop_sync( xc_handle, domid, &op, NULL );
   19.33 -
   19.34 +                xc_domain_pause(xc_handle, domid);
   19.35              } 
   19.36  
   19.37              if ( xc_shadow_control( xc_handle, domid, 
    20.1 --- a/tools/xc/lib/xc_netbsd_build.c	Tue Jun 22 08:54:26 2004 +0000
    20.2 +++ b/tools/xc/lib/xc_netbsd_build.c	Tue Jun 22 11:32:53 2004 +0000
    20.3 @@ -258,7 +258,7 @@ int xc_netbsd_build(int xc_handle,
    20.4          PERROR("Could not get info on domain");
    20.5          goto error_out;
    20.6      }
    20.7 -    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_STOPPED) ||
    20.8 +    if ( !(op.u.getdomaininfo.flags & DOMFLAGS_PAUSED) ||
    20.9           (op.u.getdomaininfo.ctxt->pt_base != 0) )
   20.10      {
   20.11          ERROR("Domain is already constructed");
    21.1 --- a/tools/xc/lib/xc_private.c	Tue Jun 22 08:54:26 2004 +0000
    21.2 +++ b/tools/xc/lib/xc_private.c	Tue Jun 22 11:32:53 2004 +0000
    21.3 @@ -199,19 +199,6 @@ int finish_mmu_updates(int xc_handle, mm
    21.4  }
    21.5  
    21.6  
    21.7 -/***********************************************************/
    21.8 -
    21.9 -/* this function is a hack until we get proper synchronous domain stop */
   21.10 -
   21.11 -int xc_domain_stop_sync( int xc_handle, domid_t domid,
   21.12 -                         dom0_op_t *op, full_execution_context_t *ctxt)
   21.13 -{
   21.14 -    op->cmd = DOM0_STOPDOMAIN;
   21.15 -    op->u.stopdomain.domain = (domid_t)domid;
   21.16 -    do_dom0_op(xc_handle, op);
   21.17 -    return 0;
   21.18 -}
   21.19 -
   21.20  long long  xc_domain_get_cpu_usage( int xc_handle, domid_t domid )
   21.21  {
   21.22      dom0_op_t op;
   21.23 @@ -229,8 +216,6 @@ long long  xc_domain_get_cpu_usage( int 
   21.24  }
   21.25  
   21.26  
   21.27 -/**********************************************************************/
   21.28 -
   21.29  /* This is shared between save and restore, and may generally be useful. */
   21.30  unsigned long csum_page (void * page)
   21.31  {
    22.1 --- a/tools/xc/lib/xc_private.h	Tue Jun 22 08:54:26 2004 +0000
    22.2 +++ b/tools/xc/lib/xc_private.h	Tue Jun 22 11:32:53 2004 +0000
    22.3 @@ -200,11 +200,6 @@ int mfn_mapper_flush_queue(mfn_mapper_t 
    22.4  void * mfn_mapper_queue_entry(mfn_mapper_t *t, int offset, 
    22.5  			      unsigned long mfn, int size );
    22.6  
    22.7 -/*********************/
    22.8 -
    22.9 -int xc_domain_stop_sync( int xc_handle, domid_t dom, 
   22.10 -			 dom0_op_t *op, full_execution_context_t *ctxt );
   22.11 -
   22.12  long long  xc_domain_get_cpu_usage( int xc_handle, domid_t domid );
   22.13  
   22.14  #endif /* __XC_PRIVATE_H__ */
    23.1 --- a/tools/xc/py/Xc.c	Tue Jun 22 08:54:26 2004 +0000
    23.2 +++ b/tools/xc/py/Xc.c	Tue Jun 22 11:32:53 2004 +0000
    23.3 @@ -55,7 +55,7 @@ static PyObject *pyxc_domain_create(PyOb
    23.4      return PyInt_FromLong(dom);
    23.5  }
    23.6  
    23.7 -static PyObject *pyxc_domain_start(PyObject *self,
    23.8 +static PyObject *pyxc_domain_pause(PyObject *self,
    23.9                                     PyObject *args,
   23.10                                     PyObject *kwds)
   23.11  {
   23.12 @@ -68,16 +68,16 @@ static PyObject *pyxc_domain_start(PyObj
   23.13      if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   23.14          return NULL;
   23.15  
   23.16 -    if ( xc_domain_start(xc->xc_handle, dom) != 0 )
   23.17 +    if ( xc_domain_pause(xc->xc_handle, dom) != 0 )
   23.18          return PyErr_SetFromErrno(xc_error);
   23.19      
   23.20      Py_INCREF(zero);
   23.21      return zero;
   23.22  }
   23.23  
   23.24 -static PyObject *pyxc_domain_stop(PyObject *self,
   23.25 -                                  PyObject *args,
   23.26 -                                  PyObject *kwds)
   23.27 +static PyObject *pyxc_domain_unpause(PyObject *self,
   23.28 +                                     PyObject *args,
   23.29 +                                     PyObject *kwds)
   23.30  {
   23.31      XcObject *xc = (XcObject *)self;
   23.32  
   23.33 @@ -88,7 +88,7 @@ static PyObject *pyxc_domain_stop(PyObje
   23.34      if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   23.35          return NULL;
   23.36  
   23.37 -    if ( xc_domain_stop(xc->xc_handle, dom) != 0 )
   23.38 +    if ( xc_domain_unpause(xc->xc_handle, dom) != 0 )
   23.39          return PyErr_SetFromErrno(xc_error);
   23.40      
   23.41      Py_INCREF(zero);
   23.42 @@ -102,15 +102,13 @@ static PyObject *pyxc_domain_destroy(PyO
   23.43      XcObject *xc = (XcObject *)self;
   23.44  
   23.45      u32 dom;
   23.46 -    int force = 0;
   23.47  
   23.48 -    static char *kwd_list[] = { "dom", "force", NULL };
   23.49 +    static char *kwd_list[] = { "dom", NULL };
   23.50  
   23.51 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, 
   23.52 -                                      &dom, &force) )
   23.53 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) )
   23.54          return NULL;
   23.55  
   23.56 -    if ( xc_domain_destroy(xc->xc_handle, dom, force) != 0 )
   23.57 +    if ( xc_domain_destroy(xc->xc_handle, dom) != 0 )
   23.58          return PyErr_SetFromErrno(xc_error);
   23.59      
   23.60      Py_INCREF(zero);
   23.61 @@ -166,19 +164,21 @@ static PyObject *pyxc_domain_getinfo(PyO
   23.62      {
   23.63          PyList_SetItem(
   23.64              list, i, 
   23.65 -            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}",
   23.66 +            Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
   23.67 +                          ",s:l,s:L,s:s,s:l,s:i}",
   23.68                            "dom",       info[i].domid,
   23.69                            "cpu",       info[i].cpu,
   23.70                            "dying",     info[i].dying,
   23.71                            "crashed",   info[i].crashed,
   23.72 -                          "suspended", info[i].suspended,
   23.73 -                          "stopped",   info[i].stopped,
   23.74 +                          "shutdown",  info[i].shutdown,
   23.75 +                          "paused",    info[i].paused,
   23.76                            "blocked",   info[i].blocked,
   23.77                            "running",   info[i].running,
   23.78                            "mem_kb",    info[i].nr_pages*4,
   23.79                            "cpu_time",  info[i].cpu_time,
   23.80                            "name",      info[i].name,
   23.81 -                          "maxmem_kb", info[i].max_memkb
   23.82 +                          "maxmem_kb", info[i].max_memkb,
   23.83 +                          "shutdown_reason", info[i].shutdown_reason
   23.84                  ));
   23.85      }
   23.86  
   23.87 @@ -270,7 +270,7 @@ static PyObject *pyxc_linux_save(PyObjec
   23.88              if ( rc == 0 )
   23.89              {
   23.90                  printf("Migration succesful -- destroy local copy\n");
   23.91 -                xc_domain_destroy( xc->xc_handle, dom, 1 );
   23.92 +                xc_domain_destroy(xc->xc_handle, dom);
   23.93                  close(sd);
   23.94                  Py_INCREF(zero);
   23.95                  return zero;
   23.96 @@ -281,7 +281,7 @@ static PyObject *pyxc_linux_save(PyObjec
   23.97  
   23.98      serr:
   23.99          printf("Migration failed -- restart local copy\n");
  23.100 -        xc_domain_start( xc->xc_handle, dom );
  23.101 +        xc_domain_unpause(xc->xc_handle, dom);
  23.102          PyErr_SetFromErrno(xc_error);
  23.103          if ( sd >= 0 ) close(sd);
  23.104          return NULL;
  23.105 @@ -327,7 +327,7 @@ static PyObject *pyxc_linux_save(PyObjec
  23.106              /* kill domain. We don't want to do this for checkpointing, but
  23.107                 if we don't do it here I think people will hurt themselves
  23.108                 by accident... */
  23.109 -            xc_domain_destroy( xc->xc_handle, dom, 1 );
  23.110 +            xc_domain_destroy(xc->xc_handle, dom);
  23.111              gzclose(gfd);
  23.112              close(fd);
  23.113  
  23.114 @@ -1015,26 +1015,25 @@ static PyMethodDef pyxc_methods[] = {
  23.115        " name   [str, '(anon)']: Informative textual name.\n\n"
  23.116        "Returns: [int] new domain identifier; -1 on error.\n" },
  23.117  
  23.118 -    { "domain_start", 
  23.119 -      (PyCFunction)pyxc_domain_start, 
  23.120 +    { "domain_pause", 
  23.121 +      (PyCFunction)pyxc_domain_pause, 
  23.122        METH_VARARGS | METH_KEYWORDS, "\n"
  23.123 -      "Start execution of a domain.\n"
  23.124 -      " dom [int]: Identifier of domain to be started.\n\n"
  23.125 +      "Temporarily pause execution of a domain.\n"
  23.126 +      " dom [int]: Identifier of domain to be paused.\n\n"
  23.127        "Returns: [int] 0 on success; -1 on error.\n" },
  23.128  
  23.129 -    { "domain_stop", 
  23.130 -      (PyCFunction)pyxc_domain_stop, 
  23.131 +    { "domain_unpause", 
  23.132 +      (PyCFunction)pyxc_domain_unpause, 
  23.133        METH_VARARGS | METH_KEYWORDS, "\n"
  23.134 -      "Stop execution of a domain.\n"
  23.135 -      " dom [int]: Identifier of domain to be stopped.\n\n"
  23.136 +      "(Re)start execution of a domain.\n"
  23.137 +      " dom [int]: Identifier of domain to be unpaused.\n\n"
  23.138        "Returns: [int] 0 on success; -1 on error.\n" },
  23.139  
  23.140      { "domain_destroy", 
  23.141        (PyCFunction)pyxc_domain_destroy, 
  23.142        METH_VARARGS | METH_KEYWORDS, "\n"
  23.143        "Destroy a domain.\n"
  23.144 -      " dom   [int]:    Identifier of domain to be destroyed.\n"
  23.145 -      " force [int, 0]: Bool - force immediate destruction?\n\n"
  23.146 +      " dom [int]:    Identifier of domain to be destroyed.\n\n"
  23.147        "Returns: [int] 0 on success; -1 on error.\n" },
  23.148  
  23.149      { "domain_pincpu", 
  23.150 @@ -1059,13 +1058,15 @@ static PyMethodDef pyxc_methods[] = {
  23.151        " cpu      [int]:  CPU to which this domain is bound\n"
  23.152        " dying    [int]:  Bool - is the domain dying?\n"
  23.153        " crashed  [int]:  Bool - has the domain crashed?\n"
  23.154 -      " suspended[int]:  Bool - has the domain suspended itself?\n"
  23.155 -      " stopped  [int]:  Bool - is the domain stopped by control software?\n"
  23.156 +      " shutdown [int]:  Bool - has the domain shut itself down?\n"
  23.157 +      " paused   [int]:  Bool - is the domain paused by control software?\n"
  23.158        " blocked  [int]:  Bool - is the domain blocked waiting for an event?\n"
  23.159        " running  [int]:  Bool - is the domain currently running?\n"
  23.160        " mem_kb   [int]:  Memory reservation, in kilobytes\n"
  23.161        " cpu_time [long]: CPU time consumed, in nanoseconds\n"
  23.162 -      " name     [str]:  Identifying name\n" },
  23.163 +      " name     [str]:  Identifying name\n"
  23.164 +      " shutdown_reason [int]: Numeric code from guest OS, explaining "
  23.165 +      "reason why it shut itself down.\n" },
  23.166  
  23.167      { "linux_save", 
  23.168        (PyCFunction)pyxc_linux_save, 
    24.1 --- a/tools/xend/lib/domain_controller.h	Tue Jun 22 08:54:26 2004 +0000
    24.2 +++ b/tools/xend/lib/domain_controller.h	Tue Jun 22 11:32:53 2004 +0000
    24.3 @@ -29,13 +29,13 @@ typedef struct {
    24.4  
    24.5  
    24.6  /*
    24.7 - * Stop codes for SCHEDOP_suspend. These are opaque to Xen but interpreted by
    24.8 - * control software to determine appropriate action.
    24.9 + * Reason codes for SCHEDOP_shutdown. These are opaque to Xen but may be
   24.10 + * interpreted by control software to determine the appropriate action. These 
   24.11 + * are only really advisories: the controller can actually do as it likes.
   24.12   */
   24.13 -
   24.14 -#define STOPCODE_shutdown   0  /* Domain exited normally. Clean up and kill. */
   24.15 -#define STOPCODE_reboot     1  /* Clean up, kill, and then restart. */
   24.16 -#define STOPCODE_suspend    2  /* Clean up, save suspend info, kill. */
   24.17 +#define SHUTDOWN_poweroff   0  /* Domain exited normally. Clean up and kill. */
   24.18 +#define SHUTDOWN_reboot     1  /* Clean up, kill, and then restart.          */
   24.19 +#define SHUTDOWN_suspend    2  /* Clean up, save suspend info, kill.         */
   24.20  
   24.21  
   24.22  /*
   24.23 @@ -69,7 +69,6 @@ typedef struct {
   24.24  #define CMSG_BLKIF_FE       2  /* Block-device frontend   */
   24.25  #define CMSG_NETIF_BE       3  /* Network-device backend  */
   24.26  #define CMSG_NETIF_FE       4  /* Network-device frontend */
   24.27 -#define CMSG_SUSPEND        5  /* Suspend messages        */
   24.28  #define CMSG_SHUTDOWN       6  /* Shutdown messages       */
   24.29  
   24.30  
   24.31 @@ -519,25 +518,15 @@ typedef struct {
   24.32  
   24.33  
   24.34  /******************************************************************************
   24.35 - * SUSPEND DEFINITIONS
   24.36 - */
   24.37 -
   24.38 -/*
   24.39 - * Subtypes for console messages.
   24.40 - */
   24.41 -/* None. */
   24.42 -
   24.43 -
   24.44 -/******************************************************************************
   24.45   * CONSOLE DEFINITIONS
   24.46   */
   24.47  
   24.48  /*
   24.49   * Subtypes for console messages.
   24.50   */
   24.51 -#define CMSG_SHUTDOWN_HALT      0   /* Shutdown and halt (don't die). */
   24.52 -#define CMSG_SHUTDOWN_POWEROFF  1   /* 'Poweroff' => clean death.     */
   24.53 -#define CMSG_SHUTDOWN_REBOOT    2   /* Shutdown and restart.          */
   24.54 -
   24.55 +#define CMSG_SHUTDOWN_POWEROFF  0   /* Clean shutdown (SHUTDOWN_poweroff).   */
   24.56 +#define CMSG_SHUTDOWN_REBOOT    1   /* Clean shutdown (SHUTDOWN_reboot).     */
   24.57 +#define CMSG_SHUTDOWN_SUSPEND   2   /* Create suspend info, then             */
   24.58 +                                    /* SHUTDOWN_suspend.                     */
   24.59  
   24.60  #endif /* __DOMAIN_CONTROLLER_H__ */
    25.1 --- a/tools/xenmgr/lib/EventTypes.py	Tue Jun 22 08:54:26 2004 +0000
    25.2 +++ b/tools/xenmgr/lib/EventTypes.py	Tue Jun 22 11:32:53 2004 +0000
    25.3 @@ -5,8 +5,8 @@
    25.4  ## xend.domain.destroy: dom, reason:died/crashed
    25.5  ## xend.domain.up ?
    25.6  
    25.7 -## xend.domain.start: dom
    25.8 -## xend.domain.stop: dom
    25.9 +## xend.domain.unpause: dom
   25.10 +## xend.domain.pause: dom
   25.11  ## xend.domain.shutdown: dom
   25.12  ## xend.domain.halt: dom
   25.13  
    26.1 --- a/tools/xenmgr/lib/XendClient.py	Tue Jun 22 08:54:26 2004 +0000
    26.2 +++ b/tools/xenmgr/lib/XendClient.py	Tue Jun 22 11:32:53 2004 +0000
    26.3 @@ -187,13 +187,13 @@ class Xend:
    26.4      def xend_domain(self, id):
    26.5          return xend_get(self.domainurl(id))
    26.6  
    26.7 -    def xend_domain_start(self, id):
    26.8 +    def xend_domain_unpause(self, id):
    26.9          return xend_call(self.domainurl(id),
   26.10 -                         {'op'      : 'start'})
   26.11 +                         {'op'      : 'unpause'})
   26.12  
   26.13 -    def xend_domain_stop(self, id):
   26.14 +    def xend_domain_pause(self, id):
   26.15          return xend_call(self.domainurl(id),
   26.16 -                         {'op'      : 'stop'})
   26.17 +                         {'op'      : 'pause'})
   26.18  
   26.19      def xend_domain_shutdown(self, id):
   26.20          return xend_call(self.domainurl(id),
    27.1 --- a/tools/xenmgr/lib/XendDomain.py	Tue Jun 22 08:54:26 2004 +0000
    27.2 +++ b/tools/xenmgr/lib/XendDomain.py	Tue Jun 22 11:32:53 2004 +0000
    27.3 @@ -192,18 +192,18 @@ class XendDomain:
    27.4          self.refresh_domain(id)
    27.5          return self.domain[id]
    27.6      
    27.7 -    def domain_start(self, id):
    27.8 -        """Start domain running.
    27.9 +    def domain_unpause(self, id):
   27.10 +        """(Re)start domain running.
   27.11          """
   27.12          dom = int(id)
   27.13 -        eserver.inject('xend.domain.start', id)
   27.14 -        return xend.domain_start(dom)
   27.15 +        eserver.inject('xend.domain.unpause', id)
   27.16 +        return xc.domain_unpause(dom=dom)
   27.17      
   27.18 -    def domain_stop(self, id):
   27.19 -        """Stop domain running.
   27.20 +    def domain_pause(self, id):
   27.21 +        """Pause domain execution.
   27.22          """
   27.23          dom = int(id)
   27.24 -        return xend.domain_stop(dom)
   27.25 +        return xc.domain_pause(dom=dom)
   27.26      
   27.27      def domain_shutdown(self, id):
   27.28          """Shutdown domain (nicely).
   27.29 @@ -212,7 +212,7 @@ class XendDomain:
   27.30          if dom <= 0:
   27.31              return 0
   27.32          eserver.inject('xend.domain.shutdown', id)
   27.33 -        val = xend.domain_destroy(dom, force=0)
   27.34 +        val = xc.domain_destroy(dom=dom) # FIXME -- send CMSG_SHUTDOWN
   27.35          self.refresh()
   27.36          return val
   27.37      
   27.38 @@ -223,7 +223,7 @@ class XendDomain:
   27.39          if dom <= 0:
   27.40              return 0
   27.41          eserver.inject('xend.domain.halt', id)
   27.42 -        val = xend.domain_destroy(dom, force=1)
   27.43 +        val = xc.domain_destroy(dom=dom)
   27.44          self.refresh()
   27.45          return val       
   27.46  
   27.47 @@ -237,7 +237,7 @@ class XendDomain:
   27.48          """Save domain state to file, halt domain.
   27.49          """
   27.50          dom = int(id)
   27.51 -        self.domain_stop(id)
   27.52 +        self.domain_pause(id)
   27.53          eserver.inject('xend.domain.save', id)
   27.54          rc = xc.linux_save(dom=dom, state_file=dst, progress=progress)
   27.55          if rc == 0:
    28.1 --- a/tools/xenmgr/lib/XendDomainInfo.py	Tue Jun 22 08:54:26 2004 +0000
    28.2 +++ b/tools/xenmgr/lib/XendDomainInfo.py	Tue Jun 22 11:32:53 2004 +0000
    28.3 @@ -118,8 +118,8 @@ class XendDomainInfo:
    28.4          if self.info:
    28.5              run   = (self.info['running'] and 'r') or '-'
    28.6              block = (self.info['blocked'] and 'b') or '-'
    28.7 -            stop  = (self.info['stopped'] and 's') or '-'
    28.8 -            susp  = (self.info['suspended'] and 'S') or '-'
    28.9 +            stop  = (self.info['paused']  and 'p') or '-'
   28.10 +            susp  = (self.info['shutdown'] and 's') or '-'
   28.11              crash = (self.info['crashed'] and 'c') or '-'
   28.12              state = run + block + stop + susp + crash
   28.13              sxpr.append(['cpu', self.info['cpu']])
   28.14 @@ -177,7 +177,7 @@ class XendDomainInfo:
   28.15      def destroy(self):
   28.16          if self.dom <= 0:
   28.17              return 0
   28.18 -        return xc.domain_destroy(dom=self.dom, force=1)
   28.19 +        return xc.domain_destroy(dom=self.dom)
   28.20  
   28.21      def show(self):
   28.22          """Print virtual machine info.
    29.1 --- a/tools/xenmgr/lib/server/SrvDomain.py	Tue Jun 22 08:54:26 2004 +0000
    29.2 +++ b/tools/xenmgr/lib/server/SrvDomain.py	Tue Jun 22 11:32:53 2004 +0000
    29.3 @@ -18,12 +18,12 @@ class SrvDomain(SrvDir):
    29.4          self.xd = XendDomain.instance()
    29.5          self.xconsole = XendConsole.instance()
    29.6  
    29.7 -    def op_start(self, op, req):
    29.8 -        val = self.xd.domain_start(self.dom.id)
    29.9 +    def op_unpause(self, op, req):
   29.10 +        val = self.xd.domain_unpause(self.dom.id)
   29.11          return val
   29.12          
   29.13 -    def op_stop(self, op, req):
   29.14 -        val = self.xd.domain_stop(self.dom.id)
   29.15 +    def op_pause(self, op, req):
   29.16 +        val = self.xd.domain_pause(self.dom.id)
   29.17          return val
   29.18  
   29.19      def op_shutdown(self, op, req):
    30.1 --- a/tools/xenmgr/lib/xm/create.py	Tue Jun 22 08:54:26 2004 +0000
    30.2 +++ b/tools/xenmgr/lib/xm/create.py	Tue Jun 22 11:32:53 2004 +0000
    30.3 @@ -275,7 +275,7 @@ def make_domain(opts, config):
    30.4      else:
    30.5          console_port = None
    30.6      
    30.7 -    if server.xend_domain_start(dom) < 0:
    30.8 +    if server.xend_domain_unpause(dom) < 0:
    30.9          server.xend_domain_halt(dom)
   30.10          opts.err("Failed to start domain %d" % dom)
   30.11      opts.info("Started domain %d, console on port %d"
    31.1 --- a/tools/xenmgr/lib/xm/main.py	Tue Jun 22 08:54:26 2004 +0000
    31.2 +++ b/tools/xenmgr/lib/xm/main.py	Tue Jun 22 11:32:53 2004 +0000
    31.3 @@ -119,11 +119,11 @@ class Xm:
    31.4          """Pause execution of a domain."""
    31.5          if help:
    31.6              print args[0], 'DOM'
    31.7 -            print '\nStop execution of domain DOM.'
    31.8 +            print '\nPause execution of domain DOM.'
    31.9              return
   31.10          if len(args) < 2: self.err("%s: Missing domain" % args[0])
   31.11          dom = args[1]
   31.12 -        server.xend_domain_stop(dom)
   31.13 +        server.xend_domain_pause(dom)
   31.14  
   31.15      def xm_unpause(self, help, args):
   31.16          """Unpause a paused domain."""
   31.17 @@ -133,7 +133,7 @@ class Xm:
   31.18              return
   31.19          if len(args) < 2: self.err("%s: Missing domain" % args[0])
   31.20          dom = args[1]
   31.21 -        server.xend_domain_start(dom)
   31.22 +        server.xend_domain_unpause(dom)
   31.23  
   31.24      def xm_pincpu(self, help, args):
   31.25          """Pin a domain to a cpu. """
    32.1 --- a/xen/arch/x86/process.c	Tue Jun 22 08:54:26 2004 +0000
    32.2 +++ b/xen/arch/x86/process.c	Tue Jun 22 11:32:53 2004 +0000
    32.3 @@ -76,7 +76,7 @@ void startup_cpu_idle_loop(void)
    32.4  {
    32.5      /* Just some sanity to ensure that the scheduler is set up okay. */
    32.6      ASSERT(current->domain == IDLE_DOMAIN_ID);
    32.7 -    domain_start(current);
    32.8 +    domain_unpause_by_systemcontroller(current);
    32.9      __enter_scheduler();
   32.10  
   32.11      /*
    33.1 --- a/xen/common/debug.c	Tue Jun 22 08:54:26 2004 +0000
    33.2 +++ b/xen/common/debug.c	Tue Jun 22 11:32:53 2004 +0000
    33.3 @@ -52,7 +52,7 @@ void pdb_do_debug (dom0_op_t *op)
    33.4  	    struct domain *d = find_domain_by_id(op->u.debug.domain);
    33.5  	    if ( d != NULL )
    33.6  	    {
    33.7 -                domain_start(d);
    33.8 +                domain_unpause_by_systemcontroller(d);
    33.9  		put_domain(d);
   33.10  	    }
   33.11  	    else
   33.12 @@ -94,7 +94,7 @@ void pdb_do_debug (dom0_op_t *op)
   33.13  
   33.14  	    if ( d != NULL )
   33.15  	    {
   33.16 -                domain_stop(d);
   33.17 +                domain_pause_by_systemcontroller(d);
   33.18  		put_domain(d);
   33.19  	    }
   33.20  	    else
    34.1 --- a/xen/common/dom0_ops.c	Tue Jun 22 08:54:26 2004 +0000
    34.2 +++ b/xen/common/dom0_ops.c	Tue Jun 22 11:32:53 2004 +0000
    34.3 @@ -80,16 +80,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
    34.4      }
    34.5      break;
    34.6  
    34.7 -    case DOM0_STARTDOMAIN:
    34.8 +    case DOM0_PAUSEDOMAIN:
    34.9      {
   34.10 -        struct domain *d = find_domain_by_id(op->u.startdomain.domain);
   34.11 +        struct domain *d = find_domain_by_id(op->u.pausedomain.domain);
   34.12          ret = -ESRCH;
   34.13          if ( d != NULL )
   34.14          {
   34.15              ret = -EINVAL;
   34.16 -            if ( test_bit(DF_CONSTRUCTED, &d->flags) )
   34.17 +            if ( d != current )
   34.18              {
   34.19 -                domain_start(d);
   34.20 +                domain_pause_by_systemcontroller(d);
   34.21                  ret = 0;
   34.22              }
   34.23              put_domain(d);
   34.24 @@ -97,16 +97,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   34.25      }
   34.26      break;
   34.27  
   34.28 -    case DOM0_STOPDOMAIN:
   34.29 +    case DOM0_UNPAUSEDOMAIN:
   34.30      {
   34.31 -        struct domain *d = find_domain_by_id(op->u.stopdomain.domain);
   34.32 +        struct domain *d = find_domain_by_id(op->u.unpausedomain.domain);
   34.33          ret = -ESRCH;
   34.34          if ( d != NULL )
   34.35          {
   34.36              ret = -EINVAL;
   34.37 -            if ( d != current )
   34.38 +            if ( test_bit(DF_CONSTRUCTED, &d->flags) )
   34.39              {
   34.40 -                domain_stop(d);
   34.41 +                domain_unpause_by_systemcontroller(d);
   34.42                  ret = 0;
   34.43              }
   34.44              put_domain(d);
   34.45 @@ -299,16 +299,16 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
   34.46          strcpy(op->u.getdomaininfo.name, d->name);
   34.47          
   34.48          op->u.getdomaininfo.flags =
   34.49 -            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING     : 0) |
   34.50 -            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED   : 0) |
   34.51 -            (test_bit(DF_SUSPENDED, &d->flags) ? DOMFLAGS_SUSPENDED : 0) |
   34.52 -            (test_bit(DF_STOPPED,   &d->flags) ? DOMFLAGS_STOPPED   : 0) |
   34.53 -            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED   : 0) |
   34.54 -            (test_bit(DF_RUNNING,   &d->flags) ? DOMFLAGS_RUNNING   : 0);
   34.55 +            (test_bit(DF_DYING,     &d->flags) ? DOMFLAGS_DYING    : 0) |
   34.56 +            (test_bit(DF_CRASHED,   &d->flags) ? DOMFLAGS_CRASHED  : 0) |
   34.57 +            (test_bit(DF_SHUTDOWN,  &d->flags) ? DOMFLAGS_SHUTDOWN : 0) |
   34.58 +            (test_bit(DF_CTRLPAUSE, &d->flags) ? DOMFLAGS_PAUSED   : 0) |
   34.59 +            (test_bit(DF_BLOCKED,   &d->flags) ? DOMFLAGS_BLOCKED  : 0) |
   34.60 +            (test_bit(DF_RUNNING,   &d->flags) ? DOMFLAGS_RUNNING  : 0);
   34.61  
   34.62          op->u.getdomaininfo.flags |= d->processor << DOMFLAGS_CPUSHIFT;
   34.63          op->u.getdomaininfo.flags |= 
   34.64 -            d->suspend_code << DOMFLAGS_SUSPCODESHIFT;
   34.65 +            d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
   34.66  
   34.67          op->u.getdomaininfo.tot_pages   = d->tot_pages;
   34.68          op->u.getdomaininfo.max_pages   = d->max_pages;
    35.1 --- a/xen/common/domain.c	Tue Jun 22 08:54:26 2004 +0000
    35.2 +++ b/xen/common/domain.c	Tue Jun 22 11:32:53 2004 +0000
    35.3 @@ -11,6 +11,7 @@
    35.4  #include <xen/shadow.h>
    35.5  #include <xen/console.h>
    35.6  #include <xen/shadow.h>
    35.7 +#include <xen/irq.h>
    35.8  #include <asm/io.h>
    35.9  #include <asm/domain_page.h>
   35.10  #include <asm/flushtlb.h>
   35.11 @@ -193,19 +194,19 @@ void domain_crash(void)
   35.12      BUG();
   35.13  }
   35.14  
   35.15 -void domain_suspend(u8 reason)
   35.16 +void domain_shutdown(u8 reason)
   35.17  {
   35.18      struct domain *d;
   35.19  
   35.20      if ( current->domain == 0 )
   35.21      {
   35.22          extern void machine_restart(char *);
   35.23 -        printk("Domain 0 halted: rebooting machine!\n");
   35.24 +        printk("Domain 0 shutdown: rebooting machine!\n");
   35.25          machine_restart(0);
   35.26      }
   35.27  
   35.28 -    current->suspend_code = reason;
   35.29 -    set_bit(DF_SUSPENDED, &current->flags);
   35.30 +    current->shutdown_code = reason;
   35.31 +    set_bit(DF_SHUTDOWN, &current->flags);
   35.32  
   35.33      d = find_domain_by_id(0);
   35.34      send_guest_virq(d, VIRQ_DOM_EXC);
    36.1 --- a/xen/common/kernel.c	Tue Jun 22 08:54:26 2004 +0000
    36.2 +++ b/xen/common/kernel.c	Tue Jun 22 11:32:53 2004 +0000
    36.3 @@ -286,8 +286,8 @@ void cmain(unsigned long magic, multiboo
    36.4  
    36.5      init_trace_bufs();
    36.6  
    36.7 -    domain_start(current);
    36.8 -    domain_start(new_dom);
    36.9 +    domain_unpause_by_systemcontroller(current);
   36.10 +    domain_unpause_by_systemcontroller(new_dom);
   36.11      startup_cpu_idle_loop();
   36.12  }
   36.13  
    37.1 --- a/xen/common/schedule.c	Tue Jun 22 08:54:26 2004 +0000
    37.2 +++ b/xen/common/schedule.c	Tue Jun 22 11:32:53 2004 +0000
    37.3 @@ -129,7 +129,8 @@ struct domain *alloc_domain_struct(void)
    37.4   */
    37.5  void sched_add_domain(struct domain *d) 
    37.6  {
    37.7 -    set_bit(DF_STOPPED, &d->flags);
    37.8 +    /* Must be unpaused by control software to start execution. */
    37.9 +    set_bit(DF_CTRLPAUSE, &d->flags);
   37.10  
   37.11      if ( d->domain != IDLE_DOMAIN_ID )
   37.12      {
   37.13 @@ -269,9 +270,9 @@ long do_sched_op(unsigned long op)
   37.14          break;
   37.15      }
   37.16  
   37.17 -    case SCHEDOP_suspend:
   37.18 +    case SCHEDOP_shutdown:
   37.19      {
   37.20 -        domain_suspend((u8)(op >> SCHEDOP_reasonshift));
   37.21 +        domain_shutdown((u8)(op >> SCHEDOP_reasonshift));
   37.22          break;
   37.23      }
   37.24  
    38.1 --- a/xen/common/shadow.c	Tue Jun 22 08:54:26 2004 +0000
    38.2 +++ b/xen/common/shadow.c	Tue Jun 22 11:32:53 2004 +0000
    38.3 @@ -417,7 +417,7 @@ static int shadow_mode_table_op(struct d
    38.4  
    38.5          /* Might as well stop the domain as an optimization. */
    38.6  		if ( zero )
    38.7 -            domain_stop(d);
    38.8 +            domain_pause_by_systemcontroller(d);
    38.9  
   38.10  		break;
   38.11      }
    39.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Tue Jun 22 08:54:26 2004 +0000
    39.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Tue Jun 22 11:32:53 2004 +0000
    39.3 @@ -19,7 +19,7 @@
    39.4   * This makes sure that old versions of dom0 tools will stop working in a
    39.5   * well-defined way (rather than crashing the machine, for instance).
    39.6   */
    39.7 -#define DOM0_INTERFACE_VERSION   0xAAAA000F
    39.8 +#define DOM0_INTERFACE_VERSION   0xAAAA0010
    39.9  
   39.10  #define MAX_DOMAIN_NAME    16
   39.11  
   39.12 @@ -63,20 +63,19 @@ typedef struct {
   39.13  typedef struct {
   39.14      /* IN variables. */
   39.15      domid_t      domain;              /*  0 */
   39.16 -    u32          force;               /*  4 */
   39.17 -} PACKED dom0_destroydomain_t; /* 8 bytes */
   39.18 +} PACKED dom0_destroydomain_t; /* 4 bytes */
   39.19  
   39.20 -#define DOM0_STARTDOMAIN      10
   39.21 +#define DOM0_PAUSEDOMAIN      10
   39.22  typedef struct {
   39.23      /* IN parameters. */
   39.24      domid_t domain;                   /*  0 */
   39.25 -} PACKED dom0_startdomain_t; /* 4 bytes */
   39.26 +} PACKED dom0_pausedomain_t; /* 4 bytes */
   39.27  
   39.28 -#define DOM0_STOPDOMAIN       11
   39.29 +#define DOM0_UNPAUSEDOMAIN    11
   39.30  typedef struct {
   39.31      /* IN parameters. */
   39.32      domid_t domain;                   /*  0 */
   39.33 -} PACKED dom0_stopdomain_t; /* 4 bytes */
   39.34 +} PACKED dom0_unpausedomain_t; /* 4 bytes */
   39.35  
   39.36  #define DOM0_GETDOMAININFO    12
   39.37  typedef struct {
   39.38 @@ -85,14 +84,14 @@ typedef struct {
   39.39      /* OUT variables. */
   39.40  #define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
   39.41  #define DOMFLAGS_CRASHED   (1<<1) /* Crashed domain; frozen for postmortem.  */
   39.42 -#define DOMFLAGS_SUSPENDED (1<<2) /* Domain voluntarily halted it execution. */
   39.43 -#define DOMFLAGS_STOPPED   (1<<3) /* Currently stopped by control software.  */
   39.44 +#define DOMFLAGS_SHUTDOWN  (1<<2) /* The guest OS has shut itself down.      */
   39.45 +#define DOMFLAGS_PAUSED    (1<<3) /* Currently paused by control software.   */
   39.46  #define DOMFLAGS_BLOCKED   (1<<4) /* Currently blocked pending an event.     */
   39.47  #define DOMFLAGS_RUNNING   (1<<5) /* Domain is currently running.            */
   39.48  #define DOMFLAGS_CPUMASK      255 /* CPU to which this domain is bound.      */
   39.49  #define DOMFLAGS_CPUSHIFT       8
   39.50 -#define DOMFLAGS_SUSPCODEMASK 255 /* DOMSTATE_SUSPENDED guest-supplied code. */
   39.51 -#define DOMFLAGS_SUSPCODESHIFT 16
   39.52 +#define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code.  */
   39.53 +#define DOMFLAGS_SHUTDOWNSHIFT 16
   39.54      u32      flags;                   /*  4 */
   39.55      u8       name[MAX_DOMAIN_NAME];   /*  8 */
   39.56      full_execution_context_t *ctxt;   /* 24 */ /* NB. IN/OUT variable. */
   39.57 @@ -319,8 +318,8 @@ typedef struct {
   39.58      union {                           /* 8 */
   39.59  	u32                      dummy[18]; /* 72 bytes */
   39.60          dom0_createdomain_t      createdomain;
   39.61 -        dom0_startdomain_t       startdomain;
   39.62 -        dom0_stopdomain_t        stopdomain;
   39.63 +        dom0_pausedomain_t       pausedomain;
   39.64 +        dom0_unpausedomain_t     unpausedomain;
   39.65          dom0_destroydomain_t     destroydomain;
   39.66          dom0_getmemlist_t        getmemlist;
   39.67          dom0_schedctl_t          schedctl;
    40.1 --- a/xen/include/hypervisor-ifs/hypervisor-if.h	Tue Jun 22 08:54:26 2004 +0000
    40.2 +++ b/xen/include/hypervisor-ifs/hypervisor-if.h	Tue Jun 22 11:32:53 2004 +0000
    40.3 @@ -164,9 +164,9 @@
    40.4   */
    40.5  #define SCHEDOP_yield           0   /* Give up the CPU voluntarily.       */
    40.6  #define SCHEDOP_block           1   /* Block until an event is received.  */
    40.7 -#define SCHEDOP_suspend         2   /* Stop executing this domain.        */
    40.8 +#define SCHEDOP_shutdown        2   /* Stop executing this domain.        */
    40.9  #define SCHEDOP_cmdmask       255   /* 8-bit command. */
   40.10 -#define SCHEDOP_reasonshift     8   /* 8-bit suspend code. (SCHEDOP_suspend) */
   40.11 +#define SCHEDOP_reasonshift     8   /* 8-bit reason code. (SCHEDOP_shutdown) */
   40.12  
   40.13  /*
   40.14   * Commands to HYPERVISOR_console_io().
    41.1 --- a/xen/include/xen/sched.h	Tue Jun 22 08:54:26 2004 +0000
    41.2 +++ b/xen/include/xen/sched.h	Tue Jun 22 11:32:53 2004 +0000
    41.3 @@ -96,7 +96,7 @@ struct domain
    41.4  
    41.5      /* Scheduling. */
    41.6      struct list_head run_list;
    41.7 -    int              suspend_code;  /* code value from OS (if DF_SUSPENDED). */
    41.8 +    int              shutdown_code; /* code value from OS (if DF_SHUTDOWN). */
    41.9      s_time_t         lastschd;      /* time this domain was last scheduled */
   41.10      s_time_t         lastdeschd;    /* time this domain was last descheduled */
   41.11      s_time_t         cpu_time;      /* total CPU time received till now */
   41.12 @@ -193,7 +193,7 @@ struct domain *find_last_domain(void);
   41.13  extern void domain_destruct(struct domain *d);
   41.14  extern void domain_kill(struct domain *d);
   41.15  extern void domain_crash(void);
   41.16 -extern void domain_suspend(u8 reason);
   41.17 +extern void domain_shutdown(u8 reason);
   41.18  
   41.19  /* arch/process.c */
   41.20  void new_thread(struct domain *d,
   41.21 @@ -254,8 +254,8 @@ extern struct domain *task_list;
   41.22  #define DF_CONSOLEWRITEBUG 6 /* Has this domain used the obsolete console?  */
   41.23  #define DF_PHYSDEV      7 /* May this domain do IO to physical devices?     */
   41.24  #define DF_BLOCKED      8 /* Domain is blocked waiting for an event.        */
   41.25 -#define DF_STOPPED      9 /* Domain is stopped by control software.          */
   41.26 -#define DF_SUSPENDED   10 /* Guest suspended its execution for some reason. */
   41.27 +#define DF_CTRLPAUSE    9 /* Domain is paused by controller software.       */
   41.28 +#define DF_SHUTDOWN    10 /* Guest shut itself down for some reason.        */
   41.29  #define DF_CRASHED     11 /* Domain crashed inside Xen, cannot continue.    */
   41.30  #define DF_DYING       12 /* Death rattle.                                  */
   41.31  #define DF_RUNNING     13 /* Currently running on a CPU.                    */
   41.32 @@ -264,8 +264,8 @@ extern struct domain *task_list;
   41.33  static inline int domain_runnable(struct domain *d)
   41.34  {
   41.35      return ( (atomic_read(&d->pausecnt) == 0) &&
   41.36 -             !(d->flags & ((1<<DF_BLOCKED)|(1<<DF_STOPPED)|
   41.37 -                           (1<<DF_SUSPENDED)|(1<<DF_CRASHED))) );
   41.38 +             !(d->flags & ((1<<DF_BLOCKED)|(1<<DF_CTRLPAUSE)|
   41.39 +                           (1<<DF_SHUTDOWN)|(1<<DF_CRASHED))) );
   41.40  }
   41.41  
   41.42  static inline void domain_pause(struct domain *d)
   41.43 @@ -289,24 +289,17 @@ static inline void domain_unblock(struct
   41.44          domain_wake(d);
   41.45  }
   41.46  
   41.47 -static inline void domain_unsuspend(struct domain *d)
   41.48 +static inline void domain_pause_by_systemcontroller(struct domain *d)
   41.49  {
   41.50      ASSERT(d != current);
   41.51 -    if ( test_and_clear_bit(DF_SUSPENDED, &d->flags) )
   41.52 -        domain_wake(d);
   41.53 -}
   41.54 -
   41.55 -static inline void domain_stop(struct domain *d)
   41.56 -{
   41.57 -    ASSERT(d != current);
   41.58 -    if ( !test_and_set_bit(DF_STOPPED, &d->flags) )
   41.59 +    if ( !test_and_set_bit(DF_CTRLPAUSE, &d->flags) )
   41.60          domain_sleep(d);
   41.61  }
   41.62  
   41.63 -static inline void domain_start(struct domain *d)
   41.64 +static inline void domain_unpause_by_systemcontroller(struct domain *d)
   41.65  {
   41.66      ASSERT(d != current);
   41.67 -    if ( test_and_clear_bit(DF_STOPPED, &d->flags) )
   41.68 +    if ( test_and_clear_bit(DF_CTRLPAUSE, &d->flags) )
   41.69          domain_wake(d);
   41.70  }
   41.71