[pve-devel] [PATCH] fix: this will prevent the undefined message if the config file dos not exist.

Wolfgang Link w.link at proxmox.com
Tue Sep 1 08:34:52 CEST 2015


e.g. datacenter.cfg is optional and produce at start of a Vm an error if it is missing.
---
 src/PVE/JSONSchema.pm | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 2837cf5..d40692f 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -1144,14 +1144,13 @@ sub get_options {
 sub parse_config {
     my ($schema, $filename, $raw) = @_;
 
     # do fast check (avoid validate_schema($schema))
     die "got strange schema" if !$schema->{type} || 
 	!$schema->{properties} || $schema->{type} ne 'object';
 
     my $cfg = {};
 
-    while ($raw =~ /^\s*(.+?)\s*$/gm) {
+    while (defined($raw) && $raw =~ /^\s*(.+?)\s*$/gm) {
 	my $line = $1;
 
 	next if $line =~ /^#/;
-- 
2.1.4




More information about the pve-devel mailing list