all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu-server v1 1/3] fix #4888: qmrestore: add diskformat option
@ 2025-02-04 16:13 Markus Frank
  2025-02-04 16:13 ` [pve-devel] [PATCH manager v1 2/3] ui: form: add hideFormatWhenStorageEmpty option to DiskStorageSelector Markus Frank
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Markus Frank @ 2025-02-04 16:13 UTC (permalink / raw)
  To: pve-devel

Add an option to choose a file format (qcow2, raw, vmdk) when restoring
a vm backup to file based storage. This options allows all disks to be
recreated with the specified file format if supported by the target
storage.

Signed-off-by: Markus Frank <m.frank@proxmox.com>
---
Choosing the file format and storage for each disk would require much
more change and would be more in line with Feature Request #4275.

 PVE/API2/Qemu.pm     |  3 +++
 PVE/CLI/qmrestore.pm |  1 +
 PVE/QemuServer.pm    | 10 +++++++---
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index 295260e7..b742e71f 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1013,6 +1013,7 @@ __PACKAGE__->register_method({
 		    default => 0,
 		    description => "Start VM after it was created successfully.",
 		},
+		diskformat => PVE::JSONSchema::get_standard_option('pve-qm-image-format'),
 		'import-working-storage' => get_standard_option('pve-storage-id', {
 		    description => "A file-based storage with 'images' content-type enabled, which"
 			." is used as an intermediary extraction storage during import. Defaults to"
@@ -1046,6 +1047,7 @@ __PACKAGE__->register_method({
 	my $storage = extract_param($param, 'storage');
 	my $unique = extract_param($param, 'unique');
 	my $live_restore = extract_param($param, 'live-restore');
+	my $diskformat = extract_param($param, 'diskformat');
 	my $extraction_storage = extract_param($param, 'import-working-storage');
 
 	if (defined(my $ssh_keys = $param->{sshkeys})) {
@@ -1143,6 +1145,7 @@ __PACKAGE__->register_method({
 		    unique => $unique,
 		    bwlimit => $bwlimit,
 		    live => $live_restore,
+		    diskformat => $diskformat,
 		    override_conf => $param,
 		};
 		if (my $volid = $archive->{volid}) {
diff --git a/PVE/CLI/qmrestore.pm b/PVE/CLI/qmrestore.pm
index a47648bd..c698ca77 100755
--- a/PVE/CLI/qmrestore.pm
+++ b/PVE/CLI/qmrestore.pm
@@ -64,6 +64,7 @@ __PACKAGE__->register_method({
 		type => 'boolean',
 		description => "Start the VM immediately from the backup and restore in background. PBS only.",
 	    },
+	    diskformat => PVE::JSONSchema::get_standard_option('pve-qm-image-format'),
 	},
     },
     returns => {
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 808c0e1c..f6c58f09 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6660,7 +6660,7 @@ my $parse_backup_hints = sub {
 #
 # Returns: { $virtdev => $volid }
 my $restore_allocate_devices = sub {
-    my ($storecfg, $virtdev_hash, $vmid) = @_;
+    my ($storecfg, $virtdev_hash, $vmid, $diskformat) = @_;
 
     my $map = {};
     foreach my $virtdev (sort keys %$virtdev_hash) {
@@ -6670,6 +6670,10 @@ my $restore_allocate_devices = sub {
 	my $storeid = $d->{storeid};
 	my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
 
+	if ($diskformat) {
+	    $d->{format} = $diskformat;
+	}
+
 	# test if requested format is supported
 	my ($defFormat, $validFormats) = PVE::Storage::storage_default_format($storecfg, $storeid);
 	my $supported = grep { $_ eq $d->{format} } @$validFormats;
@@ -7047,7 +7051,7 @@ sub restore_proxmox_backup_archive {
 	$restore_cleanup_oldconf->($storecfg, $vmid, $oldconf, $virtdev_hash) if $oldconf;
 
 	# allocate volumes
-	my $map = $restore_allocate_devices->($storecfg, $virtdev_hash, $vmid);
+	my $map = $restore_allocate_devices->($storecfg, $virtdev_hash, $vmid, $options->{'diskformat'});
 
 	foreach my $virtdev (sort keys %$virtdev_hash) {
 	    my $d = $virtdev_hash->{$virtdev};
@@ -7444,7 +7448,7 @@ sub restore_vma_archive {
 	}
 
 	# allocate volumes
-	my $map = $restore_allocate_devices->($cfg, $virtdev_hash, $vmid);
+	my $map = $restore_allocate_devices->($cfg, $virtdev_hash, $vmid, $opts->{'diskformat'});
 
 	# print restore information to $fifofh
 	foreach my $virtdev (sort keys %$virtdev_hash) {
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-02-04 16:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-04 16:13 [pve-devel] [PATCH qemu-server v1 1/3] fix #4888: qmrestore: add diskformat option Markus Frank
2025-02-04 16:13 ` [pve-devel] [PATCH manager v1 2/3] ui: form: add hideFormatWhenStorageEmpty option to DiskStorageSelector Markus Frank
2025-02-04 16:13 ` [pve-devel] [PATCH manager v1 3/3] ui: window: add diskformat option to the restore window Markus Frank
2025-02-04 16:21 ` [pve-devel] [PATCH qemu-server v1 1/3] fix #4888: qmrestore: add diskformat option Fiona Ebner
2025-02-04 16:39   ` Fiona Ebner
2025-02-04 16:44     ` Markus Frank
2025-02-04 16:53       ` Fiona Ebner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal