From: iap10@labyrinth.cl.cam.ac.uk Date: Tue, 4 May 2004 18:05:30 +0000 (+0000) Subject: bitkeeper revision 1.890 (4097db6aFEC7daHFzipUePnphBmwaw) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~18231 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=64a240698b34607607c87dc55f0dce8ca1826d95;p=xen.git bitkeeper revision 1.890 (4097db6aFEC7daHFzipUePnphBmwaw) domain_create allows CPU to be specified. defaults file binds domain to CPU (vmid % num_cpus). --- 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); diff --git a/xen/common/dom0_ops.c b/xen/common/dom0_ops.c index 55a024435b..9370a61a8d 100644 --- a/xen/common/dom0_ops.c +++ b/xen/common/dom0_ops.c @@ -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; diff --git a/xen/include/hypervisor-ifs/dom0_ops.h b/xen/include/hypervisor-ifs/dom0_ops.h index 997c5156fb..024e75ad83 100644 --- a/xen/include/hypervisor-ifs/dom0_ops.h +++ b/xen/include/hypervisor-ifs/dom0_ops.h @@ -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;