From d2c6bf93ae20156da4e60a31a81ca2b0f95acb0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 17 Mar 2017 11:01:32 +0100 Subject: [PATCH] update_vm: check whether opt is set before deleting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit otherwise we get lots uninitialized warnings: update VM 600: -delete unused7 Use of uninitialized value $data in split at /usr/share/perl5/PVE/JSONSchema.pm line 533. Use of uninitialized value in concatenation (.) or string at /usr/share/perl5/PVE/API2/Qemu.pm line 1012. Use of uninitialized value $volid in pattern match (m//) at /usr/share/perl5/PVE/QemuServer.pm line 1824. Use of uninitialized value $volid in pattern match (m//) at /usr/share/perl5/PVE/Storage/Plugin.pm line 201. Use of uninitialized value $volid in concatenation (.) or string at /usr/share/perl5/PVE/Storage/Plugin.pm line 205. vs: update VM 600: -delete unused7 cannot delete 'unused7' - not set in current configuration! Signed-off-by: Fabian Grünbichler --- PVE/API2/Qemu.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index 7b3a525..616dc48 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -1007,6 +1007,12 @@ my $update_vm_api = sub { foreach my $opt (@delete) { $modified->{$opt} = 1; $conf = PVE::QemuConfig->load_config($vmid); # update/reload + if (!defined($conf->{$opt})) { + warn "cannot delete '$opt' - not set in current configuration!\n"; + $modified->{$opt} = 0; + next; + } + if ($opt =~ m/^unused/) { my $drive = PVE::QemuServer::parse_drive($opt, $conf->{$opt}); PVE::QemuConfig->check_protection($conf, "can't remove unused disk '$drive->{file}'"); -- 2.39.2