From 9224dceefede935cd6823b8f9c7a053d0357b2bb Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 11 Jul 2018 08:40:07 +0200 Subject: [PATCH] qm rescan: add dryrun option 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 --- PVE/CLI/qm.pm | 12 +++++++++++- PVE/QemuServer.pm | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm index 48fbc5f..cf26943 100755 --- a/PVE/CLI/qm.pm +++ b/PVE/CLI/qm.pm @@ -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; }}); diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index e997049..5e4d0b6 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -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)) { -- 2.39.2