I attempted to use the new xCAT 2.8.0 lvm:// pseudo-URI syntax for
specifying the vmstorage attribute, but discovered that it fails on mkvm
if you try to use an existing LVM volume group, eg.
$ chdef mynode vmstorage="lvm://vm"
$ mkvm mynode -s 100G
... error relating to failure running vgcreate ...
Obviously, vgcreate will (and should) fail upon trying to create an
volume group that already exists. After some trial and error, I
discovered the call that prompts libvirt to call vgcreate is
$poolobj->build() in kvm.pm. Avoiding that call allows everything to
work as expected.
In order to determine whether or not to call build(), my patch checks to
see if the user specifies any block devices for physical volumes in the
lvm:// URI. If they didn't provide any, it assumes that the volume
group already exists and that it should not call build(). This is safe
because the call to build() (and thus vgcreate) cannot possibly succeed
without any physical volumes. Conversely if the given volume group does
not exist, the call to mkvm will fail as before, though with a slightly
different reason given.
Side note, why would I want to do this? The alternative is to specify
the physical volume that make up the LVM volume group in the lvm:// URI
for every VM (either directly or via a group). This is bad because it
ruins the abstraction of LVM as a generic storage resource pool by
forcing each VM object to know about the physical composition of the
volume group
Michael
--- a/xcat/lib/perl/xCAT_plugin/kvm.pm 2013-03-08 14:08:14.596514478 -0500
+++ b/xcat/lib/perl/xCAT_plugin/kvm.pm 2013-03-08 14:41:33.695642740 -0500
@@ -114,6 +114,7 @@
sub build_pool_xml {
my $url = shift;
my $pooldesc;
+ my $should_build_pool = 1;
my $name=$url;
$name=~ s!nfs://!nfs_!;
$name=~ s!dir://!dir_!;
@@ -122,7 +123,7 @@
if ($url =~ /^dir:/) { #directory style..
my $path=$url;
$path =~ s/dir:\/\///g;
- return "<pool type=\"dir\"><name>$name</name><target><path>$path</path></target></pool>";
+ return ("<pool type=\"dir\"><name>$name</name><target><path>$path</path></target></pool>", $should_build_pool);
} elsif ($url =~ /^lvm:\/\//) { #lvm specified
my $path = $url;
$path =~ s/^lvm:\/\///;
@@ -137,9 +138,11 @@
$xml .= '<device path="'.$_.'"/>';
}
$xml .= "</source>";
- }
+ }else {
+ $should_build_pool = 0;
+ }
$xml .= "</pool>";
- return $xml;
+ return ($xml, $should_build_pool);
}
my $mounthost = shift;
unless ($mounthost) { $mounthost = $hyp; }
@@ -162,7 +165,7 @@
#system("ssh $mounthost mkdir -p /var/lib/xcat/pools/$uuid"); #ok, so not *technically* just building XML, but here is the cheapest
#place to know uuid... And yes, we must be allowed to ssh in
#libvirt just isn't capable enough for this sort of usage
- return $pooldesc;
+ return ($pooldesc, $should_build_pool);
}
@@ -225,8 +228,11 @@
};
return $poolobj;
}
- $poolobj = $virtconn->define_storage_pool(build_pool_xml($url,$mounthost));
- $poolobj->build();
+ my ($poolxml, $should_build_pool) = build_pool_xml($url,$mounthost);
+ $poolobj = $virtconn->define_storage_pool($poolxml);
+ $poolobj->build() if $should_build_pool; # trying to do a build() on a
+ # pre-created lvm volume group
+ # results in a vgcreate failure
$poolobj->create();
eval { #wrap in eval, not likely to fail here, but calling it at all may be superfluous anyway
$poolobj->refresh();
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
xCAT-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xcat-user