[pve-devel] [RFC qemu-server v2 21/25] backup: implement restore for external providers
Fabian Grünbichler
f.gruenbichler at proxmox.com
Thu Sep 12 14:44:03 CEST 2024
On August 13, 2024 3:28 pm, Fiona Ebner wrote:
> First, the provider is asked about what restore mechanism to use.
> Currently, only 'qemu-img' is possible. Then the configuration files
> are restored, the provider gives information about volumes contained
> in the backup and finally the volumes are restored via
> 'qemu-img convert'.
>
> The code for the restore_external_archive() function was copied and
> adapted from the restore_proxmox_backup_archive() function. Together
> with restore_vma_archive() it seems sensible to extract the common
> parts and use a dedicated module for restore code.
>
> The parse_restore_archive() helper was renamed, because it's not just
> parsing.
>
> Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
> ---
>
> Changes in v2:
> * Adapt to API changes.
>
> PVE/API2/Qemu.pm | 29 +++++++++-
> PVE/QemuServer.pm | 139 ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 165 insertions(+), 3 deletions(-)
>
[snip..]
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 37f56f69..6cd21b7d 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
[snip..]
> +
> + # allocate volumes
> + my $map = $restore_allocate_devices->($storecfg, $virtdev_hash, $vmid);
> +
> + for my $virtdev (sort keys $virtdev_hash->%*) {
> + my $d = $virtdev_hash->{$virtdev};
> + next if $d->{is_cloudinit}; # no need to restore cloudinit
> +
> + my $info =
> + $backup_provider->restore_vm_volume_init($volname, $storeid, $d->{devname}, {});
> + my $source_path = $info->{'qemu-img-path'}
> + or die "did not get source image path from backup provider\n";
> + eval {
> + qemu_img_convert(
> + $source_path, $d->{volid}, $d->{size}, undef, 0, $options->{bwlimit});
> + };
this definitely needs to get a call to file_size_info with import
hardening patches applied ;)
> + my $err = $@;
> + eval {
> + $backup_provider->restore_vm_volume_cleanup($volname, $storeid, $d->{devname}, {});
> + };
> + if (my $cleanup_err = $@) {
> + die $cleanup_err if !$err;
> + warn $cleanup_err;
> + }
> + die $err if $err
> + }
> +
More information about the pve-devel
mailing list