From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6A72E69658 for ; Thu, 6 Aug 2020 13:14:01 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5A1BD1C084 for ; Thu, 6 Aug 2020 13:14:01 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 39CD41C077 for ; Thu, 6 Aug 2020 13:13:57 +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 065CC438A8 for ; Thu, 6 Aug 2020 13:13:57 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Thu, 6 Aug 2020 13:13:48 +0200 Message-Id: <20200806111349.67063-1-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.045 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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] [RFC qemu-server] fix #2862: properly backup (all) VM templates X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Aug 2020 11:14:01 -0000 until we maybe have a 'pbs-backup' that links Qemu and PBS like 'pbs-restore', we need to do a regular backup for the template case to support all storage types and image formats. Signed-off-by: Fabian Grünbichler --- Notes: requires patched pve-qemu to drop read-only check alternatively, we could also start writing a pbs-backup (or a general pbs-qemu ?) soon, and just disable PBS template backups in the meantime. PVE/QemuServer.pm | 6 +++++- PVE/VZDump/QemuServer.pm | 22 +++++++--------------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 0a09f3a..e789dea 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -3402,6 +3402,8 @@ sub config_to_command { } my $drive_cmd = print_drive_commandline_full($storecfg, $vmid, $drive); + $drive_cmd .= ',readonly' if PVE::QemuConfig->is_template($conf); + push @$devices, '-drive',$drive_cmd; push @$devices, '-device', print_drivedevice_full($storecfg, $conf, $vmid, $drive, $bridges, $arch, $machine_type); }); @@ -4780,7 +4782,8 @@ sub vm_start { return PVE::QemuConfig->lock_config($vmid, sub { my $conf = PVE::QemuConfig->load_config($vmid, $migrate_opts->{migratedfrom}); - die "you can't start a vm if it's a template\n" if PVE::QemuConfig->is_template($conf); + die "you can't start a vm if it's a template\n" + if !$params->{skiptemplate} && PVE::QemuConfig->is_template($conf); my $has_suspended_lock = PVE::QemuConfig->has_lock($conf, 'suspended'); @@ -4809,6 +4812,7 @@ sub vm_start { # params: # statefile => 'tcp', 'unix' for migration or path/volid for RAM state # skiplock => 0/1, skip checking for config lock +# skiptemplate => 0/1, skip checking whether VM is template # forcemachine => to force Qemu machine (rollback/migration) # forcecpu => a QEMU '-cpu' argument string to override get_cpu_options # timeout => in seconds diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm index 4614efc..3502111 100644 --- a/PVE/VZDump/QemuServer.pm +++ b/PVE/VZDump/QemuServer.pm @@ -395,20 +395,11 @@ sub archive_pbs { my $keyfile = PVE::Storage::PBSPlugin::pbs_encryption_key_file_name($scfg, $opts->{storage}); my $diskcount = scalar(@{$task->{disks}}); - if (PVE::QemuConfig->is_template($self->{vmlist}->{$vmid}) || !$diskcount) { + # proxmox-backup-client can only handle raw files and block devs + # only use it (directly) for disk-less VMs + if (!$diskcount) { my @pathlist; - # FIXME: accumulate disk sizes to use for backup job (email) log - foreach my $di (@{$task->{disks}}) { - if ($di->{type} eq 'block' || $di->{type} eq 'file') { - push @pathlist, "$di->{qmdevice}.img:$di->{path}"; - } else { - die "implement me (type $di->{type})"; - } - } - - if (!$diskcount) { - $self->loginfo("backup contains no disks"); - } + $self->loginfo("backup contains no disks"); local $ENV{PBS_PASSWORD} = $password; local $ENV{PBS_FINGERPRINT} = $fingerprint if defined($fingerprint); @@ -423,7 +414,6 @@ sub archive_pbs { push @$cmd, "qemu-server.conf:$conffile"; push @$cmd, "fw.conf:$firewall" if -e $firewall; - push @$cmd, @pathlist if scalar(@pathlist); $self->loginfo("starting template backup"); $self->loginfo(join(' ', @$cmd)); @@ -471,7 +461,8 @@ sub archive_pbs { $params->{encrypt} = JSON::false; } - $params->{'use-dirty-bitmap'} = JSON::true if $qemu_support->{'pbs-dirty-bitmap'}; + $params->{'use-dirty-bitmap'} = JSON::true + if $qemu_support->{'pbs-dirty-bitmap'} && !PVE::QemuConfig->is_template($self->{vmlist}->{$vmid}); $params->{timeout} = 60; # give some time to connect to the backup server @@ -752,6 +743,7 @@ sub enforce_vm_running_for_backup { # start with skiplock my $params = { skiplock => 1, + skiptemplate => 1, paused => 1, }; PVE::QemuServer::vm_start($self->{storecfg}, $vmid, $params); -- 2.20.1