[pve-devel] [PATCH qemu-server 2/2] qm rescan: add dryrun option
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Jul 5 15:36:43 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>
---
PVE/CLI/qm.pm | 14 +++++++++++++-
PVE/QemuServer.pm | 6 +++---
2 files changed, 16 insertions(+), 4 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 90bf745..b115f81 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -5539,7 +5539,7 @@ sub update_disksize {
my $changes;
- my $print = sub { print "VM $vmid: $_[0]\n"; };
+ my $print = sub { print "VM $vmid: $_[0]\n" };
# used and unused disks
my $referenced = {};
@@ -5607,7 +5607,7 @@ sub update_disksize {
}
sub rescan {
- my ($vmid, $nolock) = @_;
+ my ($vmid, $nolock, $dryrun) = @_;
my $cfg = PVE::Storage::config();
@@ -5636,7 +5636,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