direct-io.hg

changeset 989:c27b19a9ea1d

bitkeeper revision 1.639 (3fccbe07JV6j1aK3O8_w92nf6uQSBw)

Misc improvements to pincpu stuff.
author iap10@labyrinth.cl.cam.ac.uk
date Tue Dec 02 16:29:59 2003 +0000 (2003-12-02)
parents acc6520a4d4f
children ac6bee72a4ae
files .rootkeys tools/examples/destroydom.py tools/examples/listdoms.py tools/examples/mynewdom.py tools/examples/pincpu.py tools/examples/startdom.py tools/examples/stopdom.py tools/xc/py/XenoUtil.py xen/common/dom0_ops.c
line diff
     1.1 --- a/.rootkeys	Sun Nov 30 23:04:40 2003 +0000
     1.2 +++ b/.rootkeys	Tue Dec 02 16:29:59 2003 +0000
     1.3 @@ -44,6 +44,7 @@ 3fbe2f12dZbmXLlgQdMgkmnSUj23AQ tools/exa
     1.4  3fbe2f12ltvweb13kBSsxqzZDAq4sg tools/examples/listdoms.py
     1.5  3fca7788tBihusQSq3HJI-YKQTN2iQ tools/examples/mynewdom.py
     1.6  3fca7700PVj36cZObaFZlQicRiw1pQ tools/examples/pincpu.py
     1.7 +3fccbe068ov0YCxnk-2m4law19QMmA tools/examples/startdom.py
     1.8  3fbe2f12Bnt8mwmr1ZCP6HWGS6yvYw tools/examples/stopdom.py
     1.9  3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
    1.10  3f6dc136ZKOjd8PIqLbFBl_v-rnkGg tools/misc/miniterm/Makefile
     4.1 --- a/tools/examples/mynewdom.py	Sun Nov 30 23:04:40 2003 +0000
     4.2 +++ b/tools/examples/mynewdom.py	Tue Dec 02 16:29:59 2003 +0000
     4.3 @@ -1,8 +1,9 @@
     4.4  #!/usr/bin/env python
     4.5  
     4.6 -#
     4.7 -# Example script for creating and building a new Linux guest OS for Xen.
     4.8 -#
     4.9 +# Example script for creating and building a new Linux guest OS for
    4.10 +# Xen.  THIS IS VERY SITE SPECIFIC, but shows an example configuration
    4.11 +# using multiple root partitions with a common /usr.  e.g. Domain1
    4.12 +# uses root /dev/sda8, usr /dev/sda6, and the next sequential IP address.
    4.13  
    4.14  import Xc, XenoUtil, sys, os, socket, re
    4.15  
    4.16 @@ -19,18 +20,18 @@ memory_megabytes = 64
    4.17  # STEP 3. A handy name for your new domain.
    4.18  domain_name = "My new domain"
    4.19  
    4.20 -# Allocate new domain
    4.21 +# Allocate new domain ad get its domain id
    4.22  xc = Xc.new()
    4.23  id = xc.domain_create( mem_kb=memory_megabytes*1024, name=domain_name )
    4.24  if id <= 0:
    4.25      print "Error creating domain"
    4.26      sys.exit()
    4.27  
    4.28 -# Set the CPU, or leave to round robin
    4.29 +# Set the CPU, or leave to round robin allocation
    4.30  #xc.domain_pincpu( dom=id, cpu=1 )
    4.31  
    4.32  # STEP 4. Specify IP address, netmask and gateway for the new domain.
    4.33 -ipaddr  = XenoUtil.add_to_ip(XenoUtil.addr_of_iface('eth0'),id)
    4.34 +ipaddr  = XenoUtil.add_offset_to_ip(XenoUtil.get_current_ipaddr(),id)
    4.35  netmask = XenoUtil.get_current_ipmask()
    4.36  gateway = XenoUtil.get_current_ipgw()
    4.37  
     5.1 --- a/tools/examples/pincpu.py	Sun Nov 30 23:04:40 2003 +0000
     5.2 +++ b/tools/examples/pincpu.py	Tue Dec 02 16:29:59 2003 +0000
     5.3 @@ -4,7 +4,7 @@
     5.4  # Destroy specified domain.
     5.5  #
     5.6  
     5.7 -import Xc, sys, re
     5.8 +import Xc, sys, re, time
     5.9  
    5.10  xc = Xc.new()
    5.11  
    5.12 @@ -12,5 +12,20 @@ if len(sys.argv) < 3:
    5.13      print "Specify a domain identifier and CPU"
    5.14      sys.exit()
    5.15  
    5.16 -xc.domain_pincpu( dom=int(sys.argv[1]), cpu=int(sys.argv[2]))
    5.17 +dom = int(sys.argv[1])
    5.18 +cpu = int(sys.argv[2])
    5.19 +
    5.20 +orig_state = xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped']
    5.21 +
    5.22 +while xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] != 1:
    5.23 +    xc.domain_stop( dom=dom )
    5.24 +    time.sleep(0.1)
    5.25  
    5.26 +xc.domain_pincpu( dom, cpu )
    5.27 +
    5.28 +if orig_state == 0:
    5.29 +    xc.domain_start( dom=dom )
    5.30 +
    5.31 +
    5.32 +
    5.33 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/examples/startdom.py	Tue Dec 02 16:29:59 2003 +0000
     6.3 @@ -0,0 +1,15 @@
     6.4 +#!/usr/bin/env python
     6.5 +
     6.6 +#
     6.7 +# Start execution of specified domain.
     6.8 +#
     6.9 +
    6.10 +import Xc, sys, re
    6.11 +
    6.12 +xc = Xc.new()
    6.13 +
    6.14 +if len(sys.argv) != 2:
    6.15 +    print "Specify a domain identifier"
    6.16 +    sys.exit()
    6.17 +
    6.18 +xc.domain_start( dom=int(sys.argv[1]) )
     8.1 --- a/tools/xc/py/XenoUtil.py	Sun Nov 30 23:04:40 2003 +0000
     8.2 +++ b/tools/xc/py/XenoUtil.py	Tue Dec 02 16:29:59 2003 +0000
     8.3 @@ -129,16 +129,11 @@ def setup_vfr_rules_for_vif(dom,vif,addr
     8.4      os.close( fd )
     8.5      return None
     8.6  
     8.7 -def addr_of_iface( iface ):
     8.8 -    fd = os.popen( '/sbin/ifconfig '+iface )
     8.9 -    lines = fd.readlines()
    8.10 -    for line in lines:
    8.11 -	m = re.search( 'inet addr:([0-9.]+)', line )
    8.12 -	if m: 
    8.13 -	    return m.group(1)
    8.14 -    return None
    8.15 +def add_offset_to_ip( ip, off ):
    8.16 +    l = string.split(ip,'.')
    8.17 +    a = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
    8.18 +	  (string.atoi(l[2])<<8)  | string.atoi(l[3]) ) + off
    8.19 +    
    8.20 +    return '%d.%d.%d.%d' % ( ((a>>24)&0xff), ((a>>16)&0xff),
    8.21 +			     ((a>>8)&0xff), (a&0xff) )
    8.22  
    8.23 -def add_to_ip( ip, off ):
    8.24 -    l = string.split(ip,'.')
    8.25 -    return '%s.%s.%s.%d' % ( l[0],l[1],l[2],string.atoi(l[3])+off )
    8.26 -
     9.1 --- a/xen/common/dom0_ops.c	Sun Nov 30 23:04:40 2003 +0000
     9.2 +++ b/xen/common/dom0_ops.c	Tue Dec 02 16:29:59 2003 +0000
     9.3 @@ -196,14 +196,17 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     9.4  	    else
     9.5  	      {
     9.6  		/* For the moment, we are unable to move running
     9.7 -		domains between CPUs. (We need a way of cleanly stopping 
     9.8 -		running domains). For now, if we discover the domain is
     9.9 -		running then cowardly bail out with ENOSYS */
    9.10 +		domains between CPUs. (We need a way of synchronously
    9.11 +		stopping running domains). For now, if we discover the
    9.12 +		domain is not stopped already then cowardly bail out
    9.13 +		with ENOSYS */
    9.14  
    9.15 -		if(p->flags & PF_CONSTRUCTED) 
    9.16 +		if( !(p->state & TASK_STOPPED) ) 
    9.17  		  ret = -ENOSYS;
    9.18  		else
    9.19  		  {
    9.20 +		    /* We need a task structure lock here!!! 
    9.21 +		       FIX ME!! */
    9.22  		    cpu = cpu % smp_num_cpus;
    9.23  		    p->processor = cpu;
    9.24  		    p->cpupinned = 1;