]> git.proxmox.com Git - qemu-server.git/commitdiff
qm rescan: add dryrun option
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 11 Jul 2018 06:40:07 +0000 (08:40 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 11 Jul 2018 07:35:45 +0000 (09:35 +0200)
tells an user what would get touched, so he has a chance to fix
unwanted things before changes are actually made.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/CLI/qm.pm
PVE/QemuServer.pm

index 48fbc5fca3430b857d4697973ad09b990c86bfb8..cf26943ce3709f1a6d73f57a091658bcc86fc38f 100755 (executable)
@@ -404,13 +404,23 @@ __PACKAGE__->register_method ({
                optional => 1,
                completion => \&PVE::QemuServer::complete_vmid,
            }),
+           dryrun => {
+               type => 'boolean',
+               optional => 1,
+               default => 0,
+               description => 'Do not actually write changes out to conifg.',
+           },
        },
     },
     returns => { type => 'null'},
     code => sub {
        my ($param) = @_;
 
-       PVE::QemuServer::rescan($param->{vmid});
+       my $dryrun = $param->{dryrun};
+
+       print "NOTE: running in dry-run mode, won't write changes out!\n" if $dryrun;
+
+       PVE::QemuServer::rescan($param->{vmid}, 0, $dryrun);
 
        return undef;
     }});
index e997049a4c13e0a920f249a605d2d89d53911658..5e4d0b6890cb9a93c49efb3342533ee5f11fd58a 100644 (file)
@@ -5606,7 +5606,7 @@ sub update_disksize {
 }
 
 sub rescan {
-    my ($vmid, $nolock) = @_;
+    my ($vmid, $nolock, $dryrun) = @_;
 
     my $cfg = PVE::Storage::config();
 
@@ -5634,7 +5634,7 @@ sub rescan {
 
        my $changes = update_disksize($vmid, $conf, $vm_volids);
 
-       PVE::QemuConfig->write_config($vmid, $conf) if $changes;
+       PVE::QemuConfig->write_config($vmid, $conf) if $changes && !$dryrun;
     };
 
     if (defined($vmid)) {