ia64/xen-unstable

changeset 1344:b91c80687fb5

bitkeeper revision 1.890 (4097db6aFEC7daHFzipUePnphBmwaw)

domain_create allows CPU to be specified.
defaults file binds domain to CPU (vmid % num_cpus).
author iap10@labyrinth.cl.cam.ac.uk
date Tue May 04 18:05:30 2004 +0000 (2004-05-04)
parents edc18ca91c16
children 2b2dc843edfb
files tools/examples/defaults tools/examples/xc_dom_create.py tools/xc/lib/xc.h tools/xc/lib/xc_domain.c tools/xc/py/Xc.c xen/common/dom0_ops.c xen/include/hypervisor-ifs/dom0_ops.h
line diff
     1.1 --- a/tools/examples/defaults	Tue May 04 16:24:42 2004 +0000
     1.2 +++ b/tools/examples/defaults	Tue May 04 18:05:30 2004 +0000
     1.3 @@ -31,12 +31,15 @@ builder_fn='linux' # this is a linux dom
     1.4  # STEP 2. The initial memory allocation (in megabytes) for the new domain.
     1.5  mem_size = 64
     1.6  
     1.7 -
     1.8  # STEP 3. A handy name for your new domain.
     1.9  domain_name = "This is VM %d" % vmid
    1.10  
    1.11 +# STEP 4. Which CPU to start domain on? 
    1.12 +#cpu = -1   # leave to Xen to pick
    1.13 +cpu = vmid  # set based on vmid (mod number of CPUs)
    1.14  
    1.15 -# STEP 4. Specify IP address(es), for the new domain.  You need to
    1.16 +
    1.17 +# STEP 5. Specify IP address(es), for the new domain.  You need to
    1.18  # configure IP addrs within the domain just as you do normally.  This
    1.19  # is just to let Xen know about them so it can route packets
    1.20  # appropriately.
    1.21 @@ -46,7 +49,7 @@ vfr_ipaddr  = [xenctl.utils.add_offset_t
    1.22  	       xenctl.utils.add_offset_to_ip('169.254.1.0',vmid),]
    1.23  
    1.24  
    1.25 -# STEP 5a. Identify any physcial partitions or virtual disks you want the
    1.26 +# STEP 6. Identify any physcial partitions or virtual disks you want the
    1.27  # domain to have access to, and what you want them accessible as
    1.28  # e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
    1.29  #	 ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
    1.30 @@ -66,7 +69,7 @@ vbd_list = [ ('phy:sda%d'%(7+vmid),'sda1
    1.31  vbd_expert = 0
    1.32  
    1.33  
    1.34 -# STEP 6. Build the command line for the new domain. Edit as req'd.
    1.35 +# STEP 7. Build the command line for the new domain. Edit as req'd.
    1.36  # You only need the ip= line if you're NFS booting or the root file system
    1.37  # doesn't set it later e.g. in ifcfg-eth0 or via DHCP
    1.38  # You can use 'extrabit' to set the runlevel and custom environment
    1.39 @@ -82,12 +85,12 @@ cmdline_root = "root=/dev/sda1 ro"
    1.40  cmdline_extra = "4 VMID=%d usr=/dev/sda6" % vmid
    1.41  
    1.42  
    1.43 -# STEP 7. Set according to whether you want the script to watch the domain 
    1.44 +# STEP 8. Set according to whether you want the script to watch the domain 
    1.45  # and auto-restart it should it die or exit.
    1.46  
    1.47  auto_restart = False
    1.48  #auto_restart = True
    1.49  
    1.50 -# STEP 8. (Optional) Define a console port number for the new domain.
    1.51 +# STEP 9. (Optional) Define a console port number for the new domain.
    1.52  
    1.53  # console_port = 9610+vmid
     2.1 --- a/tools/examples/xc_dom_create.py	Tue May 04 16:24:42 2004 +0000
     2.2 +++ b/tools/examples/xc_dom_create.py	Tue May 04 18:05:30 2004 +0000
     2.3 @@ -156,6 +156,7 @@ for opt in opts:
     2.4      if opt[0] == '-r': ramdisk = opt[1]
     2.5      if opt[0] == '-b': builder_fn = opt[1]  
     2.6      if opt[0] == '-m': mem_size = int(opt[1])
     2.7 +    if opt[0] == '-C': cpu = int(opt[1])
     2.8      if opt[0] == '-N': domain_name = opt[1]
     2.9      if opt[0] == '-a': auto_restart = answer(opt[1])
    2.10      if opt[0] == '-e': vbd_expert = answer(opt[1])
    2.11 @@ -219,7 +220,7 @@ def make_domain():
    2.12      """
    2.13  
    2.14      # set up access to the global variables declared above
    2.15 -    global image, ramdisk, mem_size, domain_name, vfr_ipaddr, netmask
    2.16 +    global image, ramdisk, mem_size, cpu, domain_name, vfr_ipaddr, netmask
    2.17      global vbd_list, cmdline, xc, vbd_expert, builder_fn
    2.18      	
    2.19      if not os.path.isfile( image ):
    2.20 @@ -230,7 +231,7 @@ def make_domain():
    2.21          print "Ramdisk file '" + ramdisk + "' does not exist"
    2.22          sys.exit()
    2.23  
    2.24 -    id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name )
    2.25 +    id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name, cpu=cpu )
    2.26      if id <= 0:
    2.27  	print "Error creating domain"
    2.28  	sys.exit()
     3.1 --- a/tools/xc/lib/xc.h	Tue May 04 16:24:42 2004 +0000
     3.2 +++ b/tools/xc/lib/xc.h	Tue May 04 18:05:30 2004 +0000
     3.3 @@ -38,6 +38,7 @@ typedef struct {
     3.4  int xc_domain_create(int xc_handle, 
     3.5                       unsigned int mem_kb, 
     3.6                       const char *name,
     3.7 +		     int cpu,
     3.8                       u64 *pdomid);
     3.9  int xc_domain_start(int xc_handle, 
    3.10                      u64 domid);
     4.1 --- a/tools/xc/lib/xc_domain.c	Tue May 04 16:24:42 2004 +0000
     4.2 +++ b/tools/xc/lib/xc_domain.c	Tue May 04 18:05:30 2004 +0000
     4.3 @@ -11,6 +11,7 @@
     4.4  int xc_domain_create(int xc_handle,
     4.5                       unsigned int mem_kb, 
     4.6                       const char *name,
     4.7 +		     int cpu,
     4.8                       u64 *pdomid)
     4.9  {
    4.10      int err;
    4.11 @@ -20,6 +21,7 @@ int xc_domain_create(int xc_handle,
    4.12      op.u.createdomain.memory_kb = mem_kb;
    4.13      strncpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
    4.14      op.u.createdomain.name[MAX_DOMAIN_NAME-1] = '\0';
    4.15 +    op.u.createdomain.cpu = cpu;
    4.16  
    4.17      if ( (err = do_dom0_op(xc_handle, &op)) == 0 )
    4.18          *pdomid = (u64)op.u.createdomain.domain;
     5.1 --- a/tools/xc/py/Xc.c	Tue May 04 16:24:42 2004 +0000
     5.2 +++ b/tools/xc/py/Xc.c	Tue May 04 18:05:30 2004 +0000
     5.3 @@ -38,16 +38,17 @@ static PyObject *pyxc_domain_create(PyOb
     5.4  
     5.5      unsigned int mem_kb = 0;
     5.6      char        *name   = "(anon)";
     5.7 +    int          cpu = -1;
     5.8      u64          dom;
     5.9      int          ret;
    5.10  
    5.11 -    static char *kwd_list[] = { "mem_kb", "name", NULL };
    5.12 +    static char *kwd_list[] = { "mem_kb", "name", "cpu", NULL };
    5.13  
    5.14 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|is", kwd_list, 
    5.15 -                                      &mem_kb, &name) )
    5.16 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|isi", kwd_list, 
    5.17 +                                      &mem_kb, &name, &cpu) )
    5.18          return NULL;
    5.19  
    5.20 -    if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, &dom)) < 0 )
    5.21 +    if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 )
    5.22          return PyErr_SetFromErrno(xc_error);
    5.23  
    5.24      return PyLong_FromUnsignedLongLong(dom);
     6.1 --- a/xen/common/dom0_ops.c	Tue May 04 16:24:42 2004 +0000
     6.2 +++ b/xen/common/dom0_ops.c	Tue May 04 18:05:30 2004 +0000
     6.3 @@ -118,7 +118,11 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     6.4          if ( (dom = get_domnr()) == 0 ) 
     6.5              goto exit_create;
     6.6  
     6.7 -        pro = (pro+1) % smp_num_cpus;
     6.8 +	if (op->u.createdomain.cpu == -1 )
     6.9 +	    pro = (pro+1) % smp_num_cpus;
    6.10 +	else
    6.11 +	    pro = op->u.createdomain.cpu % smp_num_cpus;
    6.12 +
    6.13          p = do_createdomain(dom, pro);
    6.14          if ( p == NULL ) 
    6.15              goto exit_create;
     7.1 --- a/xen/include/hypervisor-ifs/dom0_ops.h	Tue May 04 16:24:42 2004 +0000
     7.2 +++ b/xen/include/hypervisor-ifs/dom0_ops.h	Tue May 04 18:05:30 2004 +0000
     7.3 @@ -49,6 +49,7 @@ typedef struct dom0_createdomain_st
     7.4      /* IN parameters. */
     7.5      unsigned int memory_kb; 
     7.6      char         name[MAX_DOMAIN_NAME];
     7.7 +    int          cpu;
     7.8      /* OUT parameters. */
     7.9      domid_t      domain; 
    7.10  } dom0_createdomain_t;