Changeset 612

Show
Ignore:
Timestamp:
05/19/07 17:56:18 (2 years ago)
Author:
chtekk
Message:

Initial support for CPUSETs, atm configuration must still be done manually, automation using the usual methods and vxdb will come soon.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vcc/vcc/login.c

    r586 r612  
    2222#include <lucid/chroot.h> 
    2323#include <lucid/log.h> 
     24#include <lucid/misc.h> 
     25#include <lucid/open.h> 
     26#include <lucid/printf.h> 
    2427 
    2528#include "vcc.h" 
     
    2932{ 
    3033        xmlrpc_value *result; 
     34        char *name, *vdir, *cpusetpath; 
     35        char *av[] = { "/bin/sh", NULL }; 
     36        int cpusetfd; 
    3137        xid_t xid; 
    32         char *name, *vdir; 
    33         char *av[] = { "/bin/sh", NULL }; 
    3438 
    3539        if (argc < 1) 
     
    5862        xmlrpc_DECREF(result); 
    5963 
     64        /* Add the PID of the current process to the cpuset for this 
     65         * vserver, if the cpuset exists, and then fork. */ 
     66        asprintf(&cpusetpath, "/dev/cpuset/xid%d/tasks", xid); 
     67 
     68        if (ispath(cpusetpath)) { 
     69                if ((cpusetfd = open_append(cpusetpath)) == -1) { 
     70                        log_perror_and_die("open_append(%s)", cpusetpath); 
     71                } 
     72 
     73                else { 
     74                        dprintf(cpusetfd, "%d", getpid()); 
     75                        close(cpusetfd); 
     76                } 
     77        } 
     78 
    6079        if (ns_enter(xid, 0) == -1) 
    6180                log_perror_and_die("ns_enter"); 
  • trunk/src/vshelper/main.c

    r598 r612  
    2828#include <lucid/exec.h> 
    2929#include <lucid/log.h> 
     30#include <lucid/misc.h> 
    3031#include <lucid/open.h> 
    3132#include <lucid/printf.h> 
     
    160161        xmlrpc_value *response; 
    161162        char *vdir, *init; 
    162         int i; 
     163        char *fastboot, *cpusetpath; 
     164        int i, cpusetfd; 
    163165 
    164166        vx_flags_t migrate_flags = { 
     
    179181        log_and_return_if_fault(env); 
    180182 
    181         char *fastboot = str_path_concat(vdir, "/fastboot"); 
     183        /* Write fastboot file to vdir for some distros */ 
     184        fastboot = str_path_concat(vdir, "/fastboot"); 
    182185        close(open_trunc(fastboot)); 
     186 
     187        /* Add the PID of the current process to the cpuset for this 
     188         * vserver, if the cpuset exists, and then fork. */ 
     189        asprintf(&cpusetpath, "/dev/cpuset/xid%d/tasks", xid); 
     190 
     191        if (ispath(cpusetpath)) { 
     192                if ((cpusetfd = open_append(cpusetpath)) == -1) { 
     193                        log_perror("open_append(%s)", cpusetpath); 
     194                } 
     195 
     196                else { 
     197                        dprintf(cpusetfd, "%d", getpid()); 
     198                        close(cpusetfd); 
     199                } 
     200        } 
    183201 
    184202        switch (fork()) {