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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 19F117230B for ; Thu, 1 Jul 2021 11:38:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0628D23078 for ; Thu, 1 Jul 2021 11:37:41 +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 id C00C62306D for ; Thu, 1 Jul 2021 11:37:39 +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 8E4A54242A for ; Thu, 1 Jul 2021 11:37:39 +0200 (CEST) From: Stefan Reiter To: pve-devel@lists.proxmox.com Date: Thu, 1 Jul 2021 11:37:29 +0200 Message-Id: <20210701093729.2537908-1-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.670 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 qemu-server] live-restore: preload efidisk before starting VM 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, 01 Jul 2021 09:38:11 -0000 The efidisk never got restored correctly before, since we don't use the generic print_drive_commandline_full for it, and as such it didn't get a backing image attached. This not only causes the efidisk data to be lost on restore, but also an error at the end, since we try to remove a non-existing PBS blockdev. Since it is attached differently to a regular drive, adding PBS backing would be more difficult, but not to worry: an efidisk is small enough that it doesn't hurt performance to just restore it via the regular mechanism before starting the VM, and simply excluding it from the live restore entirely. Signed-off-by: Stefan Reiter --- best viewed with -w I guess in QEMU < 6.0 this didn't cause an error, since I definitely tested with EFI VMs before, however, it would have never actually restored the data and instead always created a new one. PVE/QemuServer.pm | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index f760467..ce5a1b1 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -6365,35 +6365,36 @@ sub restore_proxmox_backup_archive { # allocate volumes my $map = $restore_allocate_devices->($storecfg, $virtdev_hash, $vmid); - if (!$options->{live}) { - foreach my $virtdev (sort keys %$virtdev_hash) { - my $d = $virtdev_hash->{$virtdev}; - next if $d->{is_cloudinit}; # no need to restore cloudinit + foreach my $virtdev (sort keys %$virtdev_hash) { + my $d = $virtdev_hash->{$virtdev}; + next if $d->{is_cloudinit}; # no need to restore cloudinit - my $volid = $d->{volid}; + # for live-restore we only want to preload the efidisk + next if $options->{live} && $virtdev ne 'efidisk0'; - my $path = PVE::Storage::path($storecfg, $volid); + my $volid = $d->{volid}; - my $pbs_restore_cmd = [ - '/usr/bin/pbs-restore', - '--repository', $repo, - $pbs_backup_name, - "$d->{devname}.img.fidx", - $path, - '--verbose', - ]; + my $path = PVE::Storage::path($storecfg, $volid); - push @$pbs_restore_cmd, '--format', $d->{format} if $d->{format}; - push @$pbs_restore_cmd, '--keyfile', $keyfile if -e $keyfile; + my $pbs_restore_cmd = [ + '/usr/bin/pbs-restore', + '--repository', $repo, + $pbs_backup_name, + "$d->{devname}.img.fidx", + $path, + '--verbose', + ]; - if (PVE::Storage::volume_has_feature($storecfg, 'sparseinit', $volid)) { - push @$pbs_restore_cmd, '--skip-zero'; - } + push @$pbs_restore_cmd, '--format', $d->{format} if $d->{format}; + push @$pbs_restore_cmd, '--keyfile', $keyfile if -e $keyfile; - my $dbg_cmdstring = PVE::Tools::cmd2string($pbs_restore_cmd); - print "restore proxmox backup image: $dbg_cmdstring\n"; - run_command($pbs_restore_cmd); + if (PVE::Storage::volume_has_feature($storecfg, 'sparseinit', $volid)) { + push @$pbs_restore_cmd, '--skip-zero'; } + + my $dbg_cmdstring = PVE::Tools::cmd2string($pbs_restore_cmd); + print "restore proxmox backup image: $dbg_cmdstring\n"; + run_command($pbs_restore_cmd); } $fh->seek(0, 0) || die "seek failed - $!\n"; @@ -6448,6 +6449,7 @@ sub restore_proxmox_backup_archive { my $conf = PVE::QemuConfig->load_config($vmid); die "cannot do live-restore for template\n" if PVE::QemuConfig->is_template($conf); + delete $devinfo->{'drive-efidisk0'}; pbs_live_restore($vmid, $conf, $storecfg, $devinfo, $repo, $keyfile, $pbs_backup_name); PVE::QemuConfig->remove_lock($vmid, "create"); -- 2.30.2