Ignore:
Timestamp:
Oct 31, 2008, 9:47:29 AM (15 years ago)
Author:
broder
Message:

Automatically startup sysvms if they're not running already

Location:
trunk/packages/invirt-xen-config/debian
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-xen-config/debian/changelog

    r1452 r1457  
     1invirt-xen-config (0.0.11) unstable; urgency=low
     2
     3  * Automatically startup sysvms if they're not running already
     4
     5 -- Evan Broder <broder@mit.edu>  Fri, 31 Oct 2008 09:47:15 -0400
     6
    17invirt-xen-config (0.0.10) unstable; urgency=low
    28
  • trunk/packages/invirt-xen-config/debian/invirt-xen-config.init

    r1452 r1457  
    1414DESC="Invirt Xen host"
    1515PARENTPACKAGE=xend
    16 GEN_FILES=(
    17     /etc/xen/xend-config.sxp.invirt
    18     /etc/xen/sysvms/s_master
    19     /etc/xen/sysvms/s_remote
    20     /etc/xen/sysvms/s_console
    21     )
     16GEN_FILES=(/etc/xen/xend-config.sxp.invirt)
     17SYSVMS=(s_master s_remote s_console)
     18i=1
     19for vm in "${SYSVMS[@]}"; do
     20    GEN_FILES[$i] = "$vm"
     21    i=$((i + 1)
     22done
    2223
    2324dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0
     
    2627. /lib/init/std-init.sh
    2728
     29start_sysvm() {
     30    # Attempt to start a sysvm, but only if it's not running already
     31    # somewhere on the cluster
     32   
     33    VM="$1"
     34    DISK="/dev/xenvg/${VM}_hda"
     35   
     36    # Don't bother trying to start the VM if it's already running
     37    if xm list "$1" >/dev/null 2>&1; then
     38        return 1
     39    fi
     40   
     41    if lvchange -a n "$DISK" >/dev/null 2>&1 && lvchange -a ey "$DISK" >/dev/null 2>&1; then
     42        # If we can lock on the VM's disk, then the VM isn't running
     43        [ "$VERBOSE" != no ] && log_daemon_msg "Starting sysvm $VM"
     44        xm create "sysvms/$VM" >/dev/null
     45        [ "$VERBOSE" != no ] && log_end_msg $?
     46        RET=0
     47    else
     48        RET=1
     49    fi
     50   
     51    # Regardless of whether we could get the lock or not, the
     52    # lvchange -a n probably disabled the LV somewhere; be sure we
     53    # clean up
     54    lvchange -a y "$DISK" >/dev/null 2>&1
     55   
     56    return $RET
     57}
     58
    2859do_startup() {
    2960    gen_files
     61   
     62    for vm in "${SYSVMS[@]}"; do
     63        start_sysvm "$vm"
     64    done
    3065   
    3166    echo 1 >/proc/sys/net/ipv4/ip_forward
Note: See TracChangeset for help on using the changeset viewer.