From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 0251C922B7
 for <pve-devel@lists.proxmox.com>; Mon,  3 Oct 2022 15:52:48 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id D3C5C32229
 for <pve-devel@lists.proxmox.com>; Mon,  3 Oct 2022 15:52:17 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Mon,  3 Oct 2022 15:52:15 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 5A7ED4477A
 for <pve-devel@lists.proxmox.com>; Mon,  3 Oct 2022 15:52:15 +0200 (CEST)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Mon,  3 Oct 2022 15:52:05 +0200
Message-Id: <20221003135211.183340-3-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20221003135211.183340-1-f.ebner@proxmox.com>
References: <20221003135211.183340-1-f.ebner@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.029 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH guest-common 1/1] vzdump: add 'performance'
 property string as a setting
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 03 Oct 2022 13:52:48 -0000

Initially, to be used for tuning backup performance with QEMU.

A few users reported IO-related issues during backup after upgrading
to PVE 7.x and using a modified QEMU build with max-workers reduced to
8 instead of 16 helped them [0].

Also generalizes the way vzdump property string are handled for easier
extension in the future.

[0]: https://forum.proxmox.com/threads/113790/

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 src/PVE/VZDump/Common.pm | 42 ++++++++++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 10 deletions(-)

diff --git a/src/PVE/VZDump/Common.pm b/src/PVE/VZDump/Common.pm
index cb46de1..8b8b75a 100644
--- a/src/PVE/VZDump/Common.pm
+++ b/src/PVE/VZDump/Common.pm
@@ -29,16 +29,21 @@ my $dowhash_to_dow = sub {
     return join ',', @da;
 };
 
-my $fixup_prune_backups_option = sub {
+our $PROPERTY_STRINGS = {
+    'performance' => 'backup-performance',
+    'prune-backups' => 'prune-backups',
+};
+
+my sub parse_property_strings {
     my ($opts) = @_;
 
-    return if !defined($opts->{'prune-backups'});
+    for my $opt (keys $PROPERTY_STRINGS->%*) {
+	next if !defined($opts->{$opt});
 
-    $opts->{'prune-backups'} = PVE::JSONSchema::parse_property_string(
-	'prune-backups',
-	$opts->{'prune-backups'}
-    );
-};
+	my $format = $PROPERTY_STRINGS->{$opt};
+	$opts->{$opt} = PVE::JSONSchema::parse_property_string($format, $opts->{$opt});
+    }
+}
 
 # parse crontab style day of week
 sub parse_dow {
@@ -71,6 +76,17 @@ sub parse_dow {
     return $res;
 };
 
+PVE::JSONSchema::register_format('backup-performance', {
+    'max-workers' => {
+	description => "Applies to VMs. Allow up to this many IO workers at the same time.",
+	type => 'integer',
+	minimum => 1,
+	maximum => 256,
+	default => 16,
+	optional => 1,
+    },
+});
+
 my $confdesc = {
     vmid => {
 	type => 'string', format => 'pve-vmid-list',
@@ -196,6 +212,12 @@ my $confdesc = {
 	maximum => 8,
 	default => 7,
     },
+    performance => {
+	type => 'string',
+	description => "Other performance-related settings.",
+	format => 'backup-performance',
+	optional => 1,
+    },
     lockwait => {
 	type => 'integer',
 	description => "Maximal time to wait for the global lock (minutes).",
@@ -311,7 +333,7 @@ sub parse_vzdump_cron_config {
 		$opts->{starttime} = sprintf "%02d:%02d", $hour, $minute;
 		$opts->{dow} = &$dowhash_to_dow($dowhash);
 
-		$fixup_prune_backups_option->($opts); # parse the property string
+		parse_property_strings($opts);
 
 		push @$jobs, $opts;
 	    };
@@ -402,8 +424,8 @@ sub command_line {
 	    }
 	} else {
 	    $v = join(",", PVE::Tools::split_list($v)) if $p eq 'mailto';
-	    $v = PVE::JSONSchema::print_property_string($v, 'prune-backups')
-		if $p eq 'prune-backups';
+	    $v = PVE::JSONSchema::print_property_string($v, $PROPERTY_STRINGS->{$p})
+		if $PROPERTY_STRINGS->{$p};
 
 	    $cmd .= " --$p " . PVE::Tools::shellquote($v) if defined($v) && $v ne '';
 	}
-- 
2.30.2