Changeset 613
- Timestamp:
- 05/27/07 00:32:04 (2 years ago)
- Files:
-
- trunk/TODO (modified) (1 diff)
- trunk/src/vcc/vce/Makefile.am (modified) (1 diff)
- trunk/src/vcc/vce/cmd.c (modified) (2 diffs)
- trunk/src/vcc/vce/cmd.h (modified) (1 diff)
- trunk/src/vcc/vce/vx_cpuset.c (added)
- trunk/src/vcd/methods.c (modified) (1 diff)
- trunk/src/vcd/methods.h (modified) (1 diff)
- trunk/src/vcd/methods/Makefile.am (modified) (1 diff)
- trunk/src/vcd/methods/helper/helper_shutdown.c (modified) (2 diffs)
- trunk/src/vcd/methods/helper/helper_startup.c (modified) (5 diffs)
- trunk/src/vcd/methods/vxdb/vxdb_vx_cpuset_get.c (added)
- trunk/src/vcd/methods/vxdb/vxdb_vx_cpuset_remove.c (added)
- trunk/src/vcd/methods/vxdb/vxdb_vx_cpuset_set.c (added)
- trunk/src/vcd/methods/vxdb/vxdb_vx_sched_remove.c (modified) (1 diff)
- trunk/src/vcd/validate.c (modified) (3 diffs)
- trunk/src/vcd/validate.h (modified) (1 diff)
- trunk/src/vcd/vxdb-tables.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/TODO
r598 r613 8 8 WANTED FEATURES: 9 9 - vx.move method to also move the VServer around on the disk 10 - cpuset support11 10 - sysctl support trunk/src/vcc/vce/Makefile.am
r561 r613 31 31 vx_bcaps.c \ 32 32 vx_ccaps.c \ 33 vx_cpuset.c \ 33 34 vx_flags.c \ 34 35 vx_limit.c \ trunk/src/vcc/vce/cmd.c
r595 r613 45 45 { "vx.ccaps.get", cmd_vx_ccaps_get }, 46 46 { "vx.ccaps.remove", cmd_vx_ccaps_remove }, 47 { "vx.cpuset.get", cmd_vx_cpuset_get }, 48 { "vx.cpuset.remove", cmd_vx_cpuset_remove }, 49 { "vx.cpuset.set", cmd_vx_cpuset_set }, 47 50 { "vx.flags.add", cmd_vx_flags_add }, 48 51 { "vx.flags.get", cmd_vx_flags_get }, … … 104 107 " vx.limit.set <name> <limit> <soft> [<max>]\n" 105 108 "\n" 109 " vx.cpuset.get <name>\n" 110 " vx.cpuset.remove <name>\n" 111 " vx.cpuset.set <name> <cpus> <mems> [<virtualize>]\n" 112 "\n" 106 113 " vx.sched.get <name> [<cpuid>]\n" 107 114 " vx.sched.remove <name> [<cpuid>]\n" trunk/src/vcc/vce/cmd.h
r561 r613 42 42 void cmd_vx_ccaps_get (xmlrpc_env *env, int argc, char **argv); 43 43 void cmd_vx_ccaps_remove (xmlrpc_env *env, int argc, char **argv); 44 void cmd_vx_cpuset_get (xmlrpc_env *env, int argc, char **argv); 45 void cmd_vx_cpuset_remove (xmlrpc_env *env, int argc, char **argv); 46 void cmd_vx_cpuset_set (xmlrpc_env *env, int argc, char **argv); 44 47 void cmd_vx_flags_add (xmlrpc_env *env, int argc, char **argv); 45 48 void cmd_vx_flags_get (xmlrpc_env *env, int argc, char **argv); trunk/src/vcd/methods.c
r589 r613 144 144 MREGISTER("vxdb.vx.ccaps.get", m_vxdb_vx_ccaps_get); 145 145 MREGISTER("vxdb.vx.ccaps.remove", m_vxdb_vx_ccaps_remove); 146 MREGISTER("vxdb.vx.cpuset.get", m_vxdb_vx_cpuset_get); 147 MREGISTER("vxdb.vx.cpuset.remove", m_vxdb_vx_cpuset_remove); 148 MREGISTER("vxdb.vx.cpuset.set", m_vxdb_vx_cpuset_set); 146 149 MREGISTER("vxdb.vx.flags.add", m_vxdb_vx_flags_add); 147 150 MREGISTER("vxdb.vx.flags.get", m_vxdb_vx_flags_get); trunk/src/vcd/methods.h
r589 r613 188 188 MPROTO(m_vxdb_vx_ccaps_get); 189 189 MPROTO(m_vxdb_vx_ccaps_remove); 190 MPROTO(m_vxdb_vx_cpuset_get); 191 MPROTO(m_vxdb_vx_cpuset_remove); 192 MPROTO(m_vxdb_vx_cpuset_set); 190 193 MPROTO(m_vxdb_vx_flags_add); 191 194 MPROTO(m_vxdb_vx_flags_get); trunk/src/vcd/methods/Makefile.am
r589 r613 82 82 vxdb/vxdb_vx_ccaps_get.c \ 83 83 vxdb/vxdb_vx_ccaps_remove.c \ 84 vxdb/vxdb_vx_cpuset_get.c \ 85 vxdb/vxdb_vx_cpuset_remove.c \ 86 vxdb/vxdb_vx_cpuset_set.c \ 84 87 vxdb/vxdb_vx_flags_add.c \ 85 88 vxdb/vxdb_vx_flags_get.c \ trunk/src/vcd/methods/helper/helper_shutdown.c
r611 r613 25 25 26 26 #include <lucid/log.h> 27 #include <lucid/misc.h> 28 #include <lucid/printf.h> 27 29 28 30 /* helper.shutdown(int xid) */ … … 47 49 if (!(name = vxdb_getname(xid))) 48 50 method_return_fault(env, MENOVPS); 51 52 /* Remove the cpuset on shutdown, if it exists */ 53 if (ismount("/dev/cpuset")) { 54 char *cpusetpath; 55 56 asprintf(&cpusetpath, "/dev/cpuset/xid%d", xid); 57 58 if (isdir(cpusetpath)) 59 rmdir(cpusetpath); 60 } 49 61 50 62 rc = vxdb_exec("DELETE FROM restart WHERE xid = %d", xid); trunk/src/vcd/methods/helper/helper_startup.c
r557 r613 35 35 #include <lucid/log.h> 36 36 #include <lucid/mem.h> 37 #include <lucid/misc.h> 37 38 #include <lucid/open.h> 38 39 #include <lucid/printf.h> … … 44 45 2) setup disk limits 45 46 3) setup resource limits 46 4) setup scheduler 47 5) setup unames 48 6) setup filesystem namespace 47 4) setup cpuset 48 5) setup scheduler 49 6) setup unames 50 7) setup filesystem namespace 49 51 */ 50 52 … … 313 315 314 316 static 317 xmlrpc_value *context_cpuset(xmlrpc_env *env) 318 { 319 LOG_TRACEME 320 321 /* We need the cpuset fs mounted */ 322 if (ismount("/dev/cpuset")) { 323 char *cpusetpath; 324 int rc; 325 326 asprintf(&cpusetpath, "/dev/cpuset/xid%d", xid); 327 328 /* First remove the cpuset, if it exists */ 329 if (isdir(cpusetpath)) 330 rmdir(cpusetpath); 331 332 /* Then query the database */ 333 rc = vxdb_prepare(&dbr, 334 "SELECT cpus,mems,virtualize " 335 "FROM vx_cpuset WHERE xid = %d", 336 xid); 337 338 if (rc != VXDB_OK) 339 method_return_vxdb_fault(env); 340 341 /* Lastly setup the new cpuset (or do nothing) */ 342 rc = vxdb_step(dbr); 343 344 if (rc == VXDB_ROW) { 345 if (!isdir(cpusetpath)) 346 mkdir(cpusetpath, 0755); 347 348 int cscpusfd; 349 char *cscpus = str_path_concat(cpusetpath, "/cpus"); 350 351 if ((cscpusfd = open_append(cscpus)) == -1) { 352 method_set_sys_faultf(env, "open_append(%s)", cscpus); 353 } 354 355 else { 356 dprintf(cscpusfd, "%s", vxdb_column_text(dbr, 0)); 357 close(cscpusfd); 358 } 359 360 int csmemsfd; 361 char *csmems = str_path_concat(cpusetpath, "/mems"); 362 363 if ((csmemsfd = open_append(csmems)) == -1) { 364 method_set_sys_faultf(env, "open_append(%s)", csmems); 365 } 366 367 else { 368 dprintf(csmemsfd, "%s", vxdb_column_text(dbr, 1)); 369 close(csmemsfd); 370 } 371 372 int csvirtfd; 373 char *csvirt = str_path_concat(cpusetpath, "/virtualize"); 374 375 if (ispath(csvirt)) { 376 if ((csvirtfd = open_append(csvirt)) == -1) { 377 method_set_sys_faultf(env, "open_append(%s)", csvirt); 378 } 379 380 else { 381 dprintf(csvirtfd, "%d", vxdb_column_int(dbr, 2)); 382 close(csvirtfd); 383 } 384 } 385 } 386 387 else if (rc != VXDB_DONE) 388 method_set_vxdb_fault(env); 389 390 vxdb_finalize(dbr); 391 } 392 393 return NULL; 394 } 395 396 static 315 397 xmlrpc_value *context_scheduler(xmlrpc_env *env) 316 398 { … … 374 456 375 457 vxdb_finalize(dbr); 458 376 459 return NULL; 377 460 } … … 623 706 method_return_if_fault(env); 624 707 708 context_cpuset(env); 709 method_return_if_fault(env); 710 625 711 context_scheduler(env); 626 712 method_return_if_fault(env); trunk/src/vcd/methods/vxdb/vxdb_vx_sched_remove.c
r610 r613 52 52 * since it has special meaning in helper.startup */ 53 53 if (cpuid == -2) 54 rc = vxdb_exec("DELETE FROM vx_sched WHERE xid = %d", 54 rc = vxdb_exec( 55 "DELETE FROM vx_sched WHERE xid = %d", 55 56 xid); 56 57 trunk/src/vcd/validate.c
r597 r613 17 17 18 18 #include <unistd.h> 19 #include <stdlib.h> 20 #include <dirent.h> 19 21 20 22 #include "lists.h" … … 23 25 #include <lucid/addr.h> 24 26 #include <lucid/log.h> 27 #include <lucid/scanf.h> 25 28 #include <lucid/str.h> 29 #include <lucid/strtok.h> 30 31 static 32 int max_mem_node(void) 33 { 34 DIR *ndir; 35 struct dirent *dent; 36 int maxmemnode = 0; 37 38 ndir = opendir("/sys/devices/system/node"); 39 if (!ndir) 40 return 0; 41 42 while ((dent = readdir(ndir))) { 43 if (str_cmpn(dent->d_name, "node", 4)) 44 continue; 45 46 int node = atoi(dent->d_name+4); 47 if (maxmemnode < node) 48 maxmemnode = node; 49 } 50 51 closedir(ndir); 52 53 return maxmemnode; 54 } 26 55 27 56 static … … 153 182 } 154 183 184 int validate_cpuset(const char *cpuset, int type) 185 { 186 LOG_TRACEME 187 188 if (str_isempty(cpuset)) 189 return 0; 190 191 int cpusetlen = str_len(cpuset)-1; 192 193 if (str_cmpn(cpuset, ",", 1) == 0 || str_cmpn(cpuset+cpusetlen, ",", 1) == 0) 194 return 0; 195 196 strtok_t _st, *st = &_st, *p; 197 198 if (!strtok_init_str(st, cpuset, ",", 0)) 199 return 0; 200 201 int maxcpus = 0, maxmems = 0; 202 203 if (type == 0) 204 maxcpus = sysconf(_SC_NPROCESSORS_ONLN); 205 else if (type == 1) 206 maxmems = max_mem_node(); 207 else 208 return 0; 209 210 int errorout = 0; 211 212 strtok_for_each(st, p) { 213 if (!str_isdigit(p->token)) { 214 errorout = 1; 215 break; 216 } 217 218 int id; 219 sscanf(p->token, "%d", &id); 220 221 if (type == 0) { 222 if (!(id >= 0 && id < maxcpus)) { 223 errorout = 1; 224 break; 225 } 226 } 227 228 else if (type == 1) { 229 if (!(id >= 0 && id <= maxmems)) { 230 errorout = 1; 231 break; 232 } 233 } 234 235 else { 236 errorout = 1; 237 break; 238 } 239 } 240 241 strtok_free(st); 242 243 return (errorout == 0) ? 1 : 0; 244 } 245 155 246 int validate_uname(const char *uname) 156 247 { trunk/src/vcd/validate.h
r551 r613 51 51 int tokensmin, int tokensmax); 52 52 53 int validate_cpuset(const char *cpuset, int type); 54 53 55 int validate_uname(const char *uname); 54 56 int validate_uname_value(const char *value); trunk/src/vcd/vxdb-tables.h
r561 r613 89 89 VXDB_UNIQUE_NEW(vx_ccaps, "xid,ccap") 90 90 91 VXDB_COLUMNS_NEW(vx_cpuset, "xid", "cpus", "mems", "virtualize") 92 VXDB_UNIQUE_NEW(vx_cpuset, "xid") 93 91 94 VXDB_COLUMNS_NEW(vx_flags, "xid", "flag") 92 95 VXDB_UNIQUE_NEW(vx_flags, "xid,flag") … … 128 131 VXDB_TABLE_NEW(vx_bcaps) 129 132 VXDB_TABLE_NEW(vx_ccaps) 133 VXDB_TABLE_NEW(vx_cpuset) 130 134 VXDB_TABLE_NEW(vx_flags) 131 135 VXDB_TABLE_NEW(vx_limit)
