Commit f75717ee authored by Leigh Stoller's avatar Leigh Stoller

Add EXTRAFS support when use EC2 package. Do not set alarm when

booting XEN VM, let the library function deal with that, since
there is now code in there to watch a dead control network and
retry.
parent 3bc4b42e
#!/usr/bin/perl -w
#
# Copyright (c) 2009-2013 University of Utah and the Flux Group.
# Copyright (c) 2009-2014 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -99,6 +99,7 @@ my $cleaning = 0;
my $rebooting = 0;
my $reload = 0;
my ($vmid,$vmtype,$ret,$err);
my $ISXENVM = (GENVNODETYPE() eq "xen" ? 1 : 0);
# Flags for leaveme.
my $LEAVEME_REBOOT = 0x1;
......@@ -136,6 +137,21 @@ if ($UID != 0) {
" Must be root to run this script!\n");
}
#
# Deal with VIFROUTING flag from the server. Do this before we switch
# our vnode_id below since it is a physical host attribute. This will
# go away at some point.
#
my %attributes = ();
if (getnodeattributes(\%attributes)) {
die("*** $0:\n".
"Could not get node attributes");
}
if (exists($attributes{"xenvifrouting"})) {
# Gack, tell backend network scripts.
system("touch $ETCDIR/xenvifrouting");
}
# Tell the library what vnode we are messing with.
libsetup_setvnodeid($vnodeid);
......@@ -657,7 +673,7 @@ if (defined(VNCONFIG('SSHDPORT')) && VNCONFIG('SSHDPORT') ne "" &&
}
#
# Start the container. If all goes well, this will exit cleanly, with the
# Start the container. If all goes well, this will exit cleanly, with
# it running in its new context. Still, lets protect it with a timer
# since it might get hung up inside and we do not want to get stuck here.
#
......@@ -665,9 +681,11 @@ my $childpid = fork();
if ($childpid) {
my $timedout = 0;
local $SIG{ALRM} = sub { kill("TERM", $childpid); $timedout = 1; };
alarm 180;
alarm 180
if (!INXENVM());
waitpid($childpid, 0);
alarm 0;
alarm 0
if (!INXENVM());
#
# If failure then cleanup.
......
......@@ -594,7 +594,7 @@ sub vnodeCreate($$$$)
#
#
if (CreateVnodeLock() != 0) {
return -1;
fatal("CreateVnodeLock()");
}
#
......@@ -636,7 +636,7 @@ sub vnodeCreate($$$$)
TBScriptUnlock();
if (TBScriptLock($imagelockname, undef, 1800)
!= TBSCRIPTLOCK_OKAY()) {
fatal("Could not get $imagelockname write lock".
fatal("Could not get $imagelockname write lock ".
"after a long time!");
}
# And now check again in case someone else snuck in.
......@@ -753,6 +753,39 @@ sub vnodeCreate($$$$)
# add an extra disk instead. But to do that we have to look at the
# disks we just parsed and see what the highest lettered drive is.
#
if (exists($attributes->{'XEN_EXTRAFS'})) {
my $dsize = $attributes->{'XEN_EXTRAFS'};
my $auxchar = ord('c');
my @stanzas = ();
foreach my $disk (keys(%{$private->{'disks'}})) {
my ($lvname,$vndisk,$vdisk) = @{$private->{'disks'}->{$disk}};
if ($vdisk =~ /^sd(\w)$/ || $vdisk =~ /^xvd(\w)$/) {
$auxchar = ord($1)
if (ord($1) > $auxchar);
}
# Generate a new set of stanzas. see below.
push(@stanzas, "'phy:$vndisk,$vdisk,w'");
}
my $vdisk = ($xeninfo{xen_major} >= 4 ? 'xvd' : "sd") .
chr($auxchar);
my $auxlvname = "${vnode_id}.${vdisk}";
if (!findLVMLogicalVolume($auxlvname)) {
if (createAuxDisk($auxlvname, $dsize . "G")) {
fatal("libvnode_xen: could not create aux disk: $vdisk");
}
}
my $vndisk = lvmVolumePath($auxlvname);
my $stanza = "'phy:$vndisk,$vdisk,w'";
$private->{'disks'}->{$auxlvname} = [$auxlvname, $vndisk, $vdisk];
push(@stanzas, $stanza);
#
# Replace the existing line in the conf file.
#
addConfig($vninfo, "disk = [" . join(",", @stanzas) . "]", 2);
}
TBScriptUnlock();
goto done;
......@@ -1646,7 +1679,13 @@ sub vnodeBoot($$$$)
# itself with an alarm.
#
vnodeHalt($vnode_id, $vmid, $vnconfig, $private);
sleep(10);
$countdown = 10;
while ($countdown >= 0) {
sleep(5);
last
if (! domainExists($vnode_id));
$countdown--;
}
}
return -1;
}
......@@ -1872,8 +1911,9 @@ sub copyRoot($$)
print "Mount root\n";
mkpath(['/mnt/xen/root']);
mkpath(['/mnt/xen/disk']);
# This is a nice way to avoid traversing NFS filesystems.
mysystem("mount $from $root_path");
mysystem("mount -o loop $to $disk_path");
mysystem("mount -o async $to $disk_path");
mkpath([map{"$disk_path/$_"} qw(proc sys home tmp)]);
print "Copying files\n";
system("nice cp -a $root_path/* $disk_path");
......@@ -2352,6 +2392,10 @@ sub disk_hacks($)
# Clear out the cached control net interface name
unlink("$path/var/run/cnet");
# Get rid of pam nonsense.
system("sed -i.bak -e 's/UsePAM yes/UsePAM no/'".
" $path/etc/ssh/sshd_config");
# remove swap partitions from fstab
system("sed -i.bak -e '/swap/d' $path/etc/fstab");
......@@ -3085,13 +3129,13 @@ sub domainStatus($)
if ($XM =~ /xl/) {
my $status = `$XM list $id | tail -n 1 | awk '{print \$5}'`;
if ($status =~ /([\w-]+)/) {
if (!$? && $status =~ /([\w-]+)/) {
return $1;
}
}
else {
my $status = `$XM list --long $id 2>/dev/null`;
if ($status =~ /\(state ([\w-]+)\)/) {
if (!$? && $status =~ /\(state ([\w-]+)\)/) {
return $1;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment