From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 1/1] vzdump: handle new 'performance' property string
Date: Mon, 3 Oct 2022 15:52:07 +0200 [thread overview]
Message-ID: <20221003135211.183340-5-f.ebner@proxmox.com> (raw)
In-Reply-To: <20221003135211.183340-1-f.ebner@proxmox.com>
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>
---
Dependency bump for libpve-guest-common-perl needed.
PVE/API2/VZDump.pm | 9 +++++----
PVE/Jobs/VZDump.pm | 23 ++++++++++-------------
PVE/VZDump.pm | 12 ++++++++++++
configs/vzdump.conf | 1 +
www/manager6/dc/Backup.js | 8 +++++---
5 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/PVE/API2/VZDump.pm b/PVE/API2/VZDump.pm
index 13b6cd46..82b28db5 100644
--- a/PVE/API2/VZDump.pm
+++ b/PVE/API2/VZDump.pm
@@ -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');
}
diff --git a/PVE/Jobs/VZDump.pm b/PVE/Jobs/VZDump.pm
index 7feb06a2..2963b348 100644
--- a/PVE/Jobs/VZDump.pm
+++ b/PVE/Jobs/VZDump.pm
@@ -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
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 87bb0bd2..d5b3c500 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -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); };
diff --git a/configs/vzdump.conf b/configs/vzdump.conf
index fe4b18ab..2ea09ae0 100644
--- a/configs/vzdump.conf
+++ b/configs/vzdump.conf
@@ -5,6 +5,7 @@
#storage: STORAGE_ID
#mode: snapshot|suspend|stop
#bwlimit: KBPS
+#performance: max-workers=N
#ionice: PRI
#lockwait: MINUTES
#stopwait: MINUTES
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index e9d74fb6..c81a76ce 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -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);
--
2.30.2
next prev parent reply other threads:[~2022-10-03 13:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-03 13:52 [pve-devel] [PATCH-SERIES qemu(-server)/guest-common/manager/docs] make QEMU's max-workers setting configurable as a vzdump setting Fiona Ebner
2022-10-03 13:52 ` [pve-devel] [PATCH qemu 1/1] PVE Backup: allow passing max-workers performance setting Fiona Ebner
2022-10-10 10:54 ` [pve-devel] applied: " Wolfgang Bumiller
2022-10-03 13:52 ` [pve-devel] [PATCH guest-common 1/1] vzdump: add 'performance' property string as a setting Fiona Ebner
2022-10-03 13:52 ` [pve-devel] [PATCH qemu-server 1/1] vzdump: set max-workers QMP option when specified and supported Fiona Ebner
2022-10-03 13:52 ` Fiona Ebner [this message]
2022-10-03 13:52 ` [pve-devel] [PATCH docs 1/4] backup: rework storage section, mentioning and recommending PBS Fiona Ebner
2022-10-03 13:52 ` [pve-devel] [PATCH docs 2/4] backup: expand section for jobs Fiona Ebner
2022-10-03 13:52 ` [pve-devel] [PATCH docs 3/4] backup: merge sections describing jobs Fiona Ebner
2022-10-03 13:52 ` [pve-devel] [PATCH docs 4/4] backup: mention max-workers performance setting Fiona Ebner
2022-10-10 11:10 ` [pve-devel] applied-series: [PATCH-SERIES qemu(-server)/guest-common/manager/docs] make QEMU's max-workers setting configurable as a vzdump setting Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221003135211.183340-5-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox