* [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature
@ 2024-07-05 13:10 Maximiliano Sandoval
2024-07-08 12:09 ` Aaron Lauterer
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Maximiliano Sandoval @ 2024-07-05 13:10 UTC (permalink / raw)
To: pve-devel
Adds the ability to change the owner of a guest image.
Btrfs does not need special commands to rename a subvolume and this can
be achieved the same as in Storage/plugin.pm's rename_volume taking
special care of how the directory structure used by Btrfs.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
Differences from v3:
- add qcow2 and vmdk support for rename
- remove unused $ppath variable
Differences from v2:
- use indices instead of assigning to undef 5 times
Differences from v1:
- avoid assigning unused values of returned list to variables
src/PVE/Storage/BTRFSPlugin.pm | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
index 42815cb..385ac30 100644
--- a/src/PVE/Storage/BTRFSPlugin.pm
+++ b/src/PVE/Storage/BTRFSPlugin.pm
@@ -618,6 +618,9 @@ sub volume_has_feature {
base => { qcow2 => 1, raw => 1, vmdk => 1 },
current => { qcow2 => 1, raw => 1, vmdk => 1 },
},
+ rename => {
+ current => { qcow2 => 1, raw => 1, vmdk => 1 },
+ },
};
my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = $class->parse_volname($volname);
@@ -930,4 +933,34 @@ sub volume_import {
return "$storeid:$volname";
}
+sub rename_volume {
+ my ($class, $scfg, $storeid, $source_volname, $target_vmid, $target_volname) = @_;
+ die "no path found\n" if !$scfg->{path};
+
+ my $format = ($class->parse_volname($source_volname))[6];
+
+ if ($format ne 'raw' && $format ne 'subvol') {
+ return $class->SUPER::rename_volume($scfg, $storeid, $source_volname, $target_vmid, $target_volname);
+ }
+
+ $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format, 1)
+ if !$target_volname;
+ $target_volname = "$target_vmid/$target_volname";
+
+ my $basedir = $class->get_subdir($scfg, 'images');
+
+ mkpath "${basedir}/${target_vmid}";
+ my $source_dir = raw_name_to_dir($source_volname);
+ my $target_dir = raw_name_to_dir($target_volname);
+
+ my $old_path = "${basedir}/${source_dir}";
+ my $new_path = "${basedir}/${target_dir}";
+
+ die "target volume '${target_volname}' already exists\n" if -e $new_path;
+ rename $old_path, $new_path ||
+ die "rename '$old_path' to '$new_path' failed - $!\n";
+
+ return "${storeid}:$target_volname";
+}
+
1
--
2.39.2
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature
2024-07-05 13:10 [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature Maximiliano Sandoval
@ 2024-07-08 12:09 ` Aaron Lauterer
2024-08-19 9:22 ` Maximiliano Sandoval
2024-09-06 17:05 ` [pve-devel] applied: " Thomas Lamprecht
2 siblings, 0 replies; 5+ messages in thread
From: Aaron Lauterer @ 2024-07-08 12:09 UTC (permalink / raw)
To: Proxmox VE development discussion, Maximiliano Sandoval
gave this a test spin once more with VM disks. default RAW ones and
manually placed qcow2 and vmdk images for the fallback option to the
SUPER implementation
Tested-By: Aaron Lauterer <a.lauterer@proxmox.com>
Reviewed-By: Aaron Lauterer <a.lauterer@proxmox.com>
On 2024-07-05 15:10, Maximiliano Sandoval wrote:
> Adds the ability to change the owner of a guest image.
>
> Btrfs does not need special commands to rename a subvolume and this can
> be achieved the same as in Storage/plugin.pm's rename_volume taking
> special care of how the directory structure used by Btrfs.
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> Differences from v3:
> - add qcow2 and vmdk support for rename
> - remove unused $ppath variable
>
> Differences from v2:
> - use indices instead of assigning to undef 5 times
>
> Differences from v1:
> - avoid assigning unused values of returned list to variables
>
> src/PVE/Storage/BTRFSPlugin.pm | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/src/PVE/Storage/BTRFSPlugin.pm b/src/PVE/Storage/BTRFSPlugin.pm
> index 42815cb..385ac30 100644
> --- a/src/PVE/Storage/BTRFSPlugin.pm
> +++ b/src/PVE/Storage/BTRFSPlugin.pm
> @@ -618,6 +618,9 @@ sub volume_has_feature {
> base => { qcow2 => 1, raw => 1, vmdk => 1 },
> current => { qcow2 => 1, raw => 1, vmdk => 1 },
> },
> + rename => {
> + current => { qcow2 => 1, raw => 1, vmdk => 1 },
> + },
> };
>
> my ($vtype, $name, $vmid, $basename, $basevmid, $isBase, $format) = $class->parse_volname($volname);
> @@ -930,4 +933,34 @@ sub volume_import {
> return "$storeid:$volname";
> }
>
> +sub rename_volume {
> + my ($class, $scfg, $storeid, $source_volname, $target_vmid, $target_volname) = @_;
> + die "no path found\n" if !$scfg->{path};
> +
> + my $format = ($class->parse_volname($source_volname))[6];
> +
> + if ($format ne 'raw' && $format ne 'subvol') {
> + return $class->SUPER::rename_volume($scfg, $storeid, $source_volname, $target_vmid, $target_volname);
> + }
> +
> + $target_volname = $class->find_free_diskname($storeid, $scfg, $target_vmid, $format, 1)
> + if !$target_volname;
> + $target_volname = "$target_vmid/$target_volname";
> +
> + my $basedir = $class->get_subdir($scfg, 'images');
> +
> + mkpath "${basedir}/${target_vmid}";
> + my $source_dir = raw_name_to_dir($source_volname);
> + my $target_dir = raw_name_to_dir($target_volname);
> +
> + my $old_path = "${basedir}/${source_dir}";
> + my $new_path = "${basedir}/${target_dir}";
> +
> + die "target volume '${target_volname}' already exists\n" if -e $new_path;
> + rename $old_path, $new_path ||
> + die "rename '$old_path' to '$new_path' failed - $!\n";
> +
> + return "${storeid}:$target_volname";
> +}
> +
> 1
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature
2024-07-05 13:10 [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature Maximiliano Sandoval
2024-07-08 12:09 ` Aaron Lauterer
@ 2024-08-19 9:22 ` Maximiliano Sandoval
2024-09-02 14:00 ` Maximiliano Sandoval
2024-09-06 17:05 ` [pve-devel] applied: " Thomas Lamprecht
2 siblings, 1 reply; 5+ messages in thread
From: Maximiliano Sandoval @ 2024-08-19 9:22 UTC (permalink / raw)
To: pve-devel
Ping.
Maximiliano Sandoval <m.sandoval@proxmox.com> writes:
> Adds the ability to change the owner of a guest image.
>
> Btrfs does not need special commands to rename a subvolume and this can
> be achieved the same as in Storage/plugin.pm's rename_volume taking
> special care of how the directory structure used by Btrfs.
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> Differences from v3:
> - add qcow2 and vmdk support for rename
> - remove unused $ppath variable
>
> Differences from v2:
> - use indices instead of assigning to undef 5 times
>
> Differences from v1:
> - avoid assigning unused values of returned list to variables
--
Maximiliano
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature
2024-08-19 9:22 ` Maximiliano Sandoval
@ 2024-09-02 14:00 ` Maximiliano Sandoval
0 siblings, 0 replies; 5+ messages in thread
From: Maximiliano Sandoval @ 2024-09-02 14:00 UTC (permalink / raw)
To: pve-devel; +Cc: Wolfgang Bumiller
Maximiliano Sandoval <m.sandoval@proxmox.com> writes:
> Ping.
Ping.
--
Maximiliano
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pve-devel] applied: [PATCH storage v4] fix #4272: btrfs: add rename feature
2024-07-05 13:10 [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature Maximiliano Sandoval
2024-07-08 12:09 ` Aaron Lauterer
2024-08-19 9:22 ` Maximiliano Sandoval
@ 2024-09-06 17:05 ` Thomas Lamprecht
2 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2024-09-06 17:05 UTC (permalink / raw)
To: Proxmox VE development discussion, Maximiliano Sandoval
Am 05/07/2024 um 15:10 schrieb Maximiliano Sandoval:
> Adds the ability to change the owner of a guest image.
>
> Btrfs does not need special commands to rename a subvolume and this can
> be achieved the same as in Storage/plugin.pm's rename_volume taking
> special care of how the directory structure used by Btrfs.
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> Differences from v3:
> - add qcow2 and vmdk support for rename
> - remove unused $ppath variable
>
> Differences from v2:
> - use indices instead of assigning to undef 5 times
>
> Differences from v1:
> - avoid assigning unused values of returned list to variables
>
> src/PVE/Storage/BTRFSPlugin.pm | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
>
applied, with Aaron's T-b and R-b, thanks!
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-06 17:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-05 13:10 [pve-devel] [PATCH storage v4] fix #4272: btrfs: add rename feature Maximiliano Sandoval
2024-07-08 12:09 ` Aaron Lauterer
2024-08-19 9:22 ` Maximiliano Sandoval
2024-09-02 14:00 ` Maximiliano Sandoval
2024-09-06 17:05 ` [pve-devel] applied: " Thomas Lamprecht
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