[pve-devel] [PATCHV2] Catch error from vgcreate.

Wolfgang Link w.link at proxmox.com
Thu Mar 3 12:00:04 CET 2016


This is necessary, if the volume group "pve" exists, say from a previous installation.
But whitout printing the reason no user will understand why this happens.
---
 proxinstall | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/proxinstall b/proxinstall
index ec15477..927722d 100755
--- a/proxinstall
+++ b/proxinstall
@@ -227,7 +227,7 @@ sub syscmd {
 }
 
 sub run_command {
-    my ($cmd, $func, $input, $noout) = @_;
+    my ($cmd, $func, $input, $noout, $errmsg) = @_;
 
     my $cmdstr;
     if (!ref($cmd)) {
@@ -328,6 +328,8 @@ sub run_command {
 
     return $? if $noout; # behave like standard system();
 
+    die "command '$cmdstr' failed with exit error:\n$ostream" if $errmsg;
+ 
     my $ec = ($? >> 8);
 
     if ($ec) {
@@ -834,8 +836,8 @@ sub create_lvm_volumes {
     # so pe_start is aligned on a 128k boundary (advantage for SSDs)
     syscmd ("/sbin/pvcreate --metadatasize 250k -y -ff $lvmdev") == 0 ||
 	die "unable to initialize physical volume $lvmdev";
-    syscmd ("/sbin/vgcreate pve $lvmdev") == 0 ||
-	die "unable to create volume group";
+
+    run_command ("/sbin/vgcreate pve $lvmdev", undef, undef, undef, 1);
 
     my $hdgb = int($os_size/(1024*1024));
     my $space = (($hdgb > 128) ? 16 : ($hdgb/8))*1024*1024;
-- 
2.1.4





More information about the pve-devel mailing list