bitkeeper revision 1.890 (4097db6aFEC7daHFzipUePnphBmwaw)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Tue, 4 May 2004 18:05:30 +0000 (18:05 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Tue, 4 May 2004 18:05:30 +0000 (18:05 +0000)
domain_create allows CPU to be specified.
defaults file binds domain to CPU (vmid % num_cpus).

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

index d5a41eebd52e6fdd3deb9560cd5a4e3a1b82e925..d391eb1d1e23b42991218e71bb03626c392b2596 100644 (file)
@@ -31,12 +31,15 @@ builder_fn='linux' # this is a linux domain
 # STEP 2. The initial memory allocation (in megabytes) for the new domain.
 mem_size = 64
 
-
 # STEP 3. A handy name for your new domain.
 domain_name = "This is VM %d" % vmid
 
+# STEP 4. Which CPU to start domain on? 
+#cpu = -1   # leave to Xen to pick
+cpu = vmid  # set based on vmid (mod number of CPUs)
+
 
-# STEP 4. Specify IP address(es), for the new domain.  You need to
+# STEP 5. Specify IP address(es), for the new domain.  You need to
 # configure IP addrs within the domain just as you do normally.  This
 # is just to let Xen know about them so it can route packets
 # appropriately.
@@ -46,7 +49,7 @@ vfr_ipaddr  = [xenctl.utils.add_offset_to_ip(xenctl.utils.get_current_ipaddr(),v
               xenctl.utils.add_offset_to_ip('169.254.1.0',vmid),]
 
 
-# STEP 5a. Identify any physcial partitions or virtual disks you want the
+# STEP 6. Identify any physcial partitions or virtual disks you want the
 # domain to have access to, and what you want them accessible as
 # e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
 #       ('phy:sda%d' % (3+vmid), 'hda2', 'r'), 
@@ -66,7 +69,7 @@ vbd_list = [ ('phy:sda%d'%(7+vmid),'sda1','w' ),
 vbd_expert = 0
 
 
-# STEP 6. Build the command line for the new domain. Edit as req'd.
+# STEP 7. Build the command line for the new domain. Edit as req'd.
 # You only need the ip= line if you're NFS booting or the root file system
 # doesn't set it later e.g. in ifcfg-eth0 or via DHCP
 # You can use 'extrabit' to set the runlevel and custom environment
@@ -82,12 +85,12 @@ cmdline_root = "root=/dev/sda1 ro"
 cmdline_extra = "4 VMID=%d usr=/dev/sda6" % vmid
 
 
-# STEP 7. Set according to whether you want the script to watch the domain 
+# STEP 8. Set according to whether you want the script to watch the domain 
 # and auto-restart it should it die or exit.
 
 auto_restart = False
 #auto_restart = True
 
-# STEP 8. (Optional) Define a console port number for the new domain.
+# STEP 9. (Optional) Define a console port number for the new domain.
 
 # console_port = 9610+vmid
index 4017b5b9a2499cef905d89c4f9822351abe71956..22479a9d14f000a43676e2f657b2aa2f9e00746a 100755 (executable)
@@ -156,6 +156,7 @@ for opt in opts:
     if opt[0] == '-r': ramdisk = opt[1]
     if opt[0] == '-b': builder_fn = opt[1]  
     if opt[0] == '-m': mem_size = int(opt[1])
+    if opt[0] == '-C': cpu = int(opt[1])
     if opt[0] == '-N': domain_name = opt[1]
     if opt[0] == '-a': auto_restart = answer(opt[1])
     if opt[0] == '-e': vbd_expert = answer(opt[1])
@@ -219,7 +220,7 @@ def make_domain():
     """
 
     # set up access to the global variables declared above
-    global image, ramdisk, mem_size, domain_name, vfr_ipaddr, netmask
+    global image, ramdisk, mem_size, cpu, domain_name, vfr_ipaddr, netmask
     global vbd_list, cmdline, xc, vbd_expert, builder_fn
        
     if not os.path.isfile( image ):
@@ -230,7 +231,7 @@ def make_domain():
         print "Ramdisk file '" + ramdisk + "' does not exist"
         sys.exit()
 
-    id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name )
+    id = xc.domain_create( mem_kb=mem_size*1024, name=domain_name, cpu=cpu )
     if id <= 0:
        print "Error creating domain"
        sys.exit()
index ef2ea1244ae908e889747c2dae420042c5760c18..a0205bcc6b292aa36d72e6a8862089a5388e948e 100644 (file)
@@ -38,6 +38,7 @@ typedef struct {
 int xc_domain_create(int xc_handle, 
                      unsigned int mem_kb, 
                      const char *name,
+                    int cpu,
                      u64 *pdomid);
 int xc_domain_start(int xc_handle, 
                     u64 domid);
index 1d77bfc0166bb127fd8274a7ae838321a6dc553b..c26a3f87c3f4db501c64437f958518cd81dc9340 100644 (file)
@@ -11,6 +11,7 @@
 int xc_domain_create(int xc_handle,
                      unsigned int mem_kb, 
                      const char *name,
+                    int cpu,
                      u64 *pdomid)
 {
     int err;
@@ -20,6 +21,7 @@ int xc_domain_create(int xc_handle,
     op.u.createdomain.memory_kb = mem_kb;
     strncpy(op.u.createdomain.name, name, MAX_DOMAIN_NAME);
     op.u.createdomain.name[MAX_DOMAIN_NAME-1] = '\0';
+    op.u.createdomain.cpu = cpu;
 
     if ( (err = do_dom0_op(xc_handle, &op)) == 0 )
         *pdomid = (u64)op.u.createdomain.domain;
index 074a7d328ae93ae4421178fdb1890e9af0b795aa..929e9f31045d5ef4bd86346e00d3bf13508f862b 100644 (file)
@@ -38,16 +38,17 @@ static PyObject *pyxc_domain_create(PyObject *self,
 
     unsigned int mem_kb = 0;
     char        *name   = "(anon)";
+    int          cpu = -1;
     u64          dom;
     int          ret;
 
-    static char *kwd_list[] = { "mem_kb", "name", NULL };
+    static char *kwd_list[] = { "mem_kb", "name", "cpu", NULL };
 
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|is", kwd_list, 
-                                      &mem_kb, &name) )
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|isi", kwd_list, 
+                                      &mem_kb, &name, &cpu) )
         return NULL;
 
-    if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, &dom)) < 0 )
+    if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 )
         return PyErr_SetFromErrno(xc_error);
 
     return PyLong_FromUnsignedLongLong(dom);
index 55a024435b3ebcc349de4390146fe2e5501a6b26..9370a61a8d60d552f8fa27a3ff2074af4c639b56 100644 (file)
@@ -118,7 +118,11 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         if ( (dom = get_domnr()) == 0 ) 
             goto exit_create;
 
-        pro = (pro+1) % smp_num_cpus;
+       if (op->u.createdomain.cpu == -1 )
+           pro = (pro+1) % smp_num_cpus;
+       else
+           pro = op->u.createdomain.cpu % smp_num_cpus;
+
         p = do_createdomain(dom, pro);
         if ( p == NULL ) 
             goto exit_create;
index 997c5156fb1dae5b79022439006aa89b198f621f..024e75ad8304ad9ebc95cba06724c7767aba70d4 100644 (file)
@@ -49,6 +49,7 @@ typedef struct dom0_createdomain_st
     /* IN parameters. */
     unsigned int memory_kb; 
     char         name[MAX_DOMAIN_NAME];
+    int          cpu;
     /* OUT parameters. */
     domid_t      domain; 
 } dom0_createdomain_t;