potential for follow-up inline On April 14, 2020 2:02 pm, Fabian Ebner wrote: > by extending the description. Also fixes the relevant for loop to > iterate over MAX_UNUSED_DISKS instead of MAX_MOUNT_POINTS. > > Signed-off-by: Fabian Ebner <f.eb...@proxmox.com> > --- > src/PVE/LXC/Config.pm | 24 +++++++++++++++++------- > 1 file changed, 17 insertions(+), 7 deletions(-) > > diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm > index 1aab6d4..000a4a2 100644 > --- a/src/PVE/LXC/Config.pm > +++ b/src/PVE/LXC/Config.pm > @@ -745,10 +745,14 @@ my $mp_desc = { > }; > PVE::JSONSchema::register_format('pve-ct-mountpoint', $mp_desc); > > -my $unuseddesc = { > - optional => 1, > - type => 'string', format => 'pve-volume-id', > - description => "Reference to unused volumes. This is used internally, > and should not be modified manually.", > +my $unused_desc = { > + volume => { > + type => 'string', > + default_key => 1, > + format => 'pve-volume-id', > + format_description => 'volume', > + description => 'The volume that is not used currently.', > + } > }; > > for (my $i = 0; $i < $MAX_MOUNT_POINTS; $i++) { > @@ -760,8 +764,12 @@ for (my $i = 0; $i < $MAX_MOUNT_POINTS; $i++) { > }; > } > > -for (my $i = 0; $i < $MAX_MOUNT_POINTS; $i++) { > - $confdesc->{"unused$i"} = $unuseddesc; > +for (my $i = 0; $i < $MAX_UNUSED_DISKS; $i++) { > + $confdesc->{"unused$i"} = { > + optional => 1, > + type => 'string', format => $unused_desc, > + description => "Reference to unused volumes. This is used internally, > and should not be modified manually.", > + } > } > > sub parse_pct_config { > @@ -1073,8 +1081,10 @@ sub parse_volume { > my $res = $parse_ct_mountpoint_full->($class, $rootfs_desc, > $volume_string, $noerr); > $res->{mp} = '/' if defined($res); > return $res; > - } elsif ($key =~ m/^mp\d+$/ || $key =~ m/^unused\d+$/) { > + } elsif ($key =~ m/^mp\d+$/) { > return $parse_ct_mountpoint_full->($class, $mp_desc, $volume_string, > $noerr); > + } elsif ($key =~ m/^unused\d+$/) { > + return $parse_ct_mountpoint_full->($class, $unused_desc, > $volume_string, $noerr); > }
if we refactor the rootfs, mpX and unusedX schemas into a separate hash (that we can directly inject into $confdesc, so no duplication) we can just inline parse_ct_mountpoint_full since the correct schema is available as $hash->{$key}->{format}. this would be inline with the $drivedesc_hash in PVE::QemuServer::Drive, and merge the actual parsing and the sub everyone calls for parsing into a single sub ;) > > die "parse_volume - unknown type: $key\n"; > -- > 2.20.1 > > > _______________________________________________ > pve-devel mailing list > pve-devel@pve.proxmox.com > https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel > > _______________________________________________ pve-devel mailing list pve-devel@pve.proxmox.com https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel