Commit fb5fb526 authored by Leigh Stoller's avatar Leigh Stoller

Minor changes so that we can allow the subos map to be used for

determining the jailosid for "static" images like OPENVZ-STD. For
example:

	tb-set-hardware $n1 d710-vm
	tb-set-node-os $n1 OPENVZ-STD FEDORA15-64-OVZ-STD

The main point is that OPENVZ-STD is a placeholder with no associated
image. It exists to tell the mapper and osload what to do. This is
accomplished with nextosid. The new approach makes things consistent
with subos stuff.
parent 8def7e94
......@@ -370,7 +370,13 @@ sub SetOS($$)
# not typically imageable.
#
if ($node->isvirtnode() && $osinfo->def_parentosid()) {
$imageable = 1;
#
# But, if the subos is static (like OPENVZ-STD), there is
# no reload, cause it is already on the parent image. Lets use
# the fact that no image link exists, to distinguish this case.
#
$imageable = 1
if (defined($osinfo->MapToImage($node->type())));
}
if ($imageable) {
......
......@@ -6560,8 +6560,7 @@ sub InitializePhysNode($$$)
#
# This is special. Look at the osid of the virtnodes on this pnode and
# map to a suitable osid using the nextosid field. This overloads nextosid
# to some extent ...
# map to a suitable osid.
#
sub nodejailosid($$)
{
......@@ -6573,35 +6572,40 @@ sub nodejailosid($$)
# features/desires).
#
my $osinfo = $virtnode->_osinfo();
my $posinfo = $virtnode->_parent_osinfo();
my $nextosid;
my $nextosinfo;
$self->printdb("nodejailosid: $virtnode, $osinfo\n");
if (!defined($posinfo)) {
return undef
if (!defined($osinfo->nextosid()));
my $newosinfo = $osinfo->ResolveNextOSID($self->experiment());
return undef
if (!defined($newosinfo));
$nextosid = $newosinfo->osid();
if (defined($nextosid)) {
$self->printdb("Mapping VM osinfo $osinfo to ".
"$newosinfo on $virtnode\n");
#
# The old method was to use nextosid, but the new method uses
# the subos stuff.
#
if (defined($osinfo->def_parentosid())) {
$nextosinfo = OSinfo->Lookup($osinfo->def_parentosid());
if (!defined($nextosinfo)) {
tbwarn("nodejailosid: could not resolve parent osid for $osinfo\n");
return undef;
}
else {
tbwarn("Could not map jail osid to real osid on $virtnode\n");
}
else {
if (!defined($osinfo->nextosid())) {
tbwarn("nodejailosid: no nextosid defined for $osinfo\n");
return undef;
}
$nextosinfo = $osinfo->ResolveNextOSID($self->experiment());
if (!defined($nextosinfo)) {
tbwarn("nodejailosid: could not resolve nextosid for $osinfo\n");
return undef;
}
}
if (defined($nextosinfo)) {
$self->printdb("Mapping VM osinfo $osinfo to ".
"$nextosinfo on $virtnode\n");
}
else {
# Don't try resolving nextosid if the vnode is booting a subOS.
$nextosid = $osinfo->osid();
$self->printdb("Mapping VM osinfo to subOS $osinfo".
" on $virtnode\n");
tbwarn("nodejailosid: Could not map to real osid on $virtnode\n");
}
return $nextosid;
return $nextosinfo->osid();
}
sub osidbootcmd($$$$)
......
......@@ -6556,8 +6556,7 @@ sub InitializePhysNode($$$)
#
# This is special. Look at the osid of the virtnodes on this pnode and
# map to a suitable osid using the nextosid field. This overloads nextosid
# to some extent ...
# map to a suitable osid.
#
sub nodejailosid($$)
{
......@@ -6569,35 +6568,40 @@ sub nodejailosid($$)
# features/desires).
#
my $osinfo = $virtnode->_osinfo();
my $posinfo = $virtnode->_parent_osinfo();
my $nextosid;
my $nextosinfo;
$self->printdb("nodejailosid: $virtnode, $osinfo\n");
if (!defined($posinfo)) {
return undef
if (!defined($osinfo->nextosid()));
my $newosinfo = $osinfo->ResolveNextOSID($self->experiment());
return undef
if (!defined($newosinfo));
$nextosid = $newosinfo->osid();
if (defined($nextosid)) {
$self->printdb("Mapping VM osinfo $osinfo to ".
"$newosinfo on $virtnode\n");
#
# The old method was to use nextosid, but the new method uses
# the subos stuff.
#
if (defined($osinfo->def_parentosid())) {
$nextosinfo = OSinfo->Lookup($osinfo->def_parentosid());
if (!defined($nextosinfo)) {
tbwarn("nodejailosid: could not resolve parent osid for $osinfo\n");
return undef;
}
else {
tbwarn("Could not map jail osid to real osid on $virtnode\n");
}
else {
if (!defined($osinfo->nextosid())) {
tbwarn("nodejailosid: no nextosid defined for $osinfo\n");
return undef;
}
$nextosinfo = $osinfo->ResolveNextOSID($self->experiment());
if (!defined($nextosinfo)) {
tbwarn("nodejailosid: could not resolve nextosid for $osinfo\n");
return undef;
}
}
if (defined($nextosinfo)) {
$self->printdb("Mapping VM osinfo $osinfo to ".
"$nextosinfo on $virtnode\n");
}
else {
# Don't try resolving nextosid if the vnode is booting a subOS.
$nextosid = $osinfo->osid();
$self->printdb("Mapping VM osinfo to subOS $osinfo".
" on $virtnode\n");
tbwarn("nodejailosid: Could not map to real osid on $virtnode\n");
}
return $nextosid;
return $nextosinfo->osid();
}
sub osidbootcmd($$$$)
......@@ -8047,6 +8051,10 @@ sub UpLoadTunnels($)
tberror("Could not add $member1 to $tunnel\n");
return -1;
}
my $tunnel_tag = `echo '$secretkey' | /usr/bin/cksum`;
if ($tunnel_tag =~ /^(\d+)/) {
$tunnel_tag = $1;
}
# Need to set a bunch of attributes later returned by tmcd.
if ($iface0->SetAttribute("tunnel_ip", $ip0) ||
......@@ -8060,6 +8068,7 @@ sub UpLoadTunnels($)
$iface0->SetAttribute("tunnel_serverport", $ipport) ||
$iface0->SetAttribute("tunnel_lan", $virtlan->vname()) ||
$iface0->SetAttribute("tunnel_unit", $iface0->memberid() + 1) ||
$iface0->SetAttribute("tunnel_tag", $tunnel_tag) ||
$iface0->SetAttribute("tunnel_style", $virtlan->_encapstyle())) {
tberror("Could not set attributes for $iface0 in $tunnel\n");
return -1;
......@@ -8075,6 +8084,7 @@ sub UpLoadTunnels($)
$iface1->SetAttribute("tunnel_serverport", $ipport) ||
$iface1->SetAttribute("tunnel_lan", $virtlan->vname()) ||
$iface1->SetAttribute("tunnel_unit", $iface1->memberid() + 1) ||
$iface1->SetAttribute("tunnel_tag", $tunnel_tag) ||
$iface1->SetAttribute("tunnel_style", $virtlan->_encapstyle())) {
tberror("Could not set attributes for $iface1 in $tunnel\n");
return -1;
......
......@@ -803,7 +803,7 @@ my $subosidquery = "select distinct o.osid,o.parent_osid from os_submap as o " .
"left join osidtoimageid as oi2 on o.parent_osid = oi2.osid " .
"left join images as i1 on oi1.imageid = i1.imageid ".
"left join images as i2 on oi2.imageid = i2.imageid ".
"where (i1.global = 1";
"where (i1.imageid is null or i1.global = 1";
if ($pid) {
$subosidquery .= " or i1.pid='$pid'";
}
......
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