aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/examples/defaults15
-rwxr-xr-xtools/examples/xc_dom_create.py5
-rw-r--r--tools/xc/lib/xc.h1
-rw-r--r--tools/xc/lib/xc_domain.c2
-rw-r--r--tools/xc/py/Xc.c9
5 files changed, 20 insertions, 12 deletions
diff --git a/tools/examples/defaults b/tools/examples/defaults
index d5a41eebd5..d391eb1d1e 100644
--- a/tools/examples/defaults
+++ b/tools/examples/defaults
@@ -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
diff --git a/tools/examples/xc_dom_create.py b/tools/examples/xc_dom_create.py
index 4017b5b9a2..22479a9d14 100755
--- a/tools/examples/xc_dom_create.py
+++ b/tools/examples/xc_dom_create.py
@@ -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()
diff --git a/tools/xc/lib/xc.h b/tools/xc/lib/xc.h
index ef2ea1244a..a0205bcc6b 100644
--- a/tools/xc/lib/xc.h
+++ b/tools/xc/lib/xc.h
@@ -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);
diff --git a/tools/xc/lib/xc_domain.c b/tools/xc/lib/xc_domain.c
index 1d77bfc016..c26a3f87c3 100644
--- a/tools/xc/lib/xc_domain.c
+++ b/tools/xc/lib/xc_domain.c
@@ -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;
diff --git a/tools/xc/py/Xc.c b/tools/xc/py/Xc.c
index 074a7d328a..929e9f3104 100644
--- a/tools/xc/py/Xc.c
+++ b/tools/xc/py/Xc.c
@@ -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);