On Wed, Sep 05, 2018 at 11:33:45AM +0200, Thomas Lamprecht wrote:
> On 9/4/18 3:43 PM, Dominik Csapak wrote:
> > $newconf->{pending} is a reference to an empty hash, which is not falsy,
> > thus we always printed the warning
> > 
> > so check if there are actual values there and if yes,
> > give the names of the properties for which pending changes are found
> > 
> > Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
> > ---
> >  PVE/API2/Qemu.pm | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> > index b0af9d9..6cd0726 100644
> > --- a/PVE/API2/Qemu.pm
> > +++ b/PVE/API2/Qemu.pm
> > @@ -2785,8 +2785,9 @@ __PACKAGE__->register_method({
> >                 delete $newconf->{lock};
> >  
> >                 # do not write pending changes
> > -               if ($newconf->{pending}) {
> > -                   warn "found pending changes, discarding for clone\n";
> > +               if ($newconf->{pending} && %{$newconf->{pending}}) {
> 
> what about the following 'not really tested but should work'™ approach:
> 
> if (my @changes = keys $newconf->{pending}) {

Needs %{} or ->%* as the experimental `keys` on references has been
removed from perl. And while it feels weird, dereferencing undef that
way doesn't even produce a warning and behaves the way you want it, so
yes, with the added % dereferencing, this version is nicer.

>     my $pending = join(',', @changes);
>     ...
> }


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to