domain_create allows CPU to be specified.
defaults file binds domain to CPU (vmid % num_cpus).
# 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.
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'),
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
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
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])
"""
# 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 ):
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()
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);
int xc_domain_create(int xc_handle,
unsigned int mem_kb,
const char *name,
+ int cpu,
u64 *pdomid)
{
int err;
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;
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);
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;
/* IN parameters. */
unsigned int memory_kb;
char name[MAX_DOMAIN_NAME];
+ int cpu;
/* OUT parameters. */
domid_t domain;
} dom0_createdomain_t;