]> git.proxmox.com Git - qemu-server.git/commitdiff
update_vm: check whether opt is set before deleting
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 17 Mar 2017 10:01:32 +0000 (11:01 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 23 Mar 2017 10:41:12 +0000 (11:41 +0100)
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 <f.gruenbichler@proxmox.com>
PVE/API2/Qemu.pm

index 7b3a525f184e5abd25fbede6ca95968d50fc480a..616dc48b88dfcc4541462ac6a8b24eeeadba88c9 100644 (file)
@@ -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}'");