[pve-devel] [PATCH qemu-server v2 2/2] qm rescan: add dryrun option
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Jul 6 11:43:58 CEST 2018
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 at proxmox.com>
---
changes v1 -> v2:
* I mistakenly touched a line not belonging to this patch in v1,
fix that, although it does not affected the outcome
PVE/CLI/qm.pm | 14 +++++++++++++-
PVE/QemuServer.pm | 4 ++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/PVE/CLI/qm.pm b/PVE/CLI/qm.pm
index 48fbc5f..29363e8 100755
--- a/PVE/CLI/qm.pm
+++ b/PVE/CLI/qm.pm
@@ -404,13 +404,25 @@ __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";
+
+ PVE::QemuServer::rescan($param->{vmid}, 0, $dryrun);
+
+ print "NOTE: ran in dry-run mode, did not actually write changes!\n";
return undef;
}});
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 8e5d54d..35d5157 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();
@@ -5635,7 +5635,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.18.0
More information about the pve-devel
mailing list