diff --git a/bin/xen-create-image b/bin/xen-create-image index af28bfd..9f04719 100755 --- a/bin/xen-create-image +++ b/bin/xen-create-image @@ -1394,40 +1394,6 @@ sub setupDefaultOptions -=begin doc - - Find the right Xen toolstack. On Debian and derivatives there's a - script which tells you about the current toolstack. - -=end doc - -=cut - -sub findXenToolstack -{ - my $helper = '/usr/lib/xen-common/bin/xen-toolstack'; - - if (-x $helper) { - my $toolstack = `$helper`; - chomp($toolstack); - return $toolstack if $toolstack; - } - - my $xm = findBinary('xm'); - if ($xm and system("$xm list >/dev/null 2>/dev/null") == 0) { - return $xm; - } - - my $xl = findBinary('xl'); - if ($xl and system("$xl list >/dev/null 2>/dev/null") == 0) { - return $xl; - } - - return undef; -} - - - =begin doc Validate options and do what is necessary with them. diff --git a/lib/Xen/Tools/Common.pm b/lib/Xen/Tools/Common.pm index 62c80e5..a68da0b 100644 --- a/lib/Xen/Tools/Common.pm +++ b/lib/Xen/Tools/Common.pm @@ -21,7 +21,7 @@ use vars qw(@EXPORT_OK @EXPORT); use English; @EXPORT = qw(readConfigurationFile xenRunning runCommand setupAdminUsers - logprint logonly fail); + findXenToolstack logprint logonly fail); =head1 FUNCTIONS @@ -134,6 +134,40 @@ sub xenRunning ($) return ($running); } +=head2 findXenToolstack + +=begin doc + + Find the right Xen toolstack. On Debian and derivatives there's a + script which tells you about the current toolstack. + +=end doc + +=cut + +sub findXenToolstack +{ + my $helper = '/usr/lib/xen-common/bin/xen-toolstack'; + + if (-x $helper) { + my $toolstack = `$helper`; + chomp($toolstack); + return $toolstack if $toolstack; + } + + my $xm = findBinary('xm'); + if ($xm and system("$xm list >/dev/null 2>/dev/null") == 0) { + return $xm; + } + + my $xl = findBinary('xl'); + if ($xl and system("$xl list >/dev/null 2>/dev/null") == 0) { + return $xl; + } + + return undef; +} + =head2 runCommand =begin doc