From 3ee15fcb6221b64ca5801f08d55f0ee586a138c1 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Thu, 22 Jul 2010 13:55:50 +0000 Subject: [PATCH] -Use libvirt storage management for storage pool fixup on migrate git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6826 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/kvm.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index ed8c4a911..8e0cf1279 100644 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -90,6 +90,8 @@ my $vmtab; sub build_pool_xml { my $url = shift; + my $mounthost = shift; + unless ($mounthost) { $mounthost = $hyp; } my $pool; my $host = $url; $host =~ s/.*:\/\///; @@ -104,7 +106,7 @@ sub build_pool_xml { $pooldesc .= ''; $pooldesc .= ''; $pooldesc .= '/var/lib/xcat/pools/'.$uuid.''; - system("ssh $hyp mkdir -p /var/lib/xcat/pools/$uuid"); #ok, so not *technically* just building XML, but here is the cheapest + 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; @@ -114,7 +116,10 @@ sub build_pool_xml { sub get_storage_pool_by_url { my $url = shift; - my @currpools = $hypconn->list_storage_pools(); + my $virtconn = shift; + my $mounthost = shift; + unless ($virtconn) { $virtconn = $hypconn; } + my @currpools = $virtconn->list_storage_pools(); my $poolobj; my $pool; foreach my $poolo (@currpools) { @@ -126,7 +131,7 @@ sub get_storage_pool_by_url { $pool = undef; } if ($pool) { return $poolobj; } - $poolobj = $hypconn->create_storage_pool(build_pool_xml($url,\@currpools)); + $poolobj = $virtconn->create_storage_pool(build_pool_xml($url,$mounthost)); return $poolobj; } @@ -672,6 +677,13 @@ sub migrate { unless ($desthypconn) { return (1,"Unable to reach $targ to perform operation of $node, destination unusable."); } + if (defined $confdata->{vm}->{$node}->[0]->{storage} and $confdata->{vm}->{$node}->[0]->{storage} =~ /^nfs:/) { + my $urls = $confdata->{vm}->{$node}->[0]->{storage} and $confdata->{vm}->{$node}->[0]->{storage}; + foreach (split /,/,$urls) { + s/=.*//; + get_storage_pool_by_url($_,$desthypconn,$targ); + } + } my $sock = IO::Socket::INET->new(Proto=>'udp'); my $ipa=inet_aton($node); my $pa;