Commit e6d0a5bc authored by Leigh Stoller's avatar Leigh Stoller

Must use the -P option (proxy) on shared nodes, when uploading or

fetching images.
parent 3c376399
......@@ -22,6 +22,7 @@ use Exporter;
use Data::Dumper;
use libtmcc;
use libsetup;
use Socket;
sub VNODE_STATUS_RUNNING() { return "running"; }
......@@ -381,8 +382,8 @@ sub findBridgeIfaces($) {
# mechanism. Caller provides an imagepath for frisbee, and a hash of args that
# comes directly from loadinfo.
#
sub downloadImage($$$) {
my ($imagepath,$todisk,$reload_args_ref) = @_;
sub downloadImage($$$$) {
my ($imagepath,$todisk,$nodeid,$reload_args_ref) = @_;
return -1
if (!defined($imagepath) || !defined($reload_args_ref));
......@@ -394,6 +395,7 @@ sub downloadImage($$$) {
if (!defined($addr) || $addr eq "") {
# frisbee master server world
my ($server, $imageid);
my $proxyopt = "";
if ($reload_args_ref->{"SERVER"} =~ /^(\d+\.\d+\.\d+\.\d+)$/) {
$server = $1;
......@@ -401,8 +403,12 @@ sub downloadImage($$$) {
if ($reload_args_ref->{"IMAGEID"} =~ /^([-\d\w]+),([-\d\w]+),([-\d\w]+)$/) {
$imageid = "$1/$3";
}
if (SHAREDHOST) {
$proxyopt = "-P $nodeid";
}
if ($server && $imageid) {
mysystem("$FRISBEE -S $server -B 30 -F $imageid $imagepath");
mysystem("$FRISBEE $proxyopt ".
" -S $server -B 30 -F $imageid $imagepath");
}
else {
print STDERR "Could not parse frisbee loadinfo\n";
......
......@@ -33,6 +33,9 @@ my $optlist = "F:S:";
#
$| = 1;
# Need this for predicates.
use libsetup;
#
# No configure vars.
#
......@@ -101,11 +104,6 @@ else {
die("Tainted output filename: $filename");
}
# This directory must exist to create the snapshot. See the openvz library.
if (0 && ! -e "/mnt/snapshot/.created") {
die("snapshot directory does not exist\n");
}
# Only LVM is supported right now.
if (! -e "/mnt/$vnodeid/private") {
die("container file system does not exist\n");
......@@ -166,26 +164,16 @@ elsif ($status ne "stopped") {
die("Container is not in a good state: $status\n");
}
#
# Too bad that imagezip will not allow a raw file to be piped into it.
# Instead, we have to create the tar file first.
#
if (0) {
chdir("/mnt/snapshot") or
die("Could not chdir to the snapshot directory\n");
system("$sudo $TAR zcf snapshot.tar.gz -C /mnt/$vnodeid/private .");
if ($?) {
die("Could not create tar file of container private area\n");
}
}
#
# If imageid is defined, we use the frisbee uploader.
#
my $cmd = "$TAR zcf - -C /mnt/$vnodeid/private . | $zipper -f - $filename";
if (defined($imageid)) {
$cmd .= " | $uploader -S $iserver -F $imageid -";
$cmd .= " | $uploader -S $iserver -F $imageid";
if (SHAREDHOST()) {
$cmd .= " -P $vnodeid";
}
$cmd .= " -";
}
#
......
......@@ -794,7 +794,8 @@ sub vz_vnodeCreate {
if (!$incache) {
# Now we just download the file, then let create do its normal thing
my $dret = libvnode::downloadImage($imagepath,0,$reload_args_ref);
my $dret = libvnode::downloadImage($imagepath,
0,$vnode_id,$reload_args_ref);
# reload has finished, file is written... so let's set its mtime
utime(time(),$reload_args{"IMAGEMTIME"},$imagepath);
......
......@@ -442,7 +442,7 @@ sub vnodeCreate($$$$)
#
libvnode::setState("RELOADING");
if (createImageDisk($imagename, $raref)) {
if (createImageDisk($imagename, $vnode_id, $raref)) {
fatal("xen_vnodeCreate: ".
"cannot create logical volume for $imagename");
}
......@@ -1093,9 +1093,9 @@ sub createAuxDisk($$)
#
# Create a logical volume for the image if it doesn't already exist.
#
sub createImageDisk($$)
sub createImageDisk($$$)
{
my ($image,$raref) = @_;
my ($image,$vnode_id,$raref) = @_;
my $tstamp = $raref->{'IMAGEMTIME'};
my $lvname = $image;
......@@ -1141,7 +1141,7 @@ sub createImageDisk($$)
# Now we just download the file, then let create do its normal thing
my $imagepath = lvmVolumePath($lvname);
if (libvnode::downloadImage($imagepath, 1, $raref)) {
if (libvnode::downloadImage($imagepath, 1, $vnode_id, $raref)) {
print STDERR "libvnode_xen: could not download image $image\n";
TBScriptUnlock();
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