]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/SectionConfig.pm
cgroup: cpu quota: fix resetting period length for v1
[pve-common.git] / src / PVE / SectionConfig.pm
index cf87d6f6c3faa5c41f200f5f890cfb29f8304c9b..af0af03d7beec66fea159b7191d26f9a04beeaf7 100644 (file)
@@ -3,6 +3,7 @@ package PVE::SectionConfig;
 use strict;
 use warnings;
 
+use Carp;
 use Digest::SHA;
 
 use PVE::Exception qw(raise_param_exc);
@@ -198,6 +199,8 @@ sub init {
 sub lookup {
     my ($class, $type) = @_;
 
+    croak "cannot lookup undefined type!" if !defined($type);
+
     my $pdata = $class->private();
     my $plugin = $pdata->{plugins}->{$type};
 
@@ -308,6 +311,7 @@ sub parse_config {
        }
     };
 
+    my $errors = [];
     while (@lines) {
        my $line = $nextline->();
        next if !$line;
@@ -346,7 +350,15 @@ sub parse_config {
                        die "duplicate attribute\n" if defined($config->{$k});
                        $config->{$k} = $plugin->check_value($type, $k, $v, $sectionId);
                    };
-                   warn "$errprefix (section '$sectionId') - unable to parse value of '$k': $@" if $@;
+                   if (my $err = $@) {
+                       warn "$errprefix (section '$sectionId') - unable to parse value of '$k': $err";
+                       push @$errors, {
+                           context => $errprefix,
+                           section => $sectionId,
+                           key => $k,
+                           err => $err,
+                       };
+                   }
 
                } else {
                    warn "$errprefix (section '$sectionId') - ignore config line: $line\n";
@@ -365,8 +377,12 @@ sub parse_config {
        }
     }
 
-
-    my $cfg = { ids => $ids, order => $order, digest => $digest};
+    my $cfg = {
+       ids => $ids,
+       order => $order,
+       digest => $digest
+    };
+    $cfg->{errors} = $errors if scalar(@$errors) > 0;
 
     return $cfg;
 }