]> git.proxmox.com Git - pve-manager.git/commitdiff
vzdump: handle new 'performance' property string
authorFiona Ebner <f.ebner@proxmox.com>
Mon, 3 Oct 2022 13:52:07 +0000 (15:52 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 10 Oct 2022 11:04:17 +0000 (13:04 +0200)
Also generalizes the way vzdump property strings are handled for jobs.
Something similar could be done in VZDump.pm, but there the maxfiles
and prune-backups settings are currently coupled, so a dedicated
parse_performance() is used instead. Can be changed once maxfiles is
dropped.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
PVE/API2/VZDump.pm
PVE/Jobs/VZDump.pm
PVE/VZDump.pm
configs/vzdump.conf
www/manager6/dc/Backup.js

index 13b6cd4666f1852815aa802568190370883d7e9d..82b28db5ec73bb8958b092e1e3eafacb29a62a86 100644 (file)
@@ -25,9 +25,10 @@ __PACKAGE__->register_method ({
     method => 'POST',
     description => "Create backup.",
     permissions => {
-       description => "The user needs 'VM.Backup' permissions on any VM, and 'Datastore.AllocateSpace'"
-           ." on the backup storage. The 'maxfiles', 'prune-backups', 'tmpdir', 'dumpdir', 'script',"
-           ." 'bwlimit' and 'ionice' parameters are restricted to the 'root\@pam' user.",
+       description => "The user needs 'VM.Backup' permissions on any VM, and "
+           ."'Datastore.AllocateSpace' on the backup storage. The 'maxfiles', 'prune-backups', "
+           ."'tmpdir', 'dumpdir', 'script', 'bwlimit', 'performance' and 'ionice' parameters are "
+           ."restricted to the 'root\@pam' user.",
        user => 'all',
     },
     protected => 1,
@@ -60,7 +61,7 @@ __PACKAGE__->register_method ({
                if $param->{stdout};
        }
 
-       foreach my $key (qw(maxfiles prune-backups tmpdir dumpdir script bwlimit ionice)) {
+       for my $key (qw(maxfiles prune-backups tmpdir dumpdir script bwlimit performance ionice)) {
            raise_param_exc({ $key => "Only root may set this option."})
                if defined($param->{$key}) && ($user ne 'root@pam');
        }
index 7feb06a2ff9b1f5f4b65faa4ce340736342c12c2..2963b3483f4e60a5f5e153a2b20e3748be94c6f5 100644 (file)
@@ -42,11 +42,8 @@ sub options {
 sub decode_value {
     my ($class, $type, $key, $value) = @_;
 
-    if ($key eq 'prune-backups' && !ref($value)) {
-       $value = PVE::JSONSchema::parse_property_string(
-           'prune-backups',
-           $value,
-       );
+    if ((my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key}) && !ref($value)) {
+       $value = PVE::JSONSchema::parse_property_string($format, $value);
     }
 
     return $value;
@@ -55,11 +52,8 @@ sub decode_value {
 sub encode_value {
     my ($class, $type, $key, $value) = @_;
 
-    if ($key eq 'prune-backups' && ref($value) eq 'HASH') {
-       $value = PVE::JSONSchema::print_property_string(
-           $value,
-           'prune-backups',
-       );
+    if ((my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key}) && ref($value) eq 'HASH') {
+       $value = PVE::JSONSchema::print_property_string($value, $format);
     }
 
     return $value;
@@ -73,9 +67,12 @@ sub run {
        delete $conf->{$opt} if !defined($props->{$opt});
     }
 
-    my $retention = $conf->{'prune-backups'};
-    if ($retention && ref($retention) eq 'HASH') { # fixup, its required as string parameter
-       $conf->{'prune-backups'} = PVE::JSONSchema::print_property_string($retention, 'prune-backups');
+    # Required as string parameters
+    for my $key (keys $PVE::VZDump::Common::PROPERTY_STRINGS->%*) {
+       if ($conf->{$key} && ref($conf->{$key}) eq 'HASH') {
+           my $format = $PVE::VZDump::Common::PROPERTY_STRINGS->{$key};
+           $conf->{$key} = PVE::JSONSchema::print_property_string($conf->{$key}, $format);
+       }
     }
 
     $conf->{quiet} = 1; # do not write to stdout/stderr
index 87bb0bd2a50231e278e79bd30536bae43dd6fa9a..d5b3c50028ff258c742848ee0ad6f54d4708e8a9 100644 (file)
@@ -122,6 +122,15 @@ my $generate_notes = sub {
     return $notes_template;
 };
 
+my sub parse_performance {
+    my ($param) = @_;
+
+    if (defined(my $perf = $param->{performance})) {
+       return if ref($perf) eq 'HASH'; # already parsed
+       $param->{performance} = PVE::JSONSchema::parse_property_string('backup-performance', $perf);
+    }
+}
+
 my $parse_prune_backups_maxfiles = sub {
     my ($param, $kind) = @_;
 
@@ -261,6 +270,7 @@ sub read_vzdump_defaults {
        } keys %$confdesc_for_defaults
     };
     $parse_prune_backups_maxfiles->($defaults, "defaults in VZDump schema");
+    parse_performance($defaults);
 
     my $raw;
     eval { $raw = PVE::Tools::file_get_contents($fn); };
@@ -276,6 +286,7 @@ sub read_vzdump_defaults {
        $res->{mailto} = [ @mailto ];
     }
     $parse_prune_backups_maxfiles->($res, "options in '$fn'");
+    parse_performance($res);
 
     foreach my $key (keys %$defaults) {
        $res->{$key} = $defaults->{$key} if !defined($res->{$key});
@@ -1354,6 +1365,7 @@ sub verify_vzdump_parameters {
        if defined($param->{'prune-backups'}) && defined($param->{maxfiles});
 
     $parse_prune_backups_maxfiles->($param, 'CLI parameters');
+    parse_performance($param);
 
     if (my $template = $param->{'notes-template'}) {
        eval { $verify_notes_template->($template); };
index fe4b18abcbc879311aae4e3479ec753a7c96bd06..2ea09ae0927b73ad3c045aee76b0f9641513b6e5 100644 (file)
@@ -5,6 +5,7 @@
 #storage: STORAGE_ID
 #mode: snapshot|suspend|stop
 #bwlimit: KBPS
+#performance: max-workers=N
 #ionice: PRI
 #lockwait: MINUTES
 #stopwait: MINUTES
index e9d74fb649569933a8128edeafda4b5a1b061047..c81a76ceacdb225fb8434a4bbbb13c3e3638b01e 100644 (file)
@@ -594,9 +594,11 @@ Ext.define('PVE.dc.BackupView', {
            delete job['repeat-missed'];
            job.all = job.all === true ? 1 : 0;
 
-           if (job['prune-backups']) {
-               job['prune-backups'] = PVE.Parser.printPropertyString(job['prune-backups']);
-           }
+           ['performance', 'prune-backups'].forEach(key => {
+               if (job[key]) {
+                   job[key] = PVE.Parser.printPropertyString(job[key]);
+               }
+           });
 
            let allNodes = PVE.data.ResourceStore.getNodes();
            let nodes = allNodes.filter(node => node.status === 'online').map(node => node.node);