[pve-devel] [PATCH qemu-server v2 2/2] qm rescan: add dryrun option

Dietmar Maurer dietmar at proxmox.com
Wed Jul 11 08:24:56 CEST 2018


comments inline

> On July 6, 2018 at 11:43 AM Thomas Lamprecht <t.lamprecht at proxmox.com> wrote:
> 
> 
> 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";

if $dryrun;

> +
> +	PVE::QemuServer::rescan($param->{vmid}, 0, $dryrun);
> +
> +	print "NOTE: ran in dry-run mode, did not actually write changes!\n";

if $dryrun;

>  
>  	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
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list